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 uploadHandler = async (args) => {
|
||||||
const file = args.file;
|
const file = args.file;
|
||||||
const responseUpload = await store.product.uploadExcel(file);
|
try {
|
||||||
|
const responseUpload = await store.product.uploadExcel(file);
|
||||||
|
|
||||||
|
if (responseUpload.status === 201) {
|
||||||
|
message.success("Success upload excel!");
|
||||||
|
} else {
|
||||||
|
message.error("Failed upload excel!");
|
||||||
|
}
|
||||||
|
|
||||||
if (responseUpload.status === 201) {
|
|
||||||
message.success("Success upload excel!");
|
|
||||||
} else {
|
|
||||||
message.error("Failed upload excel!");
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
const responseUploadProduct = await handleUploadProduct(responseUpload);
|
||||||
|
} catch (e) {
|
||||||
|
setLoading(false);
|
||||||
|
message.error("Failed upload excel!");
|
||||||
}
|
}
|
||||||
|
|
||||||
const responseUploadProduct = await handleUploadProduct(responseUpload);
|
|
||||||
setLoading(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleChange = (info) => {
|
const handleChange = (info) => {
|
||||||
|
@ -94,15 +98,21 @@ export const Product = observer(() => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleUploadProduct = async (data) => {
|
const handleUploadProduct = async (data) => {
|
||||||
const response = await store.product.uploadProduct({fileName: data.body.filename});
|
try {
|
||||||
|
const response = await store.product.uploadProduct({fileName: data.body.filename});
|
||||||
|
|
||||||
if (response.status === 201) {
|
if (response.status === 201) {
|
||||||
message.success("Success Create Product by Excel!");
|
message.success("Success Create Product by Excel!");
|
||||||
} else {
|
} else {
|
||||||
message.error("Failed Create Product by Excel!");
|
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!");
|
||||||
}
|
}
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadingState = (
|
const loadingState = (
|
||||||
|
|
Loading…
Reference in New Issue
Block a user