fix member
This commit is contained in:
@ -67,7 +67,7 @@ const Kyc = () => {
|
||||
});
|
||||
setMembers(resMembers);
|
||||
} catch (error: any) {
|
||||
alert(error.message);
|
||||
toast.error(error.message);
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
@ -117,6 +117,7 @@ const Kyc = () => {
|
||||
delete updateData.group_updated_at;
|
||||
delete updateData.group_deleted_by;
|
||||
delete updateData.group_deleted_at;
|
||||
delete updateData.updated_at;
|
||||
try {
|
||||
if (dialogType === 'reject') {
|
||||
await axios.post(`${BASE_URL}/customer/reject`, { customerid: customerId });
|
||||
@ -134,7 +135,6 @@ const Kyc = () => {
|
||||
setIsDialogOpen(false);
|
||||
toast.success('Success Update Kyc Member');
|
||||
} catch (error: any) {
|
||||
alert(error.message);
|
||||
setDialogOpen(false);
|
||||
setIsDialogOpen(false);
|
||||
toast.error(error.message);
|
||||
@ -156,15 +156,16 @@ const Kyc = () => {
|
||||
onYes={handleYes}
|
||||
onNo={() => setDialogOpen(false)}
|
||||
/>
|
||||
<CustomerDialog
|
||||
open={isDialogOpen}
|
||||
handleClose={closeDialog}
|
||||
handleReject={handleReject}
|
||||
handleSubmit={handleSubmit}
|
||||
initialData={member}
|
||||
viewStats={true}
|
||||
page={'kyc'}
|
||||
/>
|
||||
{ member.id ? (
|
||||
<CustomerDialog
|
||||
open={isDialogOpen}
|
||||
handleClose={closeDialog}
|
||||
handleSubmit={handleSubmit}
|
||||
initialData={member}
|
||||
viewStats={true}
|
||||
page={'kyc'}
|
||||
/>
|
||||
): ""}
|
||||
<h1 className="text-xl font-medium leading-none text-gray-900 mb-3 grid gap-5 lg:gap-7.5 mx-8 w-auto">Manage Member KYC</h1>
|
||||
<div className='grid gap-5 lg:gap-7.5 mx-8 w-auto'>
|
||||
<Breadcrumbs>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import axios from 'axios';
|
||||
import { Dialog,DialogActions,DialogContent,DialogTitle,TextField,Button,MenuItem,Select,InputLabel,FormControl,Typography,
|
||||
InputAdornment,Grid,Box
|
||||
InputAdornment,Grid,Box,List,ListItem,
|
||||
} from "@mui/material";
|
||||
import UploadFileIcon from "@mui/icons-material/UploadFile";
|
||||
import Divider from '@mui/material/Divider';
|
||||
@ -11,7 +11,7 @@ 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;
|
||||
|
||||
// MAIN PAGE
|
||||
const CustomerDialog = ({ open, handleClose, handleSubmit, initialData, viewStats, handleReject, page, fetchCustomers }: any) => {
|
||||
const [formData, setFormData] = useState(initialData || initialMember);
|
||||
const [viewOnly, setViewOnly] = useState(viewStats || false);
|
||||
@ -80,7 +80,8 @@ const CustomerDialog = ({ open, handleClose, handleSubmit, initialData, viewStat
|
||||
const handleChange = async (e: any) => {
|
||||
const { name, value } = e.target;
|
||||
if (name === 'municipio' || name === 'posto_adms' || name === 'suco') await getMasterAfter(name, value);
|
||||
if (name === "file_selfie" || name === "photouser") { // FOR FILE ONLY
|
||||
if (name === "file_selfie" || name === "photouser" || name === 'file_document_id' || name === "file_document_id_selfie" ||
|
||||
name === "file_commercial_license") { // FOR FILE ONLY
|
||||
setFormData({ ...formData, [name]: e.target.files[0] });
|
||||
} else {
|
||||
setFormData({ ...formData, [name]: value });
|
||||
@ -127,8 +128,9 @@ const CustomerDialog = ({ open, handleClose, handleSubmit, initialData, viewStat
|
||||
}
|
||||
|
||||
const onSubmit = () => {
|
||||
if (page === 'kyc' && !formData.description) return toast.warning(`Description for approval needed!`)
|
||||
handleSubmit(formData);
|
||||
handleClose();
|
||||
// handleClose();
|
||||
};
|
||||
|
||||
const onReject = () => {
|
||||
@ -274,9 +276,13 @@ const CustomerDialog = ({ open, handleClose, handleSubmit, initialData, viewStat
|
||||
page === 'kyc' ? (
|
||||
<>
|
||||
<Typography sx={{color:'grey'}}>Approval</Typography>
|
||||
<TextField fullWidth margin="dense" label="Approval Description" name="description" value={formData.description} onChange={handleChange} />
|
||||
<TextField fullWidth required={page === 'kyc'?true:false} margin="dense" label="Approval Description" name="description" value={formData.description} onChange={handleChange} />
|
||||
</>
|
||||
) : (<>{getAdmAccess(page, formData, handleClose, fetchCustomers, viewOnly, setViewOnly)}</>)
|
||||
) : (<>
|
||||
{getAdmAccess(page, formData, handleClose, fetchCustomers, viewOnly, setViewOnly)}
|
||||
<Divider className="pt-7"/>
|
||||
{formData.id ? showCustomerWallet(formData.id) : ""}
|
||||
</>)
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
@ -317,11 +323,11 @@ function fileTextFile(label: string, value: any, name: string, handleChange: any
|
||||
<input
|
||||
type="file"
|
||||
id="file-upload"
|
||||
style={{ display: "none" }}
|
||||
// style={{ display: "none" }}
|
||||
onChange={handleChange}
|
||||
name={name}
|
||||
/>
|
||||
<label htmlFor="file-upload">
|
||||
{/* <label htmlFor="file-upload">
|
||||
<Button
|
||||
component="span"
|
||||
variant="contained"
|
||||
@ -330,14 +336,14 @@ function fileTextFile(label: string, value: any, name: string, handleChange: any
|
||||
>
|
||||
Browse
|
||||
</Button>
|
||||
</label>
|
||||
</label> */}
|
||||
</InputAdornment>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
// ACCESS ADM
|
||||
function getAdmAccess(page: string, data: any, handleClose: any, fetchCustomers: any, viewOnly: any, setViewOnly: any) {
|
||||
const [dialogOpen, setDialogOpen] = useState(false);
|
||||
const [dialogType, setDialogType] = useState('');
|
||||
@ -517,7 +523,83 @@ function getPinStatus(status: string) {
|
||||
res: null
|
||||
}
|
||||
}
|
||||
// CUSTOMER WALLET
|
||||
function showCustomerWallet(customerid: any) {
|
||||
const [dialogOpen, setDialogOpen] = useState(false);
|
||||
const [customerWallet, setCustomerWallet] = useState([]);
|
||||
if (!customerid) return ''
|
||||
|
||||
useEffect(() => {
|
||||
fetchCustomerWallet()
|
||||
}, []);
|
||||
|
||||
function showCustomerWallet() {
|
||||
async function fetchCustomerWallet() {
|
||||
try {
|
||||
let getCustWallet = await axios.get(`${BASE_URL_CUSTOMER}/customer/wallet`, { params: { customerid: customerid }});
|
||||
setCustomerWallet(getCustWallet.data.data.wallets)
|
||||
} catch (error: any) {
|
||||
toast.error(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
const handleYes = async () => {}
|
||||
|
||||
return (
|
||||
<Box p={3} boxShadow={3} borderRadius={2} bgcolor="white">
|
||||
<Typography variant="h6" gutterBottom>Wallet Member</Typography>
|
||||
<Grid>
|
||||
<List>
|
||||
{customerWallet.map((item:any, index:any) => (
|
||||
<React.Fragment key={item.id}>
|
||||
<ListItem
|
||||
sx={{
|
||||
display: 'flex',
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
px: 2,
|
||||
py: 1.5,
|
||||
bgcolor: index % 2 === 0 ? 'grey.50' : 'background.paper',
|
||||
borderRadius: 2,
|
||||
'&:hover': {
|
||||
bgcolor: 'grey.100',
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Box>
|
||||
<Typography variant="subtitle2" color="text.secondary">
|
||||
Name
|
||||
</Typography>
|
||||
<Typography variant="body1" fontWeight={500}>
|
||||
{item.wallet.name}
|
||||
</Typography>
|
||||
</Box>
|
||||
<Box>
|
||||
<Typography variant="subtitle2" color="text.secondary">
|
||||
Description
|
||||
</Typography>
|
||||
<Typography variant="body1">{item.wallet.description}</Typography>
|
||||
</Box>
|
||||
<Box>
|
||||
<Typography variant="subtitle2" color="text.secondary">
|
||||
Transaction Today
|
||||
</Typography>
|
||||
<Typography variant="body1">{item.transaction_number_today}</Typography>
|
||||
</Box>
|
||||
</ListItem>
|
||||
{index < customerWallet.length - 1 && <Divider sx={{ my: 1 }} />}
|
||||
</React.Fragment>
|
||||
))}
|
||||
</List>
|
||||
</Grid>
|
||||
<ConfirmDialog
|
||||
open={dialogOpen}
|
||||
onClose={() => setDialogOpen(false)}
|
||||
title="Confirm Action"
|
||||
content={`Are you sure you want to show?`}
|
||||
onYes={handleYes}
|
||||
onNo={() => setDialogOpen(false)}
|
||||
/>
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
@ -20,7 +20,10 @@ const ManageMembers = () => {
|
||||
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
||||
const [dialogOpen, setDialogOpen] = useState(false);
|
||||
const [dialogType, setDialogType] = useState('');
|
||||
const closeDialog = () => setIsDialogOpen(false);
|
||||
const closeDialog = () => {
|
||||
setIsDialogOpen(false)
|
||||
setMember(initialMember)
|
||||
};
|
||||
const { getUser } = useAuthContext();
|
||||
|
||||
useEffect(() => {
|
||||
@ -48,7 +51,7 @@ const ManageMembers = () => {
|
||||
});
|
||||
setMembers(resMembers);
|
||||
} catch (error: any) {
|
||||
alert(error.message);
|
||||
toast.error(error.message);
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
@ -99,8 +102,16 @@ const ManageMembers = () => {
|
||||
delete updateData.group_deleted_at;
|
||||
delete updateData.updated_at;
|
||||
try {
|
||||
if (dialogType === 'update')
|
||||
await axios.put(`${BASE_URL}/customer/update/${selectedMember}`, updateData);
|
||||
const form = new FormData();
|
||||
for (const property in updateData) {
|
||||
if (updateData[property]) form.append(property, updateData[property]);
|
||||
}
|
||||
|
||||
if (dialogType === 'update') await axios.put(`${BASE_URL}/customer/update/${selectedMember}`, form, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
});
|
||||
// if (dialogType === 'create') await axios.post(`${BASE_URL}/customers/create`, member)
|
||||
await fetchCustomers();
|
||||
setDialogOpen(false);
|
||||
@ -130,12 +141,14 @@ const ManageMembers = () => {
|
||||
onYes={handleYes}
|
||||
onNo={() => setDialogOpen(false)}
|
||||
/>
|
||||
<CustomerDialog
|
||||
{ member.id ? (
|
||||
<CustomerDialog
|
||||
open={isDialogOpen}
|
||||
handleClose={closeDialog}
|
||||
handleSubmit={handleSubmit}
|
||||
initialData={member}
|
||||
/>
|
||||
): ""}
|
||||
<h1 className="text-xl font-medium leading-none text-gray-900 mb-3 grid gap-5 lg:gap-7.5 mx-8 w-auto">Manage Members</h1>
|
||||
<div className='grid gap-5 lg:gap-7.5 mx-8 w-auto'>
|
||||
<Breadcrumbs>
|
||||
|
||||
Reference in New Issue
Block a user