From f414f2485d0a5fe91f8d253222a27a3c07a1ed38 Mon Sep 17 00:00:00 2001 From: giomella Date: Mon, 24 Jun 2024 15:35:41 +0200 Subject: [PATCH] added missing call for station in status TO_FIX_UPDATE --- .../addEditStation/AddEditStationForm.tsx | 2163 +++++++++-------- 1 file changed, 1084 insertions(+), 1079 deletions(-) diff --git a/src/pages/stations/addEditStation/AddEditStationForm.tsx b/src/pages/stations/addEditStation/AddEditStationForm.tsx index af7a4f79f..7b43df263 100644 --- a/src/pages/stations/addEditStation/AddEditStationForm.tsx +++ b/src/pages/stations/addEditStation/AddEditStationForm.tsx @@ -1,9 +1,13 @@ /* eslint-disable sonarjs/cognitive-complexity */ /* eslint-disable complexity */ -import {ButtonNaked, theme} from '@pagopa/mui-italia'; -import {FormikProps, useFormik} from 'formik'; -import {useEffect, useState} from 'react'; -import {Trans, useTranslation} from 'react-i18next'; +import { + Badge as BadgeIcon, + Cable as CableIcon, + CallMade, + Check as CheckIcon, + MenuBook, + NorthEast as NorthEastIcon, +} from '@mui/icons-material'; import { Button, FormControl, @@ -21,27 +25,39 @@ import { TextField, Typography, } from '@mui/material'; -import {Box} from '@mui/system'; import CircularProgressIcon from '@mui/material/CircularProgress'; +import { Box } from '@mui/system'; +import { ButtonNaked, theme } from '@pagopa/mui-italia'; +import { useErrorDispatcher, useLoading } from '@pagopa/selfcare-common-frontend'; +import { FormikProps, useFormik } from 'formik'; +import { useEffect, useState } from 'react'; +import { Trans, useTranslation } from 'react-i18next'; +import { generatePath, useHistory } from 'react-router-dom'; import { - Badge as BadgeIcon, - Check as CheckIcon, - MenuBook, - NorthEast as NorthEastIcon, - Cable as CableIcon, - CallMade, -} from '@mui/icons-material'; -import {generatePath, useHistory} from 'react-router-dom'; -import {useErrorDispatcher, useLoading} from '@pagopa/selfcare-common-frontend'; -import {useFlagValue} from '../../../hooks/useFeatureFlags'; -import {RedirectProtocolEnum, StatusEnum} from '../../../api/generated/portal/StationDetailsDto'; + StationDetailResource, + WrapperStatusEnum, +} from '../../../api/generated/portal/StationDetailResource'; +import { RedirectProtocolEnum, StatusEnum } from '../../../api/generated/portal/StationDetailsDto'; +import { TestStationTypeEnum } from '../../../api/generated/portal/StationTestDto'; import { TestResultEnum, TestStationResource, } from '../../../api/generated/portal/TestStationResource'; +import { useFlagValue } from '../../../hooks/useFeatureFlags'; +import { useUserRole } from '../../../hooks/useUserRole'; +import { + ConnectionType, + GPDConfigs, + IGPDConfig, + INewConnConfig, + NewConnConfigs, + StationCategory, + StationFormAction, + StationOnCreation, +} from '../../../model/Station'; +import { useAppSelector } from '../../../redux/hooks'; +import { partiesSelectors } from '../../../redux/slices/partiesSlice'; import ROUTES from '../../../routes'; -import AddEditStationFormSectionTitle from '../addEditStation/AddEditStationFormSectionTitle'; -import ConfirmModal from '../../components/ConfirmModal'; import { createStation, createWrapperStation, @@ -55,1142 +71,1131 @@ import { LOADING_TASK_GENERATION_STATION_CODE, LOADING_TASK_STATION_ADD_EDIT, } from '../../../utils/constants'; -import {useAppSelector} from '../../../redux/hooks'; -import {partiesSelectors} from '../../../redux/slices/partiesSlice'; -import { - ConnectionType, - GPDConfigs, - IGPDConfig, - INewConnConfig, - NewConnConfigs, - StationCategory, - StationFormAction, - StationOnCreation, -} from '../../../model/Station'; +import { ENV } from '../../../utils/env'; import { alterStationValuesToFitCategories, getStationCategoryFromDetail, splitURL, } from '../../../utils/station-utils'; -import {ENV} from '../../../utils/env'; -import {useUserRole} from '../../../hooks/useUserRole'; -import { - StationDetailResource, - WrapperStatusEnum, -} from '../../../api/generated/portal/StationDetailResource'; -import {TestStationTypeEnum} from '../../../api/generated/portal/StationTestDto'; +import ConfirmModal from '../../components/ConfirmModal'; +import AddEditStationFormSectionTitle from '../addEditStation/AddEditStationFormSectionTitle'; import AddEditStationFormValidation from './components/AddEditStationFormValidation'; type Props = { - stationDetail?: StationDetailResource; - formAction: string; + stationDetail?: StationDetailResource; + formAction: string; }; -const ConnectionRadioLabel = ({type}: { type: ConnectionType }) => { - const {t} = useTranslation(); - return ( - <> - {t(`addEditStationPage.addForm.fields.connectionRadio.${type}.label`)} - - {t(`addEditStationPage.addForm.fields.connectionRadio.${type}.sublabel`)} - - - ); +const ConnectionRadioLabel = ({ type }: { type: ConnectionType }) => { + const { t } = useTranslation(); + return ( + <> + {t(`addEditStationPage.addForm.fields.connectionRadio.${type}.label`)} + + {t(`addEditStationPage.addForm.fields.connectionRadio.${type}.sublabel`)} + + + ); }; const getDefaultConnectionType = (stationDetail?: StationDetailResource) => { - if (stationDetail?.isConnectionSync) { - return ConnectionType.SYNC; - } - return ConnectionType.ASYNC; + if (stationDetail?.isConnectionSync) { + return ConnectionType.SYNC; + } + return ConnectionType.ASYNC; }; const componentPath = 'addEditStationPage.addForm'; -const AddEditStationForm = ({stationDetail, formAction}: Props) => { - const {t} = useTranslation(); - const history = useHistory(); - const [showConfirmModal, setShowConfirmModal] = useState(false); - const addError = useErrorDispatcher(); - const setLoading = useLoading(LOADING_TASK_STATION_ADD_EDIT); - const setLoadingGeneration = useLoading(LOADING_TASK_GENERATION_STATION_CODE); - const selectedParty = useAppSelector(partiesSelectors.selectPartySelected); - const [stationCodeGenerated, setStationCodeGenerated] = useState(''); - const stationCodeCleaner = typeof selectedParty !== 'undefined' ? selectedParty.fiscalCode : ''; - const brokerCodeCleaner = typeof selectedParty !== 'undefined' ? selectedParty.fiscalCode : ''; - const {userIsPagopaOperator} = useUserRole(); - const env: string = ENV.ENV; - const gpdAddresses = GPDConfigs[ENV.ENV as keyof IGPDConfig]; - const forwarderAddresses = NewConnConfigs[ENV.ENV as keyof INewConnConfig]; - const [newConn, setNewConn] = useState(false); - const [gdp, setGDP] = useState(false); - const [testRtResult, setTestRtResult] = useState(); - const [validatingRt, setValidatingRt] = useState(false); +const AddEditStationForm = ({ stationDetail, formAction }: Props) => { + const { t } = useTranslation(); + const history = useHistory(); + const [showConfirmModal, setShowConfirmModal] = useState(false); + const addError = useErrorDispatcher(); + const setLoading = useLoading(LOADING_TASK_STATION_ADD_EDIT); + const setLoadingGeneration = useLoading(LOADING_TASK_GENERATION_STATION_CODE); + const selectedParty = useAppSelector(partiesSelectors.selectPartySelected); + const [stationCodeGenerated, setStationCodeGenerated] = useState(''); + const stationCodeCleaner = typeof selectedParty !== 'undefined' ? selectedParty.fiscalCode : ''; + const brokerCodeCleaner = typeof selectedParty !== 'undefined' ? selectedParty.fiscalCode : ''; + const { userIsPagopaOperator } = useUserRole(); + const env: string = ENV.ENV; + const gpdAddresses = GPDConfigs[ENV.ENV as keyof IGPDConfig]; + const forwarderAddresses = NewConnConfigs[ENV.ENV as keyof INewConnConfig]; + const [newConn, setNewConn] = useState(false); + const [gdp, setGDP] = useState(false); + const [testRtResult, setTestRtResult] = useState(); + const [validatingRt, setValidatingRt] = useState(false); - const [testRedirectResult, setTestRedirectResult] = useState(); - const [validatingRedirect, setValidatingRedirect] = useState(false); + const [testRedirectResult, setTestRedirectResult] = useState(); + const [validatingRedirect, setValidatingRedirect] = useState(false); - const [testPofResult, setTestPofResult] = useState(); - const [validatingPof, setValidatingPof] = useState(false); + const [testPofResult, setTestPofResult] = useState(); + const [validatingPof, setValidatingPof] = useState(false); - const [connectionType, setConnectionType] = useState( - getDefaultConnectionType(stationDetail) - ); + const [connectionType, setConnectionType] = useState( + getDefaultConnectionType(stationDetail) + ); - const isTesting = useFlagValue('test-stations'); + const isTesting = useFlagValue('test-stations'); - const emptyStationData = (detail?: StationDetailResource) => ({ - brokerCode: brokerCodeCleaner, - ip: '', - password: '', - port: undefined, - primitiveVersion: 2, - protocol: undefined, - proxyConcat: '', - proxyHost: '', - proxyPort: undefined, - proxyEnabled: false, - redirectConcat: '', - redirectIp: '', - redirectPath: '', - redirectPort: undefined, - redirectProtocol: RedirectProtocolEnum.HTTPS, - redirectQueryString: '', - service: '', - stationCode: detail?.stationCode ?? stationCodeGenerated, - status: StatusEnum.TO_CHECK, - targetConcat: '', - targetHost: '', - targetPath: '', - targetPort: undefined, - targetPofConcat: '', - timeoutA: 7, - timeoutB: 30, - timeoutC: 120, - version: 0, - newConnConcat: '', - gdpConcat: '', - threadNumber: 1, - }); - const mapStationDetailToCreation = (detail: StationDetailResource) => ({ - brokerCode: detail.brokerCode ?? '', - enabled: detail.enabled, - ip: detail.ip ?? '', - password: detail.password ?? '', - port: detail.port ?? 443, - protocol: detail.protocol ?? undefined, - proxyConcat: `${detail.proxyHost ?? ''}${ - detail.proxyPort ? ':'.concat(detail.proxyPort.toString()) : '' - }`, - proxyHost: detail.proxyHost ?? '', - proxyPort: detail.proxyPort ?? undefined, - proxyEnabled: detail.proxyEnabled ?? false, + const emptyStationData = (detail?: StationDetailResource) => ({ + brokerCode: brokerCodeCleaner, + ip: '', + password: '', + port: undefined, + primitiveVersion: 2, + protocol: undefined, + proxyConcat: '', + proxyHost: '', + proxyPort: undefined, + proxyEnabled: false, + redirectConcat: '', + redirectIp: '', + redirectPath: '', + redirectPort: undefined, + redirectProtocol: RedirectProtocolEnum.HTTPS, + redirectQueryString: '', + service: '', + stationCode: detail?.stationCode ?? stationCodeGenerated, + status: StatusEnum.TO_CHECK, + targetConcat: '', + targetHost: '', + targetPath: '', + targetPort: undefined, + targetPofConcat: '', + timeoutA: 7, + timeoutB: 30, + timeoutC: 120, + version: 0, + newConnConcat: '', + gdpConcat: '', + threadNumber: 1, + }); + const mapStationDetailToCreation = (detail: StationDetailResource) => ({ + brokerCode: detail.brokerCode ?? '', + enabled: detail.enabled, + ip: detail.ip ?? '', + password: detail.password ?? '', + port: detail.port ?? 443, + protocol: detail.protocol ?? undefined, + proxyConcat: `${detail.proxyHost ?? ''}${ + detail.proxyPort ? ':'.concat(detail.proxyPort.toString()) : '' + }`, + proxyHost: detail.proxyHost ?? '', + proxyPort: detail.proxyPort ?? undefined, + proxyEnabled: detail.proxyEnabled ?? false, - service: detail.service ?? '', - stationCode: - formAction === StationFormAction.Duplicate ? stationCodeGenerated : detail.stationCode ?? '', - status: detail?.wrapperStatus, + service: detail.service ?? '', + stationCode: + formAction === StationFormAction.Duplicate ? stationCodeGenerated : detail.stationCode ?? '', + status: detail?.wrapperStatus, - timeoutA: detail.timeoutA ?? 7, - timeoutB: detail.timeoutB ?? 30, - timeoutC: detail.timeoutC ?? 120, - version: detail.version ?? undefined, - newConnConcat: - Object.entries(forwarderAddresses) - .map(([key, value]) => value) - .find((d) => - detail.pofService && detail.pofService !== '' && detail.pofService !== '/' - ? d.includes(detail.pofService) - : false - ) ?? '', - gdpConcat: - Object.entries(gpdAddresses) - .map(([key, value]) => value) - .find((gpd) => - detail.pofService && detail.pofService !== '' && detail.pofService !== '/' - ? gpd.includes(detail.pofService) - : false - ) ?? '', - threadNumber: 1, + timeoutA: detail.timeoutA ?? 7, + timeoutB: detail.timeoutB ?? 30, + timeoutC: detail.timeoutC ?? 120, + version: detail.version ?? undefined, + newConnConcat: + Object.entries(forwarderAddresses) + .map(([key, value]) => value) + .find((d) => + detail.pofService && detail.pofService !== '' && detail.pofService !== '/' + ? d.includes(detail.pofService) + : false + ) ?? '', + gdpConcat: + Object.entries(gpdAddresses) + .map(([key, value]) => value) + .find((gpd) => + detail.pofService && detail.pofService !== '' && detail.pofService !== '/' + ? gpd.includes(detail.pofService) + : false + ) ?? '', + threadNumber: 1, - // fields for redirect endpoint - redirectProtocol: detail.redirectProtocol ?? '', - redirectIp: detail.redirectIp ?? '', - redirectPort: detail.redirectPort ?? undefined, - redirectPath: detail.redirectPath ?? '', - redirectQueryString: detail.redirectQueryString ?? '', - redirectConcat: - detail.redirectPath && detail.redirectProtocol - ? `${detail.redirectProtocol.toLowerCase()}://${detail.redirectIp}${ - detail.redirectPort ? ':'.concat(detail.redirectPort.toString()) : '' - }${detail.redirectPath ?? ''}${ - detail.redirectQueryString ? '?' + String(detail.redirectQueryString) : '' - }` - : '', + // fields for redirect endpoint + redirectProtocol: detail.redirectProtocol ?? '', + redirectIp: detail.redirectIp ?? '', + redirectPort: detail.redirectPort ?? undefined, + redirectPath: detail.redirectPath ?? '', + redirectQueryString: detail.redirectQueryString ?? '', + redirectConcat: + detail.redirectPath && detail.redirectProtocol + ? `${detail.redirectProtocol.toLowerCase()}://${detail.redirectIp}${ + detail.redirectPort ? ':'.concat(detail.redirectPort.toString()) : '' + }${detail.redirectPath ?? ''}${ + detail.redirectQueryString ? '?' + String(detail.redirectQueryString) : '' + }` + : '', - // fields for RT endpoint - targetHost: detail.targetHost ?? '', - targetPath: detail.targetPath ?? '', - targetPort: detail.targetPort ?? '', - targetConcat: detail.targetHost - ? `${detail.targetHost ?? ''}${ - detail.targetPort ? ':'.concat(detail.targetPort.toString()) : '' - }${detail.targetPath ?? ''}` - : '', + // fields for RT endpoint + targetHost: detail.targetHost ?? '', + targetPath: detail.targetPath ?? '', + targetPort: detail.targetPort ?? '', + targetConcat: detail.targetHost + ? `${detail.targetHost ?? ''}${ + detail.targetPort ? ':'.concat(detail.targetPort.toString()) : '' + }${detail.targetPath ?? ''}` + : '', - targetHostPof: detail.targetHostPof, - targetPathPof: detail.targetPathPof, - targetPortPof: detail.targetPortPof, - primitiveVersion: detail.primitiveVersion ?? 2, - targetPofConcat: detail.targetHostPof - ? `${detail.targetHostPof ?? ''}${ - detail.targetPortPof ? ':'.concat(detail.targetPortPof.toString()) : '' - }${detail.targetPathPof ?? ''}` - : '', - }); - const initialFormData = (detail?: StationDetailResource) => - detail ? mapStationDetailToCreation(detail) : emptyStationData(); + targetHostPof: detail.targetHostPof, + targetPathPof: detail.targetPathPof, + targetPortPof: detail.targetPortPof, + primitiveVersion: detail.primitiveVersion ?? 2, + targetPofConcat: detail.targetHostPof + ? `${detail.targetHostPof ?? ''}${ + detail.targetPortPof ? ':'.concat(detail.targetPortPof.toString()) : '' + }${detail.targetPathPof ?? ''}` + : '', + }); + const initialFormData = (detail?: StationDetailResource) => + detail ? mapStationDetailToCreation(detail) : emptyStationData(); - 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 validatePrimitiveVersion = (primitiveVersion: number) => { - if (primitiveVersion) { - return !(primitiveVersion > 0 && primitiveVersion <= 2); - } - return false; - }; + const validatePrimitiveVersion = (primitiveVersion: number) => { + if (primitiveVersion) { + return !(primitiveVersion > 0 && primitiveVersion <= 2); + } + return false; + }; - const validateURL = (urlToValidate: string, checkProtocol: boolean) => { - if (urlToValidate === '') { - return undefined; - } - try { - const url = new URL(urlToValidate); - // eslint-disable-next-line sonarjs/prefer-single-boolean-return - if ( - checkProtocol && - !(url.protocol.toString() === 'http:' || url.protocol.toString() === 'https:') - ) { - return 'Protocollo non valido'; + const validateURL = (urlToValidate: string, checkProtocol: boolean) => { + if (urlToValidate === '') { + return undefined; + } + try { + const url = new URL(urlToValidate); + // eslint-disable-next-line sonarjs/prefer-single-boolean-return + if ( + checkProtocol && + !(url.protocol.toString() === 'http:' || url.protocol.toString() === 'https:') + ) { + return 'Protocollo non valido'; + } + return undefined; + } catch (e) { + console.error(e); + return 'URL non valido'; + } + }; + + const validate = (values: StationOnCreation) => + Object.fromEntries( + Object.entries({ + ...{ + stationCode: !values.stationCode + ? t('addEditStationPage.validation.requiredField') + : undefined, + brokerCode: + userIsPagopaOperator && formAction !== StationFormAction.Create + ? '' + : !values.brokerCode + ? t('addEditStationPage.validation.requiredField') + : '', + primitiveVersion: !values.primitiveVersion + ? t('addEditStationPage.validation.requiredField') + : validatePrimitiveVersion(values.primitiveVersion) + ? t('addEditStationPage.validation.overVersion') + : undefined, + targetConcat: validateURL(values.targetConcat, false), + redirectConcat: validateURL(values.redirectConcat, true), + targetPofConcat: validateURL(values.targetPofConcat, false), + }, + ...(userIsPagopaOperator && formAction !== StationFormAction.Create + ? { + version: !values.version + ? 'Campo obbligatorio' + : validatePrimitiveVersion(values.version) + ? t('addEditStationPage.validation.overVersion') + : undefined, + password: !values.password ? 'Campo obbligatorio' : undefined, + timeoutA: !values.timeoutA ? 'Campo obbligatorio' : undefined, + timeoutB: !values.timeoutB ? 'Campo obbligatorio' : undefined, + timeoutC: !values.timeoutC ? 'Campo obbligatorio' : undefined, + gdpConcat: gdp && values.gdpConcat === '' ? 'Campo obbligatorio' : undefined, + newConnConcat: + newConn && values.newConnConcat === '' ? 'Campo obbligatorio' : undefined, } - return undefined; - } catch (e) { - console.error(e); - return 'URL non valido'; - } - }; + : null), + }).filter(([_key, value]) => value) + ); - const validate = (values: StationOnCreation) => - Object.fromEntries( - Object.entries({ - ...{ - stationCode: !values.stationCode - ? t('addEditStationPage.validation.requiredField') - : undefined, - brokerCode: - userIsPagopaOperator && formAction !== StationFormAction.Create - ? '' - : !values.brokerCode - ? t('addEditStationPage.validation.requiredField') - : '', - primitiveVersion: !values.primitiveVersion - ? t('addEditStationPage.validation.requiredField') - : validatePrimitiveVersion(values.primitiveVersion) - ? t('addEditStationPage.validation.overVersion') - : undefined, - targetConcat: validateURL(values.targetConcat, false), - redirectConcat: validateURL(values.redirectConcat, true), - targetPofConcat: validateURL(values.targetPofConcat, false), - }, - ...(userIsPagopaOperator && formAction !== StationFormAction.Create - ? { - version: !values.version - ? 'Campo obbligatorio' - : validatePrimitiveVersion(values.version) - ? t('addEditStationPage.validation.overVersion') - : undefined, - password: !values.password ? 'Campo obbligatorio' : undefined, - timeoutA: !values.timeoutA ? 'Campo obbligatorio' : undefined, - timeoutB: !values.timeoutB ? 'Campo obbligatorio' : undefined, - timeoutC: !values.timeoutC ? 'Campo obbligatorio' : undefined, - gdpConcat: gdp && values.gdpConcat === '' ? 'Campo obbligatorio' : undefined, - newConnConcat: - newConn && values.newConnConcat === '' ? 'Campo obbligatorio' : undefined, - } - : null), - }).filter(([_key, value]) => value) - ); + const enableSubmit = (values: StationOnCreation) => { + const baseConditions = + values.stationCode !== '' && + values.brokerCode !== '' && + values.primitiveVersion.toString() !== '' && + (connectionType === ConnectionType.SYNC + ? values.targetConcat || values.redirectConcat + ? values.targetConcat && values.redirectConcat + : values.targetPofConcat + : true); + const operatorConditions = values.version?.toString() !== '' && values.password !== ''; - const enableSubmit = (values: StationOnCreation) => { - const baseConditions = - values.stationCode !== '' && - values.brokerCode !== '' && - values.primitiveVersion.toString() !== '' && - (connectionType === ConnectionType.SYNC - ? values.targetConcat || values.redirectConcat - ? values.targetConcat && values.redirectConcat - : values.targetPofConcat - : true); - const operatorConditions = values.version?.toString() !== '' && values.password !== ''; + if (!baseConditions) { + return false; + } - if (!baseConditions) { - return false; - } + if (!userIsPagopaOperator) { + return baseConditions; + } else if (userIsPagopaOperator && baseConditions && operatorConditions) { + return true; + } else { + return false; + } + }; - if (!userIsPagopaOperator) { - return baseConditions; - } else if (userIsPagopaOperator && baseConditions && operatorConditions) { - return true; - } else { - return false; - } - }; + const redirect = (stCode: string) => { + if (userIsPagopaOperator) { + history.push(generatePath(ROUTES.STATION_DETAIL, { stationId: stCode })); + } else { + history.push(ROUTES.STATIONS); + } + }; - const redirect = (stCode: string) => { - if (userIsPagopaOperator) { - history.push(generatePath(ROUTES.STATION_DETAIL, {stationId: stCode})); - } else { - history.push(ROUTES.STATIONS); - } - }; + const submit = async (valuesFromForm: StationOnCreation) => { + setLoading(true); + const stationCode = stationDetail?.stationCode ? stationDetail.stationCode : ''; + const stationCode4Redirect = + formAction !== StationFormAction.Edit ? stationCodeGenerated : stationCode; - const submit = async (valuesFromForm: StationOnCreation) => { - setLoading(true); - const stationCode = stationDetail?.stationCode ? stationDetail.stationCode : ''; - const stationCode4Redirect = - formAction !== StationFormAction.Edit ? stationCodeGenerated : stationCode; + const values = alterStationValuesToFitCategories(valuesFromForm, env); - const values = alterStationValuesToFitCategories(valuesFromForm, env); + try { + const validationUrl = `${window.location.origin}${generatePath(ROUTES.STATION_DETAIL, { + stationId: formik.values.stationCode, + })}`; + // eslint-disable-next-line functional/immutable-data + values.validationUrl = validationUrl; - try { - const validationUrl = `${window.location.origin}${generatePath(ROUTES.STATION_DETAIL, { - stationId: formik.values.stationCode, - })}`; - // eslint-disable-next-line functional/immutable-data - values.validationUrl = validationUrl; + if (formAction === StationFormAction.Create || formAction === StationFormAction.Duplicate) { + await createWrapperStation(values); + redirect(stationCode4Redirect); + } - if (formAction === StationFormAction.Create || formAction === StationFormAction.Duplicate) { - await createWrapperStation(values); - redirect(stationCode4Redirect); + if (formAction === StationFormAction.Edit) { + switch (stationDetail?.wrapperStatus) { + case WrapperStatusEnum.TO_CHECK: + if (userIsPagopaOperator) { + await createStation(values); + redirect(stationCode4Redirect); + } else { + await updateWrapperStationToCheck(values); + redirect(stationCode4Redirect); } - - if (formAction === StationFormAction.Edit) { - switch (stationDetail?.wrapperStatus) { - case WrapperStatusEnum.TO_CHECK: - if (userIsPagopaOperator) { - await createStation(values); - redirect(stationCode4Redirect); - } else { - await updateWrapperStationToCheck(values); - redirect(stationCode4Redirect); - } - break; - case WrapperStatusEnum.APPROVED: - case WrapperStatusEnum.TO_CHECK_UPDATE: - if (userIsPagopaOperator) { - await updateStation(values, stationCode); - redirect(stationCode4Redirect); - } else { - await updateWrapperStationToCheckUpdate(values); - redirect(stationCode4Redirect); - } - break; - case WrapperStatusEnum.TO_FIX: - await updateWrapperStationToCheck(values); - redirect(stationCode4Redirect); - break; - default: - redirect(stationCode4Redirect); - break; - } + break; + case WrapperStatusEnum.APPROVED: + case WrapperStatusEnum.TO_CHECK_UPDATE: + if (userIsPagopaOperator) { + await updateStation(values, stationCode); + redirect(stationCode4Redirect); + } else { + await updateWrapperStationToCheckUpdate(values); + redirect(stationCode4Redirect); } - } catch (reason) { - addError({ - id: 'ADD_EDIT_STATION', - blocking: false, - error: reason as Error, - techDescription: `An error occurred while adding/editing station`, - toNotify: true, - displayableTitle: t('general.errorTitle'), - displayableDescription: t('addEditStationPage.errorMessageDesc'), - component: 'Toast', - }); - } finally { - setLoading(false); + break; + case WrapperStatusEnum.TO_FIX: + await updateWrapperStationToCheck(values); + redirect(stationCode4Redirect); + break; + case WrapperStatusEnum.TO_FIX_UPDATE: + await updateWrapperStationToCheckUpdate(values); + redirect(stationCode4Redirect); + break; + default: + redirect(stationCode4Redirect); + break; } - }; - - const formik = useFormik({ - initialValues: initialFormData(stationDetail), - validate, - onSubmit: async () => { - setShowConfirmModal(true); - }, - enableReinitialize: true, - validateOnMount: true, - validateOnBlur: true, - validateOnChange: true, - }); - - const handleChangeNumberOnly = ( - e: React.ChangeEvent, - field: string, - formik: FormikProps - ) => { - const regex = /^[0-9\b]+$/; - if (e.target.value === '' || regex.test(e.target.value)) { - formik.setFieldValue(field, Number(e.target.value)); - } - }; - - const openConfirmModal = () => { - if (formik.isValid) { - setShowConfirmModal(true); - } else { - setShowConfirmModal(false); - } - }; + } + } catch (reason) { + addError({ + id: 'ADD_EDIT_STATION', + blocking: false, + error: reason as Error, + techDescription: `An error occurred while adding/editing station`, + toNotify: true, + displayableTitle: t('general.errorTitle'), + displayableDescription: t('addEditStationPage.errorMessageDesc'), + component: 'Toast', + }); + } finally { + setLoading(false); + } + }; - const validateRtEndpoint = () => { - const rtValidationUrl = validateURL(formik.values.targetConcat, false); - if (rtValidationUrl !== undefined) { - formik.setErrors({ - ...formik.errors, - targetConcat: rtValidationUrl, - }); - } else { - setValidatingRt(true); - const {protocolSplit, hostSplit, portSplit, pathSplit} = splitURL( - formik.values.targetConcat - ); - testStation( - protocolSplit, - hostSplit, - portSplit > 0 ? portSplit : 443, - pathSplit, - TestStationTypeEnum.PA_INVIA_RT - ) - .then((item: TestStationResource) => { - setTestRtResult(item); - }) - .finally(() => { - setValidatingRt(false); - }); - } - }; + const formik = useFormik({ + initialValues: initialFormData(stationDetail), + validate, + onSubmit: async () => { + setShowConfirmModal(true); + }, + enableReinitialize: true, + validateOnMount: true, + validateOnBlur: true, + validateOnChange: true, + }); - const validateRedirectEndpoint = () => { - const redirectValidationUrl = validateURL(formik.values.redirectConcat, false); - if (redirectValidationUrl !== undefined) { - formik.setErrors({ - ...formik.errors, - redirectConcat: redirectValidationUrl, - }); - } else { - setValidatingRedirect(true); - const {protocolSplit, hostSplit, portSplit, pathSplit} = splitURL( - formik.values.redirectConcat - ); - testStation( - protocolSplit, - hostSplit, - portSplit > 0 ? portSplit : protocolSplit.includes('https') ? 443 : 80, - pathSplit, - TestStationTypeEnum.PA_REDIRECT - ) - .then((item: TestStationResource) => { - setTestRedirectResult(item); - }) - .finally(() => { - setValidatingRedirect(false); - }); - } - }; + const handleChangeNumberOnly = ( + e: React.ChangeEvent, + field: string, + formik: FormikProps + ) => { + const regex = /^[0-9\b]+$/; + if (e.target.value === '' || regex.test(e.target.value)) { + formik.setFieldValue(field, Number(e.target.value)); + } + }; - const validatePofEndpoint = () => { - const pofValidationUrl = validateURL(formik.values.targetPofConcat, false); - if (pofValidationUrl !== undefined) { - formik.setErrors({ - ...formik.errors, - targetPofConcat: pofValidationUrl, - }); - } else { - setValidatingPof(true); - const {protocolSplit, hostSplit, portSplit, pathSplit} = splitURL( - formik.values.targetPofConcat - ); - testStation( - protocolSplit, - hostSplit, - portSplit > 0 ? portSplit : 443, - pathSplit, - TestStationTypeEnum.PA_VERIFY - ) - .then((item: TestStationResource) => { - setTestPofResult(item); - }) - .finally(() => { - setValidatingPof(false); - }); - } - }; + const openConfirmModal = () => { + if (formik.isValid) { + setShowConfirmModal(true); + } else { + setShowConfirmModal(false); + } + }; - async function handleChangeConnectionType(value: string) { - setConnectionType(value as ConnectionType); + const validateRtEndpoint = () => { + const rtValidationUrl = validateURL(formik.values.targetConcat, false); + if (rtValidationUrl !== undefined) { + formik.setErrors({ + ...formik.errors, + targetConcat: rtValidationUrl, + }); + } else { + setValidatingRt(true); + const { protocolSplit, hostSplit, portSplit, pathSplit } = splitURL( + formik.values.targetConcat + ); + testStation( + protocolSplit, + hostSplit, + portSplit > 0 ? portSplit : 443, + pathSplit, + TestStationTypeEnum.PA_INVIA_RT + ) + .then((item: TestStationResource) => { + setTestRtResult(item); + }) + .finally(() => { + setValidatingRt(false); + }); + } + }; - if (value === ConnectionType.ASYNC) { - await formik.setValues(emptyStationData(stationDetail)); - } else { - await formik.setValues(initialFormData(stationDetail)); - } + const validateRedirectEndpoint = () => { + const redirectValidationUrl = validateURL(formik.values.redirectConcat, false); + if (redirectValidationUrl !== undefined) { + formik.setErrors({ + ...formik.errors, + redirectConcat: redirectValidationUrl, + }); + } else { + setValidatingRedirect(true); + const { protocolSplit, hostSplit, portSplit, pathSplit } = splitURL( + formik.values.redirectConcat + ); + testStation( + protocolSplit, + hostSplit, + portSplit > 0 ? portSplit : protocolSplit.includes('https') ? 443 : 80, + pathSplit, + TestStationTypeEnum.PA_REDIRECT + ) + .then((item: TestStationResource) => { + setTestRedirectResult(item); + }) + .finally(() => { + setValidatingRedirect(false); + }); } + }; - useEffect(() => { - if (formAction !== StationFormAction.Edit) { - setLoadingGeneration(true); - getStationCodeV2(stationCodeCleaner) - .then((res) => { - setStationCodeGenerated(res.stationCode); - }) - .catch((error) => { - addError({ - id: 'GENERATE_STATION_CODE', - blocking: false, - error, - techDescription: `An error occurred while generating station code`, - toNotify: true, - displayableTitle: t('addEditStationPage.errorMessageStationCodeTitle'), - displayableDescription: t('addEditStationPage.errorMessageStationCodeDesc'), - component: 'Toast', - }); - }) - .finally(() => { - setLoadingGeneration(false); - }); - } - }, [stationCodeCleaner]); + const validatePofEndpoint = () => { + const pofValidationUrl = validateURL(formik.values.targetPofConcat, false); + if (pofValidationUrl !== undefined) { + formik.setErrors({ + ...formik.errors, + targetPofConcat: pofValidationUrl, + }); + } else { + setValidatingPof(true); + const { protocolSplit, hostSplit, portSplit, pathSplit } = splitURL( + formik.values.targetPofConcat + ); + testStation( + protocolSplit, + hostSplit, + portSplit > 0 ? portSplit : 443, + pathSplit, + TestStationTypeEnum.PA_VERIFY + ) + .then((item: TestStationResource) => { + setTestPofResult(item); + }) + .finally(() => { + setValidatingPof(false); + }); + } + }; - useEffect(() => { - if (stationDetail) { - setConnectionType(getDefaultConnectionType(stationDetail)); - const category = getStationCategoryFromDetail(stationDetail, env); - if (category === StationCategory.AsyncGPD) { - setGDP(true); - } - if (category === StationCategory.SyncNewConn) { - setNewConn(true); - } - } - }, [stationDetail]); + async function handleChangeConnectionType(value: string) { + setConnectionType(value as ConnectionType); - useEffect(() => { - setTestRtResult(undefined); - if (formik.values.targetConcat && formik.values.targetConcat !== '') { - const {protocolSplit, hostSplit, portSplit, pathSplit} = splitURL( - formik.values.targetConcat - ); + if (value === ConnectionType.ASYNC) { + await formik.setValues(emptyStationData(stationDetail)); + } else { + await formik.setValues(initialFormData(stationDetail)); + } + } - formik - .setValues({ - ...formik.values, - targetHost: hostSplit ?? '', - targetPort: portSplit > 0 ? portSplit : protocolSplit === 'https' ? 443 : 80, - targetPath: pathSplit, - }) - .catch((e) => console.error(e)); - } - if (formik.values.targetConcat === '') { - formik - .setValues({ - ...formik.values, - targetHost: '', - targetPort: undefined, - targetPath: '', - }) - .catch((e) => console.error(e)); - } - }, [formik.values.targetConcat]); + useEffect(() => { + if (formAction !== StationFormAction.Edit) { + setLoadingGeneration(true); + getStationCodeV2(stationCodeCleaner) + .then((res) => { + setStationCodeGenerated(res.stationCode); + }) + .catch((error) => { + addError({ + id: 'GENERATE_STATION_CODE', + blocking: false, + error, + techDescription: `An error occurred while generating station code`, + toNotify: true, + displayableTitle: t('addEditStationPage.errorMessageStationCodeTitle'), + displayableDescription: t('addEditStationPage.errorMessageStationCodeDesc'), + component: 'Toast', + }); + }) + .finally(() => { + setLoadingGeneration(false); + }); + } + }, [stationCodeCleaner]); - useEffect(() => { - if ( - testRtResult && - (testRtResult.testResult === TestResultEnum.ERROR || - testRtResult.testResult === TestResultEnum.CERTIFICATE_ERROR) - ) { - formik.setErrors({ - ...formik.errors, - targetConcat: t('addEditStationPage.addFormValidation.testFailed'), - }); - } - }, [testRtResult]); + useEffect(() => { + if (stationDetail) { + setConnectionType(getDefaultConnectionType(stationDetail)); + const category = getStationCategoryFromDetail(stationDetail, env); + if (category === StationCategory.AsyncGPD) { + setGDP(true); + } + if (category === StationCategory.SyncNewConn) { + setNewConn(true); + } + } + }, [stationDetail]); - useEffect(() => { - if ( - testRedirectResult && - (testRedirectResult.testResult === TestResultEnum.ERROR || - testRedirectResult.testResult === TestResultEnum.CERTIFICATE_ERROR) - ) { - formik.setErrors({ - ...formik.errors, - redirectConcat: t('addEditStationPage.addFormValidation.testFailed'), - }); - } - }, [testRedirectResult]); + useEffect(() => { + setTestRtResult(undefined); + if (formik.values.targetConcat && formik.values.targetConcat !== '') { + const { protocolSplit, hostSplit, portSplit, pathSplit } = splitURL( + formik.values.targetConcat + ); - useEffect(() => { - if ( - testPofResult && - (testPofResult.testResult === TestResultEnum.ERROR || - testPofResult.testResult === TestResultEnum.CERTIFICATE_ERROR) - ) { - formik.setErrors({ - ...formik.errors, - targetPofConcat: t('addEditStationPage.addFormValidation.testFailed'), - }); - } - }, [testPofResult]); + formik + .setValues({ + ...formik.values, + targetHost: hostSplit ?? '', + targetPort: portSplit > 0 ? portSplit : protocolSplit === 'https' ? 443 : 80, + targetPath: pathSplit, + }) + .catch((e) => console.error(e)); + } + if (formik.values.targetConcat === '') { + formik + .setValues({ + ...formik.values, + targetHost: '', + targetPort: undefined, + targetPath: '', + }) + .catch((e) => console.error(e)); + } + }, [formik.values.targetConcat]); - useEffect(() => { - setTestRedirectResult(undefined); - if (formik.values.redirectConcat && formik.values.redirectConcat !== '') { - const {protocolSplit, hostSplit, portSplit, pathSplit} = splitURL( - formik.values.redirectConcat - ); - const pathSplitBySearch = pathSplit.split('?'); + useEffect(() => { + if ( + testRtResult && + (testRtResult.testResult === TestResultEnum.ERROR || + testRtResult.testResult === TestResultEnum.CERTIFICATE_ERROR) + ) { + formik.setErrors({ + ...formik.errors, + targetConcat: t('addEditStationPage.addFormValidation.testFailed'), + }); + } + }, [testRtResult]); - formik - .setValues({ - ...formik.values, - redirectProtocol: protocolSplit - ? (protocolSplit.toUpperCase() as RedirectProtocolEnum) - : RedirectProtocolEnum.HTTPS.toUpperCase(), - redirectIp: hostSplit, - redirectPort: - portSplit > 0 - ? portSplit - : protocolSplit && - (protocolSplit.toUpperCase() as RedirectProtocolEnum) === RedirectProtocolEnum.HTTPS - ? 443 - : 80, - redirectPath: pathSplitBySearch[0] ?? '', - redirectQueryString: pathSplitBySearch[1] ?? '', - }) - .catch((e) => console.error(e)); - } + useEffect(() => { + if ( + testRedirectResult && + (testRedirectResult.testResult === TestResultEnum.ERROR || + testRedirectResult.testResult === TestResultEnum.CERTIFICATE_ERROR) + ) { + formik.setErrors({ + ...formik.errors, + redirectConcat: t('addEditStationPage.addFormValidation.testFailed'), + }); + } + }, [testRedirectResult]); - if (formik.values.redirectConcat === '') { - formik - .setValues({ - ...formik.values, - redirectProtocol: RedirectProtocolEnum.HTTPS.toUpperCase(), - redirectIp: '', - redirectPort: 443, - redirectPath: '', - redirectQueryString: '', - }) - .catch((e) => console.error(e)); - } - }, [formik.values.redirectConcat]); + useEffect(() => { + if ( + testPofResult && + (testPofResult.testResult === TestResultEnum.ERROR || + testPofResult.testResult === TestResultEnum.CERTIFICATE_ERROR) + ) { + formik.setErrors({ + ...formik.errors, + targetPofConcat: t('addEditStationPage.addFormValidation.testFailed'), + }); + } + }, [testPofResult]); - useEffect(() => { - setTestPofResult(undefined); - if (formik.values.targetPofConcat && formik.values.targetPofConcat !== '') { - const {protocolSplit, hostSplit, portSplit, pathSplit} = splitURL( - formik.values.targetPofConcat - ); + useEffect(() => { + setTestRedirectResult(undefined); + if (formik.values.redirectConcat && formik.values.redirectConcat !== '') { + const { protocolSplit, hostSplit, portSplit, pathSplit } = splitURL( + formik.values.redirectConcat + ); + const pathSplitBySearch = pathSplit.split('?'); - formik - .setValues({ - ...formik.values, - targetHostPof: hostSplit ?? '', - targetPortPof: - portSplit > 0 ? portSplit : protocolSplit && protocolSplit === 'https' ? 443 : 80, - targetPathPof: pathSplit, - }) - .catch((e) => console.error(e)); - } + formik + .setValues({ + ...formik.values, + redirectProtocol: protocolSplit + ? (protocolSplit.toUpperCase() as RedirectProtocolEnum) + : RedirectProtocolEnum.HTTPS.toUpperCase(), + redirectIp: hostSplit, + redirectPort: + portSplit > 0 + ? portSplit + : protocolSplit && + (protocolSplit.toUpperCase() as RedirectProtocolEnum) === + RedirectProtocolEnum.HTTPS + ? 443 + : 80, + redirectPath: pathSplitBySearch[0] ?? '', + redirectQueryString: pathSplitBySearch[1] ?? '', + }) + .catch((e) => console.error(e)); + } - if (formik.values.targetPofConcat === '') { - formik - .setValues({ - ...formik.values, - targetHostPof: '', - targetPortPof: undefined, - targetPathPof: '', - }) - .catch((e) => console.error(e)); - } - }, [formik.values.targetPofConcat]); + if (formik.values.redirectConcat === '') { + formik + .setValues({ + ...formik.values, + redirectProtocol: RedirectProtocolEnum.HTTPS.toUpperCase(), + redirectIp: '', + redirectPort: 443, + redirectPath: '', + redirectQueryString: '', + }) + .catch((e) => console.error(e)); + } + }, [formik.values.redirectConcat]); - useEffect(() => { - if (formik.values.proxyConcat && formik.values.proxyConcat !== '') { - if (!formik.values.proxyConcat.startsWith('http')) { - // eslint-disable-next-line functional/immutable-data - formik.values.proxyConcat = 'http://'.concat(formik.values.proxyConcat); - } - const {protocolSplit, hostSplit, portSplit} = splitURL(formik.values.proxyConcat); + useEffect(() => { + setTestPofResult(undefined); + if (formik.values.targetPofConcat && formik.values.targetPofConcat !== '') { + const { protocolSplit, hostSplit, portSplit, pathSplit } = splitURL( + formik.values.targetPofConcat + ); - formik - .setValues({ - ...formik.values, - proxyHost: `${protocolSplit ? String(protocolSplit) + '://' : ''}${hostSplit}`, - proxyPort: portSplit !== 0 ? portSplit : protocolSplit === 'https' ? 443 : 80, - proxyEnabled: true, - }) - .catch((e) => console.error(e)); - } - }, [formik.values.proxyConcat]); + formik + .setValues({ + ...formik.values, + targetHostPof: hostSplit ?? '', + targetPortPof: + portSplit > 0 ? portSplit : protocolSplit && protocolSplit === 'https' ? 443 : 80, + targetPathPof: pathSplit, + }) + .catch((e) => console.error(e)); + } - useEffect(() => { - void formik.validateForm(); - }, [gdp, newConn]); + if (formik.values.targetPofConcat === '') { + formik + .setValues({ + ...formik.values, + targetHostPof: '', + targetPortPof: undefined, + targetPathPof: '', + }) + .catch((e) => console.error(e)); + } + }, [formik.values.targetPofConcat]); - return ( - <> - - - {t('addEditStationPage.title')} - + useEffect(() => { + if (formik.values.proxyConcat && formik.values.proxyConcat !== '') { + if (!formik.values.proxyConcat.startsWith('http')) { + // eslint-disable-next-line functional/immutable-data + formik.values.proxyConcat = 'http://'.concat(formik.values.proxyConcat); + } + const { protocolSplit, hostSplit, portSplit } = splitURL(formik.values.proxyConcat); - - {t('stationDetailPageValidation.configuration.subtitle')} - + formik + .setValues({ + ...formik.values, + proxyHost: `${protocolSplit ? String(protocolSplit) + '://' : ''}${hostSplit}`, + proxyPort: portSplit !== 0 ? portSplit : protocolSplit === 'https' ? 443 : 80, + proxyEnabled: true, + }) + .catch((e) => console.error(e)); + } + }, [formik.values.proxyConcat]); - - - } - isRequired - /> - - - {t('general.discoverMore')} - - - - - - handleChangeConnectionType(e?.target?.value)} - data-testid="connection-type-radio-group" - value={connectionType} - > - } - label={} - sx={{pr: 8}} - disabled={userIsPagopaOperator} - /> - } - label={} - disabled={userIsPagopaOperator} - /> - - - - + useEffect(() => { + void formik.validateForm(); + }, [gdp, newConn]); - - } - isRequired - /> - - - formik.handleChange(e)} - error={formik.touched.stationCode && Boolean(formik.errors.stationCode)} - helperText={formik.touched.stationCode && formik.errors.stationCode} - inputProps={{ - 'data-testid': 'station-code-test', - }} - required - /> - - {userIsPagopaOperator && formAction !== StationFormAction.Create ? ( - - formik.handleChange(e)} - error={formik.touched.brokerCode && Boolean(formik.errors.brokerCode)} - helperText={formik.touched.brokerCode && formik.errors.brokerCode} - inputProps={{ - 'data-testid': 'broker-code-test', - }} - required - /> - - ) : null} - - + return ( + <> + + + {t('addEditStationPage.title')} + - {connectionType === ConnectionType.SYNC && ( - <> - - } - /> - - - - {testRtResult !== undefined && - testRtResult.testResult === TestResultEnum.SUCCESS ? ( - - ) : ( - '' - )} - - ), - }} - /> - - - {validatingRt ? ( - - ) : ( - isTesting && ( - validateRtEndpoint()} - sx={{color: 'primary.main'}} - weight="default" - data-testid="test-rt-endpoint-test" - endIcon={} - > - {t(`${componentPath}.testStation`)} - - ) - )} - - - - - - {testRedirectResult !== undefined && - testRedirectResult.testResult === TestResultEnum.SUCCESS ? ( - - ) : ( - '' - )} - - ), - }} - /> - - - {validatingRedirect ? ( - - ) : ( - isTesting && ( - - ) - )} - - - + + {t('stationDetailPageValidation.configuration.subtitle')} + - - } - /> - - - - {testPofResult !== undefined && - testPofResult.testResult === TestResultEnum.SUCCESS && ( - - )} - - ), - }} - /> - - - {validatingPof ? ( - - ) : ( - isTesting && ( - validatePofEndpoint()} - sx={{color: 'primary.main'}} - weight="default" - data-testid="test-pof-endpoint-test" - endIcon={} - > - {t(`${componentPath}.testStation`)} - - ) - )} - - - - - - - {t(`${componentPath}.fields.primitiveVersion`)} - - - - - - - - )} - + + + } + isRequired + /> + + + {t('general.discoverMore')} + + + + + + handleChangeConnectionType(e?.target?.value)} + data-testid="connection-type-radio-group" + value={connectionType} + > + } + label={} + sx={{ pr: 8 }} + disabled={userIsPagopaOperator} + /> + } + label={} + disabled={userIsPagopaOperator} + /> + + + + + + } + isRequired + /> + + + formik.handleChange(e)} + error={formik.touched.stationCode && Boolean(formik.errors.stationCode)} + helperText={formik.touched.stationCode && formik.errors.stationCode} + inputProps={{ + 'data-testid': 'station-code-test', + }} + required + /> + {userIsPagopaOperator && formAction !== StationFormAction.Create ? ( - + formik.handleChange(e)} + error={formik.touched.brokerCode && Boolean(formik.errors.brokerCode)} + helperText={formik.touched.brokerCode && formik.errors.brokerCode} + inputProps={{ + 'data-testid': 'broker-code-test', + }} + required /> - ) : ( - <> - )} - - - - - - - - - - L’ente riceverà una notifica di conferma attivazione della stazione. -
- - ) : ( - - Un operatore PagoPA revisionerà le informazioni inserite nella stazione prima di - approvare. Riceverai una notifica a revisione completata. -
-
+ onClick={() => validateRtEndpoint()} + sx={{ color: 'primary.main' }} + weight="default" + data-testid="test-rt-endpoint-test" + endIcon={} + > + {t(`${componentPath}.testStation`)} + ) - } - openConfirmModal={showConfirmModal} - onConfirmLabel={userIsPagopaOperator ? t('general.confirm') : t('general.send')} - onCloseLabel={t('general.turnBack')} - handleCloseConfirmModal={() => setShowConfirmModal(false)} - handleConfrimSubmit={async () => { - await submit(formik.values); - setShowConfirmModal(false); - }} - /> - - ); + )} +
+ + + + + {testRedirectResult !== undefined && + testRedirectResult.testResult === TestResultEnum.SUCCESS ? ( + + ) : ( + '' + )} + + ), + }} + /> + + + {validatingRedirect ? ( + + ) : ( + isTesting && ( + + ) + )} + + +
+ + + } + /> + + + + {testPofResult !== undefined && + testPofResult.testResult === TestResultEnum.SUCCESS && ( + + )} + + ), + }} + /> + + + {validatingPof ? ( + + ) : ( + isTesting && ( + validatePofEndpoint()} + sx={{ color: 'primary.main' }} + weight="default" + data-testid="test-pof-endpoint-test" + endIcon={} + > + {t(`${componentPath}.testStation`)} + + ) + )} + + + + + + + {t(`${componentPath}.fields.primitiveVersion`)} + + + + + + + + )} +
+ + {userIsPagopaOperator && formAction !== StationFormAction.Create ? ( + + ) : ( + <> + )} + + + + + + + + + + L’ente riceverà una notifica di conferma attivazione della stazione. +
+ + ) : ( + + Un operatore PagoPA revisionerà le informazioni inserite nella stazione prima di + approvare. Riceverai una notifica a revisione completata. +
+
+ ) + } + openConfirmModal={showConfirmModal} + onConfirmLabel={userIsPagopaOperator ? t('general.confirm') : t('general.send')} + onCloseLabel={t('general.turnBack')} + handleCloseConfirmModal={() => setShowConfirmModal(false)} + handleConfrimSubmit={async () => { + await submit(formik.values); + setShowConfirmModal(false); + }} + /> + + ); }; export default AddEditStationForm;