From bfdbb15a70d8f41ae1352733eb5fe214ca27c7e9 Mon Sep 17 00:00:00 2001 From: Mariano Fuentes Date: Thu, 7 Aug 2025 10:28:31 -0400 Subject: [PATCH 1/2] feat: update policy signature requirement and dependencies - Changed the default value of the isRequiredToSign field in the Policy model to true and updated existing records accordingly. - Removed the Employee Signature Requirement section from the UpdatePolicyOverview component. - Added new dependencies including @vitejs/plugin-react, jsdom, vite-tsconfig-paths, and vitest in bun.lock. - Updated the scheduler version in bun.lock to 0.26.0. --- .../components/UpdatePolicyOverview.tsx | 20 ------------------- bun.lock | 12 ++++++----- .../migration.sql | 5 +++++ packages/db/prisma/schema/policy.prisma | 2 +- 4 files changed, 13 insertions(+), 26 deletions(-) create mode 100644 packages/db/prisma/migrations/20250807142557_all_policies_signed/migration.sql diff --git a/apps/app/src/app/(app)/[orgId]/policies/[policyId]/components/UpdatePolicyOverview.tsx b/apps/app/src/app/(app)/[orgId]/policies/[policyId]/components/UpdatePolicyOverview.tsx index 3781bdbb4..29947124d 100644 --- a/apps/app/src/app/(app)/[orgId]/policies/[policyId]/components/UpdatePolicyOverview.tsx +++ b/apps/app/src/app/(app)/[orgId]/policies/[policyId]/components/UpdatePolicyOverview.tsx @@ -9,7 +9,6 @@ import { Calendar } from '@comp/ui/calendar'; import { cn } from '@comp/ui/cn'; import { Popover, PopoverContent, PopoverTrigger } from '@comp/ui/popover'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@comp/ui/select'; -import { Switch } from '@comp/ui/switch'; import { Departments, Frequency, Member, type Policy, PolicyStatus, User } from '@db'; import { format } from 'date-fns'; import { CalendarIcon, Loader2 } from 'lucide-react'; @@ -372,25 +371,6 @@ export function UpdatePolicyOverview({ } /> - - {/* Required to Sign Field */} -
- -
- - - {policy.isRequiredToSign ? 'Required' : 'Not Required'} - -
-
diff --git a/bun.lock b/bun.lock index 0fc962688..54850e7b9 100644 --- a/bun.lock +++ b/bun.lock @@ -424,13 +424,17 @@ "devDependencies": { "@tailwindcss/cli": "^4.1.10", "@tailwindcss/postcss": "^4.1.10", + "@vitejs/plugin-react": "^4.3.3", "autoprefixer": "^10.4.21", + "jsdom": "^26.1.0", "postcss": "^8.5.4", "react": "^19.1.1", "react-dom": "^19.1.0", "tailwindcss": "^4.1.8", "tsup": "^8.5.0", "typescript": "^5.8.3", + "vite-tsconfig-paths": "^5.1.4", + "vitest": "^3.2.4", }, "peerDependencies": { "react": "^19.1.1", @@ -4308,7 +4312,7 @@ "saxes": ["saxes@6.0.0", "", { "dependencies": { "xmlchars": "^2.2.0" } }, "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA=="], - "scheduler": ["scheduler@0.26.0", "", {}, "sha512-NlHwttCI/l5gCPR3D1nNXtWABUmBwvZpEQiD4IXSbIDq8BzLIK/7Ir5gTFSGZDUu37K5cMNp0hFtzO38sC7gWA=="], + "scheduler": ["scheduler@0.25.0", "", {}, "sha512-xFVuu11jh+xcO7JOAGJNOXld8/TcEHK/4CituBUeUb5hqxJLj9YuemAEuvm9gQ/+pgXYfbQuqAkiYu+u7YEsNA=="], "schema-utils": ["schema-utils@3.3.0", "", { "dependencies": { "@types/json-schema": "^7.0.8", "ajv": "^6.12.5", "ajv-keywords": "^3.5.2" } }, "sha512-pN/yOAvcC+5rQ5nERGuwrjLlYvLTbCibnZ1I7B1LaiAz9BRBlE9GMgE/eqV30P7aJQUf7Ddimy/RsbYO/GrVGg=="], @@ -5130,8 +5134,6 @@ "@react-email/components/@react-email/render": ["@react-email/render@1.1.2", "", { "dependencies": { "html-to-text": "^9.0.5", "prettier": "^3.5.3", "react-promise-suspense": "^0.3.4" }, "peerDependencies": { "react": "^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^18.0 || ^19.0 || ^19.0.0-rc" } }, "sha512-RnRehYN3v9gVlNMehHPHhyp2RQo7+pSkHDtXPvg3s0GbzM9SQMW4Qrf8GRNvtpLC4gsI+Wt0VatNRUFqjvevbw=="], - "@react-three/fiber/scheduler": ["scheduler@0.25.0", "", {}, "sha512-xFVuu11jh+xcO7JOAGJNOXld8/TcEHK/4CituBUeUb5hqxJLj9YuemAEuvm9gQ/+pgXYfbQuqAkiYu+u7YEsNA=="], - "@react-three/postprocessing/maath": ["maath@0.6.0", "", { "peerDependencies": { "@types/three": ">=0.144.0", "three": ">=0.144.0" } }, "sha512-dSb2xQuP7vDnaYqfoKzlApeRcR2xtN8/f7WV/TMAkBC8552TwTLtOO0JTcSygkYMjNDPoo6V01jTw/aPi4JrMw=="], "@semantic-release/github/@semantic-release/error": ["@semantic-release/error@4.0.0", "", {}, "sha512-mgdxrHTLOjOddRVYIYDo0fR3/v61GNN1YGkfbrjuIKg/uMgCd+Qzo3UAXJ+woLQQpos4pl5Esuw5A7AoNlzjUQ=="], @@ -5898,14 +5900,14 @@ "rc/strip-json-comments": ["strip-json-comments@2.0.1", "", {}, "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ=="], + "react-dom/scheduler": ["scheduler@0.26.0", "", {}, "sha512-NlHwttCI/l5gCPR3D1nNXtWABUmBwvZpEQiD4IXSbIDq8BzLIK/7Ir5gTFSGZDUu37K5cMNp0hFtzO38sC7gWA=="], + "react-dropzone/file-selector": ["file-selector@2.1.2", "", { "dependencies": { "tslib": "^2.7.0" } }, "sha512-QgXo+mXTe8ljeqUFaX3QVHc5osSItJ/Km+xpocx0aSqWGMSCf6qYs/VnzZgS864Pjn5iceMRFigeAV7AfTlaig=="], "react-email/chalk": ["chalk@5.5.0", "", {}, "sha512-1tm8DTaJhPBG3bIkVeZt1iZM9GfSX2lzOeDVZH9R9ffRHpmHvxZ/QhgQH/aDTkswQVt+YHdXAdS/In/30OjCbg=="], "react-promise-suspense/fast-deep-equal": ["fast-deep-equal@2.0.1", "", {}, "sha512-bCK/2Z4zLidyB4ReuIsvALH6w31YfAQDmXMqMx6FyfHqvBxtjC0eRumeSu4Bs3XtXwpyIywtSTrVT99BxY1f9w=="], - "react-reconciler/scheduler": ["scheduler@0.25.0", "", {}, "sha512-xFVuu11jh+xcO7JOAGJNOXld8/TcEHK/4CituBUeUb5hqxJLj9YuemAEuvm9gQ/+pgXYfbQuqAkiYu+u7YEsNA=="], - "read-cache/pify": ["pify@2.3.0", "", {}, "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog=="], "read-pkg/unicorn-magic": ["unicorn-magic@0.1.0", "", {}, "sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ=="], diff --git a/packages/db/prisma/migrations/20250807142557_all_policies_signed/migration.sql b/packages/db/prisma/migrations/20250807142557_all_policies_signed/migration.sql new file mode 100644 index 000000000..751ae3120 --- /dev/null +++ b/packages/db/prisma/migrations/20250807142557_all_policies_signed/migration.sql @@ -0,0 +1,5 @@ +-- Update the default value for the isRequiredToSign field to true +ALTER TABLE "Policy" ALTER COLUMN "isRequiredToSign" SET DEFAULT true; + +-- Set all existing policies to be required to sign +UPDATE "Policy" SET "isRequiredToSign" = true WHERE "isRequiredToSign" IS FALSE OR "isRequiredToSign" IS NULL; \ No newline at end of file diff --git a/packages/db/prisma/schema/policy.prisma b/packages/db/prisma/schema/policy.prisma index ade60c2fd..17357ba32 100644 --- a/packages/db/prisma/schema/policy.prisma +++ b/packages/db/prisma/schema/policy.prisma @@ -6,7 +6,7 @@ model Policy { content Json[] frequency Frequency? department Departments? - isRequiredToSign Boolean @default(false) + isRequiredToSign Boolean @default(true) signedBy String[] @default([]) reviewDate DateTime? isArchived Boolean @default(false) From c4bc45c6538951df172e720b09672b9cb0afabfe Mon Sep 17 00:00:00 2001 From: Mariano Fuentes Date: Thu, 7 Aug 2025 10:45:10 -0400 Subject: [PATCH 2/2] chore: update @trycompai/db version and remove signature requirement fields - Updated the @trycompai/db dependency version to 1.3.3 in package.json and bun.lock files. - Removed the isRequiredToSign field from various policy-related actions and components to simplify the policy management process. --- apps/app/package.json | 2 +- .../submit-policy-for-approval-action.ts | 11 +------- .../policies/update-policy-form-action.ts | 4 +-- .../policies/update-policy-overview-action.ts | 9 +------ apps/app/src/actions/schema.ts | 2 -- .../[orgId]/people/[employeeId]/page.tsx | 1 - .../components/EmployeesOverview.tsx | 3 --- .../components/UpdatePolicyOverview.tsx | 7 ------ .../forms/policies/policy-overview.tsx | 21 ---------------- .../forms/policies/update-policy-form.tsx | 25 ------------------- apps/portal/package.json | 2 +- bun.lock | 8 +++--- packages/db/package.json | 2 +- 13 files changed, 11 insertions(+), 86 deletions(-) diff --git a/apps/app/package.json b/apps/app/package.json index c87ecf70d..c9c32f4bb 100644 --- a/apps/app/package.json +++ b/apps/app/package.json @@ -46,7 +46,7 @@ "@tiptap/extension-table-row": "^2.22.3", "@trigger.dev/react-hooks": "3.3.17", "@trigger.dev/sdk": "3.3.17", - "@trycompai/db": "^1.3.2", + "@trycompai/db": "^1.3.3", "@types/canvas-confetti": "^1.9.0", "@types/three": "^0.177.0", "@uploadthing/react": "^7.3.0", diff --git a/apps/app/src/actions/policies/submit-policy-for-approval-action.ts b/apps/app/src/actions/policies/submit-policy-for-approval-action.ts index 214046415..ad25e71ca 100644 --- a/apps/app/src/actions/policies/submit-policy-for-approval-action.ts +++ b/apps/app/src/actions/policies/submit-policy-for-approval-action.ts @@ -16,15 +16,7 @@ export const submitPolicyForApprovalAction = authActionClient }, }) .action(async ({ parsedInput, ctx }) => { - const { - id, - assigneeId, - department, - review_frequency, - review_date, - isRequiredToSign, - approverId, - } = parsedInput; + const { id, assigneeId, department, review_frequency, review_date, approverId } = parsedInput; const { user, session } = ctx; if (!user.id || !session.activeOrganizationId) { @@ -49,7 +41,6 @@ export const submitPolicyForApprovalAction = authActionClient department, frequency: review_frequency, reviewDate: newReviewDate, - isRequiredToSign: isRequiredToSign === 'required', approverId, }, }); diff --git a/apps/app/src/actions/policies/update-policy-form-action.ts b/apps/app/src/actions/policies/update-policy-form-action.ts index cc6dc6e9c..3edac74d0 100644 --- a/apps/app/src/actions/policies/update-policy-form-action.ts +++ b/apps/app/src/actions/policies/update-policy-form-action.ts @@ -40,8 +40,7 @@ export const updatePolicyFormAction = authActionClient }, }) .action(async ({ parsedInput, ctx }) => { - const { id, status, assigneeId, department, review_frequency, review_date, isRequiredToSign } = - parsedInput; + const { id, status, assigneeId, department, review_frequency, review_date } = parsedInput; const { user, session } = ctx; if (!user.id || !session.activeOrganizationId) { @@ -81,7 +80,6 @@ export const updatePolicyFormAction = authActionClient department, frequency: review_frequency, reviewDate, - isRequiredToSign: isRequiredToSign === 'required', ...(lastPublishedAt && { lastPublishedAt }), }, }); diff --git a/apps/app/src/actions/policies/update-policy-overview-action.ts b/apps/app/src/actions/policies/update-policy-overview-action.ts index 59f363768..9445d40c1 100644 --- a/apps/app/src/actions/policies/update-policy-overview-action.ts +++ b/apps/app/src/actions/policies/update-policy-overview-action.ts @@ -18,7 +18,7 @@ export const updatePolicyOverviewAction = authActionClient }, }) .action(async ({ parsedInput, ctx }) => { - const { id, title, description, isRequiredToSign } = parsedInput; + const { id, title, description } = parsedInput; const { user, session } = ctx; if (!user) { @@ -52,13 +52,6 @@ export const updatePolicyOverviewAction = authActionClient data: { name: title, description, - // Use type assertion to handle the new field - // that might not be in the generated types yet - ...(isRequiredToSign !== undefined - ? ({ - isRequiredToSign: isRequiredToSign === 'required', - } as any) - : {}), }, }); diff --git a/apps/app/src/actions/schema.ts b/apps/app/src/actions/schema.ts index 246717025..8a95aa782 100644 --- a/apps/app/src/actions/schema.ts +++ b/apps/app/src/actions/schema.ts @@ -291,7 +291,6 @@ export const updatePolicyOverviewSchema = z.object({ id: z.string(), title: z.string(), description: z.string(), - isRequiredToSign: z.enum(['required', 'not_required']).optional(), entityId: z.string(), }); @@ -302,7 +301,6 @@ export const updatePolicyFormSchema = z.object({ department: z.nativeEnum(Departments), review_frequency: z.nativeEnum(Frequency), review_date: z.date(), - isRequiredToSign: z.enum(['required', 'not_required']), approverId: z.string().optional().nullable(), // Added for selecting an approver entityId: z.string(), }); diff --git a/apps/app/src/app/(app)/[orgId]/people/[employeeId]/page.tsx b/apps/app/src/app/(app)/[orgId]/people/[employeeId]/page.tsx index 587b8abfc..61e870d0d 100644 --- a/apps/app/src/app/(app)/[orgId]/people/[employeeId]/page.tsx +++ b/apps/app/src/app/(app)/[orgId]/people/[employeeId]/page.tsx @@ -100,7 +100,6 @@ const getPoliciesTasks = async (employeeId: string) => { const policies = await db.policy.findMany({ where: { organizationId: organizationId, - isRequiredToSign: true, }, orderBy: { name: 'asc', diff --git a/apps/app/src/app/(app)/[orgId]/people/dashboard/components/EmployeesOverview.tsx b/apps/app/src/app/(app)/[orgId]/people/dashboard/components/EmployeesOverview.tsx index b5faa8fb7..0cfa16347 100644 --- a/apps/app/src/app/(app)/[orgId]/people/dashboard/components/EmployeesOverview.tsx +++ b/apps/app/src/app/(app)/[orgId]/people/dashboard/components/EmployeesOverview.tsx @@ -52,13 +52,10 @@ export async function EmployeesOverview() { return roles.includes('employee'); }); - console.log(employees); - // Fetch required policies policies = await db.policy.findMany({ where: { organizationId: organizationId, - isRequiredToSign: true, }, }); diff --git a/apps/app/src/app/(app)/[orgId]/policies/[policyId]/components/UpdatePolicyOverview.tsx b/apps/app/src/app/(app)/[orgId]/policies/[policyId]/components/UpdatePolicyOverview.tsx index 29947124d..b56ac17db 100644 --- a/apps/app/src/app/(app)/[orgId]/policies/[policyId]/components/UpdatePolicyOverview.tsx +++ b/apps/app/src/app/(app)/[orgId]/policies/[policyId]/components/UpdatePolicyOverview.tsx @@ -104,8 +104,6 @@ export function UpdatePolicyOverview({ const assigneeId = selectedAssigneeId; // Use state instead of form data const department = formData.get('department') as Departments; const reviewFrequency = formData.get('review_frequency') as Frequency; - const isRequiredToSign = - formData.get('isRequiredToSign') === 'on' ? 'required' : 'not_required'; // Get review date from the form or use the existing one const reviewDate = tempDate || (policy.reviewDate ? new Date(policy.reviewDate) : new Date()); @@ -117,7 +115,6 @@ export function UpdatePolicyOverview({ assigneeId !== policy.assigneeId || department !== policy.department || reviewFrequency !== policy.frequency || - (policy.isRequiredToSign ? 'required' : 'not_required') !== isRequiredToSign || (policy.reviewDate ? new Date(policy.reviewDate).toDateString() : '') !== reviewDate.toDateString()); @@ -133,7 +130,6 @@ export function UpdatePolicyOverview({ department, review_frequency: reviewFrequency, review_date: reviewDate, - isRequiredToSign, approverId: null, entityId: policy.id, }); @@ -152,8 +148,6 @@ export function UpdatePolicyOverview({ const assigneeId = selectedAssigneeId; // Use state instead of form data const department = formData.get('department') as Departments; const reviewFrequency = formData.get('review_frequency') as Frequency; - const isRequiredToSign = - formData.get('isRequiredToSign') === 'on' ? 'required' : 'not_required'; // Get review date from the form or use the existing one const reviewDate = tempDate || (policy.reviewDate ? new Date(policy.reviewDate) : new Date()); @@ -166,7 +160,6 @@ export function UpdatePolicyOverview({ department, review_frequency: reviewFrequency, review_date: reviewDate, - isRequiredToSign, approverId: selectedApproverId, entityId: policy.id, }); diff --git a/apps/app/src/components/forms/policies/policy-overview.tsx b/apps/app/src/components/forms/policies/policy-overview.tsx index eea096c54..948295441 100644 --- a/apps/app/src/components/forms/policies/policy-overview.tsx +++ b/apps/app/src/components/forms/policies/policy-overview.tsx @@ -10,7 +10,6 @@ import { cn } from '@comp/ui/cn'; import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@comp/ui/form'; import { Popover, PopoverContent, PopoverTrigger } from '@comp/ui/popover'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@comp/ui/select'; -import { Switch } from '@comp/ui/switch'; import { Departments, Frequency, type Policy, type PolicyStatus } from '@db'; import { zodResolver } from '@hookform/resolvers/zod'; import { format } from 'date-fns'; @@ -52,7 +51,6 @@ export function UpdatePolicyOverview({ policy }: { policy: Policy }) { department: policy.department ?? Departments.admin, review_frequency: policy.frequency ?? Frequency.monthly, review_date: reviewDate, - isRequiredToSign: policy.isRequiredToSign ? 'required' : 'not_required', }, }); @@ -64,7 +62,6 @@ export function UpdatePolicyOverview({ policy }: { policy: Policy }) { department: data.department, review_frequency: data.review_frequency, review_date: data.review_date, - isRequiredToSign: data.isRequiredToSign, entityId: data.id, }); }; @@ -194,24 +191,6 @@ export function UpdatePolicyOverview({ policy }: { policy: Policy }) { )} /> - ( - - {'Signature Requirement'} - - { - field.onChange(checked ? 'required' : 'not_required'); - }} - /> - - - - )} - />