Skip to content

Commit c68ba1c

Browse files
committed
add login form to playground
1 parent 08e437a commit c68ba1c

3 files changed

Lines changed: 33 additions & 2 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* eslint-disable perfectionist/sort-objects */
2+
3+
import { Form } from '@douglasneuroinformatics/libui/components';
4+
import { $LoginCredentials } from '@opendatacapture/schemas/auth';
5+
6+
type LoginFormProps = {
7+
onSubmit: (credentials: $LoginCredentials) => void;
8+
};
9+
10+
export const LoginForm = ({ onSubmit }: LoginFormProps) => {
11+
return (
12+
<Form
13+
content={{
14+
username: {
15+
kind: 'string',
16+
label: 'Username',
17+
variant: 'input'
18+
},
19+
password: {
20+
kind: 'string',
21+
label: 'Password',
22+
variant: 'password'
23+
}
24+
}}
25+
submitBtnLabel="Login"
26+
validationSchema={$LoginCredentials}
27+
onSubmit={onSubmit}
28+
/>
29+
);
30+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './LoginForm';

packages/schemas/src/auth/auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export type AuthPayload = {
1010

1111
export type $LoginCredentials = z.infer<typeof $LoginCredentials>;
1212
export const $LoginCredentials = z.object({
13-
password: z.string(),
14-
username: z.string()
13+
password: z.string().min(1),
14+
username: z.string().min(1)
1515
});
1616

1717
export type TokenPayload = {

0 commit comments

Comments
 (0)