- updated zustand and react libraries;
- added 'put in draft' btn;
This commit is contained in:
@@ -6,7 +6,7 @@ import { useDebounce } from 'primereact/hooks';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore, storeGet } from '../../store';
|
||||
import { storeSet, useStoreValue, storeGet } from '../../store';
|
||||
|
||||
// components
|
||||
import { Messages } from 'primereact/messages';
|
||||
@@ -26,7 +26,7 @@ import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||
|
||||
const AddCompany = () => {
|
||||
const navigate = useNavigate();
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
const isAsyncRequest = useStoreValue('isAsyncRequest');
|
||||
const infoMsgs = useRef(null);
|
||||
const [, debouncedPivaValue, setInputPiva] = useDebounce('', 1000);
|
||||
const [vatCheckResponse, setVatCheckResponse] = useState({});
|
||||
@@ -61,7 +61,7 @@ const AddCompany = () => {
|
||||
|
||||
const onSubmit = (formData) => {
|
||||
infoMsgs.current.clear();
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
const submitData = {
|
||||
...formData,
|
||||
vatCheckResponse
|
||||
@@ -73,7 +73,7 @@ const AddCompany = () => {
|
||||
const updateCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
const company = klona(data.data);
|
||||
const companies = storeGet.main.companies();
|
||||
const companies = storeGet('companies');
|
||||
const existingCompany = head(companies.filter(o => o.id === company.id));
|
||||
let newCompanies = [];
|
||||
|
||||
@@ -81,10 +81,10 @@ const AddCompany = () => {
|
||||
newCompanies = companies.map(o => o.id === company.id ? company : o)
|
||||
} else {
|
||||
newCompanies = [...companies, company];
|
||||
storeSet.main.chosenCompanyId(company.id);
|
||||
storeSet('chosenCompanyId', company.id);
|
||||
}
|
||||
|
||||
storeSet.main.companies(newCompanies);
|
||||
storeSet('companies', newCompanies);
|
||||
|
||||
if (company.isLegalRepresentant) {
|
||||
navigate('/');
|
||||
@@ -93,12 +93,12 @@ const AddCompany = () => {
|
||||
}
|
||||
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const updateError = (data) => {
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const checkVatNumber = (value) => {
|
||||
@@ -106,7 +106,7 @@ const AddCompany = () => {
|
||||
const isValid = isPIVA(value);
|
||||
|
||||
if (isValid) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
CompanyService.checkVat(checkVatCallback, errCheckVatCallback, [['vatNumber', value]])
|
||||
} else {
|
||||
setEmptyValues();
|
||||
@@ -139,13 +139,13 @@ const AddCompany = () => {
|
||||
setEmptyValues();
|
||||
}
|
||||
trigger();
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errCheckVatCallback = (data) => {
|
||||
setEmptyValues();
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
/*const shouldDisableFiscalCode = () => {
|
||||
|
||||
Reference in New Issue
Block a user