add dialog confirm
This commit is contained in:
@ -18,15 +18,37 @@ import { useManageKycDeletionContext } from '../hooks';
|
|||||||
import { apiConfig } from '@/config/api.config';
|
import { apiConfig } from '@/config/api.config';
|
||||||
import { useDataGrid } from '@/components';
|
import { useDataGrid } from '@/components';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
import ConfirmDialog from '@/components/confirm';
|
||||||
|
|
||||||
const API_URL = apiConfig.service_customer;
|
const API_URL = apiConfig.service_customer;
|
||||||
const DetailDialog = () => {
|
const DetailDialog = () => {
|
||||||
const { showDetailDialog, setShowDetailDialog, detailKyc, handleApproveReject } = useManageKycDeletionContext();
|
const { showDetailDialog, setShowDetailDialog, detailKyc, handleApproveReject } = useManageKycDeletionContext();
|
||||||
const [genders] = useState([ { name: 'Male',id: 'M' }, { name: 'Female',id: 'F' }])
|
const [genders] = useState([ { name: 'Male',id: 'M' }, { name: 'Female',id: 'F' }])
|
||||||
|
const [dialogOpen, setDialogOpen] = useState(false);
|
||||||
|
const [dialogType, setDialogType] = useState('');
|
||||||
const { reload } = useDataGrid();
|
const { reload } = useDataGrid();
|
||||||
|
|
||||||
|
async function handleYes() {
|
||||||
|
await handleApproveReject(detailKyc.id, dialogType)
|
||||||
|
setDialogOpen(false)
|
||||||
|
reload()
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSubmit(type:string) {
|
||||||
|
setDialogType(type)
|
||||||
|
setDialogOpen(true)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={showDetailDialog} onOpenChange={setShowDetailDialog}>
|
<Dialog open={showDetailDialog} onOpenChange={setShowDetailDialog}>
|
||||||
|
<ConfirmDialog
|
||||||
|
open={dialogOpen}
|
||||||
|
onClose={() => setDialogOpen(false)}
|
||||||
|
title="Confirm Action"
|
||||||
|
content={`Are you sure you want to ${dialogType === 'Y' ? 'Approve' : 'Reject'}?`}
|
||||||
|
onYes={handleYes}
|
||||||
|
onNo={() => setDialogOpen(false)}
|
||||||
|
/>
|
||||||
<DialogContent className="container-fixed max-w-[1024px] flex flex-col p-5 overflow-hidden max-h-[90vh] overflow-y-auto">
|
<DialogContent className="container-fixed max-w-[1024px] flex flex-col p-5 overflow-hidden max-h-[90vh] overflow-y-auto">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>Customer Deletion Details </DialogTitle>
|
<DialogTitle>Customer Deletion Details </DialogTitle>
|
||||||
@ -49,12 +71,14 @@ const DetailDialog = () => {
|
|||||||
<div className="flex justify-end gap-2 mt-3">
|
<div className="flex justify-end gap-2 mt-3">
|
||||||
<Button type="button" variant="outline" onClick={() => setShowDetailDialog(false)}>Cancel</Button>
|
<Button type="button" variant="outline" onClick={() => setShowDetailDialog(false)}>Cancel</Button>
|
||||||
<Button onClick={async() => {
|
<Button onClick={async() => {
|
||||||
await handleApproveReject(detailKyc.id, 'N')
|
// await handleApproveReject(detailKyc.id, 'N')
|
||||||
reload()
|
// reload()
|
||||||
|
onSubmit('N')
|
||||||
}} variant="destructive" color="warning" disabled={detailKyc.status_approve==='Waiting Approval'?false:true}>Reject</Button>
|
}} variant="destructive" color="warning" disabled={detailKyc.status_approve==='Waiting Approval'?false:true}>Reject</Button>
|
||||||
<Button onClick={async() => {
|
<Button onClick={async() => {
|
||||||
await handleApproveReject(detailKyc.id, 'Y')
|
// await handleApproveReject(detailKyc.id, 'Y')
|
||||||
reload()
|
// reload()
|
||||||
|
onSubmit('Y')
|
||||||
}} variant="default" color="primary" disabled={detailKyc.status_approve==='Waiting Approval'?false:true}>Approve</Button>
|
}} variant="default" color="primary" disabled={detailKyc.status_approve==='Waiting Approval'?false:true}>Approve</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user