Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -49,7 +41,6 @@ export const submitPolicyForApprovalAction = authActionClient
department,
frequency: review_frequency,
reviewDate: newReviewDate,
isRequiredToSign: isRequiredToSign === 'required',
approverId,
},
});
Expand Down
4 changes: 1 addition & 3 deletions apps/app/src/actions/policies/update-policy-form-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -81,7 +80,6 @@ export const updatePolicyFormAction = authActionClient
department,
frequency: review_frequency,
reviewDate,
isRequiredToSign: isRequiredToSign === 'required',
...(lastPublishedAt && { lastPublishedAt }),
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
: {}),
},
});

Expand Down
2 changes: 0 additions & 2 deletions apps/app/src/actions/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
});

Expand All @@ -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(),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ const getPoliciesTasks = async (employeeId: string) => {
const policies = await db.policy.findMany({
where: {
organizationId: organizationId,
isRequiredToSign: true,
},
orderBy: {
name: 'asc',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -105,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());
Expand All @@ -118,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());

Expand All @@ -134,7 +130,6 @@ export function UpdatePolicyOverview({
department,
review_frequency: reviewFrequency,
review_date: reviewDate,
isRequiredToSign,
approverId: null,
entityId: policy.id,
});
Expand All @@ -153,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());
Expand All @@ -167,7 +160,6 @@ export function UpdatePolicyOverview({
department,
review_frequency: reviewFrequency,
review_date: reviewDate,
isRequiredToSign,
approverId: selectedApproverId,
entityId: policy.id,
});
Expand Down Expand Up @@ -372,25 +364,6 @@ export function UpdatePolicyOverview({
}
/>
</div>

{/* Required to Sign Field */}
<div className="mt-2 flex flex-col gap-2">
<label htmlFor="isRequiredToSign" className="text-sm font-medium">
Employee Signature Requirement
</label>
<div className="mt-4 flex items-center space-x-2">
<Switch
id="isRequiredToSign"
name="isRequiredToSign"
disabled={fieldsDisabled}
defaultChecked={policy.isRequiredToSign}
onCheckedChange={handleFormChange}
/>
<span className="text-sm text-gray-500">
{policy.isRequiredToSign ? 'Required' : 'Not Required'}
</span>
</div>
</div>
</div>

<div className="col-span-1 flex justify-end gap-2 md:col-span-2">
Expand Down
21 changes: 0 additions & 21 deletions apps/app/src/components/forms/policies/policy-overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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',
},
});

Expand All @@ -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,
});
};
Expand Down Expand Up @@ -194,24 +191,6 @@ export function UpdatePolicyOverview({ policy }: { policy: Policy }) {
</FormItem>
)}
/>
<FormField
control={form.control}
name="isRequiredToSign"
render={({ field }) => (
<FormItem className="flex flex-col gap-3">
<FormLabel>{'Signature Requirement'}</FormLabel>
<FormControl>
<Switch
checked={field.value === 'required'}
onCheckedChange={(checked) => {
field.onChange(checked ? 'required' : 'not_required');
}}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<div className="mt-4 flex justify-end">
<Button
Expand Down
25 changes: 0 additions & 25 deletions apps/app/src/components/forms/policies/update-policy-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@c
import { Button } from '@comp/ui/button';
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@comp/ui/form';
import { Input } from '@comp/ui/input';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@comp/ui/select';
import { Textarea } from '@comp/ui/textarea';
import { Policy } from '@db';
import { zodResolver } from '@hookform/resolvers/zod';
Expand Down Expand Up @@ -36,7 +35,6 @@ export function UpdatePolicyForm({ policy }: { policy: Policy }) {
id: policy.id,
title: policy.name,
description: policy.description ?? '',
isRequiredToSign: policy.isRequiredToSign ? 'required' : 'not_required',
entityId: policy.id,
},
});
Expand All @@ -47,7 +45,6 @@ export function UpdatePolicyForm({ policy }: { policy: Policy }) {
id: data.id,
title: data.title,
description: data.description,
isRequiredToSign: data.isRequiredToSign,
entityId: data.id,
});
};
Expand Down Expand Up @@ -97,28 +94,6 @@ export function UpdatePolicyForm({ policy }: { policy: Policy }) {
</FormItem>
)}
/>
<FormField
control={form.control}
name="isRequiredToSign"
render={({ field }) => (
<FormItem>
<FormLabel>{'Signature Requirement'}</FormLabel>
<FormControl>
<div className="mt-3">
<Select value={field.value} onValueChange={field.onChange}>
<SelectTrigger>
<SelectValue placeholder={'Select signature requirement'} />
</SelectTrigger>
<SelectContent>
<SelectItem value="required">{'Required'}</SelectItem>
<SelectItem value="not_required">{'Not Required'}</SelectItem>
</SelectContent>
</Select>
</div>
</FormControl>
</FormItem>
)}
/>
</div>
<div className="mt-8 flex justify-end">
<Button
Expand Down
2 changes: 1 addition & 1 deletion apps/portal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@react-email/render": "^1.1.2",
"@t3-oss/env-nextjs": "^0.13.8",
"@trycompai/analytics": "workspace:*",
"@trycompai/db": "^1.3.0",
"@trycompai/db": "^1.3.3",
"@trycompai/email": "workspace:*",
"@trycompai/kv": "workspace:*",
"@trycompai/ui": "workspace:*",
Expand Down
20 changes: 12 additions & 8 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/db/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@trycompai/db",
"description": "Database package with Prisma client and schema for Comp AI",
"version": "1.3.2",
"version": "1.3.3",
"dependencies": {
"@prisma/client": "^6.13.0",
"dotenv": "^16.4.5"
Expand Down
Loading
Loading