add attachment to confirm and reject forms

This commit is contained in:
Amirhossein Mahmoodi
2023-08-09 15:48:26 +03:30
parent 64e717990f
commit fee4fa8261
12 changed files with 36 additions and 24 deletions

View File

@@ -38,13 +38,14 @@ const Confirm = ({rowId, fetchUrl, mutate}) => {
initialValues: {
description: "",
proposed_amount: "",
confirm_img: ""
confirm_img: null
},
validationSchema,
onSubmit: (values, {setSubmitting}) => {
const formData = new FormData();
formData.append("proposed_amount", values.proposed_amount);
if (values.description != "") formData.append("expert_description", values.description);
if (values.confirm_img != null) formData.append("attachment", values.confirm_img);
requestServer(`${CONFIRM_MACHINARY_OFFICE}/${rowId}`, 'post', {
data: formData,
@@ -68,7 +69,7 @@ const Confirm = ({rowId, fetchUrl, mutate}) => {
if (uploadedFile) {
const maxFileSize = 2 * 1024 * 1024;
if (uploadedFile.size > maxFileSize) {
UploadFileNotification(directionApp, t);
UploadFileNotification(t);
event.target.value = "";
return;
}

View File

@@ -38,12 +38,13 @@ const Reject = ({rowId, fetchUrl, mutate}) => {
const formik = useFormik({
initialValues: {
description: "",
reject_img: ""
reject_img: null
},
validationSchema,
onSubmit: (values, {setSubmitting}) => {
const formData = new FormData();
formData.append("expert_description", values.description);
if (values.reject_img != null) formData.append("attachment", values.reject_img);
requestServer(`${REJECT_MACHINARY_OFFICE}/${rowId}`, 'post', {
data: formData,
@@ -65,7 +66,7 @@ const Reject = ({rowId, fetchUrl, mutate}) => {
if (uploadedFile) {
const maxFileSize = 2 * 1024 * 1024;
if (uploadedFile.size > maxFileSize) {
UploadFileNotification(directionApp, t);
UploadFileNotification(t);
event.target.value = "";
return;
}

View File

@@ -38,13 +38,14 @@ const Confirm = ({rowId, fetchUrl, mutate}) => {
initialValues: {
description: "",
approved_amount: "",
confirm_img: ""
confirm_img: null
},
validationSchema,
onSubmit: (values, {setSubmitting}) => {
const formData = new FormData();
formData.append("approved_amount", values.approved_amount);
if (values.description != "") formData.append("expert_description", values.description);
if (values.confirm_img != null) formData.append("attachment", values.confirm_img);
requestServer(`${CONFIRM_PASSENGER_BOSS}/${rowId}`, 'post', {
data: formData,
@@ -68,7 +69,7 @@ const Confirm = ({rowId, fetchUrl, mutate}) => {
if (uploadedFile) {
const maxFileSize = 2 * 1024 * 1024;
if (uploadedFile.size > maxFileSize) {
UploadFileNotification(directionApp, t);
UploadFileNotification(t);
event.target.value = "";
return;
}

View File

@@ -38,12 +38,13 @@ const Reject = ({rowId, fetchUrl, mutate}) => {
const formik = useFormik({
initialValues: {
description: "",
reject_img: ""
reject_img: null
},
validationSchema,
onSubmit: (values, {setSubmitting}) => {
const formData = new FormData();
formData.append("expert_description", values.description);
if (values.reject_img != null) formData.append("attachment", values.reject_img);
requestServer(`${REJECT_PASSENGER_BOSS}/${rowId}`, 'post', {
data: formData,
@@ -65,7 +66,7 @@ const Reject = ({rowId, fetchUrl, mutate}) => {
if (uploadedFile) {
const maxFileSize = 2 * 1024 * 1024;
if (uploadedFile.size > maxFileSize) {
UploadFileNotification(directionApp, t);
UploadFileNotification(t);
event.target.value = "";
return;
}

View File

@@ -33,11 +33,12 @@ const Confirm = ({rowId, fetchUrl, mutate}) => {
const formik = useFormik({
initialValues: {
description: "",
confirm_img: ""
confirm_img: null
},
onSubmit: (values, {setSubmitting}) => {
const formData = new FormData();
if (values.description != "") formData.append("expert_description", values.description);
if (values.confirm_img != null) formData.append("attachment", values.confirm_img);
requestServer(`${CONFIRM_PASSENGER_OFFICE}/${rowId}`, 'post', {
data: formData,
@@ -58,7 +59,7 @@ const Confirm = ({rowId, fetchUrl, mutate}) => {
if (uploadedFile) {
const maxFileSize = 2 * 1024 * 1024;
if (uploadedFile.size > maxFileSize) {
UploadFileNotification(directionApp, t);
UploadFileNotification(t);
event.target.value = "";
return;
}

View File

@@ -38,12 +38,13 @@ const Reject = ({rowId, fetchUrl, mutate}) => {
const formik = useFormik({
initialValues: {
description: "",
reject_img: ""
reject_img: null
},
validationSchema,
onSubmit: (values, {setSubmitting}) => {
const formData = new FormData();
formData.append("expert_description", values.description);
if (values.reject_img != null) formData.append("attachment", values.reject_img);
requestServer(`${REJECT_PASSENGER_OFFICE}/${rowId}`, 'post', {
data: formData,
@@ -65,7 +66,7 @@ const Reject = ({rowId, fetchUrl, mutate}) => {
if (uploadedFile) {
const maxFileSize = 2 * 1024 * 1024;
if (uploadedFile.size > maxFileSize) {
UploadFileNotification(directionApp, t);
UploadFileNotification(t);
event.target.value = "";
return;
}

View File

@@ -33,11 +33,12 @@ const Confirm = ({rowId, fetchUrl, mutate}) => {
const formik = useFormik({
initialValues: {
description: "",
confirm_img: ""
confirm_img: null
},
onSubmit: (values, {setSubmitting}) => {
const formData = new FormData();
if (values.description != "") formData.append("expert_description", values.description);
if (values.confirm_img != null) formData.append("attachment", values.confirm_img);
requestServer(`${CONFIRM_PROVINCE_MANAGER}/${rowId}`, 'post', {
data: formData,
@@ -58,7 +59,7 @@ const Confirm = ({rowId, fetchUrl, mutate}) => {
if (uploadedFile) {
const maxFileSize = 2 * 1024 * 1024;
if (uploadedFile.size > maxFileSize) {
UploadFileNotification(directionApp, t);
UploadFileNotification(t);
event.target.value = "";
return;
}

View File

@@ -38,12 +38,13 @@ const Reject = ({rowId, fetchUrl, mutate}) => {
const formik = useFormik({
initialValues: {
description: "",
reject_img: ""
reject_img: null
},
validationSchema,
onSubmit: (values, {setSubmitting}) => {
const formData = new FormData();
formData.append("expert_description", values.description);
if (values.reject_img != null) formData.append("attachment", values.reject_img);
requestServer(`${REJECT_PROVINCE_MANAGER}/${rowId}`, 'post', {
data: formData,
@@ -65,7 +66,7 @@ const Reject = ({rowId, fetchUrl, mutate}) => {
if (uploadedFile) {
const maxFileSize = 2 * 1024 * 1024;
if (uploadedFile.size > maxFileSize) {
UploadFileNotification(directionApp, t);
UploadFileNotification(t);
event.target.value = "";
return;
}

View File

@@ -33,11 +33,12 @@ const Confirm = ({rowId, fetchUrl, mutate}) => {
const formik = useFormik({
initialValues: {
description: "",
confirm_img: ""
confirm_img: null
},
onSubmit: (values, {setSubmitting}) => {
const formData = new FormData();
if (values.description != "") formData.append("expert_description", values.description);
if (values.confirm_img != null) formData.append("attachment", values.confirm_img);
requestServer(`${CONFIRM_TRANSPORTATION_ASSISTANCE}/${rowId}`, 'post', {
data: formData,
@@ -58,7 +59,7 @@ const Confirm = ({rowId, fetchUrl, mutate}) => {
if (uploadedFile) {
const maxFileSize = 2 * 1024 * 1024;
if (uploadedFile.size > maxFileSize) {
UploadFileNotification(directionApp, t);
UploadFileNotification(t);
event.target.value = "";
return;
}

View File

@@ -38,12 +38,13 @@ const Reject = ({rowId, fetchUrl, mutate}) => {
const formik = useFormik({
initialValues: {
description: "",
reject_img: ""
reject_img: null
},
validationSchema,
onSubmit: (values, {setSubmitting}) => {
const formData = new FormData();
formData.append("expert_description", values.description);
if (values.reject_img != null) formData.append("attachment", values.reject_img);
requestServer(`${REJECT_TRANSPORTATION_ASSISTANCE}/${rowId}`, 'post', {
data: formData,
@@ -65,7 +66,7 @@ const Reject = ({rowId, fetchUrl, mutate}) => {
if (uploadedFile) {
const maxFileSize = 2 * 1024 * 1024;
if (uploadedFile.size > maxFileSize) {
UploadFileNotification(directionApp, t);
UploadFileNotification(t);
event.target.value = "";
return;
}