Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"next-themes": "^0.4.6",
"react": "^19.2.4",
"react-router": "^7.13.0",
"react-dom": "^19.2.3",
"react-dom": "^19.2.4",
"react-hook-form": "^7.71.1",
"react-icons": "^5.5.0",
"sonner": "^2.0.7",
Expand Down
33 changes: 18 additions & 15 deletions ui/src/pages/Profile/components/PasswordDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,31 @@ import { Input } from '@/components/ui/input';
import { Button } from '@/components/ui/button';
import { ErrorMessage } from '@/components/ErrorMessage';

const schema = z
.object({
currentPassword: z
.string()
.min(5, { message: 'Current password must be at least 5 characters' }),
newPassword: z
.string()
.min(5, { message: 'New password must be at least 5 characters' }),
repeatedPassword: z
.string()
.min(5, { message: 'Repeat password must be at least 5 characters' }),
})
.refine((data) => data.newPassword === data.repeatedPassword, {
const baseSchema = z.object({
currentPassword: z
.string()
.min(5, { message: 'Current password must be at least 5 characters' }),
newPassword: z
.string()
.min(5, { message: 'New password must be at least 5 characters' }),
repeatedPassword: z
.string()
.min(5, { message: 'Repeat password must be at least 5 characters' }),
});

const schema = baseSchema.refine(
(data) => data.newPassword === data.repeatedPassword,
{
message: 'Passwords do not match',
path: ['repeatedPassword'],

when(payload) {
return schema
return baseSchema
.pick({ newPassword: true, repeatedPassword: true })
.safeParse(payload.value).success;
},
});
}
);

export const PasswordDetails: FC = () => {
const [storageApiKeyState, setStorageApiKeyState] = useApiKeyState();
Expand Down
27 changes: 15 additions & 12 deletions ui/src/pages/Register/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,28 @@ import { Button } from '@/components/ui/button';
import { toast } from 'sonner';
import { ErrorMessage } from '@/components/ErrorMessage';

const schema = z
.object({
login: z
.string('Login is required')
.min(3, 'Login must be at least 3 characters long'),
email: z.email('Email is required'),
password: z.string('Password is required').min(5),
repeatedPassword: z.string('Please repeat your password'),
})
.refine((data) => data.password === data.repeatedPassword, {
const baseSchema = z.object({
login: z
.string('Login is required')
.min(3, 'Login must be at least 3 characters long'),
email: z.email('Email is required'),
password: z.string('Password is required').min(5),
repeatedPassword: z.string('Please repeat your password'),
});

const schema = baseSchema.refine(
(data) => data.password === data.repeatedPassword,
{
message: 'Passwords do not match',
path: ['repeatedPassword'],

when(payload) {
return schema
return baseSchema
.pick({ password: true, repeatedPassword: true })
.safeParse(payload.value).success;
},
});
}
);

const FORM_ID = 'registration-form';

Expand Down
8 changes: 4 additions & 4 deletions ui/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4076,10 +4076,10 @@ quick-lru@^5.1.1:
resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-5.1.1.tgz#366493e6b3e42a3a6885e2e99d18f80fb7a8c932"
integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==

react-dom@^19.2.3:
version "19.2.3"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-19.2.3.tgz#f0b61d7e5c4a86773889fcc1853af3ed5f215b17"
integrity sha512-yELu4WmLPw5Mr/lmeEpox5rw3RETacE++JgHqQzd2dg+YbJuat3jH4ingc+WPZhxaoFzdv9y33G+F7Nl5O0GBg==
react-dom@^19.2.4:
version "19.2.4"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-19.2.4.tgz#6fac6bd96f7db477d966c7ec17c1a2b1ad8e6591"
integrity sha512-AXJdLo8kgMbimY95O2aKQqsz2iWi9jMgKJhRBAxECE4IFxfcazB2LmzloIoibJI3C12IlY20+KFaLv+71bUJeQ==
dependencies:
scheduler "^0.27.0"

Expand Down