diff --git a/.github/workflows/ci_integration_test.yml b/.github/workflows/ci_integration_test.yml index e919b4a4f..659fb228e 100644 --- a/.github/workflows/ci_integration_test.yml +++ b/.github/workflows/ci_integration_test.yml @@ -103,14 +103,14 @@ jobs: npx playwright test --workers=1 --max-failures=1 --project=chromium - name: Setup Pages - uses: actions/configure-pages@v5 + uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5 - name: Upload artifact - uses: actions/upload-pages-artifact@v3 + uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3 with: path: './e2e/playwright-report/' - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v4 + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4 print_debug: runs-on: ubuntu-latest diff --git a/package.json b/package.json index d756ed497..f67608ec8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pagopa-selfcare-backoffice-frontend", - "version": "1.26.4-3-next", + "version": "1.27.0", "homepage": "ui", "private": true, "scripts": { @@ -28,7 +28,7 @@ "clean:api-portal": "rimraf src/api/generated/portal && rimraf openApi/generated", "generate:api-portal": "wget https://raw.githubusercontent.com/pagopa/pagopa-selfcare-ms-backoffice-backend/main/openapi/openapi.json -O ./openApi/portal-api-docs.json && npm run generate:client", "generate:api-portal-next": "wget https://raw.githubusercontent.com/pagopa/pagopa-selfcare-ms-backoffice-backend/next/openapi/openapi.json -O ./openApi/portal-api-docs.json && npm run generate:client", - "generate:api-portal-pr": "wget https://raw.githubusercontent.com/pagopa/pagopa-selfcare-ms-backoffice-backend/VAS-1146-cart-bool-bundle/openapi/openapi.json -O ./openApi/portal-api-docs.json && npm run generate:client", + "generate:api-portal-pr": "wget https://raw.githubusercontent.com/pagopa/pagopa-selfcare-ms-backoffice-backend/next/openapi/openapi.json -O ./openApi/portal-api-docs.json && npm run generate:client", "generate:api-portal-local": "npm run generate:client", "generate:client": "jq 'walk(if type == \"object\" and has(\"parameters\") then .parameters |= map(select(.name != \"X-Request-Id\")) else . end)' ./openApi/portal-api-docs.json > ./openApi/portal-api-docs.json.temp && mv ./openApi/portal-api-docs.json.temp ./openApi/portal-api-docs.json && yarn run clean:api-portal && mkdirp openApi/generated && gen-api-models --api-spec openApi/portal-api-docs.json --out-dir src/api/generated/portal --no-strict --request-types --response-decoders --client && node openApi/scripts/api-portal_fixPostGen.js" }, diff --git a/src/pages/commisionalBundles/addEditCommissionBundle/components/AddEditCommissionBundleForm.tsx b/src/pages/commisionalBundles/addEditCommissionBundle/components/AddEditCommissionBundleForm.tsx index db5649290..f971a7e04 100644 --- a/src/pages/commisionalBundles/addEditCommissionBundle/components/AddEditCommissionBundleForm.tsx +++ b/src/pages/commisionalBundles/addEditCommissionBundle/components/AddEditCommissionBundleForm.tsx @@ -1,752 +1,749 @@ /* eslint-disable functional/no-let */ /* eslint-disable complexity */ /* eslint-disable sonarjs/cognitive-complexity */ -import { InfoOutlined, MenuBook } from '@mui/icons-material'; +import {InfoOutlined, MenuBook} from '@mui/icons-material'; import BookmarkAddIcon from '@mui/icons-material/BookmarkAdd'; import DateRangeIcon from '@mui/icons-material/DateRange'; import EuroIcon from '@mui/icons-material/Euro'; import { - Autocomplete, - Box, - FormControl, - FormControlLabel, - FormLabel, - Grid, - InputLabel, - MenuItem, - Paper, - Radio, - RadioGroup, - Select, - Switch, - TextField, - TextFieldProps, - Tooltip, - Typography, + Autocomplete, + Box, + FormControl, + FormControlLabel, + FormLabel, + Grid, + InputLabel, + MenuItem, + Paper, + Radio, + RadioGroup, + Select, + Switch, + TextField, + TextFieldProps, + Tooltip, + Typography, } from '@mui/material'; -import { DesktopDatePicker, LocalizationProvider } from '@mui/x-date-pickers'; -import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns'; -import { theme } from '@pagopa/mui-italia'; -import { useErrorDispatcher, useLoading } from '@pagopa/selfcare-common-frontend'; -import { FormikProps } from 'formik'; -import { useEffect, useState } from 'react'; -import { useTranslation } from 'react-i18next'; -import { NumericFormat } from 'react-number-format'; -import { BundleRequest } from '../../../../api/generated/portal/BundleRequest'; -import { Delegation } from '../../../../api/generated/portal/Delegation'; -import { TypeEnum } from '../../../../api/generated/portal/PSPBundleResource'; -import { PaymentTypes } from '../../../../api/generated/portal/PaymentTypes'; -import { Touchpoints } from '../../../../api/generated/portal/Touchpoints'; +import {DesktopDatePicker, LocalizationProvider} from '@mui/x-date-pickers'; +import {AdapterDateFns} from '@mui/x-date-pickers/AdapterDateFns'; +import {theme} from '@pagopa/mui-italia'; +import {useErrorDispatcher, useLoading} from '@pagopa/selfcare-common-frontend'; +import {FormikProps} from 'formik'; +import {useEffect, useState} from 'react'; +import {useTranslation} from 'react-i18next'; +import {NumericFormat} from 'react-number-format'; +import {BundleRequest} from '../../../../api/generated/portal/BundleRequest'; +import {Delegation} from '../../../../api/generated/portal/Delegation'; +import {TypeEnum} from '../../../../api/generated/portal/PSPBundleResource'; +import {PaymentTypes} from '../../../../api/generated/portal/PaymentTypes'; +import {Touchpoints} from '../../../../api/generated/portal/Touchpoints'; import FormSectionTitle from '../../../../components/Form/FormSectionTitle'; -import { useFlagValue } from '../../../../hooks/useFeatureFlags'; -import { useOrganizationType } from '../../../../hooks/useOrganizationType'; -import { Party } from '../../../../model/Party'; -import { sortPaymentType } from '../../../../model/PaymentType'; -import { ConfigurationStatus } from '../../../../model/Station'; -import { useAppSelector } from '../../../../redux/hooks'; -import { partiesSelectors } from '../../../../redux/slices/partiesSlice'; -import { getTouchpoints } from '../../../../services/bundleService'; -import { getChannels } from '../../../../services/channelService'; -import { getPaymentTypes } from '../../../../services/configurationService'; -import { getBrokerDelegation } from '../../../../services/institutionService'; -import { addCurrentBroker } from '../../../../utils/channel-utils'; -import { - LOADING_TASK_COMMISSION_BUNDLE_SELECT_DATAS, - LOADING_TASK_GET_CHANNELS_IDS, -} from '../../../../utils/constants'; -import { WrapperChannelResource } from '../../../../api/generated/portal/WrapperChannelResource'; +import {useFlagValue} from '../../../../hooks/useFeatureFlags'; +import {useOrganizationType} from '../../../../hooks/useOrganizationType'; +import {Party} from '../../../../model/Party'; +import {sortPaymentType} from '../../../../model/PaymentType'; +import {ConfigurationStatus} from '../../../../model/Station'; +import {useAppSelector} from '../../../../redux/hooks'; +import {partiesSelectors} from '../../../../redux/slices/partiesSlice'; +import {getTouchpoints} from '../../../../services/bundleService'; +import {getChannels} from '../../../../services/channelService'; +import {getPaymentTypes} from '../../../../services/configurationService'; +import {getBrokerDelegation} from '../../../../services/institutionService'; +import {addCurrentBroker} from '../../../../utils/channel-utils'; +import {LOADING_TASK_COMMISSION_BUNDLE_SELECT_DATAS, LOADING_TASK_GET_CHANNELS_IDS,} from '../../../../utils/constants'; +import {WrapperChannelResource} from '../../../../api/generated/portal/WrapperChannelResource'; type Props = { - formik: FormikProps; - isEdit: boolean; - idBrokerPsp: string | undefined; + formik: FormikProps; + isEdit: boolean; + idBrokerPsp: string | undefined; }; -const AddEditCommissionBundleForm = ({ isEdit, formik, idBrokerPsp }: Props) => { - const { t } = useTranslation(); - const { orgIsPspDirect } = useOrganizationType(); - const setLoading = useLoading(LOADING_TASK_COMMISSION_BUNDLE_SELECT_DATAS); - const setLoadingChannels = useLoading(LOADING_TASK_GET_CHANNELS_IDS); - const addError = useErrorDispatcher(); - const isPrivateEnabled = useFlagValue('commission-bundles-private'); - const isPublicEnabled = useFlagValue('commission-bundles-public'); - const selectedParty = useAppSelector(partiesSelectors.selectPartySelected); +const AddEditCommissionBundleForm = ({isEdit, formik, idBrokerPsp}: Props) => { + const {t} = useTranslation(); + const {orgIsPspDirect} = useOrganizationType(); + const setLoading = useLoading(LOADING_TASK_COMMISSION_BUNDLE_SELECT_DATAS); + const setLoadingChannels = useLoading(LOADING_TASK_GET_CHANNELS_IDS); + const addError = useErrorDispatcher(); + const isPrivateEnabled = useFlagValue('commission-bundles-private'); + const isPublicEnabled = useFlagValue('commission-bundles-public'); + const selectedParty = useAppSelector(partiesSelectors.selectPartySelected); - const [paymentOptions, setPaymentOptions] = useState(); - const [touchpointList, setTouchpointList] = useState(); - const [brokerDelegationList, setBrokerDelegationList] = useState>([]); - const [channels, setChannels] = useState>([]); - const [isChannelV2, setIsChannelV2] = useState(false); + const [paymentOptions, setPaymentOptions] = useState(); + const [touchpointList, setTouchpointList] = useState(); + const [brokerDelegationList, setBrokerDelegationList] = useState>([]); + const [channels, setChannels] = useState>([]); + const [isChannelV2, setIsChannelV2] = useState(false); - const inputGroupStyle = { - borderRadius: 1, - border: 1, - borderColor: theme.palette.divider, - p: 3, - mb: 3, - }; + const inputGroupStyle = { + borderRadius: 1, + border: 1, + borderColor: theme.palette.divider, + p: 3, + mb: 3, + }; - const getChannelsByBrokerCode = (selectedBrokerCode: string) => { - setLoadingChannels(true); - getChannels({ status: ConfigurationStatus.ACTIVE, brokerCode: selectedBrokerCode }) - .then((data) => { - if (data?.channels && data.channels.length > 0) { - setChannels([...data.channels]); - handleIsChannelV2(formik.values.idChannel, [...data.channels]); - } else { - setChannels([]); - addError({ - id: 'GET_BROKER_DELEGATIONS_DATA', - blocking: false, - error: new Error(`An error occurred while getting data`), - techDescription: `An error occurred while getting data`, - toNotify: true, - displayableTitle: t('general.errorTitle'), - displayableDescription: t( - 'commissionBundlesPage.addEditCommissionBundle.error.errorMessageNoBrokerDelegations' - ), - component: 'Toast', - }); - } - }) - .catch((error) => { - setChannels([]); - addError({ - id: 'GET_CHANNEL_IDS_DATA', - blocking: false, - error: error as Error, - techDescription: `An error occurred while getting data`, - toNotify: true, - displayableTitle: t('general.errorTitle'), - displayableDescription: t( - 'commissionBundlesPage.addEditCommissionBundle.error.errorMessageChannelIdsDataDesc' - ), - component: 'Toast', - }); - }) - .finally(() => setLoadingChannels(false)); - }; + const getChannelsByBrokerCode = (selectedBrokerCode: string) => { + setLoadingChannels(true); + getChannels({status: ConfigurationStatus.ACTIVE, brokerCode: selectedBrokerCode}) + .then((data) => { + if (data?.channels && data.channels.length > 0) { + setChannels([...data.channels]); + handleIsChannelV2(formik.values.idChannel, [...data.channels]); + } else { + setChannels([]); + addError({ + id: 'GET_BROKER_DELEGATIONS_DATA', + blocking: false, + error: new Error(`An error occurred while getting data`), + techDescription: `An error occurred while getting data`, + toNotify: true, + displayableTitle: t('general.errorTitle'), + displayableDescription: t( + 'commissionBundlesPage.addEditCommissionBundle.error.errorMessageNoBrokerDelegations' + ), + component: 'Toast', + }); + } + }) + .catch((error) => { + setChannels([]); + addError({ + id: 'GET_CHANNEL_IDS_DATA', + blocking: false, + error: error as Error, + techDescription: `An error occurred while getting data`, + toNotify: true, + displayableTitle: t('general.errorTitle'), + displayableDescription: t( + 'commissionBundlesPage.addEditCommissionBundle.error.errorMessageChannelIdsDataDesc' + ), + component: 'Toast', + }); + }) + .finally(() => setLoadingChannels(false)); + }; - useEffect(() => { - setLoading(true); - Promise.all([ - getPaymentTypes(), - getTouchpoints(0, 50), - getBrokerDelegation(selectedParty?.partyId ?? '', undefined), - ]) - .then(([paymentTypes, touchpoints, brokerDelegation]) => { - if (paymentTypes) { - setPaymentOptions(paymentTypes); - } - if (touchpoints) { - setTouchpointList(touchpoints); - } - let listBroker = brokerDelegation?.delegation_list - ? [...brokerDelegation.delegation_list] - : []; - if (orgIsPspDirect) { - listBroker = addCurrentBroker(listBroker, selectedParty as Party); - } + useEffect(() => { + setLoading(true); + Promise.all([ + getPaymentTypes(), + getTouchpoints(0, 50), + getBrokerDelegation(selectedParty?.partyId ?? '', undefined), + ]) + .then(([paymentTypes, touchpoints, brokerDelegation]) => { + if (paymentTypes) { + setPaymentOptions(paymentTypes); + } + if (touchpoints) { + setTouchpointList(touchpoints); + } + let listBroker = brokerDelegation?.delegation_list + ? [...brokerDelegation.delegation_list] + : []; + if (orgIsPspDirect) { + listBroker = addCurrentBroker(listBroker, selectedParty as Party); + } - if (listBroker.length > 0) { - setBrokerDelegationList(listBroker); - if (isEdit && idBrokerPsp) { - const brokerTaxCode = listBroker?.find( - (el) => el.broker_tax_code === idBrokerPsp - )?.broker_tax_code; - if (brokerTaxCode) { - getChannelsByBrokerCode(brokerTaxCode); - } - } - } else { - addError({ - id: 'GET_BROKER_DATA', - blocking: false, - error: new Error(`An error occurred while getting data`), - techDescription: `An error occurred while getting data`, - toNotify: true, - displayableTitle: t('general.errorTitle'), - displayableDescription: t( - 'commissionBundlesPage.addEditCommissionBundle.error.errorMessageNoBroker' - ), - component: 'Toast', - }); - } - }) - .catch((reason) => { - addError({ - id: 'GET_ALL_DATA', - blocking: false, - error: reason as Error, - techDescription: `An error occurred while getting data`, - toNotify: true, - displayableTitle: t('general.errorTitle'), - displayableDescription: t( - 'commissionBundlesPage.addEditCommissionBundle.error.errorMessageAllDataDesc' - ), - component: 'Toast', - }); - }) - .finally(() => { - setLoading(false); - }); - }, [selectedParty]); + if (listBroker.length > 0) { + setBrokerDelegationList(listBroker); + if (isEdit && idBrokerPsp) { + const brokerTaxCode = listBroker?.find( + (el) => el.broker_tax_code === idBrokerPsp + )?.broker_tax_code; + if (brokerTaxCode) { + getChannelsByBrokerCode(brokerTaxCode); + } + } + } else { + addError({ + id: 'GET_BROKER_DATA', + blocking: false, + error: new Error(`An error occurred while getting data`), + techDescription: `An error occurred while getting data`, + toNotify: true, + displayableTitle: t('general.errorTitle'), + displayableDescription: t( + 'commissionBundlesPage.addEditCommissionBundle.error.errorMessageNoBroker' + ), + component: 'Toast', + }); + } + }) + .catch((reason) => { + addError({ + id: 'GET_ALL_DATA', + blocking: false, + error: reason as Error, + techDescription: `An error occurred while getting data`, + toNotify: true, + displayableTitle: t('general.errorTitle'), + displayableDescription: t( + 'commissionBundlesPage.addEditCommissionBundle.error.errorMessageAllDataDesc' + ), + component: 'Toast', + }); + }) + .finally(() => { + setLoading(false); + }); + }, [selectedParty]); - const shouldDisableDate = (date: Date) => date < new Date(); + const shouldDisableDate = (date: Date) => date < new Date(); - function handleBrokerCodesSelection(value: string | null | undefined) { - formik.setFieldValue('idChannel', ''); - handleIsChannelV2(); - if (value === null || value === undefined) { - formik.setFieldValue('idBrokerPsp', ''); - setChannels([]); - } else { - const broker = brokerDelegationList?.find((el) => el.broker_name === value); - formik.handleChange('idBrokerPsp')(broker?.broker_tax_code ?? ''); - if (broker?.broker_tax_code) { - getChannelsByBrokerCode(broker?.broker_tax_code); - } + function handleBrokerCodesSelection(value: string | null | undefined) { + formik.setFieldValue('idChannel', ''); + handleIsChannelV2(); + if (value === null || value === undefined) { + formik.setFieldValue('idBrokerPsp', ''); + setChannels([]); + } else { + const broker = brokerDelegationList?.find((el) => el.broker_name === value); + formik.handleChange('idBrokerPsp')(broker?.broker_tax_code ?? ''); + if (broker?.broker_tax_code) { + getChannelsByBrokerCode(broker?.broker_tax_code); + } + } } - } - const handleIsChannelV2 = ( - channelCode?: string | null, - channelList?: Array - ) => { - let bool = false; - if (channelCode) { - const arrayChannel = channelList ?? channels; - bool = arrayChannel.find((el) => el.channel_code === channelCode)?.primitive_version === 2; - } + const handleIsChannelV2 = ( + channelCode?: string | null, + channelList?: Array + ) => { + let bool = false; + if (channelCode) { + const arrayChannel = channelList ?? channels; + bool = arrayChannel.find((el) => el.channel_code === channelCode)?.primitive_version === 2; + } - setIsChannelV2(bool); - if (!bool) { - formik.setFieldValue('cart', false); - } - }; + setIsChannelV2(bool); + if (!bool) { + formik.setFieldValue('cart', false); + } + }; - const handleChangeChannel = (value: string | null) => { - formik.handleChange('idChannel')(value ?? ''); - handleIsChannelV2(value); - }; + const handleChangeChannel = (value: string | null) => { + formik.handleChange('idChannel')(value ?? ''); + handleIsChannelV2(value); + }; - return ( - <> - - - {t('commissionBundlesPage.addEditCommissionBundle.form.bundleType')} - + return ( + <> + + + {t('commissionBundlesPage.addEditCommissionBundle.form.bundleType')} + - - formik.setFieldValue('type', e.target.value)} - data-testid="bundle-type-test" - value={`${formik.values.type}`} - > - } - label={t('commissionBundlesPage.globalBundles')} - sx={{ pr: 8 }} - disabled={isEdit} - /> - } - label={t('commissionBundlesPage.publicBundles')} - sx={{ pr: 8 }} - disabled={isEdit || !isPublicEnabled} - /> - } - label={t('commissionBundlesPage.privateBundles')} - disabled={isEdit || !isPrivateEnabled} - /> - - - - - - {t('commissionBundlesPage.addEditCommissionBundle.form.bundleConfiguration')} - + + formik.setFieldValue('type', e.target.value)} + data-testid="bundle-type-test" + value={`${formik.values.type}`} + > + } + label={t('commissionBundlesPage.globalBundles')} + sx={{pr: 8}} + disabled={isEdit} + /> + } + label={t('commissionBundlesPage.publicBundles')} + sx={{pr: 8}} + disabled={isEdit || !isPublicEnabled} + /> + } + label={t('commissionBundlesPage.privateBundles')} + disabled={isEdit || !isPrivateEnabled} + /> + + + + + + {t('commissionBundlesPage.addEditCommissionBundle.form.bundleConfiguration')} + - - - } - /> - - - formik.handleChange(e)} - error={formik.touched.name && Boolean(formik.errors.name)} - helperText={formik.touched.name && formik.errors.name} - inputProps={{ - 'data-testid': 'name-test', - }} - /> - + + + } + /> + + + formik.handleChange(e)} + error={formik.touched.name && Boolean(formik.errors.name)} + helperText={formik.touched.name && formik.errors.name} + inputProps={{ + 'data-testid': 'name-test', + }} + /> + - - formik.handleChange(e)} - error={formik.touched.description && Boolean(formik.errors.description)} - helperText={formik.touched.description && formik.errors.description} - inputProps={{ - 'data-testid': 'description-test', - }} - /> - - - - - {t('commissionBundlesPage.addEditCommissionBundle.form.paymentType')} - - - - - - - - {t('commissionBundlesPage.addEditCommissionBundle.form.touchpoint')} - - - - - + + formik.handleChange(e)} + error={formik.touched.description && Boolean(formik.errors.description)} + helperText={formik.touched.description && formik.errors.description} + inputProps={{ + 'data-testid': 'description-test', + }} + /> + + + + + {t('commissionBundlesPage.addEditCommissionBundle.form.paymentType')} + + + + + + + + {t('commissionBundlesPage.addEditCommissionBundle.form.touchpoint')} + + + + + - - } - /> - - - { - const numericValue = parseFloat(value.replace(',', '.')); - formik.setFieldValue('minPaymentAmount', numericValue * 100); - }} - thousandSeparator="" - decimalSeparator="," - allowNegative={false} - decimalScale={2} - fixedDecimalScale={false} - error={ - formik.touched.minPaymentAmount && Boolean(formik.errors.minPaymentAmount) - } - helperText={formik.touched.minPaymentAmount && formik.errors.minPaymentAmount} - InputProps={{ - endAdornment: , - }} - inputProps={{ 'data-testid': 'min-import-test' }} - /> - + + } + /> + + + { + const numericValue = parseFloat(value.replace(',', '.')); + formik.setFieldValue('minPaymentAmount', numericValue * 100); + }} + thousandSeparator="" + decimalSeparator="," + allowNegative={false} + decimalScale={2} + fixedDecimalScale={false} + error={ + formik.touched.minPaymentAmount && Boolean(formik.errors.minPaymentAmount) + } + helperText={formik.touched.minPaymentAmount && formik.errors.minPaymentAmount} + InputProps={{ + endAdornment: , + }} + inputProps={{'data-testid': 'min-import-test'}} + /> + - - { - const numericValue = parseFloat(value.replace(',', '.')); - formik.setFieldValue('maxPaymentAmount', numericValue * 100); - }} - thousandSeparator="" - decimalSeparator="," - allowNegative={false} - decimalScale={2} - fixedDecimalScale={false} - error={ - formik.touched.maxPaymentAmount && Boolean(formik.errors.maxPaymentAmount) - } - helperText={formik.touched.maxPaymentAmount && formik.errors.maxPaymentAmount} - InputProps={{ - endAdornment: , - }} - inputProps={{ 'data-testid': 'max-import-test' }} - /> - - - + + { + const numericValue = parseFloat(value.replace(',', '.')); + formik.setFieldValue('maxPaymentAmount', numericValue * 100); + }} + thousandSeparator="" + decimalSeparator="," + allowNegative={false} + decimalScale={2} + fixedDecimalScale={false} + error={ + formik.touched.maxPaymentAmount && Boolean(formik.errors.maxPaymentAmount) + } + helperText={formik.touched.maxPaymentAmount && formik.errors.maxPaymentAmount} + InputProps={{ + endAdornment: , + }} + inputProps={{'data-testid': 'max-import-test'}} + /> + + + - - } - /> - - - { - const numericValue = parseFloat(value.replace(',', '.')); - formik.setFieldValue('paymentAmount', numericValue * 100); - }} - thousandSeparator="" - decimalSeparator="," - allowNegative={false} - decimalScale={2} - fixedDecimalScale={false} - error={formik.touched.paymentAmount && Boolean(formik.errors.paymentAmount)} - helperText={formik.touched.paymentAmount && formik.errors.paymentAmount} - InputProps={{ - endAdornment: , - }} - inputProps={{ 'data-testid': 'payment-amount-test' }} - /> - - - - - - } - /> - - - el?.broker_name ?? '') - ?.sort((a, b) => a.localeCompare(b))} - disabled={!(brokerDelegationList && brokerDelegationList.length > 0)} - value={ - brokerDelegationList?.find( - (el) => el.broker_tax_code === formik.values.idBrokerPsp - )?.broker_name ?? '' - } - onChange={(_, value) => { - handleBrokerCodesSelection(value); - }} - fullWidth - renderInput={(params) => ( - - )} - PaperComponent={({ children }) => ( - {children} - )} - noOptionsText={t( - 'commissionBundlesPage.addEditCommissionBundle.form.noBrokersOption' - )} - data-testid="broker-code-test" - /> - - - el.channel_code).sort((a, b) => a.localeCompare(b))} - disabled={!(channels && channels.length > 0)} - onChange={(_event, value) => handleChangeChannel(value)} - value={formik.values.idChannel} - fullWidth - renderInput={(params) => ( - - )} - PaperComponent={({ children }) => ( - {children} - )} - noOptionsText={t( - 'commissionBundlesPage.addEditCommissionBundle.form.noChannelsOption' - )} - data-testid="channels-id-test" - /> - - - formik.setFieldValue('cart', e.target.checked)} - checked={formik.values.cart ?? false} - disabled={!isChannelV2} - data-testid="bundle-cart" - /> - } - label={ -
- {t('commissionBundlesPage.addEditCommissionBundle.form.cart')} - - - -
- } - /> -
-
-
- - } - /> - - - - - {t( - 'commissionBundlesPage.addEditCommissionBundle.form.paymentWithDigitalStamp' - )} - - - formik.setFieldValue('digitalStamp', e.target.value === 'true') - } - row - data-testid="digital-stamp-test" - value={formik.values.digitalStamp ? `${formik.values.digitalStamp}` : 'false'} - > - } - label={t('general.no')} - sx={{ pr: 3 }} - /> - } - disabled={formik.values.digitalStampRestriction} - label={t('general.yes')} - /> - - - - - - - {t( - 'commissionBundlesPage.addEditCommissionBundle.form.paymentOnlyDigitalStamp' - )} - - - formik.setFieldValue('digitalStampRestriction', e.target.value === 'true') - } - row - data-testid="digital-stamp-restriction-test" - value={ - formik.values.digitalStampRestriction - ? `${formik.values.digitalStampRestriction}` - : 'false' - } - > - } - label={t('general.no')} - sx={{ pr: 3 }} - /> - } - disabled={formik.values.digitalStamp} - label={t('general.yes')} - /> - - - - - - - } - /> - - - - formik.setFieldValue('validityDateFrom', value)} - renderInput={(params: TextFieldProps) => ( - - )} - shouldDisableDate={shouldDisableDate} - disabled={isEdit} - /> - - - - - formik.setFieldValue('validityDateTo', value)} - renderInput={(params: TextFieldProps) => ( - - )} - shouldDisableDate={shouldDisableDate} - /> - - - - -
-
- - ); + + } + /> + + + { + const numericValue = parseFloat(value.replace(',', '.')); + formik.setFieldValue('paymentAmount', numericValue * 100); + }} + thousandSeparator="" + decimalSeparator="," + allowNegative={false} + decimalScale={2} + fixedDecimalScale={false} + error={formik.touched.paymentAmount && Boolean(formik.errors.paymentAmount)} + helperText={formik.touched.paymentAmount && formik.errors.paymentAmount} + InputProps={{ + endAdornment: , + }} + inputProps={{'data-testid': 'payment-amount-test'}} + /> + + + + + + } + /> + + + el?.broker_name ?? '') + ?.sort((a, b) => a.localeCompare(b))} + disabled={!(brokerDelegationList && brokerDelegationList.length > 0)} + value={ + brokerDelegationList?.find( + (el) => el.broker_tax_code === formik.values.idBrokerPsp + )?.broker_name ?? '' + } + onChange={(_, value) => { + handleBrokerCodesSelection(value); + }} + fullWidth + renderInput={(params) => ( + + )} + PaperComponent={({children}) => ( + {children} + )} + noOptionsText={t( + 'commissionBundlesPage.addEditCommissionBundle.form.noBrokersOption' + )} + data-testid="broker-code-test" + /> + + + el.channel_code).sort((a, b) => a.localeCompare(b))} + disabled={!(channels && channels.length > 0)} + onChange={(_event, value) => handleChangeChannel(value)} + value={formik.values.idChannel} + fullWidth + renderInput={(params) => ( + + )} + PaperComponent={({children}) => ( + {children} + )} + noOptionsText={t( + 'commissionBundlesPage.addEditCommissionBundle.form.noChannelsOption' + )} + data-testid="channels-id-test" + /> + + + formik.setFieldValue('cart', e.target.checked)} + checked={formik.values.cart ?? false} + disabled={!isChannelV2} + data-testid="bundle-cart" + /> + } + label={ +
+ {t('commissionBundlesPage.addEditCommissionBundle.form.cart')} + + + +
+ } + /> +
+
+
+ + } + /> + + + + + {t( + 'commissionBundlesPage.addEditCommissionBundle.form.paymentWithDigitalStamp' + )} + + + formik.setFieldValue('digitalStamp', e.target.value === 'true') + } + row + data-testid="digital-stamp-test" + value={formik.values.digitalStamp ? `${formik.values.digitalStamp}` : 'false'} + > + } + label={t('general.no')} + sx={{pr: 3}} + /> + } + disabled={formik.values.digitalStampRestriction} + label={t('general.yes')} + /> + + + + + + + {t( + 'commissionBundlesPage.addEditCommissionBundle.form.paymentOnlyDigitalStamp' + )} + + + formik.setFieldValue('digitalStampRestriction', e.target.value === 'true') + } + row + data-testid="digital-stamp-restriction-test" + value={ + formik.values.digitalStampRestriction + ? `${formik.values.digitalStampRestriction}` + : 'false' + } + > + } + label={t('general.no')} + sx={{pr: 3}} + /> + } + disabled={formik.values.digitalStamp} + label={t('general.yes')} + /> + + + + + + + } + /> + + + + formik.setFieldValue('validityDateFrom', value)} + renderInput={(params: TextFieldProps) => ( + + )} + shouldDisableDate={shouldDisableDate} + disabled={isEdit} + /> + + + + + formik.setFieldValue('validityDateTo', value)} + renderInput={(params: TextFieldProps) => ( + + )} + shouldDisableDate={shouldDisableDate} + /> + + + + + +
+ + ); }; export default AddEditCommissionBundleForm; diff --git a/src/pages/commisionalBundles/addEditCommissionBundle/components/__tests__/AddEditCommissionBundleForm.test.tsx b/src/pages/commisionalBundles/addEditCommissionBundle/components/__tests__/AddEditCommissionBundleForm.test.tsx index c6b069829..b42bbad4f 100644 --- a/src/pages/commisionalBundles/addEditCommissionBundle/components/__tests__/AddEditCommissionBundleForm.test.tsx +++ b/src/pages/commisionalBundles/addEditCommissionBundle/components/__tests__/AddEditCommissionBundleForm.test.tsx @@ -90,7 +90,7 @@ describe('', () => { ); spyOnGetChannelService = jest.spyOn( require('../../../../../services/channelService'), - 'getChannels' + 'getChannels' ); spyOnErrorHook = jest .spyOn(useErrorDispatcher, 'useErrorDispatcher')