Revert to the previous version when cannot update fields
This commit is contained in:
parent
a7fb22e3b7
commit
57bc7a565a
@ -330,7 +330,7 @@ const InferencePage = () => {
|
||||
const updateRevisedData = async (newRevisedData: any) => {
|
||||
const requestID = currentRequest.RequestID;
|
||||
const token = localStorage.getItem('sbt-token') || '';
|
||||
await fetch(`${baseURL}/ctel/request/${requestID}/`, {
|
||||
const result = await fetch(`${baseURL}/ctel/request/${requestID}/`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Authorization": `${JSON.parse(token)}`,
|
||||
@ -341,8 +341,11 @@ const InferencePage = () => {
|
||||
}),
|
||||
}).catch((error) => {
|
||||
console.log(error);
|
||||
message.error("Could not update revised data");
|
||||
throw error;
|
||||
});
|
||||
if (result.status != 200) {
|
||||
throw new Error("Could not update revised data");
|
||||
}
|
||||
};
|
||||
|
||||
const handleSave = (row: DataType) => {
|
||||
@ -353,7 +356,6 @@ const InferencePage = () => {
|
||||
...item,
|
||||
...row,
|
||||
});
|
||||
setDataSource(newData);
|
||||
const newRevisedData = {};
|
||||
for (let i = 0; i < newData.length; i++) {
|
||||
newData[i].revised = normalizeData(newData[i].key, newData[i].revised);
|
||||
@ -365,7 +367,11 @@ const InferencePage = () => {
|
||||
...currentRequest,
|
||||
["Is Reviewed"]: true,
|
||||
})
|
||||
})
|
||||
}).then(() => {
|
||||
setDataSource(newData);
|
||||
}).catch((error) => {
|
||||
message.error("Could not update revised data. Please check the format.");
|
||||
});
|
||||
};
|
||||
|
||||
const submitRevisedData = async () => {
|
||||
|
@ -389,9 +389,9 @@ const ReviewPage = () => {
|
||||
};
|
||||
|
||||
const updateRevisedData = async (newRevisedData: any) => {
|
||||
const requestID = newRevisedData.request_id;
|
||||
const requestID = currentRequest.RequestID;
|
||||
const token = localStorage.getItem('sbt-token') || '';
|
||||
await fetch(`${baseURL}/ctel/request/${requestID}/`, {
|
||||
const result = await fetch(`${baseURL}/ctel/request/${requestID}/`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Authorization": `${JSON.parse(token)}`,
|
||||
@ -402,8 +402,11 @@ const ReviewPage = () => {
|
||||
}),
|
||||
}).catch((error) => {
|
||||
console.log(error);
|
||||
message.error("Could not update revised data");
|
||||
throw error;
|
||||
});
|
||||
if (result.status != 200) {
|
||||
throw new Error("Could not update revised data");
|
||||
}
|
||||
};
|
||||
|
||||
const handleSave = (row: DataType) => {
|
||||
@ -414,7 +417,6 @@ const ReviewPage = () => {
|
||||
...item,
|
||||
...row,
|
||||
});
|
||||
setDataSource(newData);
|
||||
const newRevisedData = {};
|
||||
for (let i = 0; i < newData.length; i++) {
|
||||
newData[i].revised = normalizeData(newData[i].key, newData[i].revised);
|
||||
@ -426,7 +428,11 @@ const ReviewPage = () => {
|
||||
...currentRequest,
|
||||
["Is Reviewed"]: true,
|
||||
})
|
||||
})
|
||||
}).then(() => {
|
||||
setDataSource(newData);
|
||||
}).catch((error) => {
|
||||
message.error("Could not update revised data. Please check the format.");
|
||||
});
|
||||
};
|
||||
|
||||
const submitRevisedData = async () => {
|
||||
|
@ -18,8 +18,8 @@ const normalizeData = (key, value) => {
|
||||
if (isAllSpaces(value)) {
|
||||
value = null;
|
||||
}
|
||||
if (["imei_number", "purchase_date"].includes(key) && typeof (value) === "string") {
|
||||
value = value.split(",")
|
||||
if (["imei_number", "purchase_date"].includes(key) && typeof(value) === "string") {
|
||||
value = value.split(",");
|
||||
}
|
||||
if (typeof (value) === "object" && value?.length > 0) {
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user