Skip to content

Commit

Permalink
fix(auth-admin): Tweak modal to handle general mandate delegations (#…
Browse files Browse the repository at this point in the history
…16174)

* tweak modal to handle general mandate delegations

* chore: nx format:write update dirty files

---------

Co-authored-by: andes-it <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored and thoreyjona committed Oct 2, 2024
1 parent e433a86 commit ee301d0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ export const AccessCard = ({
}

const showActions =
canModify && (isOutgoing || delegation.type === AuthDelegationType.Custom)
canModify &&
(isOutgoing ||
delegation.type === AuthDelegationType.Custom ||
delegation.type === AuthDelegationType.GeneralMandate)

const canDelete =
isOutgoing || (!isOutgoing && delegation.type === AuthDelegationType.Custom)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ query AuthDelegationsIncoming($input: AuthDelegationsInput!, $lang: String) {
authDelegations(input: $input) {
id
type
validTo
from {
nationalId
name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { AccessListContainer } from '../../../access/AccessList/AccessListContai
import { useAuthScopeTreeLazyQuery } from '../../../access/AccessList/AccessListContainer/AccessListContainer.generated'
import { AuthCustomDelegationIncoming } from '../../../../types/customDelegation'
import { m } from '../../../../lib/messages'
import format from 'date-fns/format'

type DelegationIncomingModalProps = {
delegation?: AuthCustomDelegationIncoming
Expand All @@ -26,7 +27,7 @@ export const DelegationIncomingModal = ({
useAuthScopeTreeLazyQuery()

useEffect(() => {
if (delegation) {
if (delegation && delegation.domain) {
getAuthScopeTree({
variables: {
input: {
Expand Down Expand Up @@ -84,20 +85,38 @@ export const DelegationIncomingModal = ({
/>
)}
</Box>

{delegation?.domain && (
<IdentityCard
label={formatMessage(m.domain)}
title={delegation.domain.displayName}
imgSrc={delegation.domain.organisationLogoUrl}
/>
)}

{delegation?.type === 'GeneralMandate' && (
<IdentityCard
label={formatMessage(m.domain)}
title={formatMessage(m.delegationTypeGeneralMandate)}
imgSrc="./assets/images/skjaldarmerki.svg"
/>
)}

{delegation?.validTo && delegation.type === 'GeneralMandate' && (
<IdentityCard
label={formatMessage(m.validTo)}
title={format(new Date(delegation?.validTo), 'dd.MM.yyyy')}
/>
)}
</Box>
<AccessListContainer
delegation={delegation}
scopes={delegation?.scopes}
scopeTree={authScopeTree}
loading={scopeTreeLoading}
/>
{delegation?.type !== 'GeneralMandate' && (
<AccessListContainer
delegation={delegation}
scopes={delegation?.scopes}
scopeTree={authScopeTree}
loading={scopeTreeLoading}
/>
)}
</Modal>
)
}

0 comments on commit ee301d0

Please sign in to comment.