From 7bdeaeb4cc8581a7027919ac04b957a6f941c6d0 Mon Sep 17 00:00:00 2001 From: Bhargav Ponnapalli Date: Tue, 1 Aug 2023 00:55:59 +0530 Subject: [PATCH] fix(build): build fixes --- src/app/actions.ts | 1 + src/app/item/[itemId]/page.tsx | 7 +++-- src/app/layout.tsx | 3 ++ src/app/new/page.tsx | 2 ++ .../ui/ChangeLog/ChangeLogListCard.tsx | 26 ---------------- src/components/ui/ChangeLog/index.ts | 1 - .../FeedbackComponent/FeedbackComponent.tsx | 31 ------------------- src/components/ui/FeedbackComponent/index.ts | 1 - .../ui/Headings/BasicPageHeading.tsx | 18 ----------- .../ui/Headings/LargeSectionHeading.tsx | 26 ---------------- .../ui/Headings/PageHeadingWithActions.tsx | 25 --------------- src/components/ui/Headings/index.ts | 1 - src/components/ui/Search/Search.tsx | 9 ------ src/components/ui/Search/index.ts | 1 - src/environment.d.ts | 13 ++++++++ .../createSupabaseStaticClient.ts | 16 ++++++++++ 16 files changed, 39 insertions(+), 142 deletions(-) delete mode 100644 src/components/ui/ChangeLog/ChangeLogListCard.tsx delete mode 100644 src/components/ui/ChangeLog/index.ts delete mode 100644 src/components/ui/FeedbackComponent/FeedbackComponent.tsx delete mode 100644 src/components/ui/FeedbackComponent/index.ts delete mode 100644 src/components/ui/Headings/BasicPageHeading.tsx delete mode 100644 src/components/ui/Headings/LargeSectionHeading.tsx delete mode 100644 src/components/ui/Headings/PageHeadingWithActions.tsx delete mode 100644 src/components/ui/Headings/index.ts delete mode 100644 src/components/ui/Search/Search.tsx delete mode 100644 src/components/ui/Search/index.ts create mode 100644 src/environment.d.ts create mode 100644 src/supabase-clients/createSupabaseStaticClient.ts diff --git a/src/app/actions.ts b/src/app/actions.ts index a833bc37..f7462fe5 100644 --- a/src/app/actions.ts +++ b/src/app/actions.ts @@ -44,5 +44,6 @@ export async function updateItemAction(payload: { export const deleteItemAction = async (id: string) => { const supabaseClient = createSupabaseServerActionClient(); await deleteItem(supabaseClient, id); + revalidatePath('/'); }; diff --git a/src/app/item/[itemId]/page.tsx b/src/app/item/[itemId]/page.tsx index ae4ec95f..67be30c2 100644 --- a/src/app/item/[itemId]/page.tsx +++ b/src/app/item/[itemId]/page.tsx @@ -1,11 +1,11 @@ import Link from 'next/link'; import { notFound } from 'next/navigation'; import { getItem } from '@/utils/supabase-queries'; -import { createSupabaseServerComponentClient } from '@/supabase-clients/createSupabaseServerComponentClient'; import { ConfirmDeleteItemDialog } from './ConfirmDeleteItemDialog'; import { deleteItemAction } from '@/app/actions'; import { T } from '@/components/ui/Typography'; import ArrowLeft from 'lucide-react/dist/esm/icons/arrow-left'; +import { createSupabaseServerComponentClient } from '@/supabase-clients/createSupabaseServerComponentClient'; export default async function Item({ params, @@ -14,10 +14,11 @@ export default async function Item({ itemId: string; }; }) { - const supabase = createSupabaseServerComponentClient(); + const supabaseClient = createSupabaseServerComponentClient(); + const { itemId } = params; try { - const item = await getItem(supabase, itemId); + const item = await getItem(supabaseClient, itemId); return (
diff --git a/src/app/layout.tsx b/src/app/layout.tsx index a1f1c529..54711bbf 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -2,6 +2,9 @@ import { ClientLayout } from './ClientLayout'; import { Inter, Roboto_Mono } from 'next/font/google'; import './globals.css'; +export const revalidate = 0; +export const dynamic = 'force-dynamic'; + const inter = Inter({ subsets: ['latin'], display: 'swap', diff --git a/src/app/new/page.tsx b/src/app/new/page.tsx index fd9fba06..82e75673 100644 --- a/src/app/new/page.tsx +++ b/src/app/new/page.tsx @@ -1,6 +1,8 @@ import { ClientPage } from './ClientPage'; import { insertItemAction } from '../actions'; +export const dynamic = 'force-dynamic'; + export default function NewItem() { return ; } diff --git a/src/components/ui/ChangeLog/ChangeLogListCard.tsx b/src/components/ui/ChangeLog/ChangeLogListCard.tsx deleted file mode 100644 index 4e2a58de..00000000 --- a/src/components/ui/ChangeLog/ChangeLogListCard.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import { ReactNode } from 'react'; -import { T } from '../Typography'; -type ChangeLogListCardProps = { - date: string; - title: string; - children: ReactNode; -}; - -export default function ChangeLogListCard({ - date, - title, - children, -}: ChangeLogListCardProps) { - return ( -
-

{date}

-
- {title} - {children} -
-
- ); -} diff --git a/src/components/ui/ChangeLog/index.ts b/src/components/ui/ChangeLog/index.ts deleted file mode 100644 index 3d63cd2c..00000000 --- a/src/components/ui/ChangeLog/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './ChangeLogListCard'; diff --git a/src/components/ui/FeedbackComponent/FeedbackComponent.tsx b/src/components/ui/FeedbackComponent/FeedbackComponent.tsx deleted file mode 100644 index 155da25f..00000000 --- a/src/components/ui/FeedbackComponent/FeedbackComponent.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import Image, { StaticImageData } from 'next/image'; - -type FeedbackComponentProps = { - userName: string; - feedback: string; - userImage: StaticImageData; -}; - -export default function FeedbackComponent({ - userName, - feedback, - userImage, -}: FeedbackComponentProps) { - return ( -
- {''} - -
-
-

{userName}

-

{feedback}

-
-
-
- ); -} diff --git a/src/components/ui/FeedbackComponent/index.ts b/src/components/ui/FeedbackComponent/index.ts deleted file mode 100644 index 64c19ccd..00000000 --- a/src/components/ui/FeedbackComponent/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './FeedbackComponent'; diff --git a/src/components/ui/Headings/BasicPageHeading.tsx b/src/components/ui/Headings/BasicPageHeading.tsx deleted file mode 100644 index 1e1f71b2..00000000 --- a/src/components/ui/Headings/BasicPageHeading.tsx +++ /dev/null @@ -1,18 +0,0 @@ -type BasicPageHeadingProps = { - heading: string; - subheading: string; -}; - -export default function BasicPageHeading({ - heading, - subheading, -}: BasicPageHeadingProps) { - return ( -
-
-

{heading}

-

{subheading}

-
-
- ); -} diff --git a/src/components/ui/Headings/LargeSectionHeading.tsx b/src/components/ui/Headings/LargeSectionHeading.tsx deleted file mode 100644 index 42f68c02..00000000 --- a/src/components/ui/Headings/LargeSectionHeading.tsx +++ /dev/null @@ -1,26 +0,0 @@ -type LargeSectionHeadingProps = { - heading: string; - subheading: string; - children: React.ReactNode; -}; - -export default function LargeSectionHeading({ - heading, - subheading, - children, -}: LargeSectionHeadingProps) { - return ( -
- {/* Heading */} -
-
-

{heading}

-

{subheading}

-
-
- - {/* Children */} - {children} -
- ); -} diff --git a/src/components/ui/Headings/PageHeadingWithActions.tsx b/src/components/ui/Headings/PageHeadingWithActions.tsx deleted file mode 100644 index 1565aa66..00000000 --- a/src/components/ui/Headings/PageHeadingWithActions.tsx +++ /dev/null @@ -1,25 +0,0 @@ -type PageHeadingWithActionsProps = { - heading: string; - subheading: string; - children: React.ReactNode; -}; - -export default function PageHeadingWithActions({ - heading, - subheading, - children, -}: PageHeadingWithActionsProps) { - return ( -
- {/* Heading */} -
-
-

{heading}

-

{subheading}

-
-
- {/* Children */} - {children} -
- ); -} diff --git a/src/components/ui/Headings/index.ts b/src/components/ui/Headings/index.ts deleted file mode 100644 index 73b0c30f..00000000 --- a/src/components/ui/Headings/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '../Headings'; diff --git a/src/components/ui/Search/Search.tsx b/src/components/ui/Search/Search.tsx deleted file mode 100644 index 0c3d13f9..00000000 --- a/src/components/ui/Search/Search.tsx +++ /dev/null @@ -1,9 +0,0 @@ -export default function Search() { - return ( - - ); -} diff --git a/src/components/ui/Search/index.ts b/src/components/ui/Search/index.ts deleted file mode 100644 index addd5330..00000000 --- a/src/components/ui/Search/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Search'; diff --git a/src/environment.d.ts b/src/environment.d.ts new file mode 100644 index 00000000..d4773056 --- /dev/null +++ b/src/environment.d.ts @@ -0,0 +1,13 @@ +declare global { + namespace NodeJS { + interface ProcessEnv { + NEXT_PUBLIC_SUPABASE_URL: string; + NEXT_PUBLIC_SUPABASE_ANON_KEY: string; + NODE_ENV: 'development' | 'production'; + SUPABASE_PROJECT_REF: string; + } + } +} + +// eslint-disable-next-line prettier/prettier +export { }; diff --git a/src/supabase-clients/createSupabaseStaticClient.ts b/src/supabase-clients/createSupabaseStaticClient.ts new file mode 100644 index 00000000..47df97eb --- /dev/null +++ b/src/supabase-clients/createSupabaseStaticClient.ts @@ -0,0 +1,16 @@ +import { Database } from '@/lib/database.types'; +import { createClient } from '@supabase/supabase-js'; + +export const createSupabaseStaticClient = () => + createClient( + process.env.NEXT_PUBLIC_SUPABASE_URL, + process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY, + { + global: { + fetch, + }, + auth: { + persistSession: false, + }, + } + );