- added add company page;
- connected api for delega download, upload and deleting;
This commit is contained in:
14
src/App.js
14
src/App.js
@@ -14,6 +14,7 @@ const i18n = createI18n({}, 'gepafin');
|
|||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const role = useStore().main.getRole();
|
const role = useStore().main.getRole();
|
||||||
|
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||||
|
|
||||||
const callback = (data) => {
|
const callback = (data) => {
|
||||||
//console.log('app /me', data);
|
//console.log('app /me', data);
|
||||||
@@ -30,7 +31,7 @@ function App() {
|
|||||||
storeSet.main.unsetAsyncRequest();
|
storeSet.main.unsetAsyncRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
const companyCallback = (data) => {
|
/*const companyCallback = (data) => {
|
||||||
if (data.status === 'SUCCESS') {
|
if (data.status === 'SUCCESS') {
|
||||||
storeSet.main.companies(data.data);
|
storeSet.main.companies(data.data);
|
||||||
}
|
}
|
||||||
@@ -40,13 +41,16 @@ function App() {
|
|||||||
const errCompanyCallback = (data) => {
|
const errCompanyCallback = (data) => {
|
||||||
storeSet.main.doLogout();
|
storeSet.main.doLogout();
|
||||||
storeSet.main.unsetAsyncRequest();
|
storeSet.main.unsetAsyncRequest();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (role === 'ROLE_BENEFICIARY') {
|
if (role === 'ROLE_BENEFICIARY') {
|
||||||
storeSet.main.setAsyncRequest();
|
//storeSet.main.setAsyncRequest();
|
||||||
const userData = storeGet.main.userData();
|
const userData = storeGet.main.userData();
|
||||||
CompanyService.getCompanyForUser(userData.id, companyCallback, errCompanyCallback)
|
if (userData.companies) {
|
||||||
|
storeSet.main.companies(userData.companies);
|
||||||
|
}
|
||||||
|
//CompanyService.getCompanyForUser(userData.id, companyCallback, errCompanyCallback)
|
||||||
}
|
}
|
||||||
}, [role])
|
}, [role])
|
||||||
|
|
||||||
@@ -65,7 +69,7 @@ function App() {
|
|||||||
return (
|
return (
|
||||||
<I18nProvider i18n={i18n}>
|
<I18nProvider i18n={i18n}>
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<Routes role={role}/>
|
<Routes role={role} chosenCompanyId={chosenCompanyId}/>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
</I18nProvider>
|
</I18nProvider>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,22 +7,21 @@ import FileUploadService from '../../service/file-upload-service';
|
|||||||
import { FileUpload } from 'primereact/fileupload';
|
import { FileUpload } from 'primereact/fileupload';
|
||||||
import { Tag } from 'primereact/tag';
|
import { Tag } from 'primereact/tag';
|
||||||
import { Button } from 'primereact/button';
|
import { Button } from 'primereact/button';
|
||||||
|
import CompanyService from '../../service/company-service';
|
||||||
|
|
||||||
const FileuploadStandalone = ({
|
const FileuploadDelega = ({
|
||||||
fieldName,
|
fieldName,
|
||||||
setDataFn,
|
setDataFn,
|
||||||
defaultValue = [],
|
defaultValue = [],
|
||||||
accept = ['image/*'],
|
accept = [],
|
||||||
doctype = 'images',
|
|
||||||
maxSize = 100000000,
|
maxSize = 100000000,
|
||||||
emptyText = __('Trascina qui il tuo file', 'gepafin'),
|
emptyText = __('Trascina qui il tuo file', 'gepafin'),
|
||||||
chooseLabel = __('Aggiungi immagine', 'gepafin'),
|
chooseLabel = __('Aggiungi delega', 'gepafin'),
|
||||||
multiple = false,
|
multiple = false,
|
||||||
sourceId = 0,
|
companyId = 0,
|
||||||
source = 'application',
|
|
||||||
disabled = false
|
disabled = false
|
||||||
}) => {
|
}) => {
|
||||||
const [stateFieldData, setStateFieldData] = useState([]);
|
const [stateFieldData, setStateFieldData] = useState({});
|
||||||
const [acceptFormats, setAcceptFormats] = useState('');
|
const [acceptFormats, setAcceptFormats] = useState('');
|
||||||
const inputRef = useRef();
|
const inputRef = useRef();
|
||||||
|
|
||||||
@@ -31,10 +30,7 @@ const FileuploadStandalone = ({
|
|||||||
for (const file of event.files) {
|
for (const file of event.files) {
|
||||||
formData.append('file', file)
|
formData.append('file', file)
|
||||||
}
|
}
|
||||||
FileUploadService.uploadFile(sourceId, formData, callback, errorCallback, [
|
CompanyService.uploadCompanyDelega(companyId, formData, callback, errorCallback);
|
||||||
['documentType', doctype.toUpperCase()],
|
|
||||||
['sourceType', source.toUpperCase()]
|
|
||||||
]);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const callback = (data) => {
|
const callback = (data) => {
|
||||||
@@ -51,11 +47,12 @@ const FileuploadStandalone = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const itemTemplate = (file) => {
|
const itemTemplate = (file) => {
|
||||||
|
console.log('file', file)
|
||||||
return (
|
return (
|
||||||
<div className="appForm__fileUploadItem">
|
<div className="appForm__fileUploadItem">
|
||||||
<div>
|
<div>
|
||||||
<span className="appForm__fileUploadItemName">
|
<span className="appForm__fileUploadItemName">
|
||||||
{file.name}
|
{file.fileName}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@@ -77,11 +74,10 @@ const FileuploadStandalone = ({
|
|||||||
|
|
||||||
const onTemplateRemove = (file) => {
|
const onTemplateRemove = (file) => {
|
||||||
if (file.id) {
|
if (file.id) {
|
||||||
FileUploadService.deleteFile(
|
CompanyService.deleteDelega(
|
||||||
{},
|
companyId,
|
||||||
(data) => dCallback(data, file.id),
|
(data) => dCallback(data, file.id),
|
||||||
dErrorCallback,
|
dErrorCallback
|
||||||
[['id', file.id]]
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const files = inputRef.current.getFiles()
|
const files = inputRef.current.getFiles()
|
||||||
@@ -120,7 +116,9 @@ const FileuploadStandalone = ({
|
|||||||
const MIMEtype = new RegExp(acceptFormats);
|
const MIMEtype = new RegExp(acceptFormats);
|
||||||
|
|
||||||
return Array.prototype.every.call(files, function passesAcceptedFormat(file) {
|
return Array.prototype.every.call(files, function passesAcceptedFormat(file) {
|
||||||
return MIMEtype.test(file.type);
|
const fileExtension = `.${file.name.split('.').pop().toLowerCase()}`;
|
||||||
|
const fileType = file.type;
|
||||||
|
return MIMEtype.test(fileType) || MIMEtype.test(fileExtension);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,6 +126,13 @@ const FileuploadStandalone = ({
|
|||||||
setStateFieldData(defaultValue);
|
setStateFieldData(defaultValue);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (inputRef.current) {
|
||||||
|
inputRef.current.setUploadedFiles(multiple ? defaultValue : [defaultValue]);
|
||||||
|
console.log('inputRef.current', inputRef.current, multiple ? defaultValue : [defaultValue])
|
||||||
|
}
|
||||||
|
}, [defaultValue]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// eslint-disable-next-line no-useless-escape
|
// eslint-disable-next-line no-useless-escape
|
||||||
setAcceptFormats(accept.join(',').replace(/\*/g, '.\*').replace(/,/g, '|'));
|
setAcceptFormats(accept.join(',').replace(/\*/g, '.\*').replace(/,/g, '|'));
|
||||||
@@ -135,13 +140,14 @@ const FileuploadStandalone = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (inputRef.current) {
|
if (inputRef.current) {
|
||||||
inputRef.current.setUploadedFiles(stateFieldData);
|
inputRef.current.setUploadedFiles(multiple ? stateFieldData : [stateFieldData]);
|
||||||
}
|
}
|
||||||
setDataFn(fieldName, [...stateFieldData], { shouldValidate: true });
|
|
||||||
|
setDataFn(fieldName, multiple ? [...stateFieldData] : stateFieldData, { shouldValidate: true });
|
||||||
}, [stateFieldData])
|
}, [stateFieldData])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
sourceId && sourceId !== 0
|
companyId && companyId !== 0
|
||||||
? <FileUpload
|
? <FileUpload
|
||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
@@ -164,4 +170,4 @@ const FileuploadStandalone = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default FileuploadStandalone;
|
export default FileuploadDelega;
|
||||||
@@ -126,7 +126,9 @@ const Fileupload = ({
|
|||||||
const MIMEtype = new RegExp(acceptFormats);
|
const MIMEtype = new RegExp(acceptFormats);
|
||||||
|
|
||||||
return Array.prototype.every.call(files, function passesAcceptedFormat(file) {
|
return Array.prototype.every.call(files, function passesAcceptedFormat(file) {
|
||||||
return MIMEtype.test(file.type);
|
const fileExtension = `.${file.name.split('.').pop().toLowerCase()}`;
|
||||||
|
const fileType = file.type;
|
||||||
|
return MIMEtype.test(fileType) || MIMEtype.test(fileExtension);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,9 @@ const FileuploadAsync = ({
|
|||||||
const MIMEtype = new RegExp(acceptFormats);
|
const MIMEtype = new RegExp(acceptFormats);
|
||||||
|
|
||||||
return Array.prototype.every.call(files, function passesAcceptedFormat(file) {
|
return Array.prototype.every.call(files, function passesAcceptedFormat(file) {
|
||||||
return MIMEtype.test(file.type);
|
const fileExtension = `.${file.name.split('.').pop().toLowerCase()}`;
|
||||||
|
const fileType = file.type;
|
||||||
|
return MIMEtype.test(fileType) || MIMEtype.test(fileExtension);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,12 +54,19 @@ const TopBarProfileMenu = ({ menuLeftRef }) => {
|
|||||||
command: () => {
|
command: () => {
|
||||||
navigate('/profilo-aziendale')
|
navigate('/profilo-aziendale')
|
||||||
},
|
},
|
||||||
enable: !intersection(permissions, ['MANAGE_TENDERS']).length
|
enable: !intersection(permissions, ['MANAGE_TENDERS']).length && companies.length > 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: __('Seleziona azienda', 'gepafin'),
|
label: __('Seleziona azienda', 'gepafin'),
|
||||||
items: companyItems,
|
items: companyItems,
|
||||||
enable: true
|
enable: companies.length
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __('Aggiungi Azienda', 'gepafin'),
|
||||||
|
command: () => {
|
||||||
|
navigate('/agguingi-azienda')
|
||||||
|
},
|
||||||
|
enable: !intersection(permissions, ['MANAGE_TENDERS']).length
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
separator: true,
|
separator: true,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
export const mimeTypes = [
|
export const mimeTypes = [
|
||||||
{ name: 'PDF', code: 'application/pdf' },
|
{ name: 'PDF', code: 'application/pdf' },
|
||||||
/*{ name: 'Firmato PDF o Word', code: 'application/pkcs7-mime' },*/
|
{ name: 'p7m', ext: '.p7m,application/pkcs7-mime,application/x-pkcs7-mime' },
|
||||||
{ name: 'ZIP', code: 'application/zip' },
|
{ name: 'ZIP', code: 'application/zip' },
|
||||||
{ name: 'Immagine', code: 'image/*' },
|
{ name: 'Immagine', code: 'image/*' },
|
||||||
{
|
{
|
||||||
|
|||||||
334
src/pages/AddCompany/index.js
Normal file
334
src/pages/AddCompany/index.js
Normal file
@@ -0,0 +1,334 @@
|
|||||||
|
import React, { useEffect, useRef } from 'react';
|
||||||
|
import { __ } from '@wordpress/i18n';
|
||||||
|
import { isEmpty, isNil, head } from 'ramda';
|
||||||
|
import { klona } from 'klona';
|
||||||
|
import { useDebounce } from 'primereact/hooks';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
|
// store
|
||||||
|
import { storeSet, useStore, storeGet } from '../../store';
|
||||||
|
|
||||||
|
// components
|
||||||
|
import { Messages } from 'primereact/messages';
|
||||||
|
import FormField from '../../components/FormField';
|
||||||
|
import { Button } from 'primereact/button';
|
||||||
|
import { useForm } from 'react-hook-form';
|
||||||
|
import BlockingOverlay from '../../components/BlockingOverlay';
|
||||||
|
|
||||||
|
// api
|
||||||
|
import CompanyService from '../../service/company-service';
|
||||||
|
|
||||||
|
// tools
|
||||||
|
import { isPIVA, isEmail, isEmailPEC } from '../../helpers/validators';
|
||||||
|
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||||
|
|
||||||
|
const AddCompany = () => {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||||
|
const infoMsgs = useRef(null);
|
||||||
|
const [, debouncedPivaValue, setInputPiva] = useDebounce('', 1000);
|
||||||
|
|
||||||
|
const {
|
||||||
|
control,
|
||||||
|
handleSubmit,
|
||||||
|
formState: { errors },
|
||||||
|
setValue,
|
||||||
|
getValues,
|
||||||
|
watch
|
||||||
|
} = useForm({
|
||||||
|
defaultValues: {},
|
||||||
|
mode: 'onChange'
|
||||||
|
});
|
||||||
|
const values = getValues();
|
||||||
|
const emptyValues = Object.values(values).filter(v => isEmpty(v) || isNil(v)).length;
|
||||||
|
const isPiva = watch('vatNumber')
|
||||||
|
|
||||||
|
const setEmptyValues = () => {
|
||||||
|
const formData = {
|
||||||
|
cap: '',
|
||||||
|
pec: '',
|
||||||
|
email: '',
|
||||||
|
city: '',
|
||||||
|
codiceFiscale: '',
|
||||||
|
address: '',
|
||||||
|
companyName: ''
|
||||||
|
}
|
||||||
|
Object.keys(formData).map(k => setValue(k, formData[k]));
|
||||||
|
}
|
||||||
|
|
||||||
|
const onSubmit = (formData) => {
|
||||||
|
infoMsgs.current.clear();
|
||||||
|
storeSet.main.setAsyncRequest();
|
||||||
|
|
||||||
|
CompanyService.createCompany(formData, updateCallback, updateError);
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateCallback = (data) => {
|
||||||
|
if (data.status === 'SUCCESS') {
|
||||||
|
const company = klona(data.data);
|
||||||
|
const companies = storeGet.main.companies();
|
||||||
|
const existingCompany = head(companies.filter(o => o.id === company.id));
|
||||||
|
let newCompanies = [];
|
||||||
|
|
||||||
|
if (existingCompany) {
|
||||||
|
newCompanies = companies.map(o => o.id === company.id ? company : o)
|
||||||
|
} else {
|
||||||
|
newCompanies = [...companies, company];
|
||||||
|
storeSet.main.chosenCompanyId(company.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
storeSet.main.companies(newCompanies);
|
||||||
|
|
||||||
|
if (company.isLegalRepresentant) {
|
||||||
|
navigate('/');
|
||||||
|
} else {
|
||||||
|
navigate('/profilo-aziendale');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
storeSet.main.unsetAsyncRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateError = (data) => {
|
||||||
|
set404FromErrorResponse(data);
|
||||||
|
storeSet.main.unsetAsyncRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
const checkVatNumber = (value) => {
|
||||||
|
infoMsgs.current.clear();
|
||||||
|
const isValid = isPIVA(value);
|
||||||
|
|
||||||
|
if (isValid) {
|
||||||
|
storeSet.main.setAsyncRequest();
|
||||||
|
CompanyService.checkVat(checkVatCallback, errCheckVatCallback, [['vatNumber', value]])
|
||||||
|
} else {
|
||||||
|
setEmptyValues();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const checkVatCallback = (data) => {
|
||||||
|
if (data.status === 'SUCCESS') {
|
||||||
|
const resp = data.data.data;
|
||||||
|
if (!isEmpty(resp)) {
|
||||||
|
const {
|
||||||
|
cap, cf, denominazione, piva, indirizzo, comune, dettaglio: { pec }
|
||||||
|
} = resp;
|
||||||
|
|
||||||
|
const formData = {
|
||||||
|
cap,
|
||||||
|
pec,
|
||||||
|
email: pec,
|
||||||
|
city: comune,
|
||||||
|
codiceFiscale: cf,
|
||||||
|
address: indirizzo,
|
||||||
|
vatNumber: piva,
|
||||||
|
companyName: denominazione
|
||||||
|
}
|
||||||
|
Object.keys(formData).map(k => setValue(k, formData[k]));
|
||||||
|
}
|
||||||
|
//setData(getFormattedBandiData(data.data));
|
||||||
|
} else {
|
||||||
|
setEmptyValues();
|
||||||
|
}
|
||||||
|
storeSet.main.unsetAsyncRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
const errCheckVatCallback = (data) => {
|
||||||
|
setEmptyValues();
|
||||||
|
set404FromErrorResponse(data);
|
||||||
|
storeSet.main.unsetAsyncRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setInputPiva(isPiva);
|
||||||
|
}, [isPiva]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
checkVatNumber(debouncedPivaValue);
|
||||||
|
}, [debouncedPivaValue])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="appPage">
|
||||||
|
<div className="appPage__pageHeader">
|
||||||
|
<h1>{__('Profilo aziendale', 'gepafin')}</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="appPage__spacer"></div>
|
||||||
|
<Messages ref={infoMsgs}/>
|
||||||
|
|
||||||
|
<form id="companyForm" className="appForm" onSubmit={handleSubmit(onSubmit)}>
|
||||||
|
<BlockingOverlay shouldDisplay={isAsyncRequest}/>
|
||||||
|
<div className="appPageSection">
|
||||||
|
<h2>{__('Informazioni aziendali', 'gepafin')}</h2>
|
||||||
|
<p>
|
||||||
|
{__('Inserisci P.IVA e i dati aziendali verranno inseriti automaticamente per le aziende già esistenti', 'gepafin')}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div className="appForm__cols">
|
||||||
|
<FormField
|
||||||
|
type="textinput"
|
||||||
|
/*disabled={true}*/
|
||||||
|
fieldName="companyName"
|
||||||
|
label={__('Ragione Sociale', 'gepafin')}
|
||||||
|
control={control}
|
||||||
|
errors={errors}
|
||||||
|
config={{ required: __('È obbligatorio', 'gepafin') }}
|
||||||
|
placeholder="Nome di azienda"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="appForm__cols">
|
||||||
|
<FormField
|
||||||
|
type="textinput"
|
||||||
|
fieldName="vatNumber"
|
||||||
|
label={__('P.IVA', 'gepafin')}
|
||||||
|
control={control}
|
||||||
|
errors={errors}
|
||||||
|
config={{ required: __('È obbligatorio', 'gepafin') }}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
type="textinput"
|
||||||
|
disabled={true}
|
||||||
|
fieldName="codiceFiscale"
|
||||||
|
label={__('Codice fiscale', 'gepafin')}
|
||||||
|
control={control}
|
||||||
|
errors={errors}
|
||||||
|
config={{ required: __('È obbligatorio', 'gepafin') }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="appForm__cols">
|
||||||
|
<FormField
|
||||||
|
type="textinput"
|
||||||
|
/*disabled={true}*/
|
||||||
|
fieldName="pec"
|
||||||
|
label={__('Email PEC', 'gepafin')}
|
||||||
|
control={control}
|
||||||
|
errors={errors}
|
||||||
|
config={{
|
||||||
|
required: __('È obbligatorio', 'gepafin'),
|
||||||
|
validate: {
|
||||||
|
isEmailPEC
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
type="textinput"
|
||||||
|
/*disabled={true}*/
|
||||||
|
fieldName="email"
|
||||||
|
label={__('Email', 'gepafin')}
|
||||||
|
control={control}
|
||||||
|
errors={errors}
|
||||||
|
config={{
|
||||||
|
required: __('È obbligatorio', 'gepafin'),
|
||||||
|
validate: {
|
||||||
|
isEmail
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/*<FormField
|
||||||
|
type="textinput"
|
||||||
|
fieldName="phoneNumber"
|
||||||
|
label={__('Telefono', 'gepafin')}
|
||||||
|
control={control}
|
||||||
|
errors={errors}
|
||||||
|
config={{ required: __('È obbligatorio', 'gepafin') }}
|
||||||
|
/>*/}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="appForm__cols">
|
||||||
|
<FormField
|
||||||
|
type="textinput"
|
||||||
|
/*disabled={true}*/
|
||||||
|
fieldName="address"
|
||||||
|
label={__('Indirizzo', 'gepafin')}
|
||||||
|
control={control}
|
||||||
|
errors={errors}
|
||||||
|
config={{ required: __('È obbligatorio', 'gepafin') }}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
type="textinput"
|
||||||
|
/*disabled={true}*/
|
||||||
|
fieldName="city"
|
||||||
|
label={__('Città', 'gepafin')}
|
||||||
|
control={control}
|
||||||
|
errors={errors}
|
||||||
|
config={{ required: __('È obbligatorio', 'gepafin') }}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
type="textinput"
|
||||||
|
/*disabled={true}*/
|
||||||
|
fieldName="cap"
|
||||||
|
label={__('CAP', 'gepafin')}
|
||||||
|
control={control}
|
||||||
|
errors={errors}
|
||||||
|
config={{ required: __('È obbligatorio', 'gepafin') }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="appForm__cols">
|
||||||
|
<FormField
|
||||||
|
type="textinput"
|
||||||
|
fieldName="contactName"
|
||||||
|
label={__('Nome di referente aziendale', 'gepafin')}
|
||||||
|
control={control}
|
||||||
|
errors={errors}
|
||||||
|
config={{ required: __('È obbligatorio', 'gepafin') }}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
type="textinput"
|
||||||
|
fieldName="contactEmail"
|
||||||
|
label={__('Email di referente aziendale', 'gepafin')}
|
||||||
|
control={control}
|
||||||
|
errors={errors}
|
||||||
|
config={{
|
||||||
|
required: __('È obbligatorio', 'gepafin'),
|
||||||
|
validate: {
|
||||||
|
isEmail
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="appPageSection">
|
||||||
|
<FormField
|
||||||
|
type="switch"
|
||||||
|
fieldName="isLegalRepresentant"
|
||||||
|
label={__('Sei il Rapprentante Legale dell’azienda?', 'gepafin')}
|
||||||
|
control={control}
|
||||||
|
errors={errors}
|
||||||
|
onLabel={__('Si', 'gepafin')}
|
||||||
|
offLabel={__('No', 'gepafin')}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div className="appPage__spacer"></div>
|
||||||
|
|
||||||
|
<div className="appPageSection__hr">
|
||||||
|
<span>{__('Azioni rapide', 'gepafin')}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="appPageSection">
|
||||||
|
<div className="appPageSection__actions">
|
||||||
|
<Button
|
||||||
|
form="companyForm"
|
||||||
|
disabled={isAsyncRequest || emptyValues}
|
||||||
|
label={__('Salva modifiche', 'gepafin')}
|
||||||
|
icon="pi pi-check" iconPos="right"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AddCompany;
|
||||||
@@ -1,12 +1,19 @@
|
|||||||
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { isEmpty, isNil, pathOr, head } from 'ramda';
|
import { isEmpty, pathOr, head } from 'ramda';
|
||||||
import { klona } from 'klona';
|
import { klona } from 'klona';
|
||||||
import { wrap } from 'object-path-immutable';
|
import { wrap } from 'object-path-immutable';
|
||||||
|
|
||||||
// store
|
// store
|
||||||
import { storeSet, useStore, storeGet } from '../../store';
|
import { storeSet, useStore, storeGet } from '../../store';
|
||||||
|
|
||||||
|
// api
|
||||||
|
import CompanyService from '../../service/company-service';
|
||||||
|
|
||||||
|
// tools
|
||||||
|
import { isPIVA, isEmail, isEmailPEC } from '../../helpers/validators';
|
||||||
|
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||||
|
|
||||||
// components
|
// components
|
||||||
import { Messages } from 'primereact/messages';
|
import { Messages } from 'primereact/messages';
|
||||||
import FormField from '../../components/FormField';
|
import FormField from '../../components/FormField';
|
||||||
@@ -14,17 +21,11 @@ import { Button } from 'primereact/button';
|
|||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import BlockingOverlay from '../../components/BlockingOverlay';
|
import BlockingOverlay from '../../components/BlockingOverlay';
|
||||||
import { InputText } from 'primereact/inputtext';
|
import { InputText } from 'primereact/inputtext';
|
||||||
|
import FileuploadDelega from '../../components/FileuploadDelega';
|
||||||
// api
|
|
||||||
import CompanyService from '../../service/company-service';
|
|
||||||
|
|
||||||
// tools
|
|
||||||
import { isPIVA, isCodiceFiscale, isEmail, isEmailPEC } from '../../helpers/validators';
|
|
||||||
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
|
||||||
import FileuploadStandalone from '../../components/FileuploadStandalone';
|
|
||||||
|
|
||||||
const ProfileCompany = () => {
|
const ProfileCompany = () => {
|
||||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||||
|
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||||
const companies = useStore().main.companies();
|
const companies = useStore().main.companies();
|
||||||
const infoMsgs = useRef(null);
|
const infoMsgs = useRef(null);
|
||||||
const [formInitialData, setFormInitialData] = useState({});
|
const [formInitialData, setFormInitialData] = useState({});
|
||||||
@@ -37,17 +38,13 @@ const ProfileCompany = () => {
|
|||||||
handleSubmit,
|
handleSubmit,
|
||||||
formState: { errors },
|
formState: { errors },
|
||||||
setValue,
|
setValue,
|
||||||
getValues,
|
|
||||||
watch,
|
watch,
|
||||||
register
|
|
||||||
} = useForm({
|
} = useForm({
|
||||||
defaultValues: useMemo(() => {
|
defaultValues: useMemo(() => {
|
||||||
return formInitialData;
|
return formInitialData;
|
||||||
}, [formInitialData]),
|
}, [formInitialData]),
|
||||||
mode: 'onChange'
|
mode: 'onChange'
|
||||||
});
|
});
|
||||||
const values = getValues();
|
|
||||||
const emptyValues = Object.values(values).filter(v => isEmpty(v) || isNil(v)).length;
|
|
||||||
const isLegalRepresentant = watch('isLegalRepresentant')
|
const isLegalRepresentant = watch('isLegalRepresentant')
|
||||||
|
|
||||||
const setEmptyValues = () => {
|
const setEmptyValues = () => {
|
||||||
@@ -67,11 +64,7 @@ const ProfileCompany = () => {
|
|||||||
infoMsgs.current.clear();
|
infoMsgs.current.clear();
|
||||||
storeSet.main.setAsyncRequest();
|
storeSet.main.setAsyncRequest();
|
||||||
|
|
||||||
if (isNil(formData.id)) {
|
CompanyService.updateCompany(formData.id, formData, updateCallback, updateError);
|
||||||
CompanyService.createCompany(formData, updateCallback, updateError);
|
|
||||||
} else {
|
|
||||||
CompanyService.updateCompany(formData.id, formData, updateCallback, updateError);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateCallback = (data) => {
|
const updateCallback = (data) => {
|
||||||
@@ -148,9 +141,47 @@ const ProfileCompany = () => {
|
|||||||
setDelegaData(newDelegaData)
|
setDelegaData(newDelegaData)
|
||||||
}
|
}
|
||||||
|
|
||||||
const setDelegaFile = (data) => {
|
const setDelegaFile = (name, value) => {
|
||||||
console.log('setDelegaFile', data)
|
console.log('setDelegaFile', value)
|
||||||
setDelega(data);
|
setDelega(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
const getDellegaCallback = (data) => {
|
||||||
|
console.log(data)
|
||||||
|
if (data.data) {
|
||||||
|
setDelega(data.data);
|
||||||
|
}
|
||||||
|
storeSet.main.unsetAsyncRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
const errDellegaCallback = () => {
|
||||||
|
storeSet.main.unsetAsyncRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
const downloadDelega = () => {
|
||||||
|
storeSet.main.setAsyncRequest();
|
||||||
|
const data = {
|
||||||
|
codiceFiscale: delegaCodiceFiscale,
|
||||||
|
firstName: delegaFirstName,
|
||||||
|
lastName: delegaLastName
|
||||||
|
}
|
||||||
|
CompanyService.downloadCompanyDelega(formInitialData.id, data, getDellegaDownloadCallback, errDellegaDownloadCallback)
|
||||||
|
}
|
||||||
|
|
||||||
|
const getDellegaDownloadCallback = (data) => {
|
||||||
|
const pdfFile = new Blob([data], { type: 'application/octet-stream' })
|
||||||
|
const url = window.URL.createObjectURL(pdfFile);
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = url;
|
||||||
|
link.setAttribute('download', 'delega.docx');
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
link.remove();
|
||||||
|
storeSet.main.unsetAsyncRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
const errDellegaDownloadCallback = () => {
|
||||||
|
storeSet.main.unsetAsyncRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -159,9 +190,43 @@ const ProfileCompany = () => {
|
|||||||
}, [formInitialData]);
|
}, [formInitialData]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const chosenCompany = pathOr({}, [0], companies);
|
let chosenCompany = {};
|
||||||
setFormInitialData(chosenCompany);
|
|
||||||
}, [companies]);
|
if (chosenCompanyId) {
|
||||||
|
chosenCompany = head(companies.filter(o => o.id === chosenCompanyId));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!chosenCompany) {
|
||||||
|
chosenCompany = pathOr({}, [0], companies);
|
||||||
|
}
|
||||||
|
|
||||||
|
const {
|
||||||
|
cap, codiceFiscale, companyName, vatNumber, address, city, pec, email,
|
||||||
|
contactName, contactEmail, isLegalRepresentant, id
|
||||||
|
} = chosenCompany;
|
||||||
|
const companyData = {
|
||||||
|
id,
|
||||||
|
cap,
|
||||||
|
pec,
|
||||||
|
email,
|
||||||
|
city,
|
||||||
|
codiceFiscale,
|
||||||
|
address,
|
||||||
|
vatNumber,
|
||||||
|
companyName,
|
||||||
|
contactName,
|
||||||
|
contactEmail,
|
||||||
|
isLegalRepresentant
|
||||||
|
}
|
||||||
|
setFormInitialData(companyData);
|
||||||
|
}, [chosenCompanyId, companies]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (formInitialData.id) {
|
||||||
|
storeSet.main.setAsyncRequest();
|
||||||
|
CompanyService.getCompanyDelega(formInitialData.id, getDellegaCallback, errDellegaCallback);
|
||||||
|
}
|
||||||
|
}, [formInitialData])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="appPage">
|
<div className="appPage">
|
||||||
@@ -179,7 +244,6 @@ const ProfileCompany = () => {
|
|||||||
<div className="appForm__cols">
|
<div className="appForm__cols">
|
||||||
<FormField
|
<FormField
|
||||||
type="textinput"
|
type="textinput"
|
||||||
disabled={true}
|
|
||||||
fieldName="companyName"
|
fieldName="companyName"
|
||||||
label={__('Ragione Sociale', 'gepafin')}
|
label={__('Ragione Sociale', 'gepafin')}
|
||||||
control={control}
|
control={control}
|
||||||
@@ -193,7 +257,7 @@ const ProfileCompany = () => {
|
|||||||
<FormField
|
<FormField
|
||||||
type="textinput"
|
type="textinput"
|
||||||
fieldName="vatNumber"
|
fieldName="vatNumber"
|
||||||
disabled={!isNil(formInitialData.id)}
|
disabled={true}
|
||||||
label={__('P.IVA', 'gepafin')}
|
label={__('P.IVA', 'gepafin')}
|
||||||
onBlurFn={checkVatNumber}
|
onBlurFn={checkVatNumber}
|
||||||
control={control}
|
control={control}
|
||||||
@@ -215,7 +279,6 @@ const ProfileCompany = () => {
|
|||||||
<div className="appForm__cols">
|
<div className="appForm__cols">
|
||||||
<FormField
|
<FormField
|
||||||
type="textinput"
|
type="textinput"
|
||||||
disabled={isNil(formInitialData.id)}
|
|
||||||
fieldName="pec"
|
fieldName="pec"
|
||||||
label={__('Email PEC', 'gepafin')}
|
label={__('Email PEC', 'gepafin')}
|
||||||
control={control}
|
control={control}
|
||||||
@@ -230,7 +293,6 @@ const ProfileCompany = () => {
|
|||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
type="textinput"
|
type="textinput"
|
||||||
disabled={true}
|
|
||||||
fieldName="email"
|
fieldName="email"
|
||||||
label={__('Email', 'gepafin')}
|
label={__('Email', 'gepafin')}
|
||||||
control={control}
|
control={control}
|
||||||
@@ -256,7 +318,6 @@ const ProfileCompany = () => {
|
|||||||
<div className="appForm__cols">
|
<div className="appForm__cols">
|
||||||
<FormField
|
<FormField
|
||||||
type="textinput"
|
type="textinput"
|
||||||
disabled={true}
|
|
||||||
fieldName="address"
|
fieldName="address"
|
||||||
label={__('Indirizzo', 'gepafin')}
|
label={__('Indirizzo', 'gepafin')}
|
||||||
control={control}
|
control={control}
|
||||||
@@ -266,7 +327,6 @@ const ProfileCompany = () => {
|
|||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
type="textinput"
|
type="textinput"
|
||||||
disabled={true}
|
|
||||||
fieldName="city"
|
fieldName="city"
|
||||||
label={__('Città', 'gepafin')}
|
label={__('Città', 'gepafin')}
|
||||||
control={control}
|
control={control}
|
||||||
@@ -276,7 +336,6 @@ const ProfileCompany = () => {
|
|||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
type="textinput"
|
type="textinput"
|
||||||
disabled={true}
|
|
||||||
fieldName="cap"
|
fieldName="cap"
|
||||||
label={__('CAP', 'gepafin')}
|
label={__('CAP', 'gepafin')}
|
||||||
control={control}
|
control={control}
|
||||||
@@ -288,7 +347,6 @@ const ProfileCompany = () => {
|
|||||||
<div className="appForm__cols">
|
<div className="appForm__cols">
|
||||||
<FormField
|
<FormField
|
||||||
type="textinput"
|
type="textinput"
|
||||||
disabled={isNil(formInitialData.id)}
|
|
||||||
fieldName="contactName"
|
fieldName="contactName"
|
||||||
label={__('Nome di referente aziendale', 'gepafin')}
|
label={__('Nome di referente aziendale', 'gepafin')}
|
||||||
control={control}
|
control={control}
|
||||||
@@ -379,6 +437,7 @@ const ProfileCompany = () => {
|
|||||||
<div>
|
<div>
|
||||||
<Button
|
<Button
|
||||||
disabled={isEmpty(delegaCodiceFiscale) || isEmpty(delegaFirstName) || isEmpty(delegaLastName)}
|
disabled={isEmpty(delegaCodiceFiscale) || isEmpty(delegaFirstName) || isEmpty(delegaLastName)}
|
||||||
|
onClick={downloadDelega}
|
||||||
type="button"
|
type="button"
|
||||||
label={__('Genera documento Delega', 'gepafin')}
|
label={__('Genera documento Delega', 'gepafin')}
|
||||||
icon="pi pi-check" iconPos="right"/>
|
icon="pi pi-check" iconPos="right"/>
|
||||||
@@ -389,16 +448,15 @@ const ProfileCompany = () => {
|
|||||||
{__('Carica documento Delega Firmato', 'gepafin')}
|
{__('Carica documento Delega Firmato', 'gepafin')}
|
||||||
<span className="appForm__field--required">*</span>
|
<span className="appForm__field--required">*</span>
|
||||||
</label>
|
</label>
|
||||||
<FileuploadStandalone
|
<FileuploadDelega
|
||||||
setDataFn={setDelegaFile}
|
setDataFn={setDelegaFile}
|
||||||
fieldName="delega"
|
fieldName="delega"
|
||||||
defaultValue={[delega]}
|
defaultValue={delega}
|
||||||
accept={['']}
|
accept={['.p7m,application/pkcs7-mime,application/x-pkcs7-mime']}
|
||||||
chooseLabel={__('Aggiungi documento', 'gepafin')}
|
chooseLabel={__('Aggiungi documento', 'gepafin')}
|
||||||
multiple={false}
|
multiple={false}
|
||||||
doctype="document"
|
doctype="document"
|
||||||
sourceId={formInitialData.id}
|
companyId={formInitialData.id}
|
||||||
source="call"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,10 @@ import LoginAdmin from './pages/LoginAdmin';
|
|||||||
import Profile from './pages/Profile';
|
import Profile from './pages/Profile';
|
||||||
import ProfileCompany from './pages/ProfileCompany';
|
import ProfileCompany from './pages/ProfileCompany';
|
||||||
import Users from './pages/Users';
|
import Users from './pages/Users';
|
||||||
|
import AddCompany from './pages/AddCompany';
|
||||||
|
|
||||||
|
const routes = ({ role, chosenCompanyId }) => {
|
||||||
|
|
||||||
const routes = ({ role }) => {
|
|
||||||
return (
|
return (
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route element={<ProtectedRoute/>}>
|
<Route element={<ProtectedRoute/>}>
|
||||||
@@ -78,7 +80,11 @@ const routes = ({ role }) => {
|
|||||||
</DefaultLayout>}/>
|
</DefaultLayout>}/>
|
||||||
<Route path="/profilo-aziendale" element={<DefaultLayout>
|
<Route path="/profilo-aziendale" element={<DefaultLayout>
|
||||||
{'ROLE_SUPER_ADMIN' === role ? <PageNotFound/> : null}
|
{'ROLE_SUPER_ADMIN' === role ? <PageNotFound/> : null}
|
||||||
{'ROLE_BENEFICIARY' === role ? <ProfileCompany/> : null}
|
{'ROLE_BENEFICIARY' === role && chosenCompanyId > 0 ? <ProfileCompany/> : <PageNotFound/>}
|
||||||
|
</DefaultLayout>}/>
|
||||||
|
<Route path="/agguingi-azienda" element={<DefaultLayout>
|
||||||
|
{'ROLE_SUPER_ADMIN' === role ? <PageNotFound/> : null}
|
||||||
|
{'ROLE_BENEFICIARY' === role ? <AddCompany/> : null}
|
||||||
</DefaultLayout>}/>
|
</DefaultLayout>}/>
|
||||||
<Route path="/utenti" element={<DefaultLayout>
|
<Route path="/utenti" element={<DefaultLayout>
|
||||||
{'ROLE_SUPER_ADMIN' === role ? <Users/> : null}
|
{'ROLE_SUPER_ADMIN' === role ? <Users/> : null}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export default class CompanyService {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static updateCompany = (id, body, callback, errCallback) => {
|
static updateCompany = (id, body, callback, errCallback) => {
|
||||||
NetworkService.post(`${API_BASE_URL}/company/${id}`, body, callback, errCallback);
|
NetworkService.put(`${API_BASE_URL}/company/${id}`, body, callback, errCallback);
|
||||||
};
|
};
|
||||||
|
|
||||||
static checkVat = (callback, errCallback, queryParams) => {
|
static checkVat = (callback, errCallback, queryParams) => {
|
||||||
@@ -19,4 +19,20 @@ export default class CompanyService {
|
|||||||
static getCompanyForUser = (id, callback, errCallback) => {
|
static getCompanyForUser = (id, callback, errCallback) => {
|
||||||
NetworkService.get(`${API_BASE_URL}/company/user/${id}`, callback, errCallback);
|
NetworkService.get(`${API_BASE_URL}/company/user/${id}`, callback, errCallback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static getCompanyDelega = (id, callback, errCallback) => {
|
||||||
|
NetworkService.get(`${API_BASE_URL}/company/${id}/delegation`, callback, errCallback);
|
||||||
|
};
|
||||||
|
|
||||||
|
static downloadCompanyDelega = (id, body, callback, errCallback) => {
|
||||||
|
NetworkService.postBlob(`${API_BASE_URL}/company/${id}/delegation/download`, body, callback, errCallback);
|
||||||
|
};
|
||||||
|
|
||||||
|
static uploadCompanyDelega = (id, body, callback, errCallback, queryParams) => {
|
||||||
|
NetworkService.postMultiPart(`${API_BASE_URL}/company/${id}/delegation/upload`, body, callback, errCallback, queryParams);
|
||||||
|
};
|
||||||
|
|
||||||
|
static deleteDelega = (id, callback, errCallback) => {
|
||||||
|
NetworkService.delete(`${API_BASE_URL}/company/${id}/delegation`, {}, callback, errCallback);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,6 +126,47 @@ export class NetworkService {
|
|||||||
.catch(err => errorCallback(err));
|
.catch(err => errorCallback(err));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static postBlob = (url, body, callback, errorCallback, queryParams) => {
|
||||||
|
|
||||||
|
if (queryParams) {
|
||||||
|
url += '?'
|
||||||
|
for (let i = 0; i < queryParams.length; i++) {
|
||||||
|
if (queryParams[i] && this.isNotBlank(queryParams[i][0]) && this.isNotBlank(queryParams[i][1])) {
|
||||||
|
let param = queryParams[i][0] + '=' + queryParams[i][1]
|
||||||
|
|
||||||
|
if (i !== queryParams.length - 1)
|
||||||
|
param += '&'
|
||||||
|
|
||||||
|
url += param;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (url.charAt(url.length) === '&')
|
||||||
|
url = url.substring(0, url.length - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
fetch(url, {
|
||||||
|
method: 'POST',
|
||||||
|
mode: 'cors',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Authorization': 'Bearer ' + storeGet.main.getToken(),
|
||||||
|
},
|
||||||
|
body: JSON.stringify(body)
|
||||||
|
})
|
||||||
|
.then(async response => {
|
||||||
|
let status = response.status;
|
||||||
|
return { response: await response.blob(), status: status }
|
||||||
|
})
|
||||||
|
.then(data => {
|
||||||
|
if (data.status >= 400 && data.status <= 599)
|
||||||
|
errorCallback(data.response)
|
||||||
|
else
|
||||||
|
callback(data.response)
|
||||||
|
})
|
||||||
|
.catch(err => errorCallback(err));
|
||||||
|
};
|
||||||
|
|
||||||
static unauthorizedPost = (url, body, callback, errorCallback, queryParams) => {
|
static unauthorizedPost = (url, body, callback, errorCallback, queryParams) => {
|
||||||
if (queryParams) {
|
if (queryParams) {
|
||||||
url += '?'
|
url += '?'
|
||||||
|
|||||||
Reference in New Issue
Block a user