- saving progress;
This commit is contained in:
3
.env
3
.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
|
||||
REACT_APP_EVALUATION_FLOW_ID=1
|
||||
REACT_APP_LOCAL_DEVELOPMENT=1
|
||||
@@ -8,7 +8,8 @@
|
||||
"@date-fns/tz": "1.1.2",
|
||||
"@emailjs/browser": "^4.4.1",
|
||||
"@emotion/styled": "11.13.0",
|
||||
"@number-flow/react": "0.2.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",
|
||||
|
||||
41
src/components/ErrorBoundary/index.js
Normal file
41
src/components/ErrorBoundary/index.js
Normal file
@@ -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 <div>Error</div>;
|
||||
}
|
||||
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
export default ErrorBoundary;
|
||||
@@ -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 (<Navigate to={'/'} replace/>);
|
||||
}*/
|
||||
|
||||
return <Outlet/>;
|
||||
return <ErrorBoundary><Outlet/></ErrorBoundary>;
|
||||
}
|
||||
|
||||
export default ProtectedRoute;
|
||||
@@ -35,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 = {
|
||||
@@ -138,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]);
|
||||
@@ -145,7 +152,7 @@ const AddCompany = () => {
|
||||
useEffect(() => {
|
||||
checkVatNumber(debouncedPivaValue);
|
||||
}, [debouncedPivaValue])
|
||||
|
||||
console.log('APP_EVALUATION_FLOW_ID', APP_EVALUATION_FLOW_ID)
|
||||
return (
|
||||
<div className="appPage">
|
||||
<div className="appPage__pageHeader">
|
||||
@@ -176,6 +183,23 @@ const AddCompany = () => {
|
||||
/>
|
||||
</div>
|
||||
|
||||
{APP_EVALUATION_FLOW_ID === '2'
|
||||
? <div className="appForm__cols">
|
||||
<FormField
|
||||
type="radio"
|
||||
fieldName="type"
|
||||
label={__('Type', 'gepafin')}
|
||||
control={control}
|
||||
errors={errors}
|
||||
config={{ required: __('È obbligatorio', 'gepafin') }}
|
||||
defaultValue="giuridica"
|
||||
options={[
|
||||
{ name: 'giuridica', label: 'Giuridica' },
|
||||
{ name: 'fisica', label: 'Fisica' },
|
||||
]}
|
||||
/>
|
||||
</div> : null}
|
||||
|
||||
<div className="appForm__cols">
|
||||
<FormField
|
||||
type="textinput"
|
||||
@@ -186,15 +210,25 @@ const AddCompany = () => {
|
||||
config={{ required: __('È obbligatorio', 'gepafin') }}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
type="textinput"
|
||||
disabled={APP_EVALUATION_FLOW_ID === '1'}
|
||||
fieldName="codiceFiscale"
|
||||
label={__('Codice fiscale', 'gepafin')}
|
||||
control={control}
|
||||
errors={errors}
|
||||
config={{ required: __('È obbligatorio', 'gepafin') }}
|
||||
/>
|
||||
{APP_EVALUATION_FLOW_ID === '1'
|
||||
? <FormField
|
||||
type="textinput"
|
||||
disabled
|
||||
fieldName="codiceFiscale"
|
||||
label={__('Codice fiscale', 'gepafin')}
|
||||
control={control}
|
||||
errors={errors}
|
||||
config={{ required: __('È obbligatorio', 'gepafin') }}
|
||||
/>
|
||||
: <FormField
|
||||
type="textinput"
|
||||
disabled={shouldDisableFiscalCode()}
|
||||
fieldName="codiceFiscale"
|
||||
label={__('Codice fiscale', 'gepafin')}
|
||||
control={control}
|
||||
errors={errors}
|
||||
config={{ required: __('È obbligatorio', 'gepafin') }}
|
||||
/>}
|
||||
</div>
|
||||
|
||||
<div className="appForm__cols">
|
||||
|
||||
@@ -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 = () => {
|
||||
<div className="appPage__spacer"></div>
|
||||
|
||||
<div className="appPageSection">
|
||||
<MyLatestSubmissionsTable/>
|
||||
<ErrorBoundary><MyLatestSubmissionsTable/></ErrorBoundary>
|
||||
</div>
|
||||
|
||||
<div className="appPage__spacer"></div>
|
||||
|
||||
@@ -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}
|
||||
|
||||
<div className="appPageSection">
|
||||
<AllBandiAccordion/>
|
||||
<ErrorBoundary><AllBandiAccordion/></ErrorBoundary>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -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 = () => {
|
||||
|
||||
<div className="appPageSection">
|
||||
<h2>{__('Domande in lavorazione', 'gepafin')}</h2>
|
||||
<MyLatestSubmissionsTable/>
|
||||
<ErrorBoundary><MyLatestSubmissionsTable/></ErrorBoundary>
|
||||
</div>
|
||||
|
||||
<div className="appPage__spacer"></div>
|
||||
@@ -105,7 +106,7 @@ const DashboardBeneficiario = () => {
|
||||
|
||||
<div className="appPageSection">
|
||||
<h2>{__('Bandi disponibili', 'gepafin')}</h2>
|
||||
<LatestBandiTable/>
|
||||
<ErrorBoundary><LatestBandiTable/></ErrorBoundary>
|
||||
</div>
|
||||
|
||||
<div className="appPage__spacer"></div>
|
||||
|
||||
@@ -1,9 +1,36 @@
|
||||
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
|
||||
static REFRESH_TOKEN_KEY
|
||||
|
||||
static logApiError = (endpoint, status = 0, resp) => {
|
||||
try {
|
||||
if ([500].includes(status)) {
|
||||
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
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
|
||||
static postEmptyResponse = (url, body, callback, errorCallback) => {
|
||||
fetch(url, {
|
||||
method: 'POST',
|
||||
@@ -77,10 +104,12 @@ export class NetworkService {
|
||||
return { response: await response.json(), status: status }
|
||||
})
|
||||
.then(data => {
|
||||
if (data.status >= 400 && data.status <= 599)
|
||||
if (data.status >= 400 && data.status <= 599) {
|
||||
errorCallback(data.response)
|
||||
else
|
||||
this.logApiError(url, data.status, data.response);
|
||||
} else {
|
||||
callback(data.response)
|
||||
}
|
||||
})
|
||||
.catch(err => errorCallback(err));
|
||||
};
|
||||
@@ -118,10 +147,12 @@ export class NetworkService {
|
||||
return { response: await response.json(), status: status }
|
||||
})
|
||||
.then(data => {
|
||||
if (data.status >= 400 && data.status <= 599)
|
||||
if (data.status >= 400 && data.status <= 599) {
|
||||
errorCallback(data.response)
|
||||
else
|
||||
this.logApiError(url, data.status, data.response);
|
||||
} else {
|
||||
callback(data.response)
|
||||
}
|
||||
})
|
||||
.catch(err => errorCallback(err));
|
||||
};
|
||||
@@ -159,10 +190,12 @@ export class NetworkService {
|
||||
return { response: await response.blob(), status: status }
|
||||
})
|
||||
.then(data => {
|
||||
if (data.status >= 400 && data.status <= 599)
|
||||
if (data.status >= 400 && data.status <= 599) {
|
||||
errorCallback(data.response)
|
||||
else
|
||||
this.logApiError(url, data.status, data.response);
|
||||
} else {
|
||||
callback(data.response)
|
||||
}
|
||||
})
|
||||
.catch(err => errorCallback(err));
|
||||
};
|
||||
@@ -198,10 +231,12 @@ export class NetworkService {
|
||||
return { response: await response.json(), status: status }
|
||||
})
|
||||
.then(data => {
|
||||
if (data.status >= 400 && data.status <= 599)
|
||||
if (data.status >= 400 && data.status <= 599) {
|
||||
errorCallback(data.response)
|
||||
else
|
||||
this.logApiError(url, data.status, data.response);
|
||||
} else {
|
||||
callback(data.response)
|
||||
}
|
||||
})
|
||||
.catch(err => errorCallback(err));
|
||||
};
|
||||
@@ -261,10 +296,12 @@ export class NetworkService {
|
||||
return { response: await response.json(), status: status }
|
||||
})
|
||||
.then(data => {
|
||||
if (data.status >= 400 && data.status <= 599)
|
||||
if (data.status >= 400 && data.status <= 599) {
|
||||
errorCallback(data.response)
|
||||
else
|
||||
this.logApiError(url, data.status, data.response);
|
||||
} else {
|
||||
callback(data.response)
|
||||
}
|
||||
})
|
||||
.catch(err => errorCallback(err));
|
||||
};
|
||||
@@ -381,12 +418,15 @@ export class NetworkService {
|
||||
})
|
||||
.then(data => {
|
||||
if (data.status >= 400 && data.status <= 599) {
|
||||
errorCallback(data.response)
|
||||
errorCallback(data.response);
|
||||
this.logApiError(url, data.status, data.response);
|
||||
} else {
|
||||
callback(data.response)
|
||||
}
|
||||
})
|
||||
.catch(err => errorCallback(err));
|
||||
.catch(err => {
|
||||
errorCallback(err)
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
@@ -422,10 +462,12 @@ export class NetworkService {
|
||||
return { response: await response.blob(), status: status }
|
||||
})
|
||||
.then(data => {
|
||||
if (data.status >= 400 && data.status <= 599)
|
||||
if (data.status >= 400 && data.status <= 599) {
|
||||
errorCallback(data.response)
|
||||
else
|
||||
this.logApiError(url, data.status, data.response);
|
||||
} else {
|
||||
callback(data.response)
|
||||
}
|
||||
})
|
||||
.catch(err => errorCallback(err));
|
||||
};
|
||||
@@ -504,10 +546,12 @@ export class NetworkService {
|
||||
return { response: await response.json(), status: status }
|
||||
})
|
||||
.then(data => {
|
||||
if (data.status >= 400 && data.status <= 599)
|
||||
if (data.status >= 400 && data.status <= 599) {
|
||||
errorCallback(data.response)
|
||||
else
|
||||
this.logApiError(url, data.status, data.response);
|
||||
} else {
|
||||
callback(data.response)
|
||||
}
|
||||
})
|
||||
.catch(err => errorCallback(err));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user