From b171268517e704f8857733aeb05344d17c0a09e3 Mon Sep 17 00:00:00 2001 From: JeremiahUy Date: Fri, 22 Nov 2024 12:19:07 +0100 Subject: [PATCH] UPDATE: to use aksel components --- .../Process/Accordion/AccordionProcess.tsx | 186 ++++++++---------- .../Process/Accordion/AccordionTitle.tsx | 40 ++-- 2 files changed, 104 insertions(+), 122 deletions(-) diff --git a/apps/frontend/src/components/Process/Accordion/AccordionProcess.tsx b/apps/frontend/src/components/Process/Accordion/AccordionProcess.tsx index 140aaa16b..cbeabc615 100644 --- a/apps/frontend/src/components/Process/Accordion/AccordionProcess.tsx +++ b/apps/frontend/src/components/Process/Accordion/AccordionProcess.tsx @@ -1,6 +1,6 @@ import { faExclamationCircle, faGavel, faTrash } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { Panel, StatelessAccordion } from 'baseui/accordion' +import { Accordion } from '@navikt/ds-react' import { Plus } from 'baseui/icon' import { Modal, ModalBody, SIZE } from 'baseui/modal' import { Spinner } from 'baseui/spinner' @@ -176,12 +176,7 @@ const AccordionProcess = (props: TAccordionProcessProps) => { return (
- - onChangeProcess(expanded.length ? (expanded[0] as string) : undefined) - } - expanded={params.processId ? [params.processId] : []} - > + {processList && processList .sort((a, b) => { @@ -197,114 +192,105 @@ const AccordionProcess = (props: TAccordionProcessProps) => { const expanded = params.processId === process.id return ( - { + onChangeProcess(open ? process.id : undefined) + }} + > + - } - key={process.id} - overrides={{ - ToggleIcon: { - component: () => null, - }, - Content: { - style: { - backgroundColor: theme.colors.white, - // Outline width - paddingTop: '4px', - paddingBottom: '4px', - paddingLeft: '4px', - paddingRight: '4px', - }, - }, - }} - > - {isLoading && ( -
- -
- )} +
+ + {expanded && isLoading && ( +
+ +
+ )} - {!isLoading && currentProcess && ( -
-
- setShowEditProcessModal(true)} - deleteProcess={() => setShowDeleteModal(true)} - /> - -
-
- - {`Sist endret av ${currentProcess.changeStamp.lastModifiedBy}, ${lastModifiedDate(currentProcess.changeStamp?.lastModifiedDate)}`} - + {expanded && !isLoading && currentProcess && ( +
+
+ setShowEditProcessModal(true)} + deleteProcess={() => setShowDeleteModal(true)} + /> + +
+
+ + {`Sist endret av ${currentProcess.changeStamp.lastModifiedBy}, ${lastModifiedDate(currentProcess.changeStamp?.lastModifiedDate)}`} + +
-
-
-
- {canViewAlerts() && ( -
- -
- )} - {(user.isAdmin() || user.isSuper()) && ( -
- +
+
+ {canViewAlerts() && ( +
+ +
+ )} + {(user.isAdmin() || user.isSuper()) && ( +
+ +
+ )} +
+ {hasAccess() && ( +
+
+ {renderAddDocumentButton()} + {renderCreatePolicyButton()} + {renderDeleteAllPolicyButton()}
)}
- {hasAccess() && ( -
-
- {renderAddDocumentButton()} - {renderCreatePolicyButton()} - {renderDeleteAllPolicyButton()} -
- )}
+
- - -
- )} - + )} + + ) })} - + {!processList.length && Ingen behandlinger} {!!currentProcess && ( diff --git a/apps/frontend/src/components/Process/Accordion/AccordionTitle.tsx b/apps/frontend/src/components/Process/Accordion/AccordionTitle.tsx index b656becb8..52b15015b 100644 --- a/apps/frontend/src/components/Process/Accordion/AccordionTitle.tsx +++ b/apps/frontend/src/components/Process/Accordion/AccordionTitle.tsx @@ -12,38 +12,34 @@ type TAccordionTitleProps = { process: IProcessShort expanded: boolean forwardRef?: Ref + noChevron?: boolean } export const InformationTypeRef: RefObject = createRef() const AccordionTitle = (props: TAccordionTitleProps) => { - const { process, expanded, forwardRef, codelistUtils } = props + const { process, expanded, forwardRef, codelistUtils, noChevron } = props const today: string = new Date().toISOString().split('T')[0] const isActive: boolean = today < process.end return ( - <> -
- - {expanded ? ( - - ) : ( - - )} - - {isActive ? 'Aktiv' : 'Utgått'} - - - {process.purposes - .map((purpose: ICode) => codelistUtils.getShortname(EListName.PURPOSE, purpose.code)) - .join(', ')} - :{' '} - - {process.name} - -
- +
+ + {!noChevron && expanded && } + {!noChevron && !expanded && } + + {isActive ? 'Aktiv' : 'Utgått'} + + + {process.purposes + .map((purpose: ICode) => codelistUtils.getShortname(EListName.PURPOSE, purpose.code)) + .join(', ')} + :{' '} + + {process.name} + +
) }