Implement save method for revised data
This commit is contained in:
parent
d89cc70ec5
commit
7a3ad4c78c
@ -4,7 +4,7 @@
|
|||||||
"Back to Dashboard": "Back to Dashboard",
|
"Back to Dashboard": "Back to Dashboard",
|
||||||
"Create New Report": "Create New Report",
|
"Create New Report": "Create New Report",
|
||||||
"Dashboard": "Dashboard",
|
"Dashboard": "Dashboard",
|
||||||
"Date": "Date",
|
"Date (GMT+8)": "Date (GMT+8)",
|
||||||
"Download": "Download",
|
"Download": "Download",
|
||||||
"Download Report": "Download Report",
|
"Download Report": "Download Report",
|
||||||
"Duration": "Duration",
|
"Duration": "Duration",
|
||||||
@ -12,6 +12,7 @@
|
|||||||
"English": "English",
|
"English": "English",
|
||||||
"Go to Reports": "Go to Reports",
|
"Go to Reports": "Go to Reports",
|
||||||
"Inference": "Inference",
|
"Inference": "Inference",
|
||||||
|
"Is Test": "Is Test",
|
||||||
"Language": "Language",
|
"Language": "Language",
|
||||||
"Login": "Login",
|
"Login": "Login",
|
||||||
"Logout": "Logout",
|
"Logout": "Logout",
|
||||||
@ -28,8 +29,11 @@
|
|||||||
"Please specify a password": "Please specify a password",
|
"Please specify a password": "Please specify a password",
|
||||||
"Please specify a username": "Please specify a username",
|
"Please specify a username": "Please specify a username",
|
||||||
"Report Details": "Report Details",
|
"Report Details": "Report Details",
|
||||||
|
"Report Filters": "Report Filters",
|
||||||
"Reports": "Reports",
|
"Reports": "Reports",
|
||||||
"Retry": "Retry",
|
"Retry": "Retry",
|
||||||
|
"Review": "Review",
|
||||||
|
"Reviewed": "Reviewed",
|
||||||
"Service temporarily unavailable.": "Service temporarily unavailable.",
|
"Service temporarily unavailable.": "Service temporarily unavailable.",
|
||||||
"Something went wrong.": "Something went wrong.",
|
"Something went wrong.": "Something went wrong.",
|
||||||
"Sorry, something went wrong.": "Sorry, something went wrong.",
|
"Sorry, something went wrong.": "Sorry, something went wrong.",
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"Back to Dashboard": "",
|
"Back to Dashboard": "",
|
||||||
"Create New Report": "",
|
"Create New Report": "",
|
||||||
"Dashboard": "",
|
"Dashboard": "",
|
||||||
"Date": "",
|
"Date (GMT+8)": "",
|
||||||
"Download": "",
|
"Download": "",
|
||||||
"Download Report": "",
|
"Download Report": "",
|
||||||
"Duration": "",
|
"Duration": "",
|
||||||
@ -12,6 +12,7 @@
|
|||||||
"English": "Tiếng Anh",
|
"English": "Tiếng Anh",
|
||||||
"Go to Reports": "",
|
"Go to Reports": "",
|
||||||
"Inference": "",
|
"Inference": "",
|
||||||
|
"Is Test": "",
|
||||||
"Language": "Ngôn ngữ",
|
"Language": "Ngôn ngữ",
|
||||||
"Login": "Đăng nhập",
|
"Login": "Đăng nhập",
|
||||||
"Logout": "Đăng xuất",
|
"Logout": "Đăng xuất",
|
||||||
@ -28,8 +29,11 @@
|
|||||||
"Please specify a password": "Vui lòng nhập một mật khẩu",
|
"Please specify a password": "Vui lòng nhập một mật khẩu",
|
||||||
"Please specify a username": "Vui lòng nhập một tên tài khoản",
|
"Please specify a username": "Vui lòng nhập một tên tài khoản",
|
||||||
"Report Details": "",
|
"Report Details": "",
|
||||||
|
"Report Filters": "",
|
||||||
"Reports": "",
|
"Reports": "",
|
||||||
"Retry": "Thử lại",
|
"Retry": "Thử lại",
|
||||||
|
"Review": "",
|
||||||
|
"Reviewed": "",
|
||||||
"Service temporarily unavailable.": "Dịch vụ máy chủ hiện tại không sẵn sàng.",
|
"Service temporarily unavailable.": "Dịch vụ máy chủ hiện tại không sẵn sàng.",
|
||||||
"Something went wrong.": "Có lỗi xảy ra",
|
"Something went wrong.": "Có lỗi xảy ra",
|
||||||
"Sorry, something went wrong.": "Hệ thống gặp lỗi",
|
"Sorry, something went wrong.": "Hệ thống gặp lỗi",
|
||||||
|
@ -305,26 +305,7 @@ const ReviewPage = () => {
|
|||||||
const [currentRequestIndex, setCurrentRequestIndex] = useState(1);
|
const [currentRequestIndex, setCurrentRequestIndex] = useState(1);
|
||||||
const [hasNextRequest, setHasNextRequest] = useState(true);
|
const [hasNextRequest, setHasNextRequest] = useState(true);
|
||||||
const [totalPages, setTotalPages] = useState(0);
|
const [totalPages, setTotalPages] = useState(0);
|
||||||
|
const [dataSource, setDataSource] = useState([]);
|
||||||
// purchase_date: "2024-01-20",
|
|
||||||
// retailername: "Test Retailer",
|
|
||||||
// sold_to_party: "Test Party",
|
|
||||||
const dataSource = [];
|
|
||||||
|
|
||||||
const predicted = (currentRequest && currentRequest["Reviewed Result"]) ? currentRequest["Reviewed Result"] : {};
|
|
||||||
const submitted = (currentRequest && currentRequest["Feedback Result"]) ? currentRequest["Feedback Result"] : {};
|
|
||||||
const revised = (currentRequest && currentRequest["Reviewed Result"]) ? currentRequest["Reviewed Result"] : {};
|
|
||||||
|
|
||||||
|
|
||||||
const keys = Object.keys(predicted);
|
|
||||||
for (let i = 0; i < keys.length; i++) {
|
|
||||||
let instance = {};
|
|
||||||
instance["key"] = keys[i];
|
|
||||||
instance["predicted"] = predicted[keys[i]];
|
|
||||||
instance["submitted"] = submitted[keys[i]];
|
|
||||||
instance["revised"] = revised[keys[i]];
|
|
||||||
dataSource.push(instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
const [pageIndexToGoto, setPageIndexToGoto] = useState(1);
|
const [pageIndexToGoto, setPageIndexToGoto] = useState(1);
|
||||||
|
|
||||||
@ -337,6 +318,21 @@ const ReviewPage = () => {
|
|||||||
const requestData = fetchRequest(data?.subscription_requests[0].RequestID);
|
const requestData = fetchRequest(data?.subscription_requests[0].RequestID);
|
||||||
requestData.then(async (data) => {
|
requestData.then(async (data) => {
|
||||||
if (data) setCurrentRequest(data);
|
if (data) setCurrentRequest(data);
|
||||||
|
const predicted = (data && data["Reviewed Result"]) ? data["Reviewed Result"] : {};
|
||||||
|
const submitted = (data && data["Feedback Result"]) ? data["Feedback Result"] : {};
|
||||||
|
const revised = (data && data["Reviewed Result"]) ? data["Reviewed Result"] : {};
|
||||||
|
const keys = Object.keys(predicted);
|
||||||
|
const tableRows = [];
|
||||||
|
for (let i = 0; i < keys.length; i++) {
|
||||||
|
let instance = {};
|
||||||
|
instance["key"] = keys[i];
|
||||||
|
instance["predicted"] = predicted[keys[i]];
|
||||||
|
instance["submitted"] = submitted[keys[i]];
|
||||||
|
instance["revised"] = revised[keys[i]];
|
||||||
|
tableRows.push(instance);
|
||||||
|
}
|
||||||
|
setDataSource(tableRows);
|
||||||
|
setLoading(false);
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
});
|
});
|
||||||
@ -407,16 +403,38 @@ const ReviewPage = () => {
|
|||||||
revised: string;
|
revised: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const updateRevisedData = async (newRevisedData:any) => {
|
||||||
|
const requestID = newRevisedData.request_id;
|
||||||
|
const token = localStorage.getItem('sbt-token') || '';
|
||||||
|
console.log(newRevisedData)
|
||||||
|
await fetch(`${baseURL}/ctel/request/${requestID}/`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
"Authorization": `${JSON.parse(token)}`,
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(newRevisedData),
|
||||||
|
}).catch((error) => {
|
||||||
|
console.log(error);
|
||||||
|
message.error("Could not update revised data");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const handleSave = (row: DataType) => {
|
const handleSave = (row: DataType) => {
|
||||||
const newData = [...dataSource];
|
const newData = [...dataSource];
|
||||||
console.log(row);
|
console.log(row);
|
||||||
// const index = newData.findIndex((item) => row.key === item.key);
|
const index = newData.findIndex((item) => row.key === item.key);
|
||||||
// const item = newData[index];
|
const item = newData[index];
|
||||||
// newData.splice(index, 1, {
|
newData.splice(index, 1, {
|
||||||
// ...item,
|
...item,
|
||||||
// ...row,
|
...row,
|
||||||
// });
|
});
|
||||||
// setDataSource(newData);
|
setDataSource(newData);
|
||||||
|
const newRevisedData = {};
|
||||||
|
for (let i = 0; i < newData.length; i++) {
|
||||||
|
newRevisedData[newData[i].key] = newData[i].revised;
|
||||||
|
}
|
||||||
|
updateRevisedData(newRevisedData);
|
||||||
};
|
};
|
||||||
|
|
||||||
const columns = defaultColumns.map((col) => {
|
const columns = defaultColumns.map((col) => {
|
||||||
@ -643,10 +661,6 @@ const ReviewPage = () => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<DatePicker.RangePicker
|
<DatePicker.RangePicker
|
||||||
value={filterDateRange}
|
|
||||||
onChange={(value) => {
|
|
||||||
setFilterDateRange(value);
|
|
||||||
}}
|
|
||||||
style={{ width: 200 }}
|
style={{ width: 200 }}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
Loading…
Reference in New Issue
Block a user