Skip to content

Commit cc45590

Browse files
committed
hotfix: validation messaging when update user profile details
1 parent 7187bb9 commit cc45590

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

src/app/(app)/settings/profile/page.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ import {
77
TooltipTrigger,
88
} from '@/components/ui/tooltip';
99
import { Button } from '@/components/ui/button';
10-
import { Form, FormControl, FormField, FormItem } from '@/components/ui/form';
10+
import {
11+
Form,
12+
FormControl,
13+
FormField,
14+
FormItem,
15+
FormMessage,
16+
} from '@/components/ui/form';
1117
import { InputWithLabel } from '@/components/ui/input-label';
1218
import { Switch } from '@/components/ui/switch';
1319
import { Label } from '@/components/ui/label';
@@ -207,6 +213,7 @@ export default function SettingsProfilePage() {
207213
</p>
208214
</div>
209215
</div>
216+
<FormMessage />
210217
</FormItem>
211218
)}
212219
/>
@@ -226,6 +233,7 @@ export default function SettingsProfilePage() {
226233
value={field.value || ''}
227234
/>
228235
</FormControl>
236+
<FormMessage />
229237
</FormItem>
230238
)}
231239
/>
@@ -246,6 +254,7 @@ export default function SettingsProfilePage() {
246254
value={field.value || ''}
247255
/>
248256
</FormControl>
257+
<FormMessage />
249258
</FormItem>
250259
)}
251260
/>
@@ -266,6 +275,7 @@ export default function SettingsProfilePage() {
266275
value={field.value || ''}
267276
/>
268277
</FormControl>
278+
<FormMessage />
269279
</FormItem>
270280
)}
271281
/>
@@ -297,6 +307,7 @@ export default function SettingsProfilePage() {
297307
</Tooltip>
298308
</TooltipProvider>
299309
</FormControl>
310+
<FormMessage />
300311
</FormItem>
301312
)}
302313
/>
@@ -329,6 +340,7 @@ export default function SettingsProfilePage() {
329340
</Tooltip>
330341
</TooltipProvider>
331342
</FormControl>
343+
<FormMessage />
332344
</FormItem>
333345
)}
334346
/>
@@ -363,6 +375,7 @@ export default function SettingsProfilePage() {
363375
/>
364376
</div>
365377
</FormControl>
378+
<FormMessage />
366379
</FormItem>
367380
)}
368381
/>

src/components/app/onboarding/onboarding-step-one.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ import {
1313
} from '@/components/ui/tooltip';
1414
import { Switch } from '@/components/ui/switch';
1515
import { Label } from '@/components/ui/label';
16-
import { Form, FormField, FormItem, FormControl } from '@/components/ui/form';
16+
import {
17+
Form,
18+
FormField,
19+
FormItem,
20+
FormControl,
21+
FormMessage,
22+
} from '@/components/ui/form';
1723
import { useOnboardingContext } from './onboarding-context';
1824
import { onboardingStepOneSchema } from '@/lib/zod/schemas/onboarding/step-one';
1925
import type { UpdatableUserFields } from '@/types/User';
@@ -95,6 +101,9 @@ export default function OnboardingStepOne() {
95101
value={field.value ?? ''}
96102
/>
97103
</FormControl>
104+
<FormMessage className="mt-0.5 text-start">
105+
{form.formState?.errors?.username?.message}
106+
</FormMessage>
98107
</FormItem>
99108
)}
100109
/>
@@ -127,6 +136,9 @@ export default function OnboardingStepOne() {
127136
className="bg-black-50"
128137
/>
129138
</FormControl>
139+
<FormMessage className="mt-0.5 text-start">
140+
{form.formState?.errors?.showTimeTaken?.message}
141+
</FormMessage>
130142
</FormItem>
131143
)}
132144
/>
@@ -167,6 +179,12 @@ export default function OnboardingStepOne() {
167179
disabled
168180
/>
169181
</FormControl>
182+
<FormMessage className="mt-0.5 text-start">
183+
{
184+
form.formState?.errors?.sendPushNotifications
185+
?.message
186+
}
187+
</FormMessage>
170188
</FormItem>
171189
)}
172190
/>

src/lib/zod/schemas/onboarding/step-one.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { z } from 'zod';
22

33
// step one of the onboarding only requires a username.
44
export const onboardingStepOneSchema = z.object({
5-
username: z.string().min(3).max(20),
5+
username: z.string().min(2).max(20),
66
showTimeTaken: z.boolean().default(false),
7-
sendPushNotifications: z.boolean().default(false)
7+
sendPushNotifications: z.boolean().default(false),
88
});

src/lib/zod/schemas/user-details-schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { z } from 'zod';
33
// Updated schema to properly handle optional fields
44
export const userDetailsSchema = z
55
.object({
6-
username: z.string().min(3),
6+
username: z.string().min(2),
77
firstName: z.string().optional(),
88
lastName: z.string().optional(),
99
showTimeTaken: z.boolean().optional(),

0 commit comments

Comments
 (0)