Skip to content

Commit 7d5b295

Browse files
LOTaherAnzhuo-W
authored andcommitted
[CRM][Backend] - Fix Email, Deprecate Unique Link (#286)
* fix email, deprecate uniqueLink * lint and prettier
1 parent dfe53a9 commit 7d5b295

14 files changed

Lines changed: 36 additions & 44 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
Warnings:
3+
4+
- You are about to drop the column `uniqueLink` on the `Assessment` table. All the data in the column will be lost.
5+
6+
*/
7+
-- DropIndex
8+
DROP INDEX "public"."Assessment_uniqueLink_key";
9+
10+
-- AlterTable
11+
ALTER TABLE "public"."Assessment" DROP COLUMN "uniqueLink";

prisma/schema.prisma

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ model Assessment {
224224
assessmentTemplateId String
225225
assignedAt DateTime @default(now())
226226
submittedAt DateTime?
227-
uniqueLink String @unique
228227
deadline DateTime?
229228
230229
application Application @relation(fields: [applicationId], references: [id], onDelete: Cascade)

prisma/seed-data/assessment.seed.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ export const assessmentsData = [
22
{
33
id: 'assessment_carter_001',
44
assessmentTemplateId: 'assessment_template_general_001',
5-
uniqueLink: 'https://assessment.sarge.dev/take/carter-herman-001',
65
deadline: new Date('2035-12-20T23:59:59Z'),
76
},
87
{
98
id: 'assessment_laith_001',
109
assessmentTemplateId: 'assessment_template_general_001',
11-
uniqueLink: 'https://assessment.sarge.dev/take/laith-taher-001',
1210
deadline: new Date('2035-12-20T23:59:59Z'),
1311
},
1412
];
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export const organizationsData = [
22
{
33
id: 'org_nextlab_001',
4-
name: 'Next Lab',
5-
slug: 'next-lab',
4+
name: 'NExT',
5+
slug: 'next',
66
logo: null,
77
},
88
];

prisma/seed.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,14 +399,12 @@ async function seedAssessments() {
399399
where: { applicationId: application.id },
400400
update: {
401401
assessmentTemplateId: assessmentData.assessmentTemplateId,
402-
uniqueLink: assessmentData.uniqueLink,
403402
deadline: assessmentData.deadline,
404403
},
405404
create: {
406405
id: assessmentData.id,
407406
applicationId: application.id,
408407
assessmentTemplateId: assessmentData.assessmentTemplateId,
409-
uniqueLink: assessmentData.uniqueLink,
410408
deadline: assessmentData.deadline,
411409
},
412410
});

src/lib/components/templates/AssessmentTemplatePreview.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,22 @@ export function AssessmentTemplatePreview({
9393
<h1 className="text-display-xs text-foreground truncate font-medium">
9494
{assessmentTemplatePreview.title}
9595
</h1>
96-
<div className="flex flex-row items-center gap-0.5">
97-
<p className="text-body-s font-medium text-gray-400">Assigned to</p>
98-
<p className="text-label-s text-sarge-primary-600 underline">
99-
{assessmentTemplatePreview.positions.length > 0
100-
? assessmentTemplatePreview.positions
101-
.map((position) => position.title)
102-
.join(', ')
103-
: '0 positions'}
104-
</p>
96+
<div className="flex flex-row flex-wrap items-center gap-0.5">
97+
<p className="text-body-s font-medium text-gray-400">Assigned to </p>
98+
{assessmentTemplatePreview.positions.length > 0 ? (
99+
assessmentTemplatePreview.positions.map((position, index) => (
100+
<span key={position.id}>
101+
<span className="text-label-s text-sarge-primary-600 underline">
102+
{position.title}
103+
</span>
104+
{index < assessmentTemplatePreview.positions.length - 1 && ','}
105+
</span>
106+
))
107+
) : (
108+
<p className="text-label-s text-sarge-primary-600 underline">
109+
0 positions
110+
</p>
111+
)}
105112
</div>
106113
</div>
107114
<Button variant="secondary" className="h-fit px-4 py-2" asChild>

src/lib/schemas/assessment.schema.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ export const assessmentSchema = z.object({
1010
assessmentTemplateId: z.string(),
1111
deadline: z.date().nullable(),
1212
assignedAt: z.date(),
13-
uniqueLink: z.string(),
1413
submittedAt: z.date().nullable(),
1514
});
1615

17-
export const createAssessmentSchema = assessmentSchema.omit({ id: true, uniqueLink: true });
16+
export const createAssessmentSchema = assessmentSchema.omit({ id: true });
1817

1918
export const updateAssessmentSchema = assessmentSchema.partial().extend({
2019
id: z.string(),

src/lib/services/application.service.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import crypto from 'node:crypto';
21
import { prisma } from '@/lib/prisma';
32
import { NotFoundException, ForbiddenException } from '@/lib/utils/errors.utils';
43
import { type AddApplicationWithCandidateDataDTO } from '@/lib/schemas/application.schema';
@@ -65,7 +64,6 @@ async function addApplicationToPosition(
6564
data: {
6665
applicationId: createdApplication.id,
6766
assessmentTemplateId: position.assessmentId,
68-
uniqueLink: crypto.randomUUID(),
6967
},
7068
});
7169

@@ -93,7 +91,6 @@ async function addApplicationToPosition(
9391
assessment: {
9492
select: {
9593
id: true,
96-
uniqueLink: true,
9794
submittedAt: true,
9895
},
9996
},
@@ -184,7 +181,6 @@ async function batchAddApplicationsToPosition(
184181
data: {
185182
applicationId: application.id,
186183
assessmentTemplateId,
187-
uniqueLink: crypto.randomUUID(),
188184
},
189185
});
190186

@@ -218,7 +214,6 @@ async function batchAddApplicationsToPosition(
218214
assessment: {
219215
select: {
220216
id: true,
221-
uniqueLink: true,
222217
submittedAt: true,
223218
},
224219
},
@@ -270,7 +265,6 @@ async function getPositionApplications(
270265
assessment: {
271266
select: {
272267
id: true,
273-
uniqueLink: true,
274268
submittedAt: true,
275269
},
276270
},

src/lib/services/assessment.service.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,14 @@ async function createAssessment(
7575
`Assessment Template with id ${assessment.assessmentTemplateId} not found`
7676
);
7777
}
78-
// the unique link shouldn't be the full link (bc the env of the link matters) so we just use id
7978
const id = crypto.randomUUID();
8079
const newAssessment = await prisma.assessment.create({
81-
data: { ...assessment, id, uniqueLink: id },
80+
data: { ...assessment, id },
8281
});
8382

8483
return newAssessment;
8584
}
8685

87-
function buildAssessmentLinkToken() {
88-
return crypto.randomUUID();
89-
}
90-
9186
async function assignTemplateToPosition(params: {
9287
positionId: string;
9388
assessmentTemplateId: string;
@@ -165,7 +160,6 @@ async function assignTemplateToPosition(params: {
165160
data: {
166161
applicationId: application.id,
167162
assessmentTemplateId,
168-
uniqueLink: buildAssessmentLinkToken(),
169163
},
170164
});
171165

src/lib/services/candidate.service.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ async function addCandidateToPosition(
7272
assessment: {
7373
select: {
7474
id: true,
75-
uniqueLink: true,
7675
submittedAt: true,
7776
},
7877
},
@@ -149,7 +148,6 @@ async function batchAddCandidatesToPosition(
149148
assessment: {
150149
select: {
151150
id: true,
152-
uniqueLink: true,
153151
submittedAt: true,
154152
},
155153
},
@@ -198,7 +196,6 @@ async function getPositionCandidates(
198196
assessment: {
199197
select: {
200198
id: true,
201-
uniqueLink: true,
202199
submittedAt: true,
203200
},
204201
},

0 commit comments

Comments
 (0)