From 1aa93bff459ee6ba556a8c3b9612e89afb922da4 Mon Sep 17 00:00:00 2001 From: tarunsoftprodigy Date: Tue, 15 Oct 2024 19:56:27 +0530 Subject: [PATCH] new sections and auth added --- .../app/(auth-pages)/create-account/page.tsx | 39 +++++- mirror-2/app/(auth-pages)/login/page.tsx | 50 +++++-- mirror-2/app/home/components/sidebar.tsx | 4 +- mirror-2/app/home/page.tsx | 24 ++-- mirror-2/app/my/account/page.tsx | 76 +++++++++++ .../app/{my-assets => my/assets}/page.tsx | 6 +- .../app/{my-spaces => my/spaces}/page.tsx | 29 ++-- mirror-2/app/protected/blank-redirect.tsx | 8 +- mirror-2/app/protected/page.tsx | 6 +- mirror-2/app/protected/reset-email/page.tsx | 38 ++++++ mirror-2/hooks/auth.tsx | 97 ++++++++------ mirror-2/next.config.js | 4 +- mirror-2/state/spaces.tsx | 125 +++++++++++++----- mirror-2/tsconfig.json | 9 +- mirror-2/utils/supabase/middleware.ts | 6 +- 15 files changed, 381 insertions(+), 140 deletions(-) create mode 100644 mirror-2/app/my/account/page.tsx rename mirror-2/app/{my-assets => my/assets}/page.tsx (92%) rename mirror-2/app/{my-spaces => my/spaces}/page.tsx (74%) create mode 100644 mirror-2/app/protected/reset-email/page.tsx diff --git a/mirror-2/app/(auth-pages)/create-account/page.tsx b/mirror-2/app/(auth-pages)/create-account/page.tsx index e989679a..ee1f8a9b 100644 --- a/mirror-2/app/(auth-pages)/create-account/page.tsx +++ b/mirror-2/app/(auth-pages)/create-account/page.tsx @@ -1,16 +1,26 @@ -"use client" +"use client"; import { createAccountAction, loginAction } from "@/actions/auth"; import { FormMessage, Message } from "@/components/form-message"; import { SubmitButton } from "@/components/submit-button"; -import { Card, CardHeader, CardTitle, CardContent, CardFooter } from "@/components/ui/card"; +import { + Card, + CardHeader, + CardTitle, + CardContent, + CardFooter, +} from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { useRedirectToHomeIfSignedIn } from "@/hooks/auth"; import { AppLogoImageMedium } from "@/lib/theme-service"; import Link from "next/link"; -export default function CreateAccount({ searchParams }: { searchParams: Message }) { - useRedirectToHomeIfSignedIn() +export default function CreateAccount({ + searchParams, +}: { + searchParams: Message; +}) { + useRedirectToHomeIfSignedIn(); return (
@@ -25,7 +35,13 @@ export default function CreateAccount({ searchParams }: { searchParams: Message
- +
@@ -33,11 +49,20 @@ export default function CreateAccount({ searchParams }: { searchParams: Message
- Create Account + + Create Account +

Already have an account?{" "} - + Login

diff --git a/mirror-2/app/(auth-pages)/login/page.tsx b/mirror-2/app/(auth-pages)/login/page.tsx index 26ef1228..411fb1d2 100644 --- a/mirror-2/app/(auth-pages)/login/page.tsx +++ b/mirror-2/app/(auth-pages)/login/page.tsx @@ -1,8 +1,14 @@ -"use client" +"use client"; import { loginAction } from "@/actions/auth"; import { FormMessage, Message } from "@/components/form-message"; import { SubmitButton } from "@/components/submit-button"; -import { Card, CardHeader, CardTitle, CardContent, CardFooter } from "@/components/ui/card"; +import { + Card, + CardHeader, + CardTitle, + CardContent, + CardFooter, +} from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { useRedirectToHomeIfSignedIn } from "@/hooks/auth"; @@ -11,9 +17,9 @@ import Link from "next/link"; import { useRef } from "react"; export default function Login({ searchParams }: { searchParams: Message }) { - useRedirectToHomeIfSignedIn() + useRedirectToHomeIfSignedIn(); - const isDevelopment = process.env.NODE_ENV === 'development'; + const isDevelopment = process.env.NODE_ENV === "development"; // References for email and password fields const emailRef = useRef(null); @@ -23,7 +29,7 @@ export default function Login({ searchParams }: { searchParams: Message }) { const handleDevLoginWithUser = (userEmail: string) => { if (emailRef.current && passwordRef.current) { emailRef.current.value = userEmail; - passwordRef.current.value = 'password'; // Default password for all dev users + passwordRef.current.value = "password"; // Default password for all dev users } // Simulate form submission by calling formAction @@ -45,21 +51,41 @@ export default function Login({ searchParams }: { searchParams: Message }) {
- +
- +
- + Login

Don't have an account?{" "} - + Create Account

@@ -70,21 +96,21 @@ export default function Login({ searchParams }: { searchParams: Message }) { diff --git a/mirror-2/app/home/components/sidebar.tsx b/mirror-2/app/home/components/sidebar.tsx index 49971290..2d804084 100644 --- a/mirror-2/app/home/components/sidebar.tsx +++ b/mirror-2/app/home/components/sidebar.tsx @@ -43,7 +43,7 @@ export function Sidebar({ className, playlists, style }: SidebarProps) { className="w-full justify-start" asChild > - + My Spaces @@ -53,7 +53,7 @@ export function Sidebar({ className, playlists, style }: SidebarProps) { className="w-full justify-start" asChild > - + My Assets diff --git a/mirror-2/app/home/page.tsx b/mirror-2/app/home/page.tsx index 7448d5cb..1746c2d0 100644 --- a/mirror-2/app/home/page.tsx +++ b/mirror-2/app/home/page.tsx @@ -1,18 +1,20 @@ +"use client"; import Image from "next/image"; import { Sidebar } from "./components/sidebar"; import { listenNowAlbums, madeForYouAlbums } from "./data/albums"; import { playlists } from "./data/playlists"; import { Separator } from "@/components/ui/separator"; import { appDescription, appName } from "@/lib/theme-service"; -import { Metadata } from "next"; import AccountDropdownMenu from "@/components/ui/account-dropdown-menu"; import { Card, CardContent, CardFooter } from "@/components/ui/card"; +import { useGetSpacesByUserIdQuery } from "@/state/spaces"; + +const dummyImg = + "https://images.unsplash.com/photo-1513745405825-efaf9a49315f?w=300&dpr=2&q=80"; -export const metadata: Metadata = { - title: "The Mirror", - description: "", -}; export default function Home() { + const { data: spaces, error } = useGetSpacesByUserIdQuery(""); + return ( <>
@@ -99,7 +101,7 @@ export default function Home() {
- {madeForYouAlbums.slice(0, 4).map((album) => ( + {spaces?.slice(0, 4).map((space) => ( {album?.name}
-

{album.name}

+

+ {space?.name} +

- {album.artist} + Created At {space?.created_at.split("T")[0]}

diff --git a/mirror-2/app/my/account/page.tsx b/mirror-2/app/my/account/page.tsx new file mode 100644 index 00000000..f4e4fa4d --- /dev/null +++ b/mirror-2/app/my/account/page.tsx @@ -0,0 +1,76 @@ +import React from "react"; +import { Separator } from "@/components/ui/separator"; +import { Metadata } from "next"; +import { Sidebar } from "@/app/home/components/sidebar"; +import { playlists } from "@/app/home/data/playlists"; + +export const metadata: Metadata = { + title: "Discover", + description: "", +}; +const MyAccount = () => { + return ( +
+ +
+
+
+

+ Account Settings +

+
+
+ +
+
+
+ + +
+
+ +
+
+
+ ); +}; + +export default MyAccount; diff --git a/mirror-2/app/my-assets/page.tsx b/mirror-2/app/my/assets/page.tsx similarity index 92% rename from mirror-2/app/my-assets/page.tsx rename to mirror-2/app/my/assets/page.tsx index f614c8a3..d5b2cbe8 100644 --- a/mirror-2/app/my-assets/page.tsx +++ b/mirror-2/app/my/assets/page.tsx @@ -1,9 +1,9 @@ import React from "react"; -import { madeForYouAlbums } from "../home/data/albums"; +import { madeForYouAlbums } from "../../home/data/albums"; import { Card, CardContent, CardFooter } from "@/components/ui/card"; import Image from "next/image"; -import { Sidebar } from "../home/components/sidebar"; -import { playlists } from "../home/data/playlists"; +import { Sidebar } from "../../home/components/sidebar"; +import { playlists } from "../../home/data/playlists"; import { Separator } from "@/components/ui/separator"; import { PlusCircleIcon } from "lucide-react"; import { Metadata } from "next"; diff --git a/mirror-2/app/my-spaces/page.tsx b/mirror-2/app/my/spaces/page.tsx similarity index 74% rename from mirror-2/app/my-spaces/page.tsx rename to mirror-2/app/my/spaces/page.tsx index 2b5af40e..1f269e1b 100644 --- a/mirror-2/app/my-spaces/page.tsx +++ b/mirror-2/app/my/spaces/page.tsx @@ -1,20 +1,23 @@ +"use client"; import React from "react"; -import { listenNowAlbums, madeForYouAlbums } from "../home/data/albums"; import { Card, CardContent, CardFooter } from "@/components/ui/card"; import Image from "next/image"; -import { Sidebar } from "../home/components/sidebar"; -import { playlists } from "../home/data/playlists"; +import { Sidebar } from "../../home/components/sidebar"; +import { playlists } from "../../home/data/playlists"; import { Separator } from "@/components/ui/separator"; import Link from "next/link"; import { Button } from "@/components/ui/button"; import { PlusCircleIcon } from "lucide-react"; -import { Metadata } from "next"; +import { useGetSpacesByUserIdQuery } from "@/state/spaces"; +import { useRedirectToLoginIfNotSignedIn } from "@/hooks/auth"; + +const dummyImg = + "https://images.unsplash.com/photo-1615247001958-f4bc92fa6a4a?w=300&dpr=2&q=80"; -export const metadata: Metadata = { - title: "My Spaces", - description: "", -}; const MySpaces = () => { + useRedirectToLoginIfNotSignedIn(); + const { data: spaces, error } = useGetSpacesByUserIdQuery(""); + return (
{
- {madeForYouAlbums?.map((album) => ( + {spaces?.map((space) => ( { > {album?.name} {
-

{album.name}

+

{space?.name}

- {album.artist} + Created At {space?.created_at.split("T")[0]}

diff --git a/mirror-2/app/protected/blank-redirect.tsx b/mirror-2/app/protected/blank-redirect.tsx index 53e36bbb..c269bb00 100644 --- a/mirror-2/app/protected/blank-redirect.tsx +++ b/mirror-2/app/protected/blank-redirect.tsx @@ -1,8 +1,8 @@ -"use client" +"use client"; -import { useRedirectToHomeIfSignedIn } from "@/hooks/auth" +import { useRedirectToHomeIfSignedIn } from "@/hooks/auth"; export function BlankRedirect() { - useRedirectToHomeIfSignedIn() - return <> + useRedirectToHomeIfSignedIn(); + return <> ; } diff --git a/mirror-2/app/protected/page.tsx b/mirror-2/app/protected/page.tsx index eb089ce3..9fd4fa88 100644 --- a/mirror-2/app/protected/page.tsx +++ b/mirror-2/app/protected/page.tsx @@ -1,12 +1,9 @@ - import { BlankRedirect } from "@/app/protected/blank-redirect"; import { createServerClient } from "@/utils/supabase/server"; import { redirect } from "next/navigation"; export default async function ProtectedPage() { - const supabase = createServerClient(); - const { data: { user }, } = await supabase.auth.getUser(); @@ -16,8 +13,7 @@ export default async function ProtectedPage() { } return ( - // delete this page eventually. it's here from boilerplate auth that users server side + // delete this page eventually. it's here from boilerplate auth that users server side ); } - diff --git a/mirror-2/app/protected/reset-email/page.tsx b/mirror-2/app/protected/reset-email/page.tsx new file mode 100644 index 00000000..43b2fc2b --- /dev/null +++ b/mirror-2/app/protected/reset-email/page.tsx @@ -0,0 +1,38 @@ +import { resetPasswordAction } from "@/actions/auth"; +import { FormMessage, Message } from "@/components/form-message"; +import { SubmitButton } from "@/components/submit-button"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; + +export default async function ResetEmail({ + searchParams, +}: { + searchParams: Message; +}) { + return ( + +

Reset Email

+

+ Please enter your new password below. +

+ + + + + + Reset password + + + + ); +} diff --git a/mirror-2/hooks/auth.tsx b/mirror-2/hooks/auth.tsx index 67ae6aa8..32ac9789 100644 --- a/mirror-2/hooks/auth.tsx +++ b/mirror-2/hooks/auth.tsx @@ -1,4 +1,4 @@ -"use client" +"use client"; import { useAppDispatch, useAppSelector } from "@/hooks/hooks"; import { updateLocalUserState, clearLocalUserState } from "@/state/local"; import { store } from "@/state/store"; @@ -8,15 +8,14 @@ import { useRouter } from "next/navigation"; export const signOut = async () => { const supabase = createSupabaseBrowserClient(); await supabase.auth.signOut(); - store.dispatch(clearLocalUserState()) - window.location.href = "/login" + store.dispatch(clearLocalUserState()); + window.location.href = "/login"; }; - export function useSetupAuthEvents() { const supabase = createSupabaseBrowserClient(); const dispatch = useAppDispatch(); - const router = useRouter() + const router = useRouter(); // if no user, clear local state // useEffect(() => { @@ -29,56 +28,66 @@ export function useSetupAuthEvents() { // clearStateIfNoUser() // }, [dispatch, supabase]) - const { data: authListener } = supabase.auth.onAuthStateChange((event, session) => { - function handleLogin() { - if (session?.user) { - // console.log('auth: DID fire') - // console.log("updateLocalUserState", event, session?.user) - const { id, email, is_anonymous } = session.user - dispatch(updateLocalUserState({ id, email, is_anonymous })) - } else { - console.log('auth: did not fire') + const { data: authListener } = supabase.auth.onAuthStateChange( + (event, session) => { + function handleLogin() { + if (session?.user) { + // console.log('auth: DID fire') + // console.log("updateLocalUserState", event, session?.user) + const { id, email, is_anonymous } = session.user; + dispatch(updateLocalUserState({ id, email, is_anonymous })); + } else { + console.log("auth: did not fire"); + } } - } - function handleLogout() { - dispatch(clearLocalUserState()) - router.push("/login") - } - // console.log("auth", event, session) - if (event === 'INITIAL_SESSION') { - // handle initial session - if (session?.user) { - handleLogin() - } else { - handleLogout() + function handleLogout() { + dispatch(clearLocalUserState()); + router.push("/login"); + } + // console.log("auth", event, session) + if (event === "INITIAL_SESSION") { + // handle initial session + if (session?.user) { + handleLogin(); + } else { + handleLogout(); + } + } else if (event === "SIGNED_IN") { + // handle sign in event + handleLogin(); + } else if (event === "SIGNED_OUT") { + // handle sign out event + handleLogout(); + } else if (event === "PASSWORD_RECOVERY") { + // handle password recovery event + } else if (event === "TOKEN_REFRESHED") { + // handle token refreshed event + } else if (event === "USER_UPDATED") { + // handle user updated event } - } else if (event === 'SIGNED_IN') { - // handle sign in event - handleLogin() - } else if (event === 'SIGNED_OUT') { - // handle sign out event - handleLogout() - } else if (event === 'PASSWORD_RECOVERY') { - // handle password recovery event - } else if (event === 'TOKEN_REFRESHED') { - // handle token refreshed event - } else if (event === 'USER_UPDATED') { - // handle user updated event } - }) + ); // Cleanup the subscription when the component is unmounted return () => { - authListener.subscription.unsubscribe() + authListener.subscription.unsubscribe(); }; } export function useRedirectToHomeIfSignedIn() { - const router = useRouter() - const id = useAppSelector(state => state.local?.user?.id); - console.log('auth router check', id) + const router = useRouter(); + const id = useAppSelector((state) => state.local?.user?.id); + console.log("auth router check", id); if (id) { - router.replace("/home") + router.replace("/home"); + } +} + +export function useRedirectToLoginIfNotSignedIn() { + const router = useRouter(); + const id = useAppSelector((state) => state.local?.user?.id); + if (!id) { + router.replace("/login"); } } diff --git a/mirror-2/next.config.js b/mirror-2/next.config.js index c61491f3..9910920e 100644 --- a/mirror-2/next.config.js +++ b/mirror-2/next.config.js @@ -10,10 +10,10 @@ const nextConfig = { source: "/sign-up", destination: "/create-account", permanent: true, - } + }, ], images: { - domains: ['images.unsplash.com', '127.0.0.1', 'localhost', 'picsum.photos'], + domains: ["images.unsplash.com", "127.0.0.1", "localhost", "picsum.photos"], }, }; diff --git a/mirror-2/state/spaces.tsx b/mirror-2/state/spaces.tsx index 894a95c1..2f01194f 100644 --- a/mirror-2/state/spaces.tsx +++ b/mirror-2/state/spaces.tsx @@ -1,46 +1,66 @@ -import { createApi, fakeBaseQuery } from '@reduxjs/toolkit/query/react'; -import { createSupabaseBrowserClient } from '@/utils/supabase/client'; -import { Database } from '@/utils/database.types'; -import { generateSpaceName } from '@/actions/name-generator'; -import { scenesApi, TAG_NAME_FOR_GENERAL_ENTITY as SCENES_TAG_NAME_FOR_GENERAL_ENTITY } from '@/state/scenes'; -import { TAG_NAME_FOR_GENERAL_ENTITY as ENTITIES_TAG_NAME_FOR_GENERAL_ENTITY, entitiesApi } from '@/state/entities'; -import { TAG_NAME_FOR_GENERAL_ENTITY as COMPONENTS_TAG_NAME_FOR_GENERAL_ENTITY } from '@/state/components'; -import { TAG_NAME_FOR_BUILD_MODE_SPACE_QUERY } from '@/state/shared-cache-tags'; - -export const TAG_NAME_FOR_GENERAL_ENTITY = 'Spaces' +import { createApi, fakeBaseQuery } from "@reduxjs/toolkit/query/react"; +import { createSupabaseBrowserClient } from "@/utils/supabase/client"; +import { Database } from "@/utils/database.types"; +import { generateSpaceName } from "@/actions/name-generator"; +import { + scenesApi, + TAG_NAME_FOR_GENERAL_ENTITY as SCENES_TAG_NAME_FOR_GENERAL_ENTITY, +} from "@/state/scenes"; +import { + TAG_NAME_FOR_GENERAL_ENTITY as ENTITIES_TAG_NAME_FOR_GENERAL_ENTITY, + entitiesApi, +} from "@/state/entities"; +import { TAG_NAME_FOR_GENERAL_ENTITY as COMPONENTS_TAG_NAME_FOR_GENERAL_ENTITY } from "@/state/components"; +import { TAG_NAME_FOR_BUILD_MODE_SPACE_QUERY } from "@/state/shared-cache-tags"; + +export const TAG_NAME_FOR_GENERAL_ENTITY = "Spaces"; // Supabase API for spaces export const spacesApi = createApi({ - reducerPath: 'spacesApi', + reducerPath: "spacesApi", baseQuery: fakeBaseQuery(), - tagTypes: [TAG_NAME_FOR_GENERAL_ENTITY, SCENES_TAG_NAME_FOR_GENERAL_ENTITY, ENTITIES_TAG_NAME_FOR_GENERAL_ENTITY, TAG_NAME_FOR_BUILD_MODE_SPACE_QUERY, 'LIST'], + tagTypes: [ + TAG_NAME_FOR_GENERAL_ENTITY, + SCENES_TAG_NAME_FOR_GENERAL_ENTITY, + ENTITIES_TAG_NAME_FOR_GENERAL_ENTITY, + TAG_NAME_FOR_BUILD_MODE_SPACE_QUERY, + "LIST", + ], endpoints: (builder) => ({ createSpace: builder.mutation({ queryFn: async (_, { dispatch }) => { const supabase = createSupabaseBrowserClient(); - const { data: { user } } = await supabase.auth.getUser() + const { + data: { user }, + } = await supabase.auth.getUser(); if (!user) { - throw new Error('User not found') + throw new Error("User not found"); } - const name = await generateSpaceName() + const name = await generateSpaceName(); const { data, error } = await supabase .from("spaces") - .insert([{ - name, - creator_user_id: user?.id, - owner_user_id: user.id - }]) - .select('*') - .single() + .insert([ + { + name, + creator_user_id: user?.id, + owner_user_id: user.id, + }, + ]) + .select("*") + .single(); if (error) { return { error: error.message }; } // Now that the space is created, dispatch the `createScene` mutation - const { data: createSceneData, error: createSceneError } = await dispatch( - scenesApi.endpoints.createScene.initiate({ name: "Main", space_id: data.id }) - ) + const { data: createSceneData, error: createSceneError } = + await dispatch( + scenesApi.endpoints.createScene.initiate({ + name: "Main", + space_id: data.id, + }) + ); if (createSceneError) { return { error: createSceneError }; @@ -52,7 +72,7 @@ export const spacesApi = createApi({ // } return { data }; }, - invalidatesTags: [{ type: TAG_NAME_FOR_GENERAL_ENTITY, id: 'LIST' }], + invalidatesTags: [{ type: TAG_NAME_FOR_GENERAL_ENTITY, id: "LIST" }], }), getSingleSpace: builder.query({ @@ -63,17 +83,25 @@ export const spacesApi = createApi({ .from("spaces") .select("*") .eq("id", spaceId) - .single() + .single(); if (error) { return { error: error.message }; } return { data }; }, - providesTags: (result, error, id) => [{ type: TAG_NAME_FOR_GENERAL_ENTITY, id }], + providesTags: (result, error, id) => [ + { type: TAG_NAME_FOR_GENERAL_ENTITY, id }, + ], }), - updateSpace: builder.mutation }>({ + updateSpace: builder.mutation< + Database["public"]["Tables"]["spaces"]["Row"], + { + id: string; + updateData: Partial; + } + >({ queryFn: async ({ id: spaceId, updateData }) => { const supabase = createSupabaseBrowserClient(); const { data, error } = await supabase @@ -89,10 +117,15 @@ export const spacesApi = createApi({ return { data }; }, - invalidatesTags: (result, error, { id: spaceId }) => [{ type: TAG_NAME_FOR_GENERAL_ENTITY, id: spaceId }], + invalidatesTags: (result, error, { id: spaceId }) => [ + { type: TAG_NAME_FOR_GENERAL_ENTITY, id: spaceId }, + ], }), - deleteSpace: builder.mutation({ + deleteSpace: builder.mutation< + Database["public"]["Tables"]["spaces"]["Row"], + string + >({ queryFn: async (spaceId) => { const supabase = createSupabaseBrowserClient(); const { data, error } = await supabase @@ -107,16 +140,40 @@ export const spacesApi = createApi({ return { data }; }, - invalidatesTags: (result, error, spaceId) => [{ type: TAG_NAME_FOR_GENERAL_ENTITY, id: spaceId }], + invalidatesTags: (result, error, spaceId) => [ + { type: TAG_NAME_FOR_GENERAL_ENTITY, id: spaceId }, + ], + }), + // ========== + getSpacesByUserId: builder.query({ + queryFn: async () => { + const supabase = createSupabaseBrowserClient(); + const { + data: { user }, + } = await supabase.auth.getUser(); + + const { data, error } = await supabase + .from("spaces") + .select("*") + .eq("creator_user_id", user?.id); + + if (error) { + return { error: error.message }; + } + return { data }; + }, + providesTags: (result, error, id) => [ + { type: TAG_NAME_FOR_GENERAL_ENTITY, id }, + ], }), }), }); // Export the API hooks export const { - useGetSingleSpaceQuery, useCreateSpaceMutation, + useGetSingleSpaceQuery, useUpdateSpaceMutation, useDeleteSpaceMutation, + useGetSpacesByUserIdQuery, } = spacesApi; - diff --git a/mirror-2/tsconfig.json b/mirror-2/tsconfig.json index ca206332..b6e55e90 100644 --- a/mirror-2/tsconfig.json +++ b/mirror-2/tsconfig.json @@ -24,6 +24,13 @@ "@/*": ["./*"] } }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], + "include": [ + "next-env.d.ts", + "**/*.ts", + "**/*.tsx", + ".next/types/**/*.ts", + ".next/types/app/my/spaces/page.tsx", + ".next/types/app/my/assets/page.tsx" + ], "exclude": ["node_modules"] } diff --git a/mirror-2/utils/supabase/middleware.ts b/mirror-2/utils/supabase/middleware.ts index 93994e54..dac79412 100644 --- a/mirror-2/utils/supabase/middleware.ts +++ b/mirror-2/utils/supabase/middleware.ts @@ -22,17 +22,17 @@ export const updateSession = async (request: NextRequest) => { }, setAll(cookiesToSet) { cookiesToSet.forEach(({ name, value }) => - request.cookies.set(name, value), + request.cookies.set(name, value) ); response = NextResponse.next({ request, }); cookiesToSet.forEach(({ name, value, options }) => - response.cookies.set(name, value, options), + response.cookies.set(name, value, options) ); }, }, - }, + } ); // This will refresh session if expired - required for Server Components