Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: PIN-5747 - Attributi in-add #1021

Merged
merged 4 commits into from
Dec 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/api/eservice/eservice.mutations.ts
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next'
import type { EServiceRiskAnalysisSeed, UpdateEServiceDescriptorSeed } from '../api.generatedTypes'
import { EServiceServices } from './eservice.services'
import { EServiceQueries } from './eservice.queries'
import type { AttributeKey } from '@/types/attribute.types'

function useCreateDraft() {
const { t } = useTranslation('mutations-feedback', { keyPrefix: 'eservice.createDraft' })
@@ -306,6 +307,31 @@ function useUpdateEServiceDescription() {
})
}

function useUpdateDescriptorAttributes() {
const { t } = useTranslation('mutations-feedback', {
keyPrefix: 'eservice.updateDescriptorAttributes',
})
const { t: tAttribute } = useTranslation('attribute', { keyPrefix: 'type' })
return useMutation({
mutationFn: EServiceServices.updateDescriptorAttributes,
meta: {
successToastLabel: (_: unknown, variables: unknown) =>
t('outcome.success', {
attributeKind: tAttribute(
`${(variables as { attributeKey: AttributeKey }).attributeKey}_other`
),
}),
errorToastLabel: (_: unknown, variables: unknown) =>
t('outcome.error', {
attributeKind: tAttribute(
`${(variables as { attributeKey: AttributeKey }).attributeKey}_other`
),
}),
loadingLabel: t('loading'),
},
})
}

export const EServiceMutations = {
useCreateDraft,
useUpdateDraft,
@@ -326,4 +352,5 @@ export const EServiceMutations = {
useUpdateEServiceDescription,
useUpdateVersionDraftDocumentDescription,
useImportVersion,
useUpdateDescriptorAttributes,
}
19 changes: 19 additions & 0 deletions src/api/eservice/eservice.services.ts
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ import type {
CreatedEServiceDescriptor,
CreatedResource,
CreateEServiceDocumentPayload,
DescriptorAttributesSeed,
EServiceDescriptionSeed,
EServiceDoc,
EServiceRiskAnalysis,
@@ -26,6 +27,7 @@ import type {
UpdateEServiceDescriptorSeed,
UpdateEServiceSeed,
} from '../api.generatedTypes'
import type { AttributeKey } from '@/types/attribute.types'

async function getCatalogList(params: GetEServicesCatalogParams) {
const response = await axiosInstance.get<CatalogEServices>(
@@ -389,6 +391,22 @@ async function importVersion({ eserviceFile }: { eserviceFile: File }) {
})
}

async function updateDescriptorAttributes({
eserviceId,
descriptorId,
attributeKey: _attributeKey,
...payload
}: {
eserviceId: string
descriptorId: string
attributeKey: AttributeKey
} & DescriptorAttributesSeed) {
return axiosInstance.post<void>(
`${BACKEND_FOR_FRONTEND_URL}/eservices/${eserviceId}/descriptors/${descriptorId}/attributes/update`,
payload
)
}

export const EServiceServices = {
getCatalogList,
getProviderList,
@@ -420,4 +438,5 @@ export const EServiceServices = {
updateEServiceDescription,
exportVersion,
importVersion,
updateDescriptorAttributes,
}
3 changes: 2 additions & 1 deletion src/components/layout/containers/AttributeContainer.tsx
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ export const AttributeContainer = <TAttribute extends { id: string; name: string
}

return (
<Stack direction="row" alignItems="center" spacing={2}>
<Stack direction="row" alignItems="center">
<Stack direction="row" alignItems="center" spacing={2}>
{checked && <CheckCircleIcon sx={{ color: 'success.main' }} />}
{onRemove && (
@@ -130,6 +130,7 @@ const AttributeDetails: React.FC<{ attributeId: string }> = ({ attributeId }) =>
<Stack sx={{ mt: 1 }} spacing={2}>
<Typography variant="body2">{attribute.description}</Typography>
<InformationContainer
direction="column"
content={attributeId}
copyToClipboard={{
value: attributeId,
14 changes: 11 additions & 3 deletions src/components/layout/containers/AttributeGroupContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import React from 'react'
import ClearIcon from '@mui/icons-material/Clear'
import type { CardProps, SxProps } from '@mui/material'
import { Card, CardContent, CardHeader, IconButton, alpha } from '@mui/material'
import { theme } from '@pagopa/interop-fe-commons'
import { useTranslation } from 'react-i18next'

interface AttributeGroupContainerProps {
type AttributeGroupContainerProps = CardProps & {
title: string
onRemove?: () => void
subheader?: React.ReactNode
children?: React.ReactNode
color?: 'primary' | 'success' | 'error' | 'warning' | 'gray'
cardContentSx?: SxProps
}

const containerColors = {
@@ -50,13 +52,18 @@ export const AttributeGroupContainer: React.FC<AttributeGroupContainerProps> = (
onRemove,
children,
subheader,
cardContentSx,
color = 'primary',
...cardProps
}) => {
const { t } = useTranslation('shared-components', { keyPrefix: 'attributeGroupContainer' })
const { headerColor, borderColor, bodyColor, textColor } = containerColors[color]

return (
<Card sx={{ border: '1px solid', borderColor, bgcolor: bodyColor }}>
<Card
{...cardProps}
sx={{ border: '1px solid', borderColor, bgcolor: bodyColor, ...cardProps.sx }}
>
<CardHeader
titleTypographyProps={{ variant: 'body1', fontWeight: 600, color: textColor }}
title={title}
@@ -75,8 +82,9 @@ export const AttributeGroupContainer: React.FC<AttributeGroupContainerProps> = (
sx={{
p: 2,
'&:last-child': {
paddingBottom: 2,
pb: 2,
},
...cardContentSx,
}}
>
{children}
Original file line number Diff line number Diff line change
@@ -3,32 +3,30 @@ import { AttributeQueries } from '@/api/attribute'
import { RHFAutocompleteSingle } from '@/components/shared/react-hook-form-inputs'
import type { AttributeKey } from '@/types/attribute.types'
import { Button, Stack } from '@mui/material'
import { FormProvider, useForm, useFormContext } from 'react-hook-form'
import { FormProvider, useForm } from 'react-hook-form'
import { useTranslation } from 'react-i18next'
import type { AttributeKind, DescriptorAttribute } from '@/api/api.generatedTypes'
import { useAutocompleteTextInput } from '@pagopa/interop-fe-commons'
import type { EServiceCreateStepAttributesFormValues } from '..'
import { keepPreviousData, useQuery } from '@tanstack/react-query'

export type AttributeAutocompleteProps = {
groupIndex: number
attributeKey: AttributeKey
handleHideAutocomplete: VoidFunction
onAddAttribute: (attribute: DescriptorAttribute) => void
alreadySelectedAttributeIds: string[]
direction?: 'column' | 'row'
}

type AttributeAutocompleteFormValues = { attribute: null | DescriptorAttribute }

export const AttributeAutocomplete: React.FC<AttributeAutocompleteProps> = ({
groupIndex,
attributeKey,
handleHideAutocomplete,
onAddAttribute,
alreadySelectedAttributeIds,
direction = 'row',
}) => {
const { t } = useTranslation('attribute', { keyPrefix: 'group' })
const [attributeSearchParam, setAttributeSearchParam] = useAutocompleteTextInput()

const { watch, setValue } = useFormContext<EServiceCreateStepAttributesFormValues>()
const attributeGroups = watch(`attributes.${attributeKey}`)

const attributeAutocompleteFormMethods = useForm<AttributeAutocompleteFormValues>({
defaultValues: { attribute: null },
})
@@ -62,29 +60,26 @@ export const AttributeAutocomplete: React.FC<AttributeAutocompleteProps> = ({

const handleAddAttributeToGroup = handleSubmit(({ attribute }) => {
if (!attribute) return
const newAttributeGroups = [...attributeGroups]
newAttributeGroups[groupIndex].push(attribute)
setValue(`attributes.${attributeKey}`, newAttributeGroups)
handleHideAutocomplete()
onAddAttribute(attribute)
})

const options = React.useMemo(() => {
const attributes = data?.results ?? []
const attributesAlreadyInGroups = attributeGroups.reduce(
(acc, group) => [...acc, ...group.map(({ id }) => id)],
[] as Array<string>
)
return attributes
.filter((att) => !attributesAlreadyInGroups.includes(att.id))
.filter((att) => !alreadySelectedAttributeIds.includes(att.id))
.map((att) => ({
label: att.name,
value: att,
}))
}, [data?.results, attributeGroups])
}, [data?.results, alreadySelectedAttributeIds])

return (
<FormProvider {...attributeAutocompleteFormMethods}>
<Stack direction="row" alignItems="center" spacing={1}>
<Stack
direction={direction}
alignItems={direction === 'column' ? 'start' : 'center'}
spacing={1}
>
<RHFAutocompleteSingle
label={t('autocompleteInput.label')}
placeholder={t('autocompleteInput.placeholder')}
87 changes: 42 additions & 45 deletions src/components/shared/ReadOnlyDescriptorAttributes.tsx
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import {
} from '@/components/layout/containers'
import type { DescriptorAttribute, DescriptorAttributes } from '@/api/api.generatedTypes'
import { useCurrentRoute } from '@/router'
import type { ProviderOrConsumer } from '@/types/common.types'
import type { ActionItemButton, ProviderOrConsumer } from '@/types/common.types'
import { attributesHelpLink } from '@/config/constants'

type ReadOnlyDescriptorAttributesProps = {
@@ -19,76 +19,73 @@ type ReadOnlyDescriptorAttributesProps = {
export const ReadOnlyDescriptorAttributes: React.FC<ReadOnlyDescriptorAttributesProps> = ({
descriptorAttributes,
}) => {
const { t: tAttribute } = useTranslation('attribute')
const { mode } = useCurrentRoute()

const providerOrConsumer = mode as ProviderOrConsumer

const getSubtitle = (attributeKey: AttributeKey) => {
return (
<Trans
components={{ 1: <Link underline="hover" href={attributesHelpLink} target="_blank" /> }}
>
{tAttribute(`${attributeKey}.description`)}
</Trans>
)
}

return (
<>
<AttributeGroupsListSection
title={tAttribute('certified.label')}
subtitle={getSubtitle('certified')}
attributeGroups={descriptorAttributes.certified}
emptyLabel={tAttribute(`noAttributesRequiredAlert.${providerOrConsumer}`, {
attributeKey: tAttribute(`type.certified_other`),
})}
descriptorAttributes={descriptorAttributes}
attributeKey="certified"
/>
<Divider sx={{ my: 3 }} />
<AttributeGroupsListSection
title={tAttribute('verified.label')}
subtitle={getSubtitle('verified')}
attributeGroups={descriptorAttributes.verified}
emptyLabel={tAttribute(`noAttributesRequiredAlert.${providerOrConsumer}`, {
attributeKey: tAttribute(`type.verified_other`),
})}
descriptorAttributes={descriptorAttributes}
attributeKey="verified"
/>
<Divider sx={{ my: 3 }} />
<AttributeGroupsListSection
title={tAttribute('declared.label')}
subtitle={getSubtitle('declared')}
attributeGroups={descriptorAttributes.declared}
emptyLabel={tAttribute(`noAttributesRequiredAlert.${providerOrConsumer}`, {
attributeKey: tAttribute(`type.declared_other`),
})}
descriptorAttributes={descriptorAttributes}
attributeKey="declared"
/>
</>
)
}

type AttributeGroupsListSectionProps = {
attributeGroups: Array<Array<DescriptorAttribute>>
title: string
subtitle: React.ReactNode
emptyLabel: string
descriptorAttributes: DescriptorAttributes
attributeKey: AttributeKey
topSideActions?: Array<ActionItemButton>
}

const AttributeGroupsListSection: React.FC<AttributeGroupsListSectionProps> = ({
attributeGroups,
title,
subtitle,
emptyLabel,
export const AttributeGroupsListSection: React.FC<AttributeGroupsListSectionProps> = ({
descriptorAttributes,
attributeKey,
topSideActions,
}) => {
const { t: tAttribute } = useTranslation('attribute')

const { mode } = useCurrentRoute()

const providerOrConsumer = mode as ProviderOrConsumer

const attributeGroups = descriptorAttributes[attributeKey]

return (
<SectionContainer innerSection title={title} description={subtitle}>
<SectionContainer
innerSection
title={tAttribute(`${attributeKey}.label`)}
description={
<Trans
components={{ 1: <Link underline="hover" href={attributesHelpLink} target="_blank" /> }}
>
{tAttribute(`${attributeKey}.description`)}
</Trans>
}
topSideActions={topSideActions}
>
{attributeGroups.length > 0 && (
<Stack spacing={3}>
{attributeGroups.map((attributeGroup, index) => (
<AttributeGroup key={index} attributes={attributeGroup} index={index} />
))}
</Stack>
)}
{attributeGroups.length === 0 && <AttributeGroupContainer title={emptyLabel} color="gray" />}
{attributeGroups.length === 0 && (
<AttributeGroupContainer
title={tAttribute(`noAttributesRequiredAlert.${providerOrConsumer}`, {
attributeKey: tAttribute(`type.${attributeKey}_other`),
})}
color="gray"
/>
)}
</SectionContainer>
)
}
Original file line number Diff line number Diff line change
@@ -5,8 +5,10 @@ import { Box, Stack } from '@mui/material'
import { useTranslation } from 'react-i18next'
import AddIcon from '@mui/icons-material/Add'
import { ButtonNaked } from '@pagopa/mui-italia'
import { AttributeAutocomplete } from './AttributeAutocomplete'
import { AttributeAutocomplete } from '../../../../../components/shared/AttributeAutocomplete'
import type { DescriptorAttribute } from '@/api/api.generatedTypes'
import { useFormContext } from 'react-hook-form'
import type { EServiceCreateStepAttributesFormValues } from '../EServiceCreateStepAttributes'

export type AttributeGroupProps = {
group: Array<DescriptorAttribute>
@@ -36,7 +38,13 @@ export const AttributeGroup: React.FC<AttributeGroupProps> = ({
onRemoveAttributeFromGroup(attributeId, groupIndex)
}

const handleHideAutocomplete = () => {
const { watch, setValue } = useFormContext<EServiceCreateStepAttributesFormValues>()
const attributeGroups = watch(`attributes.${attributeKey}`)

const handleAddAttributeToGroup = (attribute: DescriptorAttribute) => {
const newAttributeGroups = [...attributeGroups]
newAttributeGroups[groupIndex].push(attribute)
setValue(`attributes.${attributeKey}`, newAttributeGroups)
setIsAttributeAutocompleteShown(false)
}

@@ -63,9 +71,12 @@ export const AttributeGroup: React.FC<AttributeGroupProps> = ({
<>
{isAttributeAutocompleteShown ? (
<AttributeAutocomplete
groupIndex={groupIndex}
attributeKey={attributeKey}
handleHideAutocomplete={handleHideAutocomplete}
onAddAttribute={handleAddAttributeToGroup}
alreadySelectedAttributeIds={attributeGroups.reduce(
(acc, group) => [...acc, ...group.map(({ id }) => id)],
[] as Array<string>
)}
/>
) : (
<ButtonNaked
Original file line number Diff line number Diff line change
@@ -1,24 +1,71 @@
import { EServiceQueries } from '@/api/eservice'
import { SectionContainer, SectionContainerSkeleton } from '@/components/layout/containers'
import { ReadOnlyDescriptorAttributes } from '@/components/shared/ReadOnlyDescriptorAttributes'
import { AttributeGroupsListSection } from '@/components/shared/ReadOnlyDescriptorAttributes'
import { useParams } from '@/router'
import type { ActionItemButton } from '@/types/common.types'
import { Divider } from '@mui/material'
import { useSuspenseQuery } from '@tanstack/react-query'
import React from 'react'
import React, { useState } from 'react'
import { useTranslation } from 'react-i18next'
import EditIcon from '@mui/icons-material/Edit'
import type { AttributeKey } from '@/types/attribute.types'
import { ProviderEServiceUpdateDescriptorAttributesDrawer } from './ProviderEServiceUpdateDescriptorAttributesDrawer'

export const ProviderEServiceDescriptorAttributes: React.FC = () => {
const { t } = useTranslation('eservice', { keyPrefix: 'read.sections.attributes' })
const { t: tCommon } = useTranslation('common')

const { eserviceId, descriptorId } = useParams<'PROVIDE_ESERVICE_MANAGE'>()
const { data: descriptorAttributes } = useSuspenseQuery({
...EServiceQueries.getDescriptorProvider(eserviceId, descriptorId),
select: (d) => d.attributes,
})

const [editAttributeDrawerState, setEditAttributeDrawerState] = useState<{
kind: AttributeKey
isOpen: boolean
}>({ isOpen: false, kind: 'certified' })

const getAttributeSectionActions = (kind: AttributeKey): Array<ActionItemButton> | undefined => {
if (descriptorAttributes[kind].length === 0) return

return [
{
action: () => setEditAttributeDrawerState({ kind, isOpen: true }),
label: tCommon('actions.edit'),
icon: EditIcon,
},
]
}

return (
<SectionContainer title={t('title')} description={t('description')}>
<ReadOnlyDescriptorAttributes descriptorAttributes={descriptorAttributes} />
</SectionContainer>
<>
<SectionContainer title={t('title')} description={t('description')}>
<AttributeGroupsListSection
attributeKey="certified"
descriptorAttributes={descriptorAttributes}
topSideActions={getAttributeSectionActions('certified')}
/>
<Divider sx={{ my: 3 }} />
<AttributeGroupsListSection
attributeKey="verified"
descriptorAttributes={descriptorAttributes}
topSideActions={getAttributeSectionActions('verified')}
/>
<Divider sx={{ my: 3 }} />
<AttributeGroupsListSection
attributeKey="declared"
descriptorAttributes={descriptorAttributes}
topSideActions={getAttributeSectionActions('declared')}
/>
</SectionContainer>
<ProviderEServiceUpdateDescriptorAttributesDrawer
isOpen={editAttributeDrawerState.isOpen}
onClose={() => setEditAttributeDrawerState({ ...editAttributeDrawerState, isOpen: false })}
attributeKey={editAttributeDrawerState.kind}
descriptorAttributes={descriptorAttributes}
/>
</>
)
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
import { Drawer } from '@/components/shared/Drawer'
import React from 'react'
import type { AttributeKey } from '@/types/attribute.types'
import type { DescriptorAttribute, DescriptorAttributes } from '@/api/api.generatedTypes'
import { Box, Stack } from '@mui/material'
import { AttributeContainer, AttributeGroupContainer } from '@/components/layout/containers'
import { useTranslation } from 'react-i18next'
import { ButtonNaked } from '@pagopa/mui-italia'
import AddIcon from '@mui/icons-material/Add'
import { AttributeAutocomplete } from '@/components/shared/AttributeAutocomplete'
import cloneDeep from 'lodash/cloneDeep'
import { EServiceMutations } from '@/api/eservice'
import { remapDescriptorAttributesToDescriptorAttributesSeed } from '@/utils/attribute.utils'
import { useParams } from '@/router'

type ProviderEServiceUpdateDescriptorAttributesDrawerProps = {
isOpen: boolean
onClose: () => void
attributeKey: AttributeKey
descriptorAttributes: DescriptorAttributes
}

export const ProviderEServiceUpdateDescriptorAttributesDrawer: React.FC<
ProviderEServiceUpdateDescriptorAttributesDrawerProps
> = ({ isOpen, onClose, descriptorAttributes, attributeKey }) => {
const { t } = useTranslation('eservice', {
keyPrefix: 'read.drawers.updateDescriptorAttributesDrawer',
})
const { t: tAttribute } = useTranslation('attribute')
const { t: tCommon } = useTranslation('common')

const { eserviceId, descriptorId } = useParams<'PROVIDE_ESERVICE_MANAGE'>()

const [selectedDescriptorAttributes, setSelectedDescriptorAttributes] =
React.useState<DescriptorAttributes>(() => cloneDeep(descriptorAttributes))

const { mutate: updateAttributes } = EServiceMutations.useUpdateDescriptorAttributes()

const attributeGroups = selectedDescriptorAttributes[attributeKey]
const [isAttributeAutocompleteShown, setIsAttributeAutocompleteShown] = React.useState(false)

const alreadySelectedAttributeIds = React.useMemo(
() =>
attributeGroups.reduce(
(acc, group) => [...acc, ...group.map(({ id }) => id)],
[] as Array<string>
),
[attributeGroups]
)

const handleAddAttributeToGroup = (groupdIdx: number, attribute: DescriptorAttribute) => {
setSelectedDescriptorAttributes((prev) => {
const newAttributeGroups = [...prev[attributeKey]]
newAttributeGroups[groupdIdx].push(attribute)
return {
...prev,
[attributeKey]: newAttributeGroups,
}
})
setIsAttributeAutocompleteShown(false)
}

const handleRemoveAttributeFromGroup = (groupIdx: number, attributeId: string) => {
setSelectedDescriptorAttributes((prev) => {
const newAttributeGroups = [...prev[attributeKey]]
newAttributeGroups[groupIdx] = newAttributeGroups[groupIdx].filter(
({ id }) => id !== attributeId
)
return {
...prev,
[attributeKey]: newAttributeGroups,
}
})
}

const canAttributeBeRemoved = (groupIdx: number, descriptorAttribute: DescriptorAttribute) => {
return !descriptorAttributes[attributeKey][groupIdx].some(
(att) => att.id === descriptorAttribute.id
)
}

const handleSubmit = () => {
updateAttributes(
{
eserviceId,
descriptorId,
attributeKey,
...remapDescriptorAttributesToDescriptorAttributesSeed(selectedDescriptorAttributes),
},
{ onSuccess: onClose }
)
}

return (
<Drawer
isOpen={isOpen}
onClose={onClose}
onTransitionExited={() => setSelectedDescriptorAttributes(cloneDeep(descriptorAttributes))}
title={t('title', { attributeKind: tAttribute(`type.${attributeKey}_other`) })}
subtitle={t('subtitle')}
buttonAction={{
label: tCommon('actions.saveEdits'),
action: handleSubmit,
}}
>
<Stack spacing={3} sx={{ mb: 3 }}>
{attributeGroups.map((group, groupIdx) => (
<AttributeGroupContainer
cardContentSx={{
py: 1,
px: 2,
}}
sx={{ border: 'none' }}
elevation={4}
key={groupIdx}
title={tAttribute('group.read.provider')}
>
<Stack sx={{ listStyleType: 'none', pl: 0, mt: 1 }} component="ul" spacing={1.2}>
{group.map((attribute) => (
<Box component="li" key={attribute.id}>
<AttributeContainer
attribute={attribute}
onRemove={
canAttributeBeRemoved(groupIdx, attribute)
? (attribute) => handleRemoveAttributeFromGroup(groupIdx, attribute)
: undefined
}
/>
</Box>
))}
</Stack>
{isAttributeAutocompleteShown ? (
<AttributeAutocomplete
attributeKey={attributeKey}
alreadySelectedAttributeIds={alreadySelectedAttributeIds}
onAddAttribute={(attribute) => handleAddAttributeToGroup(groupIdx, attribute)}
direction="column"
/>
) : (
<ButtonNaked
color="primary"
type="button"
sx={{ fontWeight: 700 }}
startIcon={<AddIcon fontSize="small" />}
onClick={() => setIsAttributeAutocompleteShown(true)}
>
{tAttribute('group.addBtn')}
</ButtonNaked>
)}
</AttributeGroupContainer>
))}
</Stack>
</Drawer>
)
}
Original file line number Diff line number Diff line change
@@ -2,12 +2,12 @@ import React from 'react'
import { ReadOnlyDescriptorAttributes } from '@/components/shared/ReadOnlyDescriptorAttributes'
import { EServiceQueries } from '@/api/eservice'
import { useParams } from '@/router'
import { useQuery } from '@tanstack/react-query'
import { useSuspenseQuery } from '@tanstack/react-query'

export const ProviderEServiceAttributeVersionSummary: React.FC = () => {
const params = useParams<'PROVIDE_ESERVICE_SUMMARY'>()

const { data: descriptor } = useQuery(
const { data: descriptor } = useSuspenseQuery(
EServiceQueries.getDescriptorProvider(params.eserviceId, params.descriptorId)
)

Original file line number Diff line number Diff line change
@@ -7,13 +7,13 @@ import AttachFileIcon from '@mui/icons-material/AttachFile'
import { EServiceDownloads, EServiceQueries } from '@/api/eservice'
import { getDownloadDocumentName } from '@/utils/eservice.utils'
import { useParams } from '@/router'
import { useQuery } from '@tanstack/react-query'
import { useSuspenseQuery } from '@tanstack/react-query'

export const ProviderEServiceDocumentationSummary: React.FC = () => {
const { t } = useTranslation('eservice', { keyPrefix: 'summary.documentationSummary' })
const params = useParams<'PROVIDE_ESERVICE_SUMMARY'>()

const { data: descriptor } = useQuery(
const { data: descriptor } = useSuspenseQuery(
EServiceQueries.getDescriptorProvider(params.eserviceId, params.descriptorId)
)

Original file line number Diff line number Diff line change
@@ -4,22 +4,20 @@ import { InformationContainer } from '@pagopa/interop-fe-commons'
import { useTranslation } from 'react-i18next'
import { EServiceQueries } from '@/api/eservice'
import { useParams } from '@/router'
import { useQuery } from '@tanstack/react-query'
import { useSuspenseQuery } from '@tanstack/react-query'
import { STAGE } from '@/config/env'
import { PagoPAEnvVars } from '@/types/common.types'
import type { PagoPAEnvVars } from '@/types/common.types'

export const ProviderEServiceGeneralInfoSummary: React.FC = () => {
const signalHubFlagDisabledStage: PagoPAEnvVars['STAGE'][] = ['PROD', 'UAT']
const isSignalHubFlagDisabled = signalHubFlagDisabledStage.includes(STAGE) //check on the environment for signal hub flag
const { t } = useTranslation('eservice', { keyPrefix: 'summary.generalInfoSummary' })
const params = useParams<'PROVIDE_ESERVICE_SUMMARY'>()

const { data: descriptor } = useQuery(
const { data: descriptor } = useSuspenseQuery(
EServiceQueries.getDescriptorProvider(params.eserviceId, params.descriptorId)
)

if (!descriptor) return null

return (
<Stack spacing={2}>
<InformationContainer
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import { PurposeQueries } from '@/api/purpose'
import useCurrentLanguage from '@/hooks/useCurrentLanguage'
import { useParams } from '@/router'
import { List, ListItem, ListItemText, Typography } from '@mui/material'
import { useQuery } from '@tanstack/react-query'
import { useQuery, useSuspenseQuery } from '@tanstack/react-query'
import React from 'react'

type QuestionItem = { question: string; answer: string; questionInfoLabel?: string }
@@ -19,7 +19,7 @@ export const ProviderEServiceRiskAnalysisSummary: React.FC<

const params = useParams<'PROVIDE_ESERVICE_SUMMARY'>()

const { data: descriptor } = useQuery(
const { data: descriptor } = useSuspenseQuery(
EServiceQueries.getDescriptorProvider(params.eserviceId, params.descriptorId)
)

@@ -70,7 +70,7 @@ export const ProviderEServiceRiskAnalysisSummary: React.FC<
return answers
}, [riskAnalysisTemplate, riskAnalysisConfig, currentLanguage])

if (!descriptor || !riskAnalysisTemplate) return null
if (!riskAnalysisTemplate) return null

return (
<>
Original file line number Diff line number Diff line change
@@ -4,18 +4,16 @@ import { Divider, Stack, Typography } from '@mui/material'
import React from 'react'
import { ProviderEServiceRiskAnalysisSummary } from './ProviderEServiceRiskAnalysisSummary'
import { useTranslation } from 'react-i18next'
import { useQuery } from '@tanstack/react-query'
import { useSuspenseQuery } from '@tanstack/react-query'

export const ProviderEServiceRiskAnalysisSummaryList: React.FC = () => {
const { t } = useTranslation('eservice', { keyPrefix: 'summary.riskAnalysisSummaryList' })
const params = useParams<'PROVIDE_ESERVICE_SUMMARY'>()

const { data: descriptor } = useQuery(
const { data: descriptor } = useSuspenseQuery(
EServiceQueries.getDescriptorProvider(params.eserviceId, params.descriptorId)
)

if (!descriptor) return null

const riskAnalysisList = descriptor.eservice.riskAnalysis

return (
Original file line number Diff line number Diff line change
@@ -5,19 +5,17 @@ import { useTranslation } from 'react-i18next'
import { formatThousands, secondsToMinutes } from '@/utils/format.utils'
import { EServiceQueries } from '@/api/eservice'
import { useParams } from '@/router'
import { useQuery } from '@tanstack/react-query'
import { useSuspenseQuery } from '@tanstack/react-query'

export const ProviderEServiceVersionInfoSummary: React.FC = () => {
const { t } = useTranslation('eservice', { keyPrefix: 'summary.versionInfoSummary' })
const { t: tCommon } = useTranslation('common')
const params = useParams<'PROVIDE_ESERVICE_SUMMARY'>()

const { data: descriptor } = useQuery(
const { data: descriptor } = useSuspenseQuery(
EServiceQueries.getDescriptorProvider(params.eserviceId, params.descriptorId)
)

if (!descriptor) return null

const voucherLifespan = secondsToMinutes(descriptor.voucherLifespan)
const hasManualApproval = descriptor.agreementApprovalPolicy === 'MANUAL'

3 changes: 2 additions & 1 deletion src/static/locales/en/common.json
Original file line number Diff line number Diff line change
@@ -38,7 +38,8 @@
"insert": "Insert",
"revoke": "Revoke",
"upload": "Upload",
"import": "Import"
"import": "Import",
"saveEdits": "Save edits"
},
"table": {
"headData": {
4 changes: 4 additions & 0 deletions src/static/locales/en/eservice.json
Original file line number Diff line number Diff line change
@@ -431,6 +431,10 @@
"noOptionsText": "No keychain found"
},
"noKeychainAlert": "There are no keychain available. <1>Create your first keychain</1>."
},
"updateDescriptorAttributesDrawer": {
"title": "Edit {{attributeKind}} attributes",
"subtitle": "The requirements already entered cannot be modified"
}
}
},
7 changes: 7 additions & 0 deletions src/static/locales/en/mutations-feedback.json
Original file line number Diff line number Diff line change
@@ -184,6 +184,13 @@
"success": "The list has been downloaded successfully",
"error": "The list could not be downloaded. Please try again"
}
},
"updateDescriptorAttributes": {
"loading": "Saving new attributes",
"outcome": {
"success": "The {{attributeKind}} attributes have been modified correctly",
"error": "It was not possible to modify the {{attributeKind}} attributes. Please, try again!"
}
}
},
"attribute": {
3 changes: 2 additions & 1 deletion src/static/locales/it/common.json
Original file line number Diff line number Diff line change
@@ -38,7 +38,8 @@
"insert": "Inserisci",
"revoke": "Revoca",
"upload": "Carica",
"import": "Importa"
"import": "Importa",
"saveEdits": "Salva modifiche"
},
"table": {
"headData": {
4 changes: 4 additions & 0 deletions src/static/locales/it/eservice.json
Original file line number Diff line number Diff line change
@@ -431,6 +431,10 @@
"noOptionsText": "Nessun portachiavi trovato"
},
"noKeychainAlert": "Non ci sono portachiavi disponibili. <1>Crea il tuo primo portachiavi</1>."
},
"updateDescriptorAttributesDrawer": {
"title": "Modifica attributi {{attributeKind}}",
"subtitle": "I requisiti già inseriti non possono essere modificati"
}
}
},
7 changes: 7 additions & 0 deletions src/static/locales/it/mutations-feedback.json
Original file line number Diff line number Diff line change
@@ -184,6 +184,13 @@
"success": "L’elenco è stato scaricato correttamente",
"error": "Non è stato possibile scaricare l’elenco. Per favore, riprova!"
}
},
"updateDescriptorAttributes": {
"loading": "Stiamo aggiornando gli attributi",
"outcome": {
"success": "Gli attributi {{attributeKind}} sono stati modificati correttamente!",
"error": "Non è stato possibile modificare gli attributi {{attributeKind}}. Per favore, riprova!"
}
}
},
"attribute": {