Skip to content

Commit

Permalink
fix(CreateService): should display spinner while processing form
Browse files Browse the repository at this point in the history
  • Loading branch information
framitdavid committed Nov 27, 2023
1 parent 2f80b1b commit e86fe5a
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions frontend/dashboard/pages/CreateService/CreateService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ export const CreateService = ({ user, organizations }: CreateServiceProps): JSX.
repoName: '',
});

const { mutate: addRepo, isLoading: isCreatingRepo } = useAddRepoMutation({
const { mutate: addRepoMutation, isLoading: isCreatingRepo } = useAddRepoMutation({
hideDefaultError: (error: AxiosError) => error?.response?.status === ServerCodes.Conflict,
});

const defaultSelectedOrgOrUser: string =
selectedContext === SelectedContextType.Self ? user.login : selectedContext;
const createAppRepo = async (createAppForm: CreateAppForm) => {
addRepo(
addRepoMutation(
{
org: createAppForm.org,
repository: createAppForm.repoName,
Expand Down Expand Up @@ -105,6 +105,7 @@ export const CreateService = ({ user, organizations }: CreateServiceProps): JSX.
return isOrgValid && isRepoNameValid;
};

console.log(isCreatingRepo);
return (
<form onSubmit={handleCreateAppFormSubmit} className={classes.createAppForm}>
<ServiceOwnerSelector
Expand All @@ -116,14 +117,16 @@ export const CreateService = ({ user, organizations }: CreateServiceProps): JSX.
/>
<RepoNameInput name='repoName' errorMessage={formError.repoName} />
<div className={classes.actionContainer}>
<Button type='submit' color='first' size='small' disabled={isCreatingRepo}>
{isCreatingRepo ? (
<AltinnSpinner size='xxsmall' aria-label={t('dashboard.creating_your_service')} />
) : (
<span>{t('dashboard.create_service_btn')}</span>
)}
</Button>
<Link to={DASHBOARD_ROOT_ROUTE}>{t('general.cancel')}</Link>
{isCreatingRepo ? (
<AltinnSpinner spinnerText={t('dashboard.creating_your_service')} />
) : (
<>
<Button type='submit' color='first' size='small' disabled={isCreatingRepo}>
{t('dashboard.create_service_btn')}
</Button>
<Link to={DASHBOARD_ROOT_ROUTE}>{t('general.cancel')}</Link>
</>
)}
</div>
</form>
);
Expand Down

0 comments on commit e86fe5a

Please sign in to comment.