- updates;
This commit is contained in:
@@ -35,7 +35,7 @@ const BandoFormsEdit = () => {
|
||||
navigate(`/bandi/${bandoId}/forms`);
|
||||
}
|
||||
|
||||
const doSave = () => {
|
||||
const doSave = (shouldRedirect = false) => {
|
||||
const content = storeGet.main.formElements();
|
||||
const bandoId = getBandoId();
|
||||
const parsedFormId = parseInt(formId)
|
||||
@@ -47,21 +47,25 @@ const BandoFormsEdit = () => {
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
if (bandoFormId === 0) {
|
||||
FormsService.createFormForCall(bandoId, formData, formCreateCallback, errFormCreateCallback);
|
||||
FormsService.createFormForCall(bandoId, formData, (data) => formCreateCallback(data, shouldRedirect), errFormCreateCallback);
|
||||
} else {
|
||||
FormsService.updateForm(bandoFormId, formData, formCreateCallback, errFormCreateCallback);
|
||||
FormsService.updateForm(bandoFormId, formData, (data) => formCreateCallback(data, shouldRedirect), errFormCreateCallback);
|
||||
}
|
||||
}
|
||||
|
||||
const formCreateCallback = (data) => {
|
||||
const formCreateCallback = (data, shouldRedirect) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
const parsed = parseInt(id)
|
||||
const bandoId = !isNaN(parsed) ? parsed : 0;
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
const bandoId = getBandoId();
|
||||
|
||||
if (shouldRedirect) {
|
||||
navigate(`/bandi/${bandoId}/forms/${data.data.id}/preview`);
|
||||
return;
|
||||
}
|
||||
if (data.data.id) {
|
||||
navigate(`/bandi/${bandoId}/forms/${data.data.id}`);
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errFormCreateCallback = (data) => {
|
||||
@@ -70,8 +74,7 @@ const BandoFormsEdit = () => {
|
||||
}
|
||||
|
||||
const openPreview = () => {
|
||||
const bandoId = getBandoId();
|
||||
navigate(`/bandi/${bandoId}/forms/${formId}/preview`);
|
||||
doSave(true);
|
||||
}
|
||||
|
||||
const confirmDelete = (event) => {
|
||||
|
||||
Reference in New Issue
Block a user