diff --git a/.eslintrc.cjs b/.eslintrc.cjs index ff064ce3..ebbfe580 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -42,6 +42,12 @@ const config = { argsIgnorePattern: '^_', }, ], + "@typescript-eslint/no-misused-promises": [ + "error", + { + "checksVoidReturn": false + } + ], 'no-unreachable': 'error', 'local-rules/require-data-mapper': 'error', }, diff --git a/app/(dashboard)/dashboard/_components/AnonymousRecruitment.tsx b/app/(dashboard)/dashboard/_components/AnonymousRecruitment.tsx deleted file mode 100644 index 5799b2aa..00000000 --- a/app/(dashboard)/dashboard/_components/AnonymousRecruitment.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { api } from '~/trpc/server'; -import AnonymousRecruitmentSwitch from './AnonymousRecruitmentSwitch'; - -const AnonymousRecruitment = async () => { - try { - const allowAnonymousRecruitment = - await api.appSettings.get.allowAnonymousRecruitment.query(undefined, { - context: { - revalidate: 0, - }, - }); - - return ( - - ); - } catch (error) { - throw new Error( - 'An error occurred while fetching allowAnonymousRecruitment', - ); - } -}; - -export default AnonymousRecruitment; diff --git a/app/(dashboard)/dashboard/_components/AnonymousRecruitmentSwitch.tsx b/app/(dashboard)/dashboard/_components/AnonymousRecruitmentSwitch.tsx deleted file mode 100644 index 8cc7c1f2..00000000 --- a/app/(dashboard)/dashboard/_components/AnonymousRecruitmentSwitch.tsx +++ /dev/null @@ -1,67 +0,0 @@ -'use client'; - -import { api } from '~/trpc/client'; -import { Switch } from '~/components/ui/switch'; - -const AnonymousRecruitmentSwitch = ({ - initialData, -}: { - initialData: boolean; -}) => { - const utils = api.useUtils(); - - const { data: allowAnonymousRecruitment } = - api.appSettings.get.allowAnonymousRecruitment.useQuery(undefined, { - initialData, - onError(error) { - throw new Error(error.message); - }, - }); - - const { mutateAsync: updateAnonymousRecruitment } = - api.appSettings.updateAnonymousRecruitment.useMutation({ - async onMutate(newState: boolean) { - await utils.appSettings.get.allowAnonymousRecruitment.cancel(); - - const previousState = - utils.appSettings.get.allowAnonymousRecruitment.getData(); - - utils.appSettings.get.allowAnonymousRecruitment.setData( - undefined, - newState, - ); - - return previousState; - }, - onError: (err, _newState, previousState) => { - utils.appSettings.get.allowAnonymousRecruitment.setData( - undefined, - previousState, - ); - throw new Error(err.message); - }, - }); - - const handleCheckedChange = async () => { - await updateAnonymousRecruitment(!allowAnonymousRecruitment); - }; - - return ( -
-
-
-

Anonymous Recruitment

-

- Allow anonymous recruitment of participants. -

-
- void handleCheckedChange()} - /> -
-
- ); -}; - -export default AnonymousRecruitmentSwitch; diff --git a/app/(dashboard)/dashboard/_components/NavigationBar.tsx b/app/(dashboard)/dashboard/_components/NavigationBar.tsx index c2387b06..73f71179 100644 --- a/app/(dashboard)/dashboard/_components/NavigationBar.tsx +++ b/app/(dashboard)/dashboard/_components/NavigationBar.tsx @@ -35,7 +35,7 @@ export function NavigationBar() { const pathname = usePathname(); return ( -