diff --git a/apps/app/src/components/forms/policies/create-policy-comment-form.tsx b/apps/app/src/components/forms/policies/create-policy-comment-form.tsx index 48bd56c97c..3c733d7713 100644 --- a/apps/app/src/components/forms/policies/create-policy-comment-form.tsx +++ b/apps/app/src/components/forms/policies/create-policy-comment-form.tsx @@ -1,6 +1,6 @@ "use client"; -import { createPolicyCommentAction } from "@/actions/policies/create-policy-comment"; +import { createPolicyCommentAction } from "@/actions/policy/create-policy-comment"; import { createPolicyCommentSchema } from "@/actions/schema"; import { useI18n } from "@/locales/client"; import { diff --git a/apps/app/src/components/forms/policies/policy-overview.tsx b/apps/app/src/components/forms/policies/policy-overview.tsx index fdf4f5565a..b3f5443bb3 100644 --- a/apps/app/src/components/forms/policies/policy-overview.tsx +++ b/apps/app/src/components/forms/policies/policy-overview.tsx @@ -4,39 +4,39 @@ import { updatePolicyFormAction } from "@/actions/policies/update-policy-form-ac import { updatePolicyFormSchema } from "@/actions/schema"; import { SelectUser } from "@/components/select-user"; import { - STATUS_TYPES, - StatusPolicies, - type StatusType, + STATUS_TYPES, + StatusPolicies, + type StatusType, } from "@/components/status-policies"; import { useI18n } from "@/locales/client"; import { - Departments, - Frequency, - type OrganizationPolicy, - type Policy, - type PolicyStatus, - type Risk, - RiskCategory, - RiskStatus, - type User, + Departments, + Frequency, + type OrganizationPolicy, + type Policy, + type PolicyStatus, + type Risk, + RiskCategory, + RiskStatus, + type User, } from "@bubba/db"; import { Button } from "@bubba/ui/button"; import { Checkbox } from "@bubba/ui/checkbox"; import { - Form, - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage, + Form, + FormControl, + FormField, + FormItem, + FormLabel, + FormMessage, } from "@bubba/ui/form"; import { Popover, PopoverTrigger, PopoverContent } from "@bubba/ui/popover"; import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, } from "@bubba/ui/select"; import { zodResolver } from "@hookform/resolvers/zod"; import { CalendarIcon, Loader2 } from "lucide-react"; @@ -50,278 +50,281 @@ import { cn } from "@bubba/ui/cn"; import { useSession } from "next-auth/react"; export function UpdatePolicyOverview({ - organizationPolicy, - users, + organizationPolicy, + users, }: { - organizationPolicy: OrganizationPolicy & { policy: Policy }; - users: User[]; + organizationPolicy: OrganizationPolicy & { policy: Policy }; + users: User[]; }) { - const t = useI18n(); - const session = useSession(); + const t = useI18n(); + const session = useSession(); - const updatePolicyForm = useAction(updatePolicyFormAction, { - onSuccess: () => { - toast.success(t("policies.overview.form.update_policy_success")); - }, - onError: () => { - toast.error(t("policies.overview.form.update_policy_error")); - }, - }); + const updatePolicyForm = useAction(updatePolicyFormAction, { + onSuccess: () => { + toast.success(t("policies.overview.form.update_policy_success")); + }, + onError: () => { + toast.error(t("policies.overview.form.update_policy_error")); + }, + }); - const calculateReviewDate = (): Date => { - if (!organizationPolicy.reviewDate) { - return new Date(); - } - return new Date(organizationPolicy.reviewDate); - }; + const calculateReviewDate = (): Date => { + if (!organizationPolicy.reviewDate) { + return new Date(); + } + return new Date(organizationPolicy.reviewDate); + }; - const reviewDate = calculateReviewDate(); + const reviewDate = calculateReviewDate(); - const form = useForm>({ - resolver: zodResolver(updatePolicyFormSchema), - defaultValues: { - id: organizationPolicy.id, - status: organizationPolicy.status, - ownerId: organizationPolicy.ownerId ?? session.data?.user?.id, - department: organizationPolicy.department ?? Departments.admin, - review_frequency: organizationPolicy.frequency ?? Frequency.monthly, - review_date: reviewDate, - isRequiredToSign: (organizationPolicy.policy as any).isRequiredToSign ? "required" : "not_required", - }, - }); + const form = useForm>({ + resolver: zodResolver(updatePolicyFormSchema), + defaultValues: { + id: organizationPolicy.id, + status: organizationPolicy.status, + ownerId: organizationPolicy.ownerId ?? session.data?.user?.id, + department: organizationPolicy.department ?? Departments.admin, + review_frequency: organizationPolicy.frequency ?? Frequency.monthly, + review_date: reviewDate, + isRequiredToSign: (organizationPolicy.policy as any).isRequiredToSign + ? "required" + : "not_required", + }, + }); - const onSubmit = (data: z.infer) => { - updatePolicyForm.execute({ - id: data.id, - status: data.status as PolicyStatus, - ownerId: data.ownerId, - department: data.department, - review_frequency: data.review_frequency, - review_date: data.review_date, - isRequiredToSign: data.isRequiredToSign, - }); - }; + const onSubmit = (data: z.infer) => { + updatePolicyForm.execute({ + id: data.id, + status: data.status as PolicyStatus, + ownerId: data.ownerId, + department: data.department, + review_frequency: data.review_frequency, + review_date: data.review_date, + isRequiredToSign: data.isRequiredToSign, + }); + }; - return ( -
- -
- ( - - {t("common.assignee.label")} - - - - - - )} - /> - ( - - {t("risk.form.risk_status")} - - - - - - )} - /> - ( - - - {t("policies.overview.form.review_frequency")} - - - - - - - )} - /> - ( - - {t("risk.form.risk_department")} - - form.handleSubmit(onSubmit)} + > + + + + + + + + + + + )} + /> + ( + + {t("risk.form.risk_status")} + + + + + + )} + /> + ( + + + {t("policies.overview.form.review_frequency")} + + + + + + + )} + /> + ( + + {t("risk.form.risk_department")} + + - - - - )} - /> -
-
- ( - - {t("policies.overview.form.review_date")} - - - - - - - - date <= new Date()} - initialFocus - /> - - - - - )} - /> - ( - - - {t("policies.overview.form.signature_requirement")} - - - - - - )} - /> -
-
- -
-
- - ); + return ( + + {formattedDepartment} + + ); + })} + + + + + + )} + /> + +
+ ( + + {t("policies.overview.form.review_date")} + + + +
+ +
+
+
+ + date <= new Date()} + initialFocus + /> + +
+ +
+ )} + /> + ( + + + {t("policies.overview.form.signature_requirement")} + + + + + + )} + /> +
+
+ +
+ + + ); }