diff --git a/.env b/.env index 9ef0c84..ef5dcea 100644 --- a/.env +++ b/.env @@ -4,4 +4,5 @@ REACT_APP_API_ADDRESS=https://api-dev-gepafin.memento.credit REACT_APP_LOGO_FILENAME=gepafin-logo.svg REACT_APP_FAVICON_FILENAME=gepafin-favicon.ico REACT_APP_HUB_ID=p4lk3bcx1RStqTaIVVbXs -REACT_APP_EVALUATION_FLOW_ID=1 \ No newline at end of file +REACT_APP_EVALUATION_FLOW_ID=1 +REACT_APP_LOCAL_DEVELOPMENT=1 \ No newline at end of file diff --git a/package.json b/package.json index e15d21d..e58a0a4 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,8 @@ "@date-fns/tz": "1.1.2", "@emailjs/browser": "^4.4.1", "@emotion/styled": "11.13.0", - "@number-flow/react": "0.2.0", - "@sentry/browser": "^8.41.0", + "@number-flow/react": "0.4.2", + "@sentry/browser": "^8.42.0", "@tanstack/react-table": "^8.20.5", "@wordpress/i18n": "5.8.0", "@wordpress/react-i18n": "4.8.0", diff --git a/src/components/ErrorBoundary/index.js b/src/components/ErrorBoundary/index.js new file mode 100644 index 0000000..4ac790c --- /dev/null +++ b/src/components/ErrorBoundary/index.js @@ -0,0 +1,41 @@ +import React, { Component } from 'react'; +import * as Sentry from '@sentry/browser'; + +const LOCAL_DEVELOPMENT = process.env.REACT_APP_LOCAL_DEVELOPMENT; + +class ErrorBoundary extends Component { + constructor(props) { + super(props); + + this.state = { + builderError: false + }; + } + + static getDerivedStateFromError(error) { + try { + if (LOCAL_DEVELOPMENT !== '1') { + Sentry.init({ + dsn: "https://e7b2134f7d816f663bb83e51b106a694@o4508381921738752.ingest.de.sentry.io/4508381935501392", + environment: process.env.NODE_ENV || "development" + }); + + Sentry.captureException(error); + } + } catch (err) { + console.log('err') + console.log(err); + } + return { builderError: true }; + } + + render() { + if (this.state.builderError) { + return
Error
; + } + + return this.props.children; + } +} + +export default ErrorBoundary; \ No newline at end of file diff --git a/src/components/ProtectedRoute/index.js b/src/components/ProtectedRoute/index.js index f50b3f8..a5620f8 100644 --- a/src/components/ProtectedRoute/index.js +++ b/src/components/ProtectedRoute/index.js @@ -3,6 +3,7 @@ import { Navigate, Outlet } from 'react-router-dom'; // tools import AuthenticationService from '../../service/authentication-service'; +import ErrorBoundary from '../ErrorBoundary'; const ProtectedRoute = () => { @@ -22,7 +23,7 @@ const ProtectedRoute = () => { return (); }*/ - return ; + return ; } export default ProtectedRoute; \ No newline at end of file diff --git a/src/helpers/formatDateString.js b/src/helpers/formatDateString.js index 9c08c55..9690a1b 100644 --- a/src/helpers/formatDateString.js +++ b/src/helpers/formatDateString.js @@ -4,7 +4,6 @@ * @return {string} */ const formatDateString = (date) => { - console.log('date', date); const year = date.getFullYear(); const month = String(date.getMonth() + 1).padStart(2, '0'); const day = String(date.getDate()).padStart(2, '0'); diff --git a/src/pages/AddCompany/index.js b/src/pages/AddCompany/index.js index 57d6d83..8f30a74 100644 --- a/src/pages/AddCompany/index.js +++ b/src/pages/AddCompany/index.js @@ -22,6 +22,8 @@ import CompanyService from '../../service/company-service'; import { isPIVA, isEmail, isEmailPEC } from '../../helpers/validators'; import set404FromErrorResponse from '../../helpers/set404FromErrorResponse'; +const APP_EVALUATION_FLOW_ID = process.env.REACT_APP_EVALUATION_FLOW_ID; + const AddCompany = () => { const navigate = useNavigate(); const isAsyncRequest = useStore().main.isAsyncRequest(); @@ -33,12 +35,14 @@ const AddCompany = () => { handleSubmit, formState: { errors }, setValue, - watch + watch, + getValues } = useForm({ defaultValues: {}, mode: 'onChange' }); const isPiva = watch('vatNumber'); + //const isPiva = watch('vatNumber'); const setEmptyValues = () => { const formData = { @@ -136,6 +140,11 @@ const AddCompany = () => { storeSet.main.unsetAsyncRequest(); } + const shouldDisableFiscalCode = () => { + const formData = getValues(); + return !formData.type || formData.type && formData.type === 'giuridica'; + } + useEffect(() => { setInputPiva(isPiva); }, [isPiva]); @@ -143,7 +152,7 @@ const AddCompany = () => { useEffect(() => { checkVatNumber(debouncedPivaValue); }, [debouncedPivaValue]) - +console.log('APP_EVALUATION_FLOW_ID', APP_EVALUATION_FLOW_ID) return (
@@ -174,6 +183,23 @@ const AddCompany = () => { />
+ {APP_EVALUATION_FLOW_ID === '2' + ?
+ +
: null} +
{ config={{ required: __('È obbligatorio', 'gepafin') }} /> - + {APP_EVALUATION_FLOW_ID === '1' + ? + : }
diff --git a/src/pages/Applications/index.js b/src/pages/Applications/index.js index 08b1012..ad3393f 100644 --- a/src/pages/Applications/index.js +++ b/src/pages/Applications/index.js @@ -5,6 +5,7 @@ import { useNavigate } from 'react-router-dom'; // components import MyLatestSubmissionsTable from '../DashboardBeneficiario/components/MyLatestSubmissionsTable'; import { Button } from 'primereact/button'; +import ErrorBoundary from '../../components/ErrorBoundary'; const Applications = () => { const navigate = useNavigate(); @@ -22,7 +23,7 @@ const Applications = () => {
- +
diff --git a/src/pages/BandiBeneficiario/index.js b/src/pages/BandiBeneficiario/index.js index be925d3..5a191be 100644 --- a/src/pages/BandiBeneficiario/index.js +++ b/src/pages/BandiBeneficiario/index.js @@ -8,6 +8,7 @@ import { useStore } from '../../store'; // components import AllBandiAccordion from './components/AllBandiAccordion'; +import ErrorBoundary from '../../components/ErrorBoundary'; const BandiBeneficiario = () => { const chosenCompanyId = useStore().main.chosenCompanyId(); @@ -34,7 +35,7 @@ const BandiBeneficiario = () => { : null}
- +
) diff --git a/src/pages/DashboardBeneficiario/index.js b/src/pages/DashboardBeneficiario/index.js index 66ac510..cc12f6e 100644 --- a/src/pages/DashboardBeneficiario/index.js +++ b/src/pages/DashboardBeneficiario/index.js @@ -14,6 +14,7 @@ import DashboardService from '../../service/dashboard-service'; import LatestBandiTable from './components/LatestBandiTable'; import MyLatestSubmissionsTable from './components/MyLatestSubmissionsTable'; import { Button } from 'primereact/button'; +import ErrorBoundary from '../../components/ErrorBoundary'; const DashboardBeneficiario = () => { const navigate = useNavigate(); @@ -85,7 +86,7 @@ const DashboardBeneficiario = () => {

{__('Domande in lavorazione', 'gepafin')}

- +
@@ -105,7 +106,7 @@ const DashboardBeneficiario = () => {

{__('Bandi disponibili', 'gepafin')}

- +
diff --git a/src/service/network-service.js b/src/service/network-service.js index c2c9b22..fa0ef72 100644 --- a/src/service/network-service.js +++ b/src/service/network-service.js @@ -1,6 +1,7 @@ import { storeGet } from '../store'; import * as Sentry from "@sentry/browser"; +const LOCAL_DEVELOPMENT = process.env.REACT_APP_LOCAL_DEVELOPMENT; export class NetworkService { static TOKEN_KEY @@ -9,19 +10,21 @@ export class NetworkService { static logApiError = (endpoint, status = 0, resp) => { try { if ([500].includes(status)) { - Sentry.init({ - dsn: "https://e7b2134f7d816f663bb83e51b106a694@o4508381921738752.ingest.de.sentry.io/4508381935501392", - environment: process.env.NODE_ENV || "development" - }); + if (LOCAL_DEVELOPMENT !== '1') { + Sentry.init({ + dsn: "https://e7b2134f7d816f663bb83e51b106a694@o4508381921738752.ingest.de.sentry.io/4508381935501392", + environment: process.env.NODE_ENV || "development" + }); - const error = new Error(`Status ${status}`); - Sentry.captureException(`Error in endpoint: ${endpoint}`, { - level: 'error', - extra: { - originalError: error, - details: resp - } - }); + const error = new Error(`Status ${status}`); + Sentry.captureException(`Error in endpoint: ${endpoint}`, { + level: 'error', + extra: { + originalError: error, + details: resp + } + }); + } } } catch (err) { console.log(err);