Skip to content

Commit

Permalink
Merge pull request #49 from socialappslab/fix/392/create-brigade-fix
Browse files Browse the repository at this point in the history
fix: Create Brigade
  • Loading branch information
zant authored Oct 31, 2024
2 parents ff234cd + 1fbf16d commit 5a6ba9c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/components/dialog/CreateCityDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export function CreateCityDialog({ handleClose, updateTable }: CreateCityDialogP
const { state } = useStateContext();
const user = state.user as IUser;
const { t } = useTranslation(['register', 'errorCodes', 'admin']);
const { createMutation: createCityMutation } = useCreateMutation<CreateCity, City>(
`admin/countries/1/states/${user.state.id}/cities/`,
const { createMutation: createCityMutation, loading: mutationLoading } = useCreateMutation<CreateCity, City>(
`countries/1/states/${user.state.id}/cities/`,
);

const { enqueueSnackbar } = useSnackbar();
Expand Down Expand Up @@ -77,6 +77,7 @@ export function CreateCityDialog({ handleClose, updateTable }: CreateCityDialogP

// eslint-disable-next-line @typescript-eslint/no-shadow, @typescript-eslint/no-explicit-any
errorData?.errors?.forEach((error: any) => {
console.log(error);
if (error?.field && watch(error.field)) {
setError(error.field, {
type: 'manual',
Expand Down Expand Up @@ -158,7 +159,7 @@ export function CreateCityDialog({ handleClose, updateTable }: CreateCityDialogP

<div className="mt-8 grid grid-cols-1 gap-4 md:flex md:justify-end md:gap-0">
<div className="md:mr-2">
<Button buttonType="large" label={t('edit.action')} disabled={false} type="submit" />
<Button buttonType="large" label={t('edit.action')} disabled={mutationLoading} type="submit" />
</div>

<div>
Expand Down
8 changes: 5 additions & 3 deletions src/components/dialog/CreateTeamDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ export function CreateTeamDialog({ handleClose, updateTable }: CreateTeamDialogP
// const { state } = useStateContext();
// const user = state.user as IUser;
const { t } = useTranslation(['register', 'errorCodes', 'admin', 'translation']);
const { createMutation: createTeamMutation } = useCreateMutation<CreateTeam, Team>(`/teams`);
const { createMutation: createTeamMutation, loading: mutationLoading } = useCreateMutation<CreateTeam, Team>(
`/teams`,
);

const [userOptions, setUserOptions] = useState<FormSelectOption[]>([]);

const [{ data: usersData, loading: loadingUsers }] = useAxios<ExistingDocumentObject, unknown, ErrorResponse>({
url: '/users?filter[roles][name]=brigadista',
url: '/users?filter[roles][name]=brigadista&filter[without_team]=true',
});

useEffect(() => {
Expand Down Expand Up @@ -228,7 +230,7 @@ export function CreateTeamDialog({ handleClose, updateTable }: CreateTeamDialogP

<div className="mt-8 grid grid-cols-1 gap-4 md:flex md:justify-end md:gap-0">
<div className="md:mr-2">
<Button buttonType="large" label={t('edit.action')} disabled={false} type="submit" />
<Button buttonType="large" label={t('edit.action')} disabled={mutationLoading} type="submit" />
</div>

<div>
Expand Down

0 comments on commit 5a6ba9c

Please sign in to comment.