fix(consume material): when we consumed material the button was never reenabled
closes #15
This commit is contained in:
@@ -16,24 +16,25 @@ export default function ConsumeMaterial() {
|
|||||||
const {token} = useSessionStore();
|
const {token} = useSessionStore();
|
||||||
|
|
||||||
const handleConsume = async (data: any) => {
|
const handleConsume = async (data: any) => {
|
||||||
setSubmitting(!submitting);
|
setSubmitting(true);
|
||||||
try {
|
try {
|
||||||
const result = await axios.post(`/api/logistics/consume`, data, {
|
const result = await axios.post(`/api/logistics/consume`, data, {
|
||||||
headers: {Authorization: `Bearer ${token}`},
|
headers: {Authorization: `Bearer ${token}`},
|
||||||
});
|
});
|
||||||
if (result.data.success) {
|
if (result.data.success) {
|
||||||
toast.success(result.data.message);
|
toast.success(result.data.message);
|
||||||
setSubmitting(!submitting);
|
setSubmitting(false);
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
if (!result.data.success) {
|
if (!result.data.success) {
|
||||||
//console.log(result.data);
|
//console.log(result.data);
|
||||||
setSubmitting(!submitting);
|
setSubmitting(false);
|
||||||
|
|
||||||
toast.error(result.data.message);
|
toast.error(result.data.message);
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
//console.log(error);
|
//console.log(error);
|
||||||
setSubmitting(!submitting);
|
setSubmitting(false);
|
||||||
if (error.status === 401) {
|
if (error.status === 401) {
|
||||||
toast.error("Unauthorized to do this task.");
|
toast.error("Unauthorized to do this task.");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user