From c94b53512f4c84c0de1ff43b36eeca86f4dd8667 Mon Sep 17 00:00:00 2001 From: Lewis Carhart Date: Sat, 5 Apr 2025 11:42:44 -0400 Subject: [PATCH] refactor: improve organization form components - Standardized formatting and structure in DeleteOrganization and UpdateOrganizationName components for better readability. - Enhanced UI elements with consistent Tailwind CSS classes and improved layout. - Maintained existing functionality while ensuring a cleaner and more modular codebase. --- .../organization/delete-organization.tsx | 195 +++++++++--------- .../organization/update-organization-name.tsx | 169 +++++++-------- 2 files changed, 184 insertions(+), 180 deletions(-) diff --git a/apps/app/src/components/forms/organization/delete-organization.tsx b/apps/app/src/components/forms/organization/delete-organization.tsx index c0cc280866..a2e67e2fa8 100644 --- a/apps/app/src/components/forms/organization/delete-organization.tsx +++ b/apps/app/src/components/forms/organization/delete-organization.tsx @@ -3,23 +3,24 @@ import { deleteOrganizationAction } from "@/actions/organization/delete-organization-action"; import { useI18n } from "@/locales/client"; import { - AlertDialog, - AlertDialogAction, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, - AlertDialogTrigger, + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogTrigger, } from "@comp/ui/alert-dialog"; import { Button } from "@comp/ui/button"; import { - Card, - CardDescription, - CardFooter, - CardHeader, - CardTitle, + Card, + CardContent, + CardDescription, + CardFooter, + CardHeader, + CardTitle, } from "@comp/ui/card"; import { Input } from "@comp/ui/input"; import { Label } from "@comp/ui/label"; @@ -30,92 +31,94 @@ import { useState } from "react"; import { toast } from "sonner"; export function DeleteOrganization({ - organizationId, + organizationId, }: { - organizationId: string; + organizationId: string; }) { - const t = useI18n(); - const [value, setValue] = useState(""); - const deleteOrganization = useAction(deleteOrganizationAction, { - onSuccess: () => { - toast.success(t("settings.general.org_delete_success")); - redirect("/"); - }, - onError: () => { - toast.error(t("settings.general.org_delete_error")); - }, - }); + const t = useI18n(); + const [value, setValue] = useState(""); + const deleteOrganization = useAction(deleteOrganizationAction, { + onSuccess: () => { + toast.success(t("settings.general.org_delete_success")); + redirect("/"); + }, + onError: () => { + toast.error(t("settings.general.org_delete_error")); + }, + }); - return ( - - -
- - - {t("settings.general.org_delete")} - -
- - {t("settings.general.org_delete_description")} - -
- -
+ return ( + + +
+ + {t("settings.general.org_delete")} + +
+ +
+ {t("settings.general.org_delete_description")} +
+
+
+ + +
- - - - - - - - {t("settings.general.org_delete_alert_title")} - - - {t("settings.general.org_delete_alert_description")} - - + + + + + + + + {t("settings.general.org_delete_alert_title")} + + + {t("settings.general.org_delete_alert_description")} + + -
- - setValue(e.target.value)} - /> -
+
+ + setValue(e.target.value)} + /> +
- - - {t("common.actions.cancel")} - - - deleteOrganization.execute({ - id: organizationId, - organizationId, - }) - } - disabled={value !== t("settings.general.delete_confirm")} - className="bg-destructive text-destructive-foreground hover:bg-destructive/90" - > - {deleteOrganization.status === "executing" ? ( - - ) : null} - {t("common.actions.delete")} - - -
-
- - - ); + + + {t("common.actions.cancel")} + + + deleteOrganization.execute({ + id: organizationId, + organizationId, + }) + } + disabled={value !== t("settings.general.delete_confirm")} + className="bg-destructive text-destructive-foreground hover:bg-destructive/90" + > + {deleteOrganization.status === "executing" ? ( + + ) : null} + {t("common.actions.delete")} + + +
+
+ + + ); } diff --git a/apps/app/src/components/forms/organization/update-organization-name.tsx b/apps/app/src/components/forms/organization/update-organization-name.tsx index bed28d05cd..1fa0d7eefd 100644 --- a/apps/app/src/components/forms/organization/update-organization-name.tsx +++ b/apps/app/src/components/forms/organization/update-organization-name.tsx @@ -5,19 +5,19 @@ import { organizationNameSchema } from "@/actions/schema"; import { useI18n } from "@/locales/client"; import { Button } from "@comp/ui/button"; import { - Card, - CardContent, - CardDescription, - CardFooter, - CardHeader, - CardTitle, + Card, + CardContent, + CardDescription, + CardFooter, + CardHeader, + CardTitle, } from "@comp/ui/card"; import { - Form, - FormControl, - FormField, - FormItem, - FormMessage, + Form, + FormControl, + FormField, + FormItem, + FormMessage, } from "@comp/ui/form"; import { Input } from "@comp/ui/input"; import { zodResolver } from "@hookform/resolvers/zod"; @@ -28,83 +28,84 @@ import { toast } from "sonner"; import type { z } from "zod"; export function UpdateOrganizationName({ - organizationName, + organizationName, }: { - organizationName: string; + organizationName: string; }) { - const t = useI18n(); - const updateOrganizationName = useAction(updateOrganizationNameAction, { - onSuccess: () => { - toast.success(t("settings.general.org_name_updated")); - }, - onError: () => { - toast.error(t("settings.general.org_name_error")); - }, - }); + const t = useI18n(); + const updateOrganizationName = useAction(updateOrganizationNameAction, { + onSuccess: () => { + toast.success(t("settings.general.org_name_updated")); + }, + onError: () => { + toast.error(t("settings.general.org_name_error")); + }, + }); - const form = useForm>({ - resolver: zodResolver(organizationNameSchema), - defaultValues: { - name: organizationName, - }, - }); + const form = useForm>({ + resolver: zodResolver(organizationNameSchema), + defaultValues: { + name: organizationName, + }, + }); - const onSubmit = (data: z.infer) => { - updateOrganizationName.execute(data); - }; + const onSubmit = (data: z.infer) => { + updateOrganizationName.execute(data); + }; - return ( -
- - - - - - {t("settings.general.org_name")} - + return ( + + + + + + {t("settings.general.org_name")} + - - {t("settings.general.org_name_description")} - - - - ( - - - - - - - )} - /> - - -
{t("settings.general.org_name_tip")}
- -
-
- - - ); + +
+ {t("settings.general.org_name_description")} +
+
+
+ + ( + + + + + + + )} + /> + + +
+ {t("settings.general.org_name_tip")} +
+ +
+
+ + + ); }