From 4c839911d990b36f2998abfca396d0e17372e3ea Mon Sep 17 00:00:00 2001 From: Rohit Kumar Saini Date: Fri, 6 Dec 2024 22:56:48 +0100 Subject: [PATCH 1/4] fix: issue on reset password --- app/routes/_auth+/reset-password.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/routes/_auth+/reset-password.tsx b/app/routes/_auth+/reset-password.tsx index 36414975b..52df4925c 100644 --- a/app/routes/_auth+/reset-password.tsx +++ b/app/routes/_auth+/reset-password.tsx @@ -68,6 +68,8 @@ export async function action({ context, request }: ActionFunctionArgs) { ResetPasswordSchema ); + console.log({ password, refreshToken }); + const authSession = await refreshAccessToken(refreshToken); await updateAccountPassword( @@ -104,7 +106,11 @@ export default function ResetPassword() { } = supabaseClient.auth.onAuthStateChange((event, supabaseSession) => { // In local development, we doesn't see "PASSWORD_RECOVERY" event because: // Effect run twice and break listener chain - if (event === "PASSWORD_RECOVERY" || event === "SIGNED_IN") { + if ( + event === "PASSWORD_RECOVERY" || + event === "SIGNED_IN" || + event === "INITIAL_SESSION" + ) { const refreshToken = supabaseSession?.refresh_token; if (!refreshToken) return; From a97ec326ccccf954116f30340e357a16b8e8df18 Mon Sep 17 00:00:00 2001 From: Rohit Kumar Saini Date: Fri, 6 Dec 2024 22:59:05 +0100 Subject: [PATCH 2/4] remove unnecessary console.log --- app/routes/_auth+/reset-password.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/routes/_auth+/reset-password.tsx b/app/routes/_auth+/reset-password.tsx index 52df4925c..99dfd7b2c 100644 --- a/app/routes/_auth+/reset-password.tsx +++ b/app/routes/_auth+/reset-password.tsx @@ -68,8 +68,6 @@ export async function action({ context, request }: ActionFunctionArgs) { ResetPasswordSchema ); - console.log({ password, refreshToken }); - const authSession = await refreshAccessToken(refreshToken); await updateAccountPassword( From c527a74a3fd2a6798374f1d5f97142cf8bd44151 Mon Sep 17 00:00:00 2001 From: Rohit Kumar Saini Date: Sat, 7 Dec 2024 17:02:08 +0100 Subject: [PATCH 3/4] fix(edit-category): fix issue on edit category page --- app/modules/category/service.server.ts | 11 +- .../_layout+/categories.$categoryId_.edit.tsx | 118 +++++++++--------- 2 files changed, 63 insertions(+), 66 deletions(-) diff --git a/app/modules/category/service.server.ts b/app/modules/category/service.server.ts index d55496d93..c25abea53 100644 --- a/app/modules/category/service.server.ts +++ b/app/modules/category/service.server.ts @@ -185,16 +185,15 @@ export async function getCategory({ organizationId, }: Pick) { try { - return await db.category.findUnique({ - where: { - id, - organizationId, - }, + return await db.category.findFirstOrThrow({ + where: { id, organizationId }, }); } catch (cause) { throw new ShelfError({ cause, - message: "Something went wrong while fetching the category", + title: "Category not found", + message: + "The category you are trying to access does not exist or you do not have permission to access it.", additionalData: { id, organizationId }, label, }); diff --git a/app/routes/_layout+/categories.$categoryId_.edit.tsx b/app/routes/_layout+/categories.$categoryId_.edit.tsx index 76c4cbb82..c21c9d915 100644 --- a/app/routes/_layout+/categories.$categoryId_.edit.tsx +++ b/app/routes/_layout+/categories.$categoryId_.edit.tsx @@ -34,6 +34,7 @@ const title = "Edit category"; export async function loader({ context, request, params }: LoaderFunctionArgs) { const authSession = context.getSession(); const { userId } = authSession; + const { categoryId: id } = getParams( params, z.object({ categoryId: z.string() }), @@ -52,11 +53,9 @@ export async function loader({ context, request, params }: LoaderFunctionArgs) { const category = await getCategory({ id, organizationId }); - const colorFromServer = category?.color; + const colorFromServer = category.color; - const header = { - title, - }; + const header = { title }; return json(data({ header, colorFromServer, category })); } catch (cause) { @@ -123,68 +122,67 @@ export default function EditCategory() { const { colorFromServer, category } = useLoaderData(); const actionData = useActionData(); - return category && colorFromServer ? ( - <> -
-
-
- +
+
+ + +
+ - -
- -
+
-
- - -
+
+ +
- {actionData?.error ? ( -
- {actionData?.error?.message} -
- ) : null} - - - ) : null; +
+ {actionData?.error ? ( +
+ {actionData?.error?.message} +
+ ) : null} + + ); } From 62f0cf5c86107cd7305b75f16b2c16a3868051ca Mon Sep 17 00:00:00 2001 From: Rohit Kumar Saini Date: Sat, 7 Dec 2024 17:06:38 +0100 Subject: [PATCH 4/4] remove unwanted code --- app/routes/_auth+/reset-password.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/routes/_auth+/reset-password.tsx b/app/routes/_auth+/reset-password.tsx index 99dfd7b2c..36414975b 100644 --- a/app/routes/_auth+/reset-password.tsx +++ b/app/routes/_auth+/reset-password.tsx @@ -104,11 +104,7 @@ export default function ResetPassword() { } = supabaseClient.auth.onAuthStateChange((event, supabaseSession) => { // In local development, we doesn't see "PASSWORD_RECOVERY" event because: // Effect run twice and break listener chain - if ( - event === "PASSWORD_RECOVERY" || - event === "SIGNED_IN" || - event === "INITIAL_SESSION" - ) { + if (event === "PASSWORD_RECOVERY" || event === "SIGNED_IN") { const refreshToken = supabaseSession?.refresh_token; if (!refreshToken) return;