diff --git a/src/pages/members/manage-members/CustomerDetailModal.tsx b/src/pages/members/manage-members/CustomerDetailModal.tsx
index 3de8037..a14815c 100644
--- a/src/pages/members/manage-members/CustomerDetailModal.tsx
+++ b/src/pages/members/manage-members/CustomerDetailModal.tsx
@@ -7,7 +7,10 @@ import UploadFileIcon from "@mui/icons-material/UploadFile";
import Divider from '@mui/material/Divider';
import { initialMember } from "./Columns";
import { apiConfig } from '@/config/api.config';
+import ConfirmDialog from '@/components/confirm';
+import { toast } from 'sonner';
const BASE_URL_MASTER_DATA = apiConfig.service_master_data;
+const BASE_URL_CUSTOMER = apiConfig.service_customer;
const CustomerDialog = ({ open, handleClose, handleSubmit, initialData, viewStats, handleReject, page }: any) => {
const [formData, setFormData] = useState(initialData || initialMember);
@@ -259,7 +262,7 @@ const CustomerDialog = ({ open, handleClose, handleSubmit, initialData, viewStat
- {getAdmAccess(page)}
+ {getAdmAccess(page, formData)}
{
page === 'kyc' ? (
<>
@@ -324,7 +327,39 @@ function fileTextFile(label: string, value: any, name: string, handleChange: any
)
}
-function getAdmAccess(page: string) {
+function getAdmAccess(page: string, data: any) {
+ const [dialogOpen, setDialogOpen] = useState(false);
+ const [dialogType, setDialogType] = useState('');
+ const handleYes = async () => {
+ try {
+ if (dialogType === "update status") {
+ let statusNext = getPinStatus(data.status).res;
+ if (statusNext) await axios.put(`${BASE_URL_CUSTOMER}/customer/statuspin`, { customerid: data.id, status: statusNext })
+ else toast.error("Handle Active/Suspend only")
+ toast.success("Success Update Status")
+ }
+ if (dialogType === "reset pin") {
+ if (data.id) await axios.post(`${BASE_URL_CUSTOMER}/customer/resetpin`, { customerid: data.id })
+ else throw({ message: 'data.id not found' })
+ toast.success("Pin will send to customer MSISDN")
+ }
+ } catch (error: any) {
+ toast.error(error.message)
+ } finally {
+ setDialogOpen(false)
+ }
+ }
+
+ function buttonStatus() {
+ setDialogType('update status')
+ setDialogOpen(true)
+ }
+
+ function buttonResetPin() {
+ setDialogType('reset pin')
+ setDialogOpen(true)
+ }
+
if (page !== "kyc") {
return (
@@ -332,12 +367,12 @@ function getAdmAccess(page: string) {
- Unblock PIN
-
+ Pin Status : {getPinStatus(data.status).msg}
+
Reset PIN
-
+
@@ -351,9 +386,45 @@ function getAdmAccess(page: string) {
+ setDialogOpen(false)}
+ title="Confirm Action"
+ content={`Are you sure you want to ${dialogType}?`}
+ onYes={handleYes}
+ onNo={() => setDialogOpen(false)}
+ />
)
} else {
return ('')
}
+}
+
+function getPinStatus(status: string) {
+ if (status === "Y") return {
+ msg: 'Active',
+ btn: 'Block PIN',
+ res: 'Block'
+ };
+ if (status === "N") return {
+ msg: 'Not Active',
+ btn: 'Activate PIN',
+ res: null
+ };
+ if (status === "P") return {
+ msg: 'Suspend PIN',
+ btn: 'Unblock PIN',
+ res: 'UnBlock'
+ };
+ if (status === "O") return {
+ msg: 'Suspend OTP',
+ btn: 'Unblock OTP',
+ res: null
+ };
+ return {
+ msg: "None",
+ btn: 'No status found',
+ res: null
+ }
}
\ No newline at end of file