detail deletion
This commit is contained in:
98
src/pages/members/kyc-delete-member/blocks/DetailDialog.tsx
Normal file
98
src/pages/members/kyc-delete-member/blocks/DetailDialog.tsx
Normal file
@ -0,0 +1,98 @@
|
||||
import {
|
||||
Dialog,
|
||||
DialogBody,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from '@/components/ui/dialog';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { useManageKycDeletionContext } from '../hooks';
|
||||
import { apiConfig } from '@/config/api.config';
|
||||
import axios from 'axios';
|
||||
|
||||
const API_URL = apiConfig.service_customer;
|
||||
const DetailDialog = () => {
|
||||
const { showDetailDialog, setShowDetailDialog, detailKyc } = useManageKycDeletionContext();
|
||||
|
||||
return (
|
||||
<Dialog open={showDetailDialog} onOpenChange={setShowDetailDialog}>
|
||||
<DialogContent className="container-fixed max-w-[1024px] flex flex-col p-5 overflow-hidden">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Customer Deletion Details </DialogTitle>
|
||||
</DialogHeader>
|
||||
<DialogBody>
|
||||
{/* Tab Content */}
|
||||
{detailKyc && detailKyc != null ? (
|
||||
<div className="flex flex-col">
|
||||
{generateInput(detailKyc, null, 'Group', 'group_name', 'text', false, true)}
|
||||
{generateInput(detailKyc, null, 'Username', 'username', 'text', false, true)}
|
||||
{generateInput(detailKyc, null, 'Full Name', 'fullname', 'text', false, true)}
|
||||
{generateInput(detailKyc, null, 'Gender', 'customers_gender', 'text', false, true)}
|
||||
{generateInput(detailKyc, null, 'Date of Birth', 'birthdate', 'date', false, true)}
|
||||
{generateInput(detailKyc, null, 'Mother Name', 'registered_mother_fullname', 'text', false, true)}
|
||||
{generateInput(detailKyc, null, 'MSISDN', 'registered_msisdn', 'text', false, true)}
|
||||
{generateInput(detailKyc, null, 'Reason Deletion', 'reason_deletion', 'text', false, true)}
|
||||
{generateInput(detailKyc, null, 'Reason Note', 'reason_note', 'text', false, true)}
|
||||
{generateInput(detailKyc, null, 'Status Approval', 'status_approve', 'text', false, true)}
|
||||
|
||||
<div className="flex justify-end gap-2 mt-3">
|
||||
<Button type="button" variant="outline" onClick={() => setShowDetailDialog(false)}>Cancel</Button>
|
||||
<Button onClick={()=>{}} variant="destructive" color="warning">Reject</Button>
|
||||
<Button onClick={()=>{}} variant="default" color="primary">Approve</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : (<div></div>)}
|
||||
</DialogBody>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
export default DetailDialog;
|
||||
|
||||
function generateInput(formData:any, handleChange:any, label:string, name:string, type: string, required: boolean, disabled: boolean) {
|
||||
function generateDate(isoString: string) {
|
||||
return isoString.slice(0, 10); // "2000-01-18"
|
||||
}
|
||||
|
||||
type Code = 'W' | 'Y' | 'N' | 'T' | 'P' | 'D' | 'L';
|
||||
interface Reason {
|
||||
label: string;
|
||||
}
|
||||
|
||||
const statusMap: Record<Code, Reason> = {
|
||||
W: {label: 'Waiting Approval'},
|
||||
Y: {label: 'Approve'},
|
||||
N: {label: 'Reject'},
|
||||
T: {label: 'Tidak lagi menggunakan layanan'},
|
||||
P: {label: 'Privasi dan keamanan'},
|
||||
D: {label: 'Akun ganda'},
|
||||
L: {label: 'Lainnya'}
|
||||
};
|
||||
if (name == 'reason_deletion' || name == 'status_approve') {
|
||||
const status = formData[name] as Code
|
||||
const fixStatus = statusMap[status] ?? {label: formData[name]}
|
||||
formData[name] = fixStatus.label
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<div className="w-full mt-5">
|
||||
<div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label className="form-label flex items-center gap-1 max-w-56">
|
||||
{label}<span className="text-red-500">{required?"*":""}</span>
|
||||
</label>
|
||||
<Input
|
||||
className="input"
|
||||
readOnly={disabled}
|
||||
required={required}
|
||||
type={type}
|
||||
name={name}
|
||||
value={formData[name]?(type === 'date' ? generateDate(formData[name]) : formData[name]):""}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@ -6,6 +6,7 @@ import { createContext, useCallback, useMemo, useState } from 'react';
|
||||
import ListToolbar from '../blocks/ListToolbar';
|
||||
import { useCallApi } from '@/hooks';
|
||||
import moment from 'moment';
|
||||
import DetailDialog from '../blocks/DetailDialog';
|
||||
|
||||
interface ManageKycDeletionProps {
|
||||
id: string;
|
||||
@ -28,10 +29,13 @@ interface ContextProps {
|
||||
filter: any
|
||||
) => Promise<{ data: ManageKycDeletionProps[]; totalCount: number } | undefined>;
|
||||
showDetailDialog: boolean;
|
||||
handleDetailDialog: (show: boolean, selected_user: ManageKycDeletionProps | null) => void;
|
||||
setShowDetailDialog: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
handleDetailDialog: (show: boolean, selected_user: string | null) => void;
|
||||
showAddDialog: boolean;
|
||||
handleAddDialog: (show: boolean) => void;
|
||||
selectedUser: ManageKycDeletionProps | null;
|
||||
selectedIdCustomer: string | null;
|
||||
detailKyc: any | null;
|
||||
setDetailKyc: React.Dispatch<React.SetStateAction<any>>;
|
||||
}
|
||||
|
||||
const initialProps: ContextProps = {
|
||||
@ -40,7 +44,10 @@ const initialProps: ContextProps = {
|
||||
handleDetailDialog: () => {},
|
||||
showAddDialog: false,
|
||||
handleAddDialog: () => {},
|
||||
selectedUser: null
|
||||
selectedIdCustomer: null,
|
||||
setShowDetailDialog: () => { },
|
||||
detailKyc: async () => {},
|
||||
setDetailKyc: () => { },
|
||||
};
|
||||
|
||||
const ManageKycDeletionContext = createContext<ContextProps>(initialProps);
|
||||
@ -79,7 +86,8 @@ export const renderStatusBadge = (statusRaw: string | null | undefined) => {
|
||||
const ManageKycDeletionContextProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
const [showDetailDialog, setShowDetailDialog] = useState(false);
|
||||
const [showAddDialog, setShowAddDialog] = useState(false);
|
||||
const [selectedUser, setSelectedUser] = useState<ManageKycDeletionProps | null>(null);
|
||||
const [selectedIdCustomer, setSelectedIdCustomer] = useState<string | null>(null);
|
||||
const [detailKyc, setDetailKyc] = useState<any>();
|
||||
const [manageKyc, setManageKyc] = useState<ManageKycDeletionProps[]>([]);
|
||||
const { GetData } = useCallApi();
|
||||
|
||||
@ -121,8 +129,13 @@ const ManageKycDeletionContextProvider = ({ children }: { children: React.ReactN
|
||||
}
|
||||
};
|
||||
|
||||
const handleDetailDialog = useCallback((show: boolean, selected_user: ManageKycDeletionProps | null) => {
|
||||
setSelectedUser(show ? selected_user : null);
|
||||
const handleDetailDialog = useCallback(async (show: boolean, selected_id_customer: string | null) => {
|
||||
setSelectedIdCustomer(show ? selected_id_customer : null);
|
||||
let detailCustomer = await GetData(`${API_URL}/customer_deletion/detail/${selected_id_customer}`, {})
|
||||
setDetailKyc(detailCustomer?.data)
|
||||
console.log('detailCustomer: ',detailCustomer)
|
||||
console.log('detailCustomer2: ',detailCustomer?.data)
|
||||
console.log('detailKyc: ', detailKyc)
|
||||
setShowDetailDialog(show);
|
||||
}, []);
|
||||
|
||||
@ -226,10 +239,14 @@ const ManageKycDeletionContextProvider = ({ children }: { children: React.ReactN
|
||||
handleDetailDialog,
|
||||
showAddDialog,
|
||||
handleAddDialog,
|
||||
selectedUser
|
||||
selectedIdCustomer,
|
||||
setShowDetailDialog,
|
||||
setDetailKyc,
|
||||
detailKyc
|
||||
}}
|
||||
>
|
||||
<Toaster expand visibleToasts={9} duration={3000} />
|
||||
<DetailDialog />
|
||||
|
||||
<DataGridProvider
|
||||
columns={columns}
|
||||
|
||||
Reference in New Issue
Block a user