Skip to content

Commit 77eb755

Browse files
authored
Add role in signup form (#1876)
This is the first task of the new onboarding, adding a new role parameter in the signup form called "role".
1 parent 9466909 commit 77eb755

File tree

11 files changed

+8121
-17
lines changed

11 files changed

+8121
-17
lines changed

apps/web/src/actions/user/setupAction.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { unsafelyFindUserByEmail } from '@latitude-data/core/data-access/users'
99

1010
import { errorHandlingProcedure } from '../procedures'
1111
import { frontendRedirect } from '$/lib/frontendRedirect'
12+
import { UserTitle } from '@latitude-data/constants/users'
1213

1314
export const setupAction = errorHandlingProcedure
1415
.inputSchema(
@@ -35,6 +36,7 @@ export const setupAction = errorHandlingProcedure
3536
companyName: z
3637
.string()
3738
.min(1, { error: 'Workspace name is a required field' }),
39+
title: z.enum(UserTitle).optional(),
3840
}),
3941
)
4042
.action(async ({ parsedInput }) => {

apps/web/src/app/(public)/setup/_components/SetupForm/index.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@ import { Separator } from '@latitude-data/web-ui/atoms/Separator'
1212
import { Text } from '@latitude-data/web-ui/atoms/Text'
1313
import { useToast } from '@latitude-data/web-ui/atoms/Toast'
1414
import Link from 'next/link'
15+
import { Select } from '@latitude-data/web-ui/atoms/Select'
16+
import { USER_TITLES, UserTitle } from '@latitude-data/constants/users'
17+
18+
export const humanizeUserTitle = (title: UserTitle): string => {
19+
switch (title) {
20+
case UserTitle.Engineer:
21+
return 'Engineer'
22+
case UserTitle.DataAIAndML:
23+
return 'Data/AI/ML'
24+
case UserTitle.ProductManager:
25+
return 'Product Manager'
26+
case UserTitle.Designer:
27+
return 'Designer'
28+
case UserTitle.Founder:
29+
return 'Founder'
30+
case UserTitle.Other:
31+
return 'Other'
32+
}
33+
}
1534

1635
export default function SetupForm({
1736
email,
@@ -74,6 +93,17 @@ export default function SetupForm({
7493
errors={errors?.companyName}
7594
defaultValue={data?.companyName || companyName}
7695
/>
96+
<Select
97+
required
98+
name='title'
99+
label='Your role'
100+
errors={errors?.title}
101+
placeholder='Select'
102+
options={USER_TITLES.map((title: UserTitle) => ({
103+
label: humanizeUserTitle(title),
104+
value: title,
105+
}))}
106+
/>
77107
<div className='flex flex-col gap-6'>
78108
<Button fullWidth isLoading={isPending} fancy>
79109
Create account

apps/web/src/services/user/setupService.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
import setupServiceFn from '@latitude-data/core/services/users/setupService'
22
import { env } from '@latitude-data/env'
33
import { captureException } from '$/helpers/captureException'
4+
import { UserTitle } from '@latitude-data/constants/users'
45

56
export default function setupService({
67
email,
78
name,
89
companyName,
910
source,
11+
title,
1012
}: {
1113
email: string
1214
name: string
1315
companyName: string
1416
source?: string
17+
title?: UserTitle
1518
}) {
1619
return setupServiceFn({
1720
email,
@@ -21,5 +24,6 @@ export default function setupService({
2124
defaultProviderName: env.NEXT_PUBLIC_DEFAULT_PROVIDER_NAME,
2225
defaultProviderApiKey: env.DEFAULT_PROVIDER_API_KEY,
2326
captureException,
27+
title,
2428
})
2529
}

packages/constants/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"./promptl": "./src/promptl.ts",
2929
"./trigger": "./src/trigger.ts",
3030
"./documentTriggers": "./src/documentTriggers/schema.ts",
31-
"./toolSources": "./src/toolSources.ts"
31+
"./toolSources": "./src/toolSources.ts",
32+
"./users": "./src/users.ts"
3233
},
3334
"devDependencies": {
3435
"@latitude-data/eslint-config": "workspace:*",
@@ -41,4 +42,4 @@
4142
"promptl-ai": "catalog:",
4243
"zod": "catalog:"
4344
}
44-
}
45+
}

packages/constants/src/users.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export enum UserTitle {
2+
Engineer = 'engineer',
3+
DataAIAndML = 'data_ai_ml',
4+
ProductManager = 'product_manager',
5+
Designer = 'designer',
6+
Founder = 'founder',
7+
Other = 'other',
8+
}
9+
10+
export const USER_TITLES = Object.values(UserTitle)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE "latitude"."users" ADD COLUMN "title" varchar(128);--> statement-breakpoint
2+
CREATE INDEX "users_title_idx" ON "latitude"."users" USING btree ("title");

0 commit comments

Comments
 (0)