Skip to content

Commit

Permalink
fix: indent org unit with no childs and refresh lists on update or ne…
Browse files Browse the repository at this point in the history
…w item
  • Loading branch information
flaminic committed Dec 18, 2024
1 parent 4e4b5b8 commit c2dd1e1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/lib/form/useOnSubmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from './createJsonPatchOperations'
import { useCreateModel } from './useCreateModel'
import { usePatchModel } from './usePatchModel'
import { useQueryClient } from 'react-query'

Check failure on line 14 in src/lib/form/useOnSubmit.ts

View workflow job for this annotation

GitHub Actions / lint

`react-query` import should occur before import of `../../types`

type OnSubmit<TValues> = FormProps<TValues>['onSubmit']

Expand All @@ -24,6 +25,7 @@ export const useOnSubmitEdit = <TFormValues extends IdentifiableObject>({
section,
}: UseOnSubmitEditOptions) => {
const patchDirtyFields = usePatchModel(modelId, section.namePlural)
const queryClient = useQueryClient()
const saveAlert = useAlert(
({ message }) => message,
(options) => options
Expand Down Expand Up @@ -53,6 +55,9 @@ export const useOnSubmitEdit = <TFormValues extends IdentifiableObject>({
message: i18n.t('Saved successfully'),
success: true,
})
queryClient.invalidateQueries({
queryKey: [{ resource: getSectionPath(section) }],
})
navigate(`/${getSectionPath(section)}`)
},
[patchDirtyFields, saveAlert, navigate, section]
Expand Down Expand Up @@ -81,6 +86,7 @@ export const useOnSubmitNew = <TFormValues extends ModelWithAttributeValues>({
section: ModelSection
}) => {
const createModel = useCreateModel(section.namePlural)
const queryClient = useQueryClient()
const saveAlert = useAlert(
({ message }) => message,
(options) => options
Expand All @@ -107,6 +113,9 @@ export const useOnSubmitNew = <TFormValues extends ModelWithAttributeValues>({
message: i18n.t('Created successfully'),
success: true,
})
queryClient.invalidateQueries({
queryKey: [{ resource: getSectionPath(section) }],
})
navigate(`/${getSectionPath(section)}`)
},
[createModel, saveAlert, navigate, section]
Expand Down
2 changes: 1 addition & 1 deletion src/pages/defaultFormTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const generateDefaultAddFormTests = ({
}) => {
xdescribe(`${componentName} default add form tests`, () => {
it('should should return to the list view when cancelling', () => {})
it('should show a loader while the form is being submitted ', () => {})
it('should show a loader while the form is being submitted', () => {})
})
}

Expand Down
4 changes: 3 additions & 1 deletion src/pages/organisationUnits/list/OrganisationUnitRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ export const OrganisationUnitRow = ({
onClick={row.getToggleExpandedHandler()}
></Button>
</>
) : null}
) : (
<span style={{ width: 26 }} />
)}
<Checkbox
checked={row.getIsSelected()}
onChange={({ checked }) =>
Expand Down

0 comments on commit c2dd1e1

Please sign in to comment.