Skip to content

Commit

Permalink
PR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexd-bes committed Sep 20, 2024
1 parent 71617ab commit 3389122
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 13 deletions.
3 changes: 1 addition & 2 deletions packages/datatrak-web/src/views/RequestProjectAccessPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ export const RequestProjectAccessPage = () => {
onClose={onReturnToProjects}
project={project}
onSubmit={requestProjectAccess}
isLoading={isLoadingProject}
isLoading={isLoadingProject || !isFetched}
isSubmitting={isLoading}
isSuccess={isSuccess}
isFetched={isFetched}
countries={countries}
/>
</Wrapper>
Expand Down
3 changes: 1 addition & 2 deletions packages/tupaia-web/src/views/RequestProjectAccessModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,10 @@ export const RequestProjectAccessModal = () => {
<RequestProjectAccess
project={requestingProject}
countries={countries}
isLoading={isLoading || isLoadingCountryAccessList}
isLoading={isLoading || isLoadingCountryAccessList || !isFetched}
isSubmitting={isSubmitting}
onSubmit={requestCountryAccess}
isSuccess={isSuccess}
isFetched={isFetched}
onClose={onCloseModal}
closeButtonText={isReturningToProjects ? 'Return to projects' : 'Close'}
errorMessage={showError ? error.message : undefined}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ interface ProjectAccessFormProps {
isSubmitting: boolean;
isSuccess: boolean;
closeButtonText?: string;
isLoading?: boolean;
}

export const ProjectAccessForm = ({
Expand All @@ -130,7 +129,6 @@ export const ProjectAccessForm = ({
isSubmitting,
isSuccess,
closeButtonText = 'Back to projects',
isLoading,
}: ProjectAccessFormProps) => {
const formContext = useForm({
mode: 'onChange',
Expand All @@ -152,7 +150,7 @@ export const ProjectAccessForm = ({
const availableCountries = countries?.filter((c: Country) => !c.hasAccess && !c.hasPendingAccess);

// show the no countries message if the country access list has loaded and there are no countries available
const showNoCountriesMessage = !isLoading && !availableCountries?.length && !isSuccess;
const showNoCountriesMessage = !availableCountries?.length && !isSuccess;

if (showNoCountriesMessage) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ interface RequestProjectAccessProps {
onClose?: () => void;
project?: WebServerProjectRequest.ResBody;
isLoading?: boolean;
isFetched?: boolean;
countries: ProjectCountryAccessListRequest.ResBody[number][];
onSubmit: (data: { entityIds: string[]; message: string; projectCode: string }) => void;
isSubmitting: boolean;
Expand All @@ -76,22 +75,19 @@ export const RequestProjectAccess = ({
onClose,
project,
isLoading,
isFetched,
countries,
onSubmit,
isSuccess,
isSubmitting,
closeButtonText,
errorMessage,
}: RequestProjectAccessProps) => {
const showLoading = isLoading || !isFetched;

return (
<Wrapper>
<Title>Request project access</Title>
<BodyText>Complete the form below to request access to this project</BodyText>
<Container>
{showLoading ? (
{isLoading ? (
<SpinningLoader />
) : (
<>
Expand All @@ -112,7 +108,6 @@ export const RequestProjectAccess = ({
isSuccess={isSuccess}
countries={countries}
closeButtonText={closeButtonText}
isLoading={isLoading}
/>
</>
)}
Expand Down

0 comments on commit 3389122

Please sign in to comment.