diff --git a/src/pages/members/search-member/blocks/DetailMember.tsx b/src/pages/members/search-member/blocks/DetailMember.tsx index b802e33..b87ec87 100644 --- a/src/pages/members/search-member/blocks/DetailMember.tsx +++ b/src/pages/members/search-member/blocks/DetailMember.tsx @@ -56,38 +56,48 @@ const DetailMember = () => { msg: 'Active', btn: 'Block PIN', canBlock: true, - variant: 'destructive' as const + canUnblock: false, + variant: 'destructive' as const, + showField: false }; if (status === 'N') return { msg: 'Not Active', btn: 'PIN Not Active', canBlock: false, - variant: 'secondary' as const + canUnblock: false, + variant: 'secondary' as const, + showField: true }; if (status === 'P') return { msg: 'Suspend PIN', - btn: 'PIN Blocked', + btn: 'Unblock PIN', canBlock: false, - variant: 'secondary' as const + canUnblock: true, + variant: 'default' as const, + showField: true }; if (status === 'O') return { msg: 'Suspend OTP', - btn: 'OTP Blocked', + btn: 'Unblock OTP', canBlock: false, - variant: 'secondary' as const + canUnblock: true, + variant: 'default' as const, + showField: true }; return { msg: 'Unknown Status', btn: 'Unknown', canBlock: false, - variant: 'secondary' as const + canUnblock: false, + variant: 'secondary' as const, + showField: true }; }; - const handleBlockPin = async () => { + const handleUnblockPin = async () => { if (!selectedCustomerData?.id) { toast.error('Customer data not available'); return; @@ -97,10 +107,10 @@ const DetailMember = () => { setIsUpdating(true); await axios.put(`${BASE_URL_CUSTOMER}/customer/statuspin`, { customerid: selectedCustomerData.id, - status: 'Block' + status: 'UnBlock' }); - toast.success('PIN successfully blocked'); + toast.success('PIN successfully unblocked'); handleEditDialog(false, null); @@ -109,7 +119,7 @@ const DetailMember = () => { }, 500); } catch (error: any) { - toast.error(error.message || 'Failed to block PIN'); + toast.error(error.message || 'Failed to unblock PIN'); } finally { setIsUpdating(false); setConfirmDialog(false); @@ -203,6 +213,10 @@ const DetailMember = () => { const generatePinStatusField = (label: string, status: string) => { const pinStatus = getPinStatus(status); + if (!pinStatus.showField) { + return null; + } + return (