- added company deletion functionality;
This commit is contained in:
@@ -4,7 +4,7 @@ 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';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import emailjs from '@emailjs/browser';
|
//import emailjs from '@emailjs/browser';
|
||||||
//import { useNavigate } from 'react-router-dom';
|
//import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
// store
|
// store
|
||||||
@@ -27,7 +27,7 @@ import { InputText } from 'primereact/inputtext';
|
|||||||
import { Toast } from 'primereact/toast';
|
import { Toast } from 'primereact/toast';
|
||||||
//import getFormatedFileSizeText from '../../helpers/getFormatedFileSizeText';
|
//import getFormatedFileSizeText from '../../helpers/getFormatedFileSizeText';
|
||||||
//import { defaultMaxFileSize } from '../../configData';
|
//import { defaultMaxFileSize } from '../../configData';
|
||||||
import { Dialog } from 'primereact/dialog';
|
//import { Dialog } from 'primereact/dialog';
|
||||||
import { confirmPopup, ConfirmPopup } from 'primereact/confirmpopup';
|
import { confirmPopup, ConfirmPopup } from 'primereact/confirmpopup';
|
||||||
|
|
||||||
const ProfileCompany = () => {
|
const ProfileCompany = () => {
|
||||||
@@ -38,7 +38,7 @@ const ProfileCompany = () => {
|
|||||||
const [formInitialData, setFormInitialData] = useState({});
|
const [formInitialData, setFormInitialData] = useState({});
|
||||||
const [delegaData, setDelegaData] = useState({});
|
const [delegaData, setDelegaData] = useState({});
|
||||||
//const [delega, setDelega] = useState([]);
|
//const [delega, setDelega] = useState([]);
|
||||||
const [isVisibleRemoveDialog, setIsVisibleRemoveDialog] = useState(false);
|
//const [isVisibleRemoveDialog, setIsVisibleRemoveDialog] = useState(false);
|
||||||
const { delegaFirstName = '', delegaLastName = '', delegaCodiceFiscale = '' } = delegaData;
|
const { delegaFirstName = '', delegaLastName = '', delegaCodiceFiscale = '' } = delegaData;
|
||||||
const toast = useRef(null);
|
const toast = useRef(null);
|
||||||
//const navigate = useNavigate();
|
//const navigate = useNavigate();
|
||||||
@@ -212,22 +212,22 @@ const ProfileCompany = () => {
|
|||||||
defaultFocus: 'reject',
|
defaultFocus: 'reject',
|
||||||
acceptClassName: 'p-button-danger',
|
acceptClassName: 'p-button-danger',
|
||||||
accept: () => {
|
accept: () => {
|
||||||
doRemoveCompany();
|
doRemoveCompanyAPI();
|
||||||
},
|
},
|
||||||
reject: () => {
|
reject: () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const headerRemoveDialog = () => {
|
/*const headerRemoveDialog = () => {
|
||||||
return <span>{__('Rimuovi azienda', 'gepafin')}</span>
|
return <span>{__('Rimuovi azienda', 'gepafin')}</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
const hideRemoveDialog = () => {
|
const hideRemoveDialog = () => {
|
||||||
setIsVisibleRemoveDialog(false);
|
setIsVisibleRemoveDialog(false);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
const doRemoveCompany = () => {
|
/*const doRemoveCompany = () => {
|
||||||
const userData = storeGet.main.userData();
|
const userData = storeGet.main.userData();
|
||||||
let chosenCompany = {};
|
let chosenCompany = {};
|
||||||
|
|
||||||
@@ -251,13 +251,13 @@ const ProfileCompany = () => {
|
|||||||
publicKey: 'TPWwaPLM2dDuEIa10'
|
publicKey: 'TPWwaPLM2dDuEIa10'
|
||||||
}
|
}
|
||||||
).then(() => {
|
).then(() => {
|
||||||
/*if (toast.current) {
|
/!*if (toast.current) {
|
||||||
toast.current.show({
|
toast.current.show({
|
||||||
severity: 'success',
|
severity: 'success',
|
||||||
summary: '',
|
summary: '',
|
||||||
detail: __('La richiesta è stata inviata!', 'gepafin')
|
detail: __('La richiesta è stata inviata!', 'gepafin')
|
||||||
});
|
});
|
||||||
}*/
|
}*!/
|
||||||
setIsVisibleRemoveDialog(true);
|
setIsVisibleRemoveDialog(true);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
@@ -270,10 +270,9 @@ const ProfileCompany = () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// TODO delete company functionality by API, ready to be shipped
|
const doRemoveCompanyAPI = () => {
|
||||||
/*const doRemoveCompanyAPI = () => {
|
|
||||||
storeSet.main.setAsyncRequest();
|
storeSet.main.setAsyncRequest();
|
||||||
CompanyService.deleteCompany(formInitialData.id, deleteCompanyCallback, errDeleteCompanyCallback)
|
CompanyService.deleteCompany(formInitialData.id, deleteCompanyCallback, errDeleteCompanyCallback)
|
||||||
}
|
}
|
||||||
@@ -289,6 +288,8 @@ const ProfileCompany = () => {
|
|||||||
if (!isEmpty(newCompanies)) {
|
if (!isEmpty(newCompanies)) {
|
||||||
const newChosenCompanyId = newCompanies[0].id;
|
const newChosenCompanyId = newCompanies[0].id;
|
||||||
storeSet.main.chosenCompanyId(newChosenCompanyId);
|
storeSet.main.chosenCompanyId(newChosenCompanyId);
|
||||||
|
} else {
|
||||||
|
storeSet.main.chosenCompanyId(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
storeSet.main.unsetAsyncRequest();
|
storeSet.main.unsetAsyncRequest();
|
||||||
@@ -297,7 +298,7 @@ const ProfileCompany = () => {
|
|||||||
const errDeleteCompanyCallback = (data) => {
|
const errDeleteCompanyCallback = (data) => {
|
||||||
set404FromErrorResponse(data);
|
set404FromErrorResponse(data);
|
||||||
storeSet.main.unsetAsyncRequest();
|
storeSet.main.unsetAsyncRequest();
|
||||||
}*/
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const newFormData = klona(formInitialData);
|
const newFormData = klona(formInitialData);
|
||||||
@@ -622,15 +623,15 @@ const ProfileCompany = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Dialog
|
{/*<Dialog
|
||||||
visible={isVisibleRemoveDialog}
|
visible={isVisibleRemoveDialog}
|
||||||
modal
|
modal
|
||||||
header={headerRemoveDialog}
|
header={headerRemoveDialog}
|
||||||
/*footer={footerRemoveDialog}*/
|
footer={footerRemoveDialog}
|
||||||
style={{ maxWidth: '600px', width: '100%' }}
|
style={{ maxWidth: '600px', width: '100%' }}
|
||||||
onHide={hideRemoveDialog}>
|
onHide={hideRemoveDialog}>
|
||||||
<p>Abbiamo preso in carica la tua richiesta a breve l'azienda sarà rimossa dal tuo profilo</p>
|
<p>Abbiamo preso in carica la tua richiesta a breve l'azienda sarà rimossa dal tuo profilo</p>
|
||||||
</Dialog>
|
</Dialog>*/}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -37,6 +37,6 @@ export default class CompanyService {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static deleteCompany = (id, callback, errCallback) => {
|
static deleteCompany = (id, callback, errCallback) => {
|
||||||
NetworkService.delete(`${API_BASE_URL}/company/${id}`, {}, callback, errCallback);
|
NetworkService.delete(`${API_BASE_URL}/company/user/${id}`, {}, callback, errCallback);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user