| 1 | import z from 'zod' |
| 2 | import { updateTimesheetDefaultsSchema as |
| 3 | import { |
| 4 | customFieldDefinitionCreateSchema, |
| 5 | customFieldDefinitionUpdateSchema, |
| 6 | } from '@/lib/custom-fields' |
| 7 | import { projectStatus } |
| 8 | |
| 9 | export const clientInvolvementEntities = |
| 10 | 'proposals', |
| 11 | 'requirements', |
| 12 | 'milestones', |
| 13 | 'timesheets', |
| 14 | 'expenses', |
| 15 | 'invoices', |
| 16 | ] as const |
| 17 | |
| 18 | export type ClientInvolvementEntity |
| 19 | |
| 20 | export const clientInvolvementToggleSchema = |
| 21 | |
| 22 | export const clientInvolvementValueSchema = |
| 23 | proposals: clientInvolvementToggleSchema, |
| 24 | requirements: clientInvolvementToggleSchema, |
| 25 | milestones: clientInvolvementToggleSchema, |
| 26 | timesheets: clientInvolvementToggleSchema, |
| 27 | expenses: clientInvolvementToggleSchema, |
| 28 | invoices: clientInvolvementToggleSchema, |
| 29 | }) |
| 30 | |
| 31 | export type ClientInvolvementValue |
| 32 | typeof clientInvolvementValueSchema |
| 33 | > |
| 34 | |
| 35 | export const defaultClientInvolvement: |
| 36 | proposals: 'on', |
| 37 | requirements: 'on', |
| 38 | milestones: 'on', |
| 39 | timesheets: 'on', |
| 40 | expenses: 'on', |
| 41 | invoices: 'on', |
| 42 | } |
| 43 | |
| 44 | export const clientInvolvementEntityLabels: |
| 45 | ClientInvolvementEntity, |
| 46 | { label: |
| 47 | > = { |
| 48 | proposals: { |
| 49 | label: 'Proposals', |
| 50 | description: 'Client signs proposals before work begins.', |
| 51 | }, |
| 52 | requirements: { |
| 53 | label: 'Requirements', |
| 54 | description: 'Client approves requirements before they can be built.', |
| 55 | }, |
| 56 | milestones: { |
| 57 | label: 'Milestones', |
| 58 | description: 'Client accepts milestone deliveries.', |
| 59 | }, |
| 60 | timesheets: { |
| 61 | label: 'Timesheets', |
| 62 | description: |
| 63 | 'Client approves timesheet reports before they can be invoiced.', |
| 64 | }, |
| 65 | expenses: { |
| 66 | label: 'Expenses', |
| 67 | description: 'Client approves expenses before they can be invoiced.', |
| 68 | }, |
| 69 | invoices: { |
| 70 | label: 'Invoices', |
| 71 | description: |
| 72 | 'Client receives invoices and marks them paid. If off, you mark invoices paid yourself.', |
| 73 | }, |
| 74 | } |
| 75 | |
| 76 | export { |
| 77 | type TimesheetDuration, |
| 78 | timesheetDurationOptions, |
| 79 | } from '@/app/(organization)/[org]/settings/common' |
| 80 | |
| 81 | export const updateProjectTimesheetDefaultsSchema = |
| 82 | orgTimesheetDefaultsSchema.extend({ |
| 83 | projectId: z.string |
| 84 | }) |
| 85 | |
| 86 | export const renameProjectSchema = |
| 87 | projectId: z.string |
| 88 | organizationId: z.string |
| 89 | name: z.string |
| 90 | dueDate: z.date |
| 91 | slug: z |
| 92 | .string() |
| 93 | .min(1, ' |
| 94 | .max(100) |
| 95 | .regex(/^[a-z0-9 |
| 96 | }) |
| 97 | |
| 98 | export const updateProjectStatusSchema = |
| 99 | projectId: z.string |
| 100 | organizationId: z.string |
| 101 | status: z.enum |
| 102 | }) |
| 103 | |
| 104 | export const deleteProjectSchema = |
| 105 | projectId: z.string |
| 106 | organizationId: z.string |
| 107 | confirmName: z.string |
| 108 | }) |
| 109 | |
| 110 | export const updateProjectBillingDetailsSchema = |
| 111 | organizationId: z.string |
| 112 | projectId: z.string |
| 113 | invoiceFromName: z.string |
| 114 | invoiceFromAddress: z.string |
| 115 | invoiceToName: z.string |
| 116 | invoiceToAddress: z.string |
| 117 | }) |
| 118 | |
| 119 | export const clientInvolvementProjectSchema = |
| 120 | clientInvolvement: clientInvolvementValueSchema, |
| 121 | projectId: z.string |
| 122 | organizationId: z.string |
| 123 | }) |
| 124 | |
| 125 | export const createProjectCustomFieldSchema = |
| 126 | organizationId: z.string |
| 127 | projectId: z.string |
| 128 | definition: customFieldDefinitionCreateSchema, |
| 129 | }) |
| 130 | |
| 131 | export const updateProjectCustomFieldSchema = |
| 132 | organizationId: z.string |
| 133 | projectId: z.string |
| 134 | fieldId: z.string |
| 135 | definition: customFieldDefinitionUpdateSchema, |
| 136 | }) |
| 137 | |
| 138 | export const deleteProjectCustomFieldSchema = |
| 139 | organizationId: z.string |
| 140 | projectId: z.string |
| 141 | fieldId: z.string |
| 142 | }) |
| 143 | |
| 144 | export const importOrgCustomFieldsSchema = |
| 145 | organizationId: z.string |
| 146 | projectId: z.string |
| 147 | fieldIds: z |
| 148 | .array(z.string |
| 149 | .min(1) |
| 150 | .refine((ids) |
| 151 | message: 'fieldIds must be unique', |
| 152 | }), |
| 153 | }) |