Skip to content

Commit cd7619c

Browse files
committed
Save the position of the randomized options to the DB
1 parent 0d111a2 commit cd7619c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

apps/webapp/app/routes/confirm-basic-details.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ function createSchema(
9999
referralSourceOther: z.string().optional(),
100100
role: z.string().optional(),
101101
roleOther: z.string().optional(),
102+
referralSourcePosition: z.coerce.number().optional(),
103+
rolePosition: z.coerce.number().optional(),
102104
})
103105
.refine((value) => value.email === value.confirmEmail, {
104106
message: "Emails must match",
@@ -141,13 +143,19 @@ export const action: ActionFunction = async ({ request }) => {
141143

142144
if (submission.value.referralSource) {
143145
onboardingData.referralSource = submission.value.referralSource;
146+
if (submission.value.referralSourcePosition) {
147+
onboardingData.referralSourcePosition = String(submission.value.referralSourcePosition);
148+
}
144149
if (submission.value.referralSource === "Other" && submission.value.referralSourceOther) {
145150
onboardingData.referralSourceOther = submission.value.referralSourceOther;
146151
}
147152
}
148153

149154
if (submission.value.role) {
150155
onboardingData.role = submission.value.role;
156+
if (submission.value.rolePosition) {
157+
onboardingData.rolePosition = String(submission.value.rolePosition);
158+
}
151159
if (submission.value.role === "Other" && submission.value.roleOther) {
152160
onboardingData.roleOther = submission.value.roleOther;
153161
}
@@ -319,6 +327,15 @@ export default function Page() {
319327
name="referralSource"
320328
value={selectedReferralSource ?? ""}
321329
/>
330+
<input
331+
type="hidden"
332+
name="referralSourcePosition"
333+
value={
334+
selectedReferralSource
335+
? shuffledReferralSources.indexOf(selectedReferralSource) + 1
336+
: ""
337+
}
338+
/>
322339
<RadioGroup
323340
value={selectedReferralSource}
324341
onValueChange={setSelectedReferralSource}
@@ -350,6 +367,11 @@ export default function Page() {
350367
<InputGroup className="mt-1">
351368
<Label id="role-label">What role fits you best?</Label>
352369
<input type="hidden" name="role" value={selectedRole} />
370+
<input
371+
type="hidden"
372+
name="rolePosition"
373+
value={selectedRole ? shuffledRoles.indexOf(selectedRole) + 1 : ""}
374+
/>
353375
<Select<string, string>
354376
value={selectedRole}
355377
setValue={setSelectedRole}

0 commit comments

Comments
 (0)