diff --git a/frontend/src/components/roles/PermissionsBody.tsx b/frontend/src/components/roles/PermissionsBody.tsx index abf70ebb..39f3cf89 100644 --- a/frontend/src/components/roles/PermissionsBody.tsx +++ b/frontend/src/components/roles/PermissionsBody.tsx @@ -41,8 +41,14 @@ const DEFAULT_PAYLOAD: IPermissionAttributes = { role: "", }; const AccordionModelHead = () => ( - - + + Action @@ -95,17 +101,19 @@ export const PermissionsBody: FC> = ({ EntityType.PERMISSION, options, ); - const [expanded, setExpanded] = useState(false); + const [expanded, setExpanded] = useState(); const [payload, setPayload] = useState(DEFAULT_PAYLOAD); const reset = () => setPayload(DEFAULT_PAYLOAD); - const handleChange = - (panel: string) => (event: React.SyntheticEvent, isExpanded: boolean) => { - setExpanded(isExpanded ? panel : false); - }; + const handleChange = (panel: string) => () => { + setExpanded(panel === expanded ? "" : panel); + setPayload(DEFAULT_PAYLOAD); + }; useEffect(() => { - if (expanded === false && models?.[0]?.id) setExpanded(models[0].id); + if (typeof expanded !== "string" && models?.[0]?.id) { + setExpanded(models[0].id); + } }, [models]); return ( @@ -139,7 +147,8 @@ export const PermissionsBody: FC> = ({ @@ -179,14 +188,21 @@ export const PermissionsBody: FC> = ({ {action} - {relation} + + {relation} + ); })} - - + + > = ({ }); reset(); }} + disabled={!payload.action || !payload.relation} >