This commit is contained in:
ajat91.sudrajat 2021-12-23 17:05:44 +07:00
commit 195e0e80e4
3 changed files with 26 additions and 19 deletions

View File

@ -32,11 +32,7 @@ export const MembershipModal = ({
form form
.validateFields() .validateFields()
.then((values) => { .then((values) => {
let input = values; onCreate(values);
if (initialData.id)
input.username = initialData.username;
onCreate(input);
form.resetFields(); form.resetFields();
}) })
.catch((info) => { .catch((info) => {

View File

@ -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 = (

View File

@ -63,5 +63,6 @@ export class Authentication {
TokenUtil.clearAccessToken(); TokenUtil.clearAccessToken();
TokenUtil.persistToken(); TokenUtil.persistToken();
this.isLoggedIn = false; this.isLoggedIn = false;
window.location.reload();
} }
} }