-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(auth-admin): View delegation and refactor access card (#16243)
* refactor AccessCard component and make change to modal to view delegation in access control * remove unused createdBy * chore: nx format:write update dirty files * refactor * fix typo * chore: nx format:write update dirty files * fix type * small refactor * fix delete function * chore: nx format:write update dirty files * Adds delete modal * chore: nx format:write update dirty files * Update DelegationDeleteModal.tsx * adds loading to create modal * chore: nx format:write update dirty files * small fixes and use view delegation modal in admin portal * Update AccessCard.tsx * chore: nx format:write update dirty files * fix query and types * chore: nx format:write update dirty files --------- Co-authored-by: andes-it <builders@andes.is> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
Showing
22 changed files
with
608 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
libs/portals/admin/delegation-admin/src/components/DelegationDeleteModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import { Box, useBreakpoint } from '@island.is/island-ui/core' | ||
import { useLocale } from '@island.is/localization' | ||
import { formatNationalId, m as coreMessages } from '@island.is/portals/core' | ||
import { Modal, ModalProps } from '@island.is/react/components' | ||
import { m } from '../lib/messages' | ||
import { | ||
DelegationsFormFooter, | ||
IdentityCard, | ||
useDynamicShadow, | ||
} from '@island.is/portals/shared-modules/delegations' | ||
import { AuthCustomDelegation } from '@island.is/api/schema' | ||
import format from 'date-fns/format' | ||
import isValid from 'date-fns/isValid' | ||
import { AuthDelegationType } from '@island.is/shared/types' | ||
|
||
type DelegationDeleteModalProps = Pick< | ||
ModalProps, | ||
'id' | 'onClose' | 'isVisible' | ||
> & { | ||
loading: boolean | ||
delegation?: AuthCustomDelegation | ||
onDelete(): void | ||
} | ||
|
||
export const DelegationDeleteModal = ({ | ||
id, | ||
loading, | ||
delegation, | ||
onClose, | ||
onDelete, | ||
...rest | ||
}: DelegationDeleteModalProps) => { | ||
const { formatMessage } = useLocale() | ||
const { md } = useBreakpoint() | ||
|
||
const { showShadow, pxProps } = useDynamicShadow({ | ||
rootMargin: md ? '-128px' : '-104px', | ||
isDisabled: !rest.isVisible, | ||
}) | ||
|
||
return ( | ||
<Modal | ||
id={id} | ||
label={formatMessage(m.deleteDelegationModalTitle)} | ||
title={formatMessage(m.deleteDelegationModalTitle)} | ||
onClose={onClose} | ||
noPaddingBottom | ||
scrollType="inside" | ||
closeButtonLabel={formatMessage(m.cancel)} | ||
{...rest} | ||
> | ||
<Box marginY={4} display="flex" flexDirection="column" rowGap={3}> | ||
<Box | ||
width="full" | ||
display="flex" | ||
flexDirection={['column', 'column', 'column', 'row']} | ||
rowGap={[3, 3, 3, 0]} | ||
columnGap={[0, 0, 0, 3]} | ||
> | ||
{delegation?.from?.name && delegation?.from?.nationalId && ( | ||
<IdentityCard | ||
label={formatMessage(m.fromNationalId)} | ||
title={delegation?.from?.name} | ||
description={formatNationalId(delegation?.from?.nationalId)} | ||
color="blue" | ||
/> | ||
)} | ||
{delegation?.to?.name && delegation?.to?.nationalId && ( | ||
<IdentityCard | ||
label={formatMessage(m.toNationalId)} | ||
title={delegation?.to.name} | ||
description={formatNationalId(delegation?.to.nationalId)} | ||
color="purple" | ||
/> | ||
)} | ||
</Box> | ||
{delegation?.type && | ||
delegation.type === AuthDelegationType.GeneralMandate && ( | ||
<IdentityCard | ||
label={formatMessage(m.type)} | ||
title={formatMessage(m.generalMandateLabel)} | ||
imgSrc="./assets/images/skjaldarmerki.svg" | ||
/> | ||
)} | ||
|
||
<Box | ||
display="flex" | ||
flexDirection={['column', 'row']} | ||
justifyContent="spaceBetween" | ||
columnGap={[0, 3]} | ||
rowGap={[3, 0]} | ||
> | ||
<IdentityCard | ||
label={formatMessage(m.validTo)} | ||
title={ | ||
delegation?.validTo && isValid(delegation.validTo) | ||
? format(new Date(delegation?.validTo), 'dd.MM.yyyy') | ||
: formatMessage(m.noEndDate) | ||
} | ||
/> | ||
{delegation?.referenceId && ( | ||
<IdentityCard | ||
label={formatMessage(m.referenceId)} | ||
title={delegation?.referenceId} | ||
/> | ||
)} | ||
</Box> | ||
</Box> | ||
|
||
<div {...pxProps} /> | ||
|
||
<Box position="sticky" bottom={0}> | ||
<DelegationsFormFooter | ||
loading={loading} | ||
showShadow={showShadow} | ||
confirmButtonColorScheme="destructive" | ||
onCancel={onClose} | ||
onConfirm={onDelete} | ||
confirmLabel={formatMessage(coreMessages.buttonDestroy)} | ||
containerPaddingBottom={[3, 3, 6]} | ||
/> | ||
</Box> | ||
</Modal> | ||
) | ||
} |
93 changes: 67 additions & 26 deletions
93
libs/portals/admin/delegation-admin/src/components/DelegationList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.