forked from harness/canary
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: reorganize validation schemas and types
- Move Zod schemas to dedicated schema files - Update type definitions to use schema inference - Fix import paths to use absolute imports - Remove duplicate schema definitions from components - Centralize types in dedicated type files
- Loading branch information
1 parent
415377a
commit f85a00a
Showing
21 changed files
with
60 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/ui/src/views/user-management/components/dialogs/create-user/schemas.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { z } from 'zod' | ||
|
||
export const newUserSchema = z.object({ | ||
uid: z.string().min(1, { message: 'Please provide a user ID' }), | ||
email: z.string().email({ message: 'Please enter a valid email address' }), | ||
display_name: z.string().min(1, { message: 'Please provide a display name' }) | ||
}) |
5 changes: 4 additions & 1 deletion
5
packages/ui/src/views/user-management/components/dialogs/create-user/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,9 @@ import { useEffect } from 'react' | |
import { SubmitHandler, useForm } from 'react-hook-form' | ||
|
||
import { AlertDialog, Button, ButtonGroup, ControlGroup, Fieldset, FormWrapper, Input } from '@/components' | ||
import { newUserSchema } from '@/views/user-management/components/dialogs/edit-user/schemas' | ||
import { IEditUserDialogProps, MemberFields } from '@/views/user-management/components/dialogs/edit-user/types' | ||
import { zodResolver } from '@hookform/resolvers/zod' | ||
import { z } from 'zod' | ||
|
||
import { IEditUserDialogProps } from './types' | ||
|
||
export const EditUserDialog: React.FC<IEditUserDialogProps> = ({ | ||
useAdminListUsersStore, | ||
|
@@ -15,13 +14,6 @@ export const EditUserDialog: React.FC<IEditUserDialogProps> = ({ | |
open | ||
}) => { | ||
const { user } = useAdminListUsersStore() | ||
const newUserSchema = z.object({ | ||
userID: z.string(), | ||
email: z.string().email({ message: 'Please provide a valid email, ex: [email protected]' }), | ||
displayName: z.string().min(1, { message: 'Please provide a display name' }) | ||
}) | ||
|
||
type MemberFields = z.infer<typeof newUserSchema> | ||
|
||
const { | ||
handleSubmit, | ||
|
@@ -33,7 +25,6 @@ export const EditUserDialog: React.FC<IEditUserDialogProps> = ({ | |
mode: 'onChange' | ||
}) | ||
|
||
// Form edit submit handler | ||
const onSubmit: SubmitHandler<MemberFields> = data => { | ||
handleUpdateUser(data) | ||
resetNewMemberForm(data) | ||
|
7 changes: 7 additions & 0 deletions
7
packages/ui/src/views/user-management/components/dialogs/edit-user/schemas.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { z } from 'zod' | ||
|
||
export const newUserSchema = z.object({ | ||
userID: z.string(), | ||
email: z.string().email({ message: 'Please provide a valid email, ex: [email protected]' }), | ||
displayName: z.string().min(1, { message: 'Please provide a display name' }) | ||
}) |
6 changes: 5 additions & 1 deletion
6
packages/ui/src/views/user-management/components/dialogs/edit-user/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
packages/ui/src/views/user-management/components/dialogs/remove-admin/remove-admin.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
packages/ui/src/views/user-management/components/dialogs/reset-password/reset-password.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/ui/src/views/user-management/components/dialogs/reset-password/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
packages/ui/src/views/user-management/components/empty-state/empty-state.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
packages/ui/src/views/user-management/components/page-components/actions/actions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...c/views/user-management/components/page-components/content/components/users-list/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { UsersList } from './users-list' |
6 changes: 6 additions & 0 deletions
6
...c/views/user-management/components/page-components/content/components/users-list/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { UsersProps } from '@views/user-management/types' | ||
|
||
export interface PageProps { | ||
users: UsersProps[] | ||
handleDialogOpen: (user: UsersProps | null, dialogLabel: string) => void | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 6 additions & 7 deletions
13
packages/ui/src/views/user-management/components/page-components/content/content.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
packages/ui/src/views/user-management/components/page-components/content/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/ui/src/views/user-management/hooks/use-user-management.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 5 additions & 6 deletions
11
packages/ui/src/views/user-management/user-management-page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters