Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 7 additions & 7 deletions __mocks__/data/eservice.mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const createMockEServiceDescriptorCatalog = createMockFactory<CatalogEServiceDes
agreementApprovalPolicy: 'MANUAL',
audience: ['Lorem'],
dailyCallsPerConsumer: 1,
dailyCallsTotal: 1,
dailyCallsTotal: 2,
description: 'Lorem',
docs: [],
eservice: {
Expand Down Expand Up @@ -132,7 +132,7 @@ const createMockEServiceDescriptorProvider = createMockFactory<ProducerEServiceD
agreementApprovalPolicy: 'MANUAL',
audience: ['nikon'],
dailyCallsPerConsumer: 1,
dailyCallsTotal: 1,
dailyCallsTotal: 2,
description: 'kinoin',
docs: [],
eservice: {
Expand Down Expand Up @@ -179,7 +179,7 @@ const createMockEServiceDescriptorProviderNoInterface =
agreementApprovalPolicy: 'MANUAL',
audience: ['nikon'],
dailyCallsPerConsumer: 1,
dailyCallsTotal: 1,
dailyCallsTotal: 2,
description: 'kinoin',
docs: [],
eservice: {
Expand Down Expand Up @@ -218,7 +218,7 @@ const createMockEServiceDescriptorProviderWithRiskAnalysis =
agreementApprovalPolicy: 'MANUAL',
audience: ['nikon'],
dailyCallsPerConsumer: 1,
dailyCallsTotal: 1,
dailyCallsTotal: 2,
description: 'kinoin',
docs: [],
eservice: {
Expand Down Expand Up @@ -267,7 +267,7 @@ const createMockEServiceDescriptorProviderWithDocs = createMockFactory<ProducerE
agreementApprovalPolicy: 'MANUAL',
audience: ['nikon'],
dailyCallsPerConsumer: 1,
dailyCallsTotal: 1,
dailyCallsTotal: 2,
description: 'kinoin',
docs: [
{
Expand Down Expand Up @@ -314,7 +314,7 @@ const createMockEServiceDescriptorProviderWithTemplateRef =
agreementApprovalPolicy: 'MANUAL',
audience: ['nikon'],
dailyCallsPerConsumer: 1,
dailyCallsTotal: 1,
dailyCallsTotal: 2,
description: 'kinoin',
docs: [],
eservice: {
Expand Down Expand Up @@ -365,7 +365,7 @@ const createMockEServiceDescriptorReceive = createMockFactory<ProducerEServiceDe
agreementApprovalPolicy: 'MANUAL',
audience: ['nikon'],
dailyCallsPerConsumer: 1,
dailyCallsTotal: 1,
dailyCallsTotal: 2,
description: 'kinoin',
docs: [],
eservice: {
Expand Down
2 changes: 1 addition & 1 deletion __mocks__/data/purpose.mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ const createMockPurposeCallsTotalExceed = createMockFactory<Purpose>({
dailyCalls: 2,
},
dailyCallsPerConsumer: 10,
dailyCallsTotal: 1,
dailyCallsTotal: 11,
})

const createMockPurposeCallsWithoutExceed = createMockFactory<Purpose>({
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/containers/AttributeContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const AttributeContainer = <
{checked && <CheckCircleIcon sx={{ color: 'success.dark' }} />}
{onRemove && (
<IconButton
aria-label={t('removeAttributeAriaLabel', { name: attribute.name })}
aria-label={t('removeAttributeAriaLabel', { attributeName: attribute.name })}
onClick={onRemove.bind(null, attribute.id, attribute.name)}
color={'error' as unknown as 'primary'}
>
Expand Down
5 changes: 5 additions & 0 deletions src/components/shared/CustomizeThresholdDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export const CustomizeThresholdDrawer: React.FC<CustomizeThresholdDrawerProps> =
const { t } = useTranslation('eservice', {
keyPrefix: 'create.step2.attributes.customizeThresholdDrawer',
})
const { t: tThreshold } = useTranslation('eservice', {
keyPrefix: 'create.step2.thresholdSection',
})
const formMethods = useForm<CustomizeThresholdFormValues>({
defaultValues: {
threshold: attribute?.dailyCallsPerConsumer,
Expand Down Expand Up @@ -105,6 +108,8 @@ export const CustomizeThresholdDrawer: React.FC<CustomizeThresholdDrawerProps> =
message: t('field.error'),
},
}),
validate: (value) =>
Number.isInteger(Number(value)) || tThreshold('validation.integer'),
}}
/>
<GreyAlert>
Expand Down
20 changes: 11 additions & 9 deletions src/components/shared/DelegationTooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type DelegationWithCompactTenants } from '@/api/api.generatedTypes'
import { AuthHooks } from '@/api/auth'
import { AltRoute } from '@mui/icons-material'
import { Tooltip } from '@mui/material'
import { Stack, Tooltip } from '@mui/material'
import React from 'react'
import { useTranslation } from 'react-i18next'

Expand All @@ -23,14 +23,16 @@ export const DelegationTooltip: React.FC<DelegationTooltipProps> = ({ delegation

return (
<Tooltip title={label}>
<AltRoute
color="primary"
sx={{
rotate: '90deg',
height: 18,
width: 18,
}}
/>
<Stack component={'span'} tabIndex={0} aria-label={label}>
<AltRoute
color="primary"
sx={{
rotate: '90deg',
height: 18,
width: 18,
}}
/>
</Stack>
</Tooltip>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { useTranslation } from 'react-i18next'
import { useSuspenseQuery } from '@tanstack/react-query'
import { EServiceTemplateQueries } from '@/api/eserviceTemplate'
import { EServiceTemplateMutations } from '@/api/eserviceTemplate'
import { EServiceTemplateThresholdsSection } from './EServiceTemplateThresholdsSection'
import { EServiceTemplateDocumentationSection } from './EServiceTemplateDocumentationSection'
import { EServiceTemplateUsefulLinksSection } from './EServiceTemplateUsefulLinksSection'
import { UpdateVoucherDrawer } from '@/components/shared/UpdateVoucherDrawer'
Expand All @@ -18,11 +17,10 @@ import EditIcon from '@mui/icons-material/Edit'
type EServiceTemplateTechnicalInfoSectionProps = {
readonly: boolean
routeKey: 'SUBSCRIBE_ESERVICE_TEMPLATE_DETAILS' | 'PROVIDE_ESERVICE_TEMPLATE_DETAILS'
hideThresholds?: boolean
}
export const EServiceTemplateTechnicalInfoSection: React.FC<
EServiceTemplateTechnicalInfoSectionProps
> = ({ readonly, routeKey, hideThresholds = false }) => {
> = ({ readonly, routeKey }) => {
const { t } = useTranslation('eserviceTemplate', {
keyPrefix: 'read.sections.technicalInformations',
})
Expand Down Expand Up @@ -94,15 +92,6 @@ export const EServiceTemplateTechnicalInfoSection: React.FC<
content={`${voucherLifespan}`}
/>
</SectionContainer>
{!hideThresholds && (
<>
<Divider />
<EServiceTemplateThresholdsSection
readonly={readonly}
eserviceTemplate={eserviceTemplate}
/>
</>
)}
<Divider />
<EServiceTemplateDocumentationSection
readonly={readonly}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -90,43 +90,6 @@ describe('EServiceTemplateTechnicalInfoSection', () => {
expect(screen.getByText('thresholds.voucherLifespan.label')).toBeInTheDocument()
})

it('renders thresholds section when hideThresholds is false', () => {
const mockData = createMockEServiceTemplateVersionDetails()
useSuspenseQueryMock.mockReturnValue({ data: mockData })

renderWithApplicationContext(
<EServiceTemplateTechnicalInfoSection
readonly={false}
routeKey="PROVIDE_ESERVICE_TEMPLATE_DETAILS"
/>,
{
withReactQueryContext: true,
withRouterContext: true,
}
)

expect(screen.getByTestId('thresholds-section')).toBeInTheDocument()
})

it('hides thresholds section when hideThresholds is true', () => {
const mockData = createMockEServiceTemplateVersionDetails()
useSuspenseQueryMock.mockReturnValue({ data: mockData })

renderWithApplicationContext(
<EServiceTemplateTechnicalInfoSection
readonly={false}
routeKey="PROVIDE_ESERVICE_TEMPLATE_DETAILS"
hideThresholds
/>,
{
withReactQueryContext: true,
withRouterContext: true,
}
)

expect(screen.queryByTestId('thresholds-section')).not.toBeInTheDocument()
})

it('renders voucher section with title and edit button when not readonly', () => {
const mockData = createMockEServiceTemplateVersionDetails()
useSuspenseQueryMock.mockReturnValue({ data: mockData })
Expand Down
1 change: 0 additions & 1 deletion src/components/shared/EserviceTemplate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ export * from './EServiceTemplateTechnicalInfoSection'
export * from './EServiceTemplateDocumentationSection'
export * from './EServiceTemplateUsefulLinksSection'
export * from './EServiceTemplateUpdateDocumentationDrawer'
export * from './EServiceTemplateThresholdsAndAttributes'
export * from './EServiceTemplateVersionSelectorDrawer'
2 changes: 1 addition & 1 deletion src/components/shared/PurposeCreateContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type PurposeCreateContextType = {

const { useContext, Provider } = createContext<PurposeCreateContextType>('PurposeCreateContext', {})

type PurposeCreateContextProviderProps = {
export type PurposeCreateContextProviderProps = {
children: React.ReactNode
type?: PurposeType
isFromPurposeTemplate?: boolean
Expand Down
7 changes: 7 additions & 0 deletions src/components/shared/UpdateDailyCallsDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export const UpdateDailyCallsDrawer: React.FC<UpdateDailyCallsDrawerProps> = ({
const { t } = useTranslation('eservice', {
keyPrefix: 'read.drawers.updateDailyCallsDrawer',
})

const { t: tThreshold } = useTranslation('eservice', {
keyPrefix: 'create.step2.thresholdSection',
})
const { t: tCommon } = useTranslation('common')

const defaultValues = {
Expand Down Expand Up @@ -113,6 +117,8 @@ export const UpdateDailyCallsDrawer: React.FC<UpdateDailyCallsDrawerProps> = ({
rules={{
required: true,
min: 1,
validate: (value) =>
Number.isInteger(Number(value)) || tThreshold('validation.integer'),
}}
/>
<RHFTextField
Expand All @@ -124,6 +130,7 @@ export const UpdateDailyCallsDrawer: React.FC<UpdateDailyCallsDrawerProps> = ({
rules={{
required: true,
validate: (value) => {
if (!Number.isInteger(Number(value))) return tThreshold('validation.integer')
const minValue = formMethods.getValues('dailyCallsPerConsumer') + 1
return value >= minValue || t('dailyCallsTotalField.validation.min')
},
Expand Down
Loading
Loading