chore: handler errors upload excel product
This commit is contained in:
parent
78d00da35d
commit
3be7561c3c
|
@ -72,17 +72,21 @@ export const Product = observer(() => {
|
|||
|
||||
const uploadHandler = async (args) => {
|
||||
const file = args.file;
|
||||
try {
|
||||
const responseUpload = await store.product.uploadExcel(file);
|
||||
|
||||
if (responseUpload.status === 201) {
|
||||
message.success("Success upload excel!");
|
||||
} else {
|
||||
message.error("Failed upload excel!");
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
const responseUploadProduct = await handleUploadProduct(responseUpload);
|
||||
setLoading(false);
|
||||
const responseUploadProduct = await handleUploadProduct(responseUpload);
|
||||
} catch (e) {
|
||||
setLoading(false);
|
||||
message.error("Failed upload excel!");
|
||||
}
|
||||
};
|
||||
|
||||
const handleChange = (info) => {
|
||||
|
@ -94,15 +98,21 @@ export const Product = observer(() => {
|
|||
};
|
||||
|
||||
const handleUploadProduct = async (data) => {
|
||||
try {
|
||||
const response = await store.product.uploadProduct({fileName: data.body.filename});
|
||||
|
||||
if (response.status === 201) {
|
||||
message.success("Success Create Product by Excel!");
|
||||
} else {
|
||||
message.error("Failed Create Product by Excel!");
|
||||
setLoading(false);
|
||||
}
|
||||
setLoading(false);
|
||||
await store.product.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
setLoading(false);
|
||||
message.error("Failed Create Product by Excel!");
|
||||
}
|
||||
}
|
||||
|
||||
const loadingState = (
|
||||
|
|
Loading…
Reference in New Issue
Block a user