update approval di list approval

This commit is contained in:
2025-09-12 11:28:15 +07:00
parent c65a95ce09
commit acfc8d1288
8 changed files with 174 additions and 62 deletions

View File

@@ -117,6 +117,43 @@ export default function Detail() {
});
}
const updateApproval = async () => {
setSubmitLoading(true);
axios
.put(`/customer-service/request/${id}`, {
status_approval: 'approved',
})
.then((response) => {
enqueueSnackbar('Berhasil Approve', { variant: 'success' });
window.location.reload();
})
.catch(({ response }) => {
enqueueSnackbar(response?.data?.message || 'Something Went Wrong', { variant: 'error' });
})
.finally(() => {
setSubmitLoading(false);
});
};
const updateDecline = async () => {
setSubmitLoading(true);
axios
.put(`/customer-service/request/${id}`, {
status_approval: 'declined',
})
.then((response) => {
enqueueSnackbar('Berhasil Approve', { variant: 'success' });
window.location.reload();
})
.catch(({ response }) => {
enqueueSnackbar(response?.data?.message || 'Something Went Wrong', { variant: 'error' });
})
.finally(() => {
setSubmitLoading(false);
});
}
const { id, approval } = useParams();
useEffect(() => {
@@ -457,13 +494,14 @@ export default function Detail() {
/>
</ButtonBase>
</Stack>
<RHFTextFieldMoney
id='nominal'
name={`nominal`}
<RHFTextFieldMoney
id="nominal"
name="nominal"
label="Nominal"
required
placeholder="Nominal"
value={requestLog?.nominal || 0}
disabled={!!approval}
/>
{/* <LoadingButton
@@ -474,81 +512,77 @@ export default function Detail() {
>
Simpan
</LoadingButton> */}
<Stack direction="row" spacing={2} sx={{ mt: 6 }}>
<Stack direction="row" spacing={2} sx={{ mt: 6 }}>
{approval ? (
<>
<Box sx={{ flexGrow: 1 }} />
{/* GRUP TOMBOL DI KANAN */}
<Stack direction="row" spacing={1.5} mt={2}>
<Button
color='error'
variant="outlined"
size="small"
onClick={() => {
setDialogSendWa(true);
setShareLink(false);
}}
>
Decline
</Button>
<Box sx={{ flexGrow: 1 }} />
{/* GRUP TOMBOL DI KANAN */}
{requestLog?.status_approval !== 'approved' && (
<Stack direction="row" spacing={1.5} mt={2}>
<Button
color="error"
variant="outlined"
size="small"
onClick={updateDecline}
>
Decline
</Button>
<Button
variant="contained"
size="small"
color='primary'
onClick={() => {
setDialogSendWa(true);
setShareLink(true);
}}
>
Approve
</Button>
</Stack>
<Button
variant="contained"
size="small"
color="primary"
onClick={updateApproval}
>
Approve
</Button>
</Stack>
)}
</>
) : (
) : (
<>
{/* TOMBOL SIMPAN DI KIRI */}
<LoadingButton
{/* TOMBOL SIMPAN DI KIRI */}
<LoadingButton
type="submit"
variant="contained"
sx={{ p: 2, backgroundColor: "#19BBBB" }}
loading={false}
size="small"
>
>
Simpan
</LoadingButton>
</LoadingButton>
{/* Ini adalah spacer untuk mendorong tombol berikutnya ke kanan */}
<Box sx={{ flexGrow: 1 }} />
{/* Ini adalah spacer untuk mendorong tombol berikutnya ke kanan */}
<Box sx={{ flexGrow: 1 }} />
{/* GRUP TOMBOL DI KANAN */}
<Stack direction="row" spacing={1.5} mt={2}>
{/* GRUP TOMBOL DI KANAN */}
<Stack direction="row" spacing={1.5} mt={2}>
<Button
variant="contained"
size="small"
sx={{ p: 2, backgroundColor: "#19BBBB" }}
onClick={() => {
variant="contained"
size="small"
sx={{ p: 2, backgroundColor: "#19BBBB" }}
onClick={() => {
setDialogSendWa(true);
setShareLink(false);
}}
}}
>
Kirim (WA Chatbot)
Kirim (WA Chatbot)
</Button>
<Button
variant="contained"
size="small"
sx={{ p: 2, backgroundColor: "#19BBBB" }}
onClick={() => {
variant="contained"
size="small"
sx={{ p: 2, backgroundColor: "#19BBBB" }}
onClick={() => {
setDialogSendWa(true);
setShareLink(true);
}}
}}
>
Share Link
Share Link
</Button>
</Stack>
</Stack>
</>
)}
)}
</Stack>
</Stack>
@@ -1009,8 +1043,7 @@ export default function Detail() {
variant="outlined"
sx={{ color: '#FF4842', borderColor: '#FF4842' }}
onClick={() => {
setOpenDialogSubmit(true);
setApprove('declined');
}}
>
Decline