kyc updated
This commit is contained in:
parent
61da636a2d
commit
3b173b4987
@ -2,6 +2,16 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
const MessageList = ({ messages }) => {
|
const MessageList = ({ messages }) => {
|
||||||
|
const formatAMPM = (date) => {
|
||||||
|
var hours = new Date(date).getHours()
|
||||||
|
var minutes = new Date(date).getMinutes()
|
||||||
|
var ampm = hours >= 12 ? 'PM' : 'AM'
|
||||||
|
hours = hours % 12
|
||||||
|
hours = hours ? hours : 12 // the hour '0' should be '12'
|
||||||
|
minutes = minutes < 10 ? '0' + minutes : minutes
|
||||||
|
var strTime = hours + ':' + minutes + ' ' + ampm
|
||||||
|
return strTime
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{messages.map((msg, index) => (
|
{messages.map((msg, index) => (
|
||||||
@ -17,7 +27,8 @@ const MessageList = ({ messages }) => {
|
|||||||
>
|
>
|
||||||
<div style={{ fontWeight: 'bold', marginBottom: '5px', color: 'white' }}>{msg.user}</div>
|
<div style={{ fontWeight: 'bold', marginBottom: '5px', color: 'white' }}>{msg.user}</div>
|
||||||
<div style={{ fontWeight: 'bold', marginBottom: '5px', color: 'white' }}>
|
<div style={{ fontWeight: 'bold', marginBottom: '5px', color: 'white' }}>
|
||||||
{msg.replyDate}
|
{new Date(`${msg.replyDate}`).toDateString()}
|
||||||
|
<span> , {`${formatAMPM(msg?.replyDate)}`}</span>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ color: 'white' }}>{msg.message}</div>
|
<div style={{ color: 'white' }}>{msg.message}</div>
|
||||||
</div>
|
</div>
|
||||||
|
55
src/views/pages/Kyc/imgModal.js
Normal file
55
src/views/pages/Kyc/imgModal.js
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/* eslint-disable react/prop-types */
|
||||||
|
import React from 'react'
|
||||||
|
import { Box, Modal, Typography, IconButton, Button } from '@mui/material'
|
||||||
|
import CloseIcon from '@mui/icons-material/Close'
|
||||||
|
|
||||||
|
const ImgModal = ({ open, handleClose, imageUrl }) => {
|
||||||
|
const handleDownload = () => {
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.href = imageUrl
|
||||||
|
link.download = imageUrl.split('/').pop()
|
||||||
|
link.click()
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
open={open}
|
||||||
|
onClose={handleClose}
|
||||||
|
aria-labelledby="modal-modal-title"
|
||||||
|
aria-describedby="modal-modal-description"
|
||||||
|
>
|
||||||
|
<Box sx={{ ...modalStyle, width: '90%', height: '90%' }}>
|
||||||
|
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 2 }}>
|
||||||
|
<Typography id="modal-modal-title" variant="h6" component="h2">
|
||||||
|
Document Image
|
||||||
|
</Typography>
|
||||||
|
<IconButton onClick={handleClose}>
|
||||||
|
<CloseIcon />
|
||||||
|
</IconButton>
|
||||||
|
</Box>
|
||||||
|
<Box sx={{ display: 'flex', justifyContent: 'center', mb: 2 }}>
|
||||||
|
<img
|
||||||
|
src={imageUrl}
|
||||||
|
alt="Document"
|
||||||
|
style={{ maxWidth: '100%', maxHeight: '600px', objectFit: 'contain' }}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
<Button variant="contained" onClick={handleDownload} sx={{ textTransform: 'unset' }}>
|
||||||
|
Download
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
</Modal>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const modalStyle = {
|
||||||
|
position: 'absolute',
|
||||||
|
top: '50%',
|
||||||
|
left: '50%',
|
||||||
|
transform: 'translate(-50%, -50%)',
|
||||||
|
bgcolor: 'background.paper',
|
||||||
|
boxShadow: 24,
|
||||||
|
p: 4,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ImgModal
|
@ -195,55 +195,59 @@ const Kyc = () => {
|
|||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{filteredRows
|
{filteredRows.length !== 0 &&
|
||||||
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
|
filteredRows
|
||||||
.map((row) => (
|
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
|
||||||
<TableRow key={row._id}>
|
.map((row) => (
|
||||||
<TableCell>{row._id}</TableCell>
|
<TableRow key={row._id}>
|
||||||
<TableCell>{row.trade_name}</TableCell>
|
<TableCell>{row._id}</TableCell>
|
||||||
<TableCell>
|
<TableCell>{row.trade_name}</TableCell>
|
||||||
{new Date(`${row?.createdAt}`).toDateString()}
|
<TableCell>
|
||||||
<span> , {`${formatAMPM(row?.createdAt)}`}</span>
|
{new Date(`${row?.createdAt}`).toDateString()}
|
||||||
</TableCell>
|
<span> , {`${formatAMPM(row?.createdAt)}`}</span>
|
||||||
<TableCell>{row.status}</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>{row.status}</TableCell>
|
||||||
<Tooltip title="View">
|
<TableCell>
|
||||||
<Button
|
<Tooltip title="View">
|
||||||
sx={{ mr: '1rem', textTransform: 'unset' }}
|
<Button
|
||||||
color="primary"
|
sx={{ mr: '1rem', textTransform: 'unset' }}
|
||||||
variant="contained"
|
color="primary"
|
||||||
onClick={() => handleViewClick(row._id)}
|
variant="contained"
|
||||||
>
|
onClick={() => handleViewClick(row._id)}
|
||||||
View
|
>
|
||||||
</Button>
|
View
|
||||||
</Tooltip>
|
</Button>
|
||||||
{tabIndex === 0 && (
|
</Tooltip>
|
||||||
<>
|
{tabIndex === 0 && (
|
||||||
<Tooltip title="Approve">
|
<>
|
||||||
<Button
|
<Tooltip title="Approve">
|
||||||
sx={{ mr: '1rem', textTransform: 'unset' }}
|
<Button
|
||||||
color="success"
|
sx={{ mr: '1rem', textTransform: 'unset' }}
|
||||||
variant="contained"
|
color="success"
|
||||||
onClick={() => handleApproveClick(row._id)}
|
variant="contained"
|
||||||
>
|
onClick={() => handleApproveClick(row._id)}
|
||||||
Approve
|
>
|
||||||
</Button>
|
Approve
|
||||||
</Tooltip>
|
</Button>
|
||||||
<Tooltip title="Reject">
|
</Tooltip>
|
||||||
<Button
|
<Tooltip title="Reject">
|
||||||
sx={{ mr: '1rem', textTransform: 'unset' }}
|
<Button
|
||||||
color="error"
|
sx={{ mr: '1rem', textTransform: 'unset' }}
|
||||||
variant="contained"
|
color="error"
|
||||||
onClick={() => handleRejectClick(row._id)}
|
variant="contained"
|
||||||
>
|
onClick={() => handleRejectClick(row._id)}
|
||||||
Reject
|
>
|
||||||
</Button>
|
Reject
|
||||||
</Tooltip>
|
</Button>
|
||||||
</>
|
</Tooltip>
|
||||||
)}
|
</>
|
||||||
</TableCell>
|
)}
|
||||||
</TableRow>
|
</TableCell>
|
||||||
))}
|
</TableRow>
|
||||||
|
))}
|
||||||
|
{filteredRows.length === 0 && (
|
||||||
|
<h5 style={{ textAlign: 'center' }}>No kyc available</h5>
|
||||||
|
)}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
</TableContainer>
|
</TableContainer>
|
||||||
|
@ -17,6 +17,7 @@ import Axios from '../../../axios'
|
|||||||
import { isAutheticated } from '../../../auth'
|
import { isAutheticated } from '../../../auth'
|
||||||
import MessageList from './MessageList'
|
import MessageList from './MessageList'
|
||||||
import Swal from 'sweetalert2'
|
import Swal from 'sweetalert2'
|
||||||
|
import ImgModal from './imgModal'
|
||||||
|
|
||||||
const KycDetails = () => {
|
const KycDetails = () => {
|
||||||
const { id } = useParams()
|
const { id } = useParams()
|
||||||
@ -25,6 +26,8 @@ const KycDetails = () => {
|
|||||||
const [rejectionReason, setRejectionReason] = useState('')
|
const [rejectionReason, setRejectionReason] = useState('')
|
||||||
const [selectedRowId, setSelectedRowId] = useState(null)
|
const [selectedRowId, setSelectedRowId] = useState(null)
|
||||||
const [retailerDetails, setRetailerDetails] = useState(null)
|
const [retailerDetails, setRetailerDetails] = useState(null)
|
||||||
|
const [openImageModal, setOpenImageModal] = useState(false)
|
||||||
|
const [selectedImageUrl, setSelectedImageUrl] = useState('')
|
||||||
const token = isAutheticated()
|
const token = isAutheticated()
|
||||||
|
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
@ -118,7 +121,7 @@ const KycDetails = () => {
|
|||||||
`/api/kyc/update/${id}`,
|
`/api/kyc/update/${id}`,
|
||||||
{
|
{
|
||||||
status: 'approved',
|
status: 'approved',
|
||||||
user: 'Principal Distributer', // Replace with actual user type
|
// user: 'Principal Distributer', // Replace with actual user type
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
@ -156,6 +159,12 @@ const KycDetails = () => {
|
|||||||
setOpenApproveModal(true)
|
setOpenApproveModal(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleImageClick = (url) => {
|
||||||
|
setSelectedImageUrl(url)
|
||||||
|
console.log(selectedImageUrl)
|
||||||
|
setOpenImageModal(true)
|
||||||
|
}
|
||||||
|
|
||||||
if (!retailerDetails) {
|
if (!retailerDetails) {
|
||||||
return <Typography>Loading...</Typography>
|
return <Typography>Loading...</Typography>
|
||||||
}
|
}
|
||||||
@ -229,6 +238,7 @@ const KycDetails = () => {
|
|||||||
variant="square"
|
variant="square"
|
||||||
src={retailerDetails.pan_img.url}
|
src={retailerDetails.pan_img.url}
|
||||||
sx={{ width: 100, height: 100, mb: 2 }}
|
sx={{ width: 100, height: 100, mb: 2 }}
|
||||||
|
onClick={() => handleImageClick(retailerDetails.pan_img.url)}
|
||||||
/>
|
/>
|
||||||
<Typography>
|
<Typography>
|
||||||
<strong>Aadhar Number:</strong> {retailerDetails.aadhar_number}
|
<strong>Aadhar Number:</strong> {retailerDetails.aadhar_number}
|
||||||
@ -237,6 +247,7 @@ const KycDetails = () => {
|
|||||||
variant="square"
|
variant="square"
|
||||||
src={retailerDetails.aadhar_img.url}
|
src={retailerDetails.aadhar_img.url}
|
||||||
sx={{ width: 100, height: 100, mb: 2 }}
|
sx={{ width: 100, height: 100, mb: 2 }}
|
||||||
|
onClick={() => handleImageClick(retailerDetails.aadhar_img.url)}
|
||||||
/>
|
/>
|
||||||
<Typography>
|
<Typography>
|
||||||
<strong>GST Number:</strong> {retailerDetails.gst_number}
|
<strong>GST Number:</strong> {retailerDetails.gst_number}
|
||||||
@ -245,6 +256,7 @@ const KycDetails = () => {
|
|||||||
variant="square"
|
variant="square"
|
||||||
src={retailerDetails.gst_img.url}
|
src={retailerDetails.gst_img.url}
|
||||||
sx={{ width: 100, height: 100, mb: 2 }}
|
sx={{ width: 100, height: 100, mb: 2 }}
|
||||||
|
onClick={() => handleImageClick(retailerDetails.gst_img.url)}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={6}>
|
<Grid item xs={6}>
|
||||||
@ -255,6 +267,7 @@ const KycDetails = () => {
|
|||||||
variant="square"
|
variant="square"
|
||||||
src={retailerDetails.pesticide_license_img.url}
|
src={retailerDetails.pesticide_license_img.url}
|
||||||
sx={{ width: 100, height: 100, mb: 2 }}
|
sx={{ width: 100, height: 100, mb: 2 }}
|
||||||
|
onClick={() => handleImageClick(retailerDetails.pesticide_license_img.url)}
|
||||||
/>
|
/>
|
||||||
<Typography>
|
<Typography>
|
||||||
<strong>Fertilizer License (optional):</strong>
|
<strong>Fertilizer License (optional):</strong>
|
||||||
@ -264,6 +277,7 @@ const KycDetails = () => {
|
|||||||
variant="square"
|
variant="square"
|
||||||
src={retailerDetails.fertilizer_license_img.url}
|
src={retailerDetails.fertilizer_license_img.url}
|
||||||
sx={{ width: 100, height: 100, mb: 2 }}
|
sx={{ width: 100, height: 100, mb: 2 }}
|
||||||
|
onClick={() => handleImageClick(retailerDetails.fertilizer_license_img.url)}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Typography>Img not available</Typography>
|
<Typography>Img not available</Typography>
|
||||||
@ -275,6 +289,7 @@ const KycDetails = () => {
|
|||||||
variant="square"
|
variant="square"
|
||||||
src={retailerDetails.selfie_entrance_img.url}
|
src={retailerDetails.selfie_entrance_img.url}
|
||||||
sx={{ width: 100, height: 100, mb: 2 }}
|
sx={{ width: 100, height: 100, mb: 2 }}
|
||||||
|
onClick={() => handleImageClick(retailerDetails.selfie_entrance_img.url)}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
@ -307,7 +322,7 @@ const KycDetails = () => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
<Typography>
|
<Typography>
|
||||||
<strong>Resubmitted on:</strong>{' '}
|
<strong>Resubmitted on:</strong>{' '}
|
||||||
{new Date(`${retailerDetails?.createdAt}`).toDateString()}
|
{new Date(`${retailerDetails?.updatedAt}`).toDateString()}
|
||||||
<span> , {`${formatAMPM(retailerDetails?.createdAt)}`}</span>
|
<span> , {`${formatAMPM(retailerDetails?.createdAt)}`}</span>
|
||||||
</Typography>
|
</Typography>
|
||||||
</Grid>
|
</Grid>
|
||||||
@ -422,6 +437,11 @@ const KycDetails = () => {
|
|||||||
</Paper>
|
</Paper>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
<ImgModal
|
||||||
|
open={openImageModal}
|
||||||
|
handleClose={() => setOpenImageModal(false)}
|
||||||
|
imageUrl={selectedImageUrl}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user