Skip to content

Commit

Permalink
zod updates
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmacdonald committed Dec 30, 2024
1 parent b3d9b59 commit 4fc4ad2
Show file tree
Hide file tree
Showing 48 changed files with 1,748 additions and 632 deletions.
36 changes: 19 additions & 17 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@date-io/date-fns": "^2.17.0",
"@date-io/date-fns": "^3.2.0",
"@ebay/nice-modal-react": "^1.2.13",
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
Expand All @@ -39,19 +39,21 @@
"@mui/icons-material": "^6.3.0",
"@mui/lab": "5.0.0-alpha.165",
"@mui/material": "^6.3.0",
"@mui/material-pigment-css": "^6.3.0",
"@mui/system": "^6.3.0",
"@mui/utils": "^6.3.0",
"@mui/x-charts": "^6.19.8",
"@mui/x-date-pickers": "^6.20.2",
"@mui/x-charts": "^7.23.2",
"@mui/x-date-pickers": "^7.23.3",
"@pigment-css/react": "^0.0.28",
"@sentry/react": "^7.119.0",
"@tanstack/react-form": "^0.19.5",
"@tanstack/react-query": "^5.54.1",
"@tanstack/react-query-devtools": "^5.54.1",
"@tanstack/react-router": "^1.53.1",
"@tanstack/react-table": "^8.20.5",
"@tanstack/router-devtools": "^1.53.1",
"@tanstack/router-vite-plugin": "^1.54.0",
"@tanstack/zod-form-adapter": "^0.19.5",
"@tanstack/react-form": "^0.41.0",
"@tanstack/react-query": "^5.62.11",
"@tanstack/react-query-devtools": "^5.62.11",
"@tanstack/react-router": "^1.92.11",
"@tanstack/react-table": "^8.20.6",
"@tanstack/router-devtools": "^1.92.11\n",
"@tanstack/router-vite-plugin": "^1.92.11",
"@tanstack/zod-form-adapter": "^0.41.0",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/eslint__js": "^8.42.3",
"@types/jquery": "^3.5.30",
Expand All @@ -69,16 +71,16 @@
"@typescript-eslint/eslint-plugin": "^8.4.0",
"@typescript-eslint/parser": "^8.4.0",
"@typescript-eslint/utils": "^8.4.0",
"@vitejs/plugin-react-swc": "^3.7.0",
"@vitejs/plugin-react-swc": "^3.7.2",
"base64-js": "^1.5.1",
"core-js": "3.35.1",
"date-fns": "2.30.0",
"date-fns": "^4.1.0",
"eslint": "^9.10.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^28.8.3",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.35.2",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-react-refresh": "^0.4.11",
"file-type": "^18.7.0",
"ip-cidr": "^4.0.2",
Expand All @@ -89,7 +91,7 @@
"material-ui-popup-state": "^5.3.1",
"minimatch": "^9.0.5",
"mui-image": "^1.0.7",
"mui-markdown": "^1.2.2",
"mui-markdown": "^1.2.5",
"mui-nested-menu": "^3.4.0",
"prettier": "^3.3.3",
"pretty-bytes": "^6.1.1",
Expand All @@ -104,10 +106,10 @@
"typescript": "^5.5.4",
"typescript-eslint": "^8.4.0",
"video-react": "^0.16.0",
"vite": "^5.4.3",
"vite": "^6.0.6",
"vite-plugin-html": "^3.2.2",
"vitest": "^1.6.0",
"zod": "^3.23.8"
"zod": "^3.24.1"
},
"browserslist": {
"production": [
Expand Down
2,166 changes: 1,665 additions & 501 deletions frontend/pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions frontend/src/component/AppealMessageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import Paper from '@mui/material/Paper';
import { useTheme } from '@mui/material/styles';
import { useForm } from '@tanstack/react-form';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { zodValidator } from '@tanstack/zod-form-adapter';
import { formatDistance } from 'date-fns';
import { z } from 'zod';
import { apiUpdateBanMessage, BanAppealMessage } from '../api';
Expand Down Expand Up @@ -61,7 +60,6 @@ export const AppealMessageView = ({ message, onDelete }: AppealMessageViewProps)
body_md: value.body_md
});
},
validatorAdapter: zodValidator,
defaultValues: {
body_md: message.message_md
}
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/component/ForumThreadMessageContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { useTheme } from '@mui/material/styles';
import { useForm } from '@tanstack/react-form';
import { useMutation } from '@tanstack/react-query';
import { useRouteContext } from '@tanstack/react-router';
import { zodValidator } from '@tanstack/zod-form-adapter';
import { isAfter } from 'date-fns/fp';
import { z } from 'zod';
import { PermissionLevel, permissionLevelString } from '../api';
Expand Down Expand Up @@ -59,7 +58,6 @@ export const ThreadMessageContainer = ({
body_md: value.body_md ?? ''
});
},
validatorAdapter: zodValidator,
defaultValues: {
body_md: message.body_md
}
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/component/ReportMessageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import Paper from '@mui/material/Paper';
import { useTheme } from '@mui/material/styles';
import { useForm } from '@tanstack/react-form';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { zodValidator } from '@tanstack/zod-form-adapter';
import { formatDistance } from 'date-fns';
import { z } from 'zod';
import { apiDeleteReportMessage, apiUpdateReportMessage, ReportMessage } from '../api';
Expand Down Expand Up @@ -82,7 +81,6 @@ export const ReportMessageView = ({ message }: ReportMessageViewProps) => {
body_md: value.body_md
});
},
validatorAdapter: zodValidator,
defaultValues: {
body_md: message.message_md
}
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/component/ReportViewComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { useTheme } from '@mui/material/styles';
import { useForm } from '@tanstack/react-form';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { useRouteContext } from '@tanstack/react-router';
import { zodValidator } from '@tanstack/zod-form-adapter';
import { z } from 'zod';
import {
apiCreateReportMessage,
Expand Down Expand Up @@ -131,7 +130,6 @@ export const ReportViewComponent = ({ report }: { report: ReportWithAuthor }): J
onSubmit: async ({ value }) => {
createMessageMutation.mutate(value);
},
validatorAdapter: zodValidator,
defaultValues: {
body_md: ''
}
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/component/WikiPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import MenuItem from '@mui/material/MenuItem';
import { useForm } from '@tanstack/react-form';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { useLoaderData, useRouteContext } from '@tanstack/react-router';
import { zodValidator } from '@tanstack/zod-form-adapter';
import { z } from 'zod';
import { PermissionLevel, PermissionLevelCollection, permissionLevelString } from '../api';
import { apiSaveWikiPage, Page } from '../api/wiki.ts';
Expand Down Expand Up @@ -80,7 +79,6 @@ export const WikiPage = ({ slug = 'home', path }: { slug: string; path: '/_guest
onSubmit: async ({ value }) => {
mutation.mutate(value);
},
validatorAdapter: zodValidator,
defaultValues: {
permission_level: page?.permission_level ?? PermissionLevel.Guest,
body_md: page?.body_md ?? ''
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/component/modal/BanASNModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Grid from '@mui/material/Grid2';
import MenuItem from '@mui/material/MenuItem';
import { useForm } from '@tanstack/react-form';
import { useMutation } from '@tanstack/react-query';
import { zodValidator } from '@tanstack/zod-form-adapter';
import { parseISO } from 'date-fns';
import { z } from 'zod';
import {
Expand Down Expand Up @@ -87,7 +86,6 @@ export const BanASNModal = NiceModal.create(({ existing }: { existing?: ASNBanRe
as_num: value.as_num
});
},
validatorAdapter: zodValidator,
defaultValues: {
target_id: existing ? existing.target_id : '',
reason: existing ? existing.reason : BanReason.Cheating,
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/component/modal/BanCIDRModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Grid from '@mui/material/Grid2';
import MenuItem from '@mui/material/MenuItem';
import { useForm } from '@tanstack/react-form';
import { useMutation } from '@tanstack/react-query';
import { zodValidator } from '@tanstack/zod-form-adapter';
import { parseISO } from 'date-fns';
import { z } from 'zod';
import {
Expand Down Expand Up @@ -86,7 +85,6 @@ export const BanCIDRModal = NiceModal.create(({ existing }: { existing?: CIDRBan
cidr: value.cidr
});
},
validatorAdapter: zodValidator,
defaultValues: {
target_id: existing ? existing.target_id : '',
reason: existing ? existing.reason : BanReason.Cheating,
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/component/modal/BanGroupModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Grid from '@mui/material/Grid2';
import MenuItem from '@mui/material/MenuItem';
import { useForm } from '@tanstack/react-form';
import { useMutation } from '@tanstack/react-query';
import { zodValidator } from '@tanstack/zod-form-adapter';
import { parseISO } from 'date-fns';
import { z } from 'zod';
import { apiCreateBanGroup, apiUpdateBanGroup, Duration, DurationCollection, GroupBanRecord } from '../../api';
Expand Down Expand Up @@ -72,7 +71,6 @@ export const BanGroupModal = NiceModal.create(({ existing }: { existing?: GroupB
note: value.note
});
},
validatorAdapter: zodValidator,
defaultValues: {
target_id: existing ? existing.target_id : '',
group_id: existing ? existing.group_id : '',
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/component/modal/BanSteamModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Grid from '@mui/material/Grid2';
import MenuItem from '@mui/material/MenuItem';
import { useForm } from '@tanstack/react-form';
import { useMutation } from '@tanstack/react-query';
import { zodValidator } from '@tanstack/zod-form-adapter';
import { parseISO } from 'date-fns';
import { z } from 'zod';
import {
Expand Down Expand Up @@ -107,7 +106,6 @@ export const BanSteamModal = NiceModal.create(
report_id: value.report_id
});
},
validatorAdapter: zodValidator,
defaultValues: {
report_id: existing ? existing.report_id : 0,
target_id: existing ? existing.target_id : steamId,
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/component/modal/CIDRBlockEditorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Dialog, DialogActions, DialogContent, DialogTitle } from '@mui/material
import Grid from '@mui/material/Grid2';
import { useForm } from '@tanstack/react-form';
import { useMutation } from '@tanstack/react-query';
import { zodValidator } from '@tanstack/zod-form-adapter';
import { z } from 'zod';
import { apiCreateCIDRBlockSource, apiUpdateCIDRBlockSource, CIDRBlockSource } from '../../api';
import { Heading } from '../Heading';
Expand Down Expand Up @@ -50,7 +49,6 @@ export const CIDRBlockEditorModal = NiceModal.create(({ source }: { source?: CID
onSubmit: async ({ value }) => {
mutation.mutate(value);
},
validatorAdapter: zodValidator,
defaultValues: {
cidr_block_source_id: source?.cidr_block_source_id ?? 0,
name: source?.name ?? '',
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/component/modal/ContestEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Grid from '@mui/material/Grid2';
import MenuItem from '@mui/material/MenuItem';
import { useForm } from '@tanstack/react-form';
import { useMutation } from '@tanstack/react-query';
import { zodValidator } from '@tanstack/zod-form-adapter';
import { parseISO } from 'date-fns';
import { z } from 'zod';
import {
Expand Down Expand Up @@ -93,7 +92,6 @@ export const ContestEditor = NiceModal.create(({ contest }: { contest?: Contest
onSubmit: async ({ value }) => {
mutation.mutate(value);
},
validatorAdapter: zodValidator,
defaultValues: {
date_start: contest?.date_start.toISOString() ?? '',
date_end: contest ? contest.date_end.toISOString() : '',
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/component/modal/FilterEditModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Grid from '@mui/material/Grid2';
import MenuItem from '@mui/material/MenuItem';
import { useForm } from '@tanstack/react-form';
import { useMutation } from '@tanstack/react-query';
import { zodValidator } from '@tanstack/zod-form-adapter';
import { z } from 'zod';
import {
apiCreateFilter,
Expand Down Expand Up @@ -73,8 +72,6 @@ export const FilterEditModal = NiceModal.create(({ filter }: { filter?: Filter }
is_regex: value.is_regex
});
},
validatorAdapter: zodValidator,

defaultValues: {
pattern: filter ? String(filter.pattern) : '',
is_regex: filter?.is_regex ?? false,
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/component/modal/ForumCategoryEditorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Dialog, DialogActions, DialogContent, DialogTitle } from '@mui/material
import Grid from '@mui/material/Grid2';
import { useForm } from '@tanstack/react-form';
import { useMutation } from '@tanstack/react-query';
import { zodValidator } from '@tanstack/zod-form-adapter';
import { apiCreateForumCategory, apiSaveForumCategory, ForumCategory } from '../../api/forum.ts';
import { useUserFlashCtx } from '../../hooks/useUserFlashCtx.ts';
import { Buttons } from '../field/Buttons.tsx';
Expand Down Expand Up @@ -54,7 +53,6 @@ export const ForumCategoryEditorModal = NiceModal.create(({ category }: { catego
onSubmit: async ({ value }) => {
mutation.mutate({ ...value });
},
validatorAdapter: zodValidator,
defaultValues: {
title: category?.title ?? '',
description: category?.description ?? '',
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/component/modal/ForumForumEditorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Grid from '@mui/material/Grid2';
import MenuItem from '@mui/material/MenuItem';
import { useForm } from '@tanstack/react-form';
import { useMutation } from '@tanstack/react-query';
import { zodValidator } from '@tanstack/zod-form-adapter';
import { z } from 'zod';
import { PermissionLevel, PermissionLevelCollection, permissionLevelString } from '../../api';
import { apiCreateForum, apiSaveForum, Forum, ForumCategory } from '../../api/forum.ts';
Expand Down Expand Up @@ -67,7 +66,6 @@ export const ForumForumEditorModal = NiceModal.create(
onSubmit: async ({ value }) => {
mutation.mutate({ ...value });
},
validatorAdapter: zodValidator,
defaultValues: {
forum_category_id: defaultCategory,
title: forum?.title ?? '',
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/component/modal/ForumThreadCreatorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { useTheme } from '@mui/material/styles';
import useMediaQuery from '@mui/material/useMediaQuery';
import { useForm } from '@tanstack/react-form';
import { useMutation } from '@tanstack/react-query';
import { zodValidator } from '@tanstack/zod-form-adapter';
import { z } from 'zod';
import { apiCreateThread, Forum, ForumThread } from '../../api/forum.ts';
import { useUserFlashCtx } from '../../hooks/useUserFlashCtx.ts';
Expand Down Expand Up @@ -73,7 +72,6 @@ export const ForumThreadCreatorModal = NiceModal.create(({ forum }: { forum: For
onSubmit: async ({ value }) => {
mutation.mutate({ ...value });
},
validatorAdapter: zodValidator,
defaultValues: {
title: '',
body_md: '',
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/component/modal/ForumThreadEditorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import DialogTitle from '@mui/material/DialogTitle';
import Grid from '@mui/material/Grid2';
import { useForm } from '@tanstack/react-form';
import { useMutation } from '@tanstack/react-query';
import { zodValidator } from '@tanstack/zod-form-adapter';
import { apiDeleteThread, apiUpdateThread, ForumThread } from '../../api/forum';
import { useUserFlashCtx } from '../../hooks/useUserFlashCtx.ts';
import { logErr } from '../../util/errors';
Expand Down Expand Up @@ -67,7 +66,6 @@ export const ForumThreadEditorModal = NiceModal.create(({ thread }: { thread: Fo
onSubmit: async ({ value }) => {
mutation.mutate({ ...value });
},
validatorAdapter: zodValidator,
defaultValues: {
title: thread.title,
sticky: thread.sticky,
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/component/modal/IPWhitelistEditorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Dialog, DialogActions, DialogContent, DialogTitle } from '@mui/material
import Grid from '@mui/material/Grid2';
import { useForm } from '@tanstack/react-form';
import { useMutation } from '@tanstack/react-query';
import { zodValidator } from '@tanstack/zod-form-adapter';
import { z } from 'zod';
import { apiCreateWhitelistIP, apiUpdateWhitelistIP, WhitelistIP } from '../../api';
import { Heading } from '../Heading';
Expand Down Expand Up @@ -38,7 +37,6 @@ export const IPWhitelistEditorModal = NiceModal.create(({ source }: { source?: W
onSubmit: async ({ value }) => {
mutation.mutate(value);
},
validatorAdapter: zodValidator,
defaultValues: {
address: source?.address ?? ''
}
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/component/modal/NewsEditModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Dialog, DialogActions, DialogContent, DialogTitle } from '@mui/material
import Grid from '@mui/material/Grid2';
import { useForm } from '@tanstack/react-form';
import { useMutation } from '@tanstack/react-query';
import { zodValidator } from '@tanstack/zod-form-adapter';
import { apiNewsCreate, apiNewsSave, NewsEntry } from '../../api/news.ts';
import { Heading } from '../Heading';
import { Buttons } from '../field/Buttons.tsx';
Expand Down Expand Up @@ -35,7 +34,6 @@ export const NewsEditModal = NiceModal.create(({ entry }: { entry?: NewsEntry })
onSubmit: async ({ value }) => {
mutation.mutate(value);
},
validatorAdapter: zodValidator,
defaultValues: {
title: entry?.title ?? '',
body_md: entry?.body_md ?? '',
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/component/modal/PersonEditModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Grid from '@mui/material/Grid2';
import MenuItem from '@mui/material/MenuItem';
import { useForm } from '@tanstack/react-form';
import { useMutation } from '@tanstack/react-query';
import { zodValidator } from '@tanstack/zod-form-adapter';
import {
apiUpdatePlayerPermission,
PermissionLevel,
Expand Down Expand Up @@ -41,7 +40,6 @@ export const PersonEditModal = NiceModal.create(({ person }: { person: Person })
permission_level: value.permission_level
});
},
validatorAdapter: zodValidator,
defaultValues: {
permission_level: person.permission_level
}
Expand Down
Loading

0 comments on commit 4fc4ad2

Please sign in to comment.