diff --git a/website/src/components/Group/GroupForm.tsx b/website/src/components/Group/GroupForm.tsx index 1050207bc..f939155b6 100644 --- a/website/src/components/Group/GroupForm.tsx +++ b/website/src/components/Group/GroupForm.tsx @@ -1,15 +1,25 @@ -import { useState, type FC, type FormEvent } from "react"; -import type { NewGroup } from "../../types/backend"; +import { useState, type FC, type FormEvent } from 'react'; + +import { + AddressLineOneInput, + AddressLineTwoInput, + CityInput, + CountryInput, + EmailContactInput, + GroupNameInput, + InstitutionNameInput, + PostalCodeInput, + StateInput, +} from './Inputs'; +import useClientFlag from '../../hooks/isClient'; +import type { NewGroup } from '../../types/backend'; import { ErrorFeedback } from '../ErrorFeedback.tsx'; -import { AddressLineOneInput, AddressLineTwoInput, CityInput, CountryInput, EmailContactInput, GroupNameInput, InstitutionNameInput, PostalCodeInput, StateInput } from "./Inputs"; -import useClientFlag from "../../hooks/isClient"; interface GroupFormProps { title: string; buttonText: string; defaultGroupData?: NewGroup; onSubmit: (group: NewGroup) => Promise; - } export type GroupSubmitSuccess = { @@ -24,7 +34,7 @@ export type GroupSubmitResult = GroupSubmitSuccess | GroupSubmitError; const chooseCountry = 'Choose a country...'; -export const GroupForm: FC = ({title, buttonText, defaultGroupData, onSubmit}) => { +export const GroupForm: FC = ({ title, buttonText, defaultGroupData, onSubmit }) => { const [errorMessage, setErrorMessage] = useState(undefined); const internalOnSubmit = async (e: FormEvent) => { @@ -80,7 +90,7 @@ export const GroupForm: FC = ({title, buttonText, defaultGroupDa

- + @@ -88,7 +98,7 @@ export const GroupForm: FC = ({title, buttonText, defaultGroupDa - +
@@ -104,7 +114,7 @@ export const GroupForm: FC = ({title, buttonText, defaultGroupDa
); -} +}; const fieldMapping = { groupName: { diff --git a/website/src/components/Group/Inputs.tsx b/website/src/components/Group/Inputs.tsx index 6345e4f0a..ceedc5357 100644 --- a/website/src/components/Group/Inputs.tsx +++ b/website/src/components/Group/Inputs.tsx @@ -1,4 +1,4 @@ -import { type ComponentProps, type FC, type FormEvent, type PropsWithChildren, useState } from 'react'; +import { type ComponentProps, type FC, type PropsWithChildren } from 'react'; import { listOfCountries } from './listOfCountries.ts'; @@ -220,7 +220,6 @@ export const StateInput: FC = ({ defaultValue }) => ( /> ); - type PostalCodeInputProps = { defaultValue?: string; }; diff --git a/website/src/components/User/GroupCreationForm.tsx b/website/src/components/User/GroupCreationForm.tsx index 442844f5a..baba09032 100644 --- a/website/src/components/User/GroupCreationForm.tsx +++ b/website/src/components/User/GroupCreationForm.tsx @@ -2,10 +2,10 @@ import { type FC } from 'react'; import { useGroupCreation } from '../../hooks/useGroupOperations.ts'; import { routes } from '../../routes/routes.ts'; +import type { NewGroup } from '../../types/backend.ts'; import { type ClientConfig } from '../../types/runtimeConfig.ts'; -import { withQueryProvider } from '../common/withQueryProvider.tsx'; import { GroupForm, type GroupSubmitError, type GroupSubmitSuccess } from '../Group/GroupForm.tsx'; -import type { NewGroup } from '../../types/backend.ts'; +import { withQueryProvider } from '../common/withQueryProvider.tsx'; interface GroupManagerProps { clientConfig: ClientConfig; @@ -25,22 +25,16 @@ const InnerGroupCreationForm: FC = ({ clientConfig, accessTok return { succeeded: true, nextPageHref: routes.groupOverviewPage(result.group.groupId), - } as GroupSubmitSuccess + } as GroupSubmitSuccess; } else { return { succeeded: false, errorMessage: result.errorMessage, - } as GroupSubmitError + } as GroupSubmitError; } }; - return ( - - ); + return ; }; export const GroupCreationForm = withQueryProvider(InnerGroupCreationForm); diff --git a/website/src/components/User/GroupEditForm.tsx b/website/src/components/User/GroupEditForm.tsx index 033fc55c1..fbf51c0a1 100644 --- a/website/src/components/User/GroupEditForm.tsx +++ b/website/src/components/User/GroupEditForm.tsx @@ -1,11 +1,11 @@ import { type FC } from 'react'; -import { useGroupCreation, useGroupEdit } from '../../hooks/useGroupOperations.ts'; +import { useGroupEdit } from '../../hooks/useGroupOperations.ts'; import { routes } from '../../routes/routes.ts'; +import type { GroupDetails, NewGroup } from '../../types/backend.ts'; import { type ClientConfig } from '../../types/runtimeConfig.ts'; -import { withQueryProvider } from '../common/withQueryProvider.tsx'; import { GroupForm, type GroupSubmitError, type GroupSubmitSuccess } from '../Group/GroupForm.tsx'; -import type { Group, GroupDetails, NewGroup } from '../../types/backend.ts'; +import { withQueryProvider } from '../common/withQueryProvider.tsx'; interface GroupEditFormProps { prefetchedGroupDetails: GroupDetails; @@ -14,7 +14,7 @@ interface GroupEditFormProps { } const InnerGroupEditForm: FC = ({ prefetchedGroupDetails, clientConfig, accessToken }) => { - const {groupId, ...groupInfo} = prefetchedGroupDetails.group; + const { groupId, ...groupInfo } = prefetchedGroupDetails.group; const { editGroup } = useGroupEdit({ clientConfig, @@ -28,12 +28,12 @@ const InnerGroupEditForm: FC = ({ prefetchedGroupDetails, cl return { succeeded: true, nextPageHref: routes.groupOverviewPage(result.group.groupId), - } as GroupSubmitSuccess + } as GroupSubmitSuccess; } else { return { succeeded: false, errorMessage: result.errorMessage, - } as GroupSubmitError + } as GroupSubmitError; } }; diff --git a/website/src/hooks/useGroupOperations.ts b/website/src/hooks/useGroupOperations.ts index 183b724a2..84166b017 100644 --- a/website/src/hooks/useGroupOperations.ts +++ b/website/src/hooks/useGroupOperations.ts @@ -76,13 +76,7 @@ export const useGroupCreation = ({ }; }; -export const useGroupEdit = ({ - clientConfig, - accessToken, -}: { - clientConfig: ClientConfig; - accessToken: string; -}) => { +export const useGroupEdit = ({ clientConfig, accessToken }: { clientConfig: ClientConfig; accessToken: string }) => { const { zodios } = useGroupManagementClient(clientConfig); const editGroup = useCallback( @@ -141,13 +135,13 @@ function callEditGroup(accessToken: string, zodios: ZodiosInstance 'Edit group', - () => 'Group error', - )} -> + { !accessToken ? (