Skip to content

Commit 6e0b968

Browse files
github-actions[bot]chasprowebdevMarfuen
authored
[FIX] Add a contractor role (#1737)
* feat(db): add deactivated column to member table * feat(db): add contractor role * feat(app): add contractor role * fix(db): remove duplicated migration for contractor role * fix(db): update date and time of migration for deactivated column * fix(app): set deactivated when creating mock member --------- Co-authored-by: chasprowebdev <chasgarciaprowebdev@gmail.com> Co-authored-by: Mariano Fuentes <marfuen98@gmail.com>
1 parent 7a3fe75 commit 6e0b968

20 files changed

Lines changed: 25 additions & 34 deletions

File tree

apps/api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@nestjs/core": "^11.0.1",
1414
"@nestjs/platform-express": "^11.1.5",
1515
"@nestjs/swagger": "^11.2.0",
16-
"@trycompai/db": "^1.3.7",
16+
"@trycompai/db": "^1.3.17",
1717
"archiver": "^7.0.1",
1818
"axios": "^1.12.2",
1919
"better-auth": "^1.3.27",

apps/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"@tiptap/extension-table-row": "^3.4.4",
5252
"@trigger.dev/react-hooks": "4.0.6",
5353
"@trigger.dev/sdk": "4.0.6",
54-
"@trycompai/db": "^1.3.7",
54+
"@trycompai/db": "^1.3.17",
5555
"@trycompai/email": "workspace:*",
5656
"@types/canvas-confetti": "^1.9.0",
5757
"@types/react-syntax-highlighter": "^15.5.13",

apps/app/src/actions/organization/invite-member.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { ActionResponse } from '../types';
88

99
const inviteMemberSchema = z.object({
1010
email: z.string().email(),
11-
role: z.enum(['owner', 'admin', 'auditor', 'employee']),
11+
role: z.enum(['owner', 'admin', 'auditor', 'employee', 'contractor']),
1212
});
1313

1414
export const inviteMember = authActionClient

apps/app/src/actions/policies/publish-all.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,10 @@ export const publishAllPoliciesAction = authActionClient
104104
where: {
105105
organizationId: parsedInput.organizationId,
106106
isActive: true,
107-
role: {
108-
contains: Role.employee,
109-
},
107+
OR: [
108+
{ role: { contains: Role.employee } },
109+
{ role: { contains: Role.contractor } },
110+
],
110111
},
111112
include: {
112113
user: {

apps/app/src/app/(app)/[orgId]/people/all/components/MemberRow.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export function MemberRow({ member, onRemove, onUpdateRole, canEdit }: MemberRow
9393
const canRemove = !isOwner;
9494

9595
const isEmployee = currentRoles.includes('employee');
96+
const isContractor = currentRoles.includes('contractor');
9697

9798
const handleDialogItemSelect = () => {
9899
focusRef.current = dropdownTriggerRef.current;
@@ -142,7 +143,7 @@ export function MemberRow({ member, onRemove, onUpdateRole, canEdit }: MemberRow
142143
<div className="min-w-0 flex-1 gap-2">
143144
<div className="flex items-center flex-wrap gap-1.5">
144145
<span className="truncate text-sm font-medium">{memberName}</span>
145-
{isEmployee && (
146+
{(isEmployee || isContractor) && (
146147
<Link
147148
href={`/${orgId}/people/${memberId}`}
148149
className="text-xs text-blue-600 hover:underline flex-shrink-0"

apps/app/src/app/(app)/[orgId]/people/all/components/MultiRoleCombobox.tsx

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -111,22 +111,7 @@ export function MultiRoleCombobox({
111111
selectedRoles.length > 0 ? `${selectedRoles.length} selected` : placeholder || 'Select role(s)';
112112

113113
const filteredRoles = availableRoles.filter((role) => {
114-
const label = (() => {
115-
switch (role.value) {
116-
case 'admin':
117-
return 'Admin';
118-
case 'auditor':
119-
return 'Auditor';
120-
case 'employee':
121-
return 'Employee';
122-
case 'contractor':
123-
return 'Contractor';
124-
case 'owner':
125-
return 'Owner';
126-
default:
127-
return role.value;
128-
}
129-
})();
114+
const label = getRoleLabel(role.value);
130115
return label.toLowerCase().includes(searchTerm.toLowerCase());
131116
});
132117

apps/app/src/app/(app)/[orgId]/policies/[policyId]/data/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export const getAssignees = async () => {
135135
where: {
136136
organizationId,
137137
role: {
138-
notIn: ['employee'],
138+
notIn: ['employee', 'contractor'],
139139
},
140140
},
141141
include: {

apps/app/src/app/(app)/[orgId]/risk/(overview)/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const getAssignees = cache(async () => {
108108
organizationId: session.session.activeOrganizationId,
109109
isActive: true,
110110
role: {
111-
notIn: ['employee'],
111+
notIn: ['employee', 'contractor'],
112112
},
113113
},
114114
include: {

apps/app/src/app/(app)/[orgId]/risk/[riskId]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const getAssignees = cache(async () => {
8989
where: {
9090
organizationId: session.session.activeOrganizationId,
9191
role: {
92-
notIn: ['employee'],
92+
notIn: ['employee', 'contractor'],
9393
},
9494
},
9595
include: {

apps/app/src/app/(app)/[orgId]/tasks/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const getMembersWithMetadata = async () => {
8383
where: {
8484
organizationId: orgId,
8585
role: {
86-
notIn: [Role.employee, Role.auditor],
86+
notIn: [Role.employee, Role.auditor, Role.contractor],
8787
},
8888
},
8989
include: {

0 commit comments

Comments
 (0)