- updated zustand and react libraries;
- added 'put in draft' btn;
This commit is contained in:
@@ -99,7 +99,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
delete formData.startDate;
|
||||
delete formData.endDate;
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
if (!formData.id) {
|
||||
BandoService.createBando(formData, createCallback, errCreateCallback);
|
||||
} else {
|
||||
@@ -108,7 +108,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
}
|
||||
|
||||
const createCallback = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
if (data.status === 'SUCCESS') {
|
||||
if (toast.current) {
|
||||
toast.current.show({
|
||||
@@ -119,7 +119,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
}
|
||||
const values = getValues();
|
||||
if (!values.id && data.data.id) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
const sampleFormData = {
|
||||
label: `Evaluation form for call #${data.data.id}`,
|
||||
content: []
|
||||
@@ -141,19 +141,19 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const createFormCallback = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
navigate(`/bandi/${resp.data.callId}`);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errCreateFormCallback = (resp) => {
|
||||
set404FromErrorResponse(resp);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const openPreview = () => {
|
||||
@@ -189,11 +189,11 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
});
|
||||
setFaqOptions(faqItems);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errLookupdataCallback = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const shouldDisableField = (fieldName) => {
|
||||
@@ -223,7 +223,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
}, [errors, isValid]);
|
||||
|
||||
useEffect(() => {
|
||||
storeSet.main.formInitialData(initialData);
|
||||
storeSet('formInitialData', initialData);
|
||||
setFormInitialData(initialData);
|
||||
}, [initialData]);
|
||||
|
||||
@@ -256,7 +256,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
LookupdataService.getItems(lookupdataCallback, errLookupdataCallback, [['type', ['AIMED_TO', 'FAQ']]]);
|
||||
|
||||
return () => {
|
||||
storeSet.main.formInitialData({});
|
||||
storeSet('formInitialData', {});
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, setInitialData, g
|
||||
delete formData.startDate;
|
||||
delete formData.endDate;
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
if (values.evaluationVersion === 'V1') {
|
||||
BandoService.updateBandoStep2(formData.id, formData, createCallback, errCreateCallback);
|
||||
} else if (values.evaluationVersion === 'V2') {
|
||||
@@ -102,7 +102,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, setInitialData, g
|
||||
}
|
||||
|
||||
const createCallback = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
if (data.status === 'SUCCESS') {
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
@@ -116,7 +116,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, setInitialData, g
|
||||
}
|
||||
|
||||
const errCreateCallback = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
console.log('errCreateCallback', data);
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, setInitialData, g
|
||||
}, [errors, isValid]);
|
||||
|
||||
useEffect(() => {
|
||||
storeSet.main.formInitialData(initialData);
|
||||
storeSet('formInitialData', initialData);
|
||||
setFormInitialData(initialData);
|
||||
}, [initialData]);
|
||||
|
||||
@@ -205,7 +205,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, setInitialData, g
|
||||
LookupdataService.getItems(lookupdataCallback, errLookupdataCallback, [['type', ['CHECKLIST', 'EVALUATION_CRITERIA']]]);
|
||||
|
||||
return () => {
|
||||
storeSet.main.formInitialData({});
|
||||
storeSet('formInitialData', {});
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -35,14 +35,14 @@ const BandoEditFormStep3 = forwardRef(function () {
|
||||
}
|
||||
|
||||
const onSaveDraft = () => {
|
||||
const content = storeGet.main.formElements();
|
||||
const formId = storeGet.main.formId();
|
||||
const content = storeGet('formElements');
|
||||
const formId = storeGet('formId');
|
||||
const formData = {
|
||||
label: formName,
|
||||
content
|
||||
}
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
EvaluationFormsService.updateForm(formId, formData, updateFormCallback, errUpdateFormCallback)
|
||||
}
|
||||
|
||||
@@ -57,12 +57,12 @@ const BandoEditFormStep3 = forwardRef(function () {
|
||||
});
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errUpdateFormCallback = (resp) => {
|
||||
set404FromErrorResponse(resp);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const openPreview = () => {
|
||||
@@ -77,51 +77,52 @@ const BandoEditFormStep3 = forwardRef(function () {
|
||||
|
||||
const getElementItemsCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
//storeSet.main.elementItems(elementItems.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
storeSet.main.elementItems(
|
||||
//storeSet('elementItems', elementItems.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
storeSet(
|
||||
'elementItems',
|
||||
data.data
|
||||
.filter(o => !['fileselect'].includes(o.name))
|
||||
.sort((a, b) => a.sortOrder - b.sortOrder)
|
||||
);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetElementItemsCallbacks = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const getFormCallback = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
storeSet.main.formId(resp.data.id);
|
||||
storeSet.main.formLabel(resp.data.label);
|
||||
storeSet('formId', resp.data.id);
|
||||
storeSet('formLabel', resp.data.label);
|
||||
setFormName(resp.data.label);
|
||||
setBandoStatus(resp.data.callStatus);
|
||||
const elements = klona(resp.data.content);
|
||||
storeSet.main.formElements(elements);
|
||||
storeSet('formElements', elements);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
const errGetFormCallback = (resp) => {
|
||||
set404FromErrorResponse(resp);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
storeSet('unsetAsyncRequest');
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
EvaluationFormsService.getFormForCall(id, getFormCallback, errGetFormCallback)
|
||||
}, [id]);
|
||||
|
||||
useEffect(() => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
storeSet('setAsyncRequest');
|
||||
FormsService.getElementItems(getElementItemsCallback, errGetElementItemsCallbacks);
|
||||
|
||||
return () => {
|
||||
storeSet.main.formId(0);
|
||||
storeSet.main.formElements([]);
|
||||
storeSet.main.activeElement('');
|
||||
storeSet.main.selectedElement('');
|
||||
storeSet('formId', 0);
|
||||
storeSet('formElements', []);
|
||||
storeSet('activeElement', '');
|
||||
storeSet('selectedElement', '');
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user