Skip to content

Commit

Permalink
fix(delegations): Fix delete for GeneralMandate delegations (#16212)
Browse files Browse the repository at this point in the history
* Fix delete

* fix hardcoded value

* fix pr comments

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
GunnlaugurG and kodiakhq[bot] authored Oct 1, 2024
1 parent 9ef986b commit 148403d
Showing 1 changed file with 26 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { useEffect, useState } from 'react'

import { useAuth } from '@island.is/auth/react'
import { Box, toast, useBreakpoint } from '@island.is/island-ui/core'
import { useLocale } from '@island.is/localization'
import { formatNationalId } from '@island.is/portals/core'
import { Problem } from '@island.is/react-spa/shared'
import { useEffect, useState } from 'react'
import { DelegationsFormFooter } from '../../delegations/DelegationsFormFooter'
import { Modal, ModalProps } from '@island.is/react/components'
import { AuthDelegationType } from '@island.is/shared/types'

import { DelegationsFormFooter } from '../../delegations/DelegationsFormFooter'
import { IdentityCard } from '../../IdentityCard/IdentityCard'
import { AccessListContainer } from '../AccessList/AccessListContainer/AccessListContainer'
import { useAuthScopeTreeLazyQuery } from '../AccessList/AccessListContainer/AccessListContainer.generated'
Expand Down Expand Up @@ -37,7 +40,7 @@ export const AccessDeleteModal = ({
useAuthScopeTreeLazyQuery()

useEffect(() => {
if (delegation) {
if (delegation && delegation.domain?.name) {
getAuthScopeTree({
variables: {
input: {
Expand Down Expand Up @@ -132,20 +135,30 @@ export const AccessDeleteModal = ({
/>
)}
</Box>
{delegation?.domain && (
{delegation?.type === AuthDelegationType.GeneralMandate ? (
<IdentityCard
label={formatMessage(m.domain)}
title={delegation.domain.displayName}
imgSrc={delegation.domain.organisationLogoUrl}
title={formatMessage(m.delegationTypeGeneralMandate)}
imgSrc="./assets/images/skjaldarmerki.svg"
/>
) : (
<>
{delegation?.domain && (
<IdentityCard
label={formatMessage(m.domain)}
title={delegation?.domain.displayName ?? ''}
imgSrc={delegation?.domain.organisationLogoUrl}
/>
)}
<AccessListContainer
delegation={delegation}
scopes={delegation?.scopes}
scopeTree={authScopeTree}
loading={scopeTreeLoading}
listMarginBottom={[0, 0, 10]}
/>
</>
)}
<AccessListContainer
delegation={delegation}
scopes={delegation?.scopes}
scopeTree={authScopeTree}
loading={scopeTreeLoading}
listMarginBottom={[0, 0, 10]}
/>
<div {...pxProps} />
</Box>
<Box position="sticky" bottom={0}>
Expand Down

0 comments on commit 148403d

Please sign in to comment.