This commit is contained in:
Malai Raja
2024-01-02 18:40:48 +05:30
parent 3ce0086e3c
commit ba582a3331
3 changed files with 133 additions and 13 deletions

Submodule nearlexpressbuild updated: 0f12f16e5c...11b027379b

View File

@@ -53,6 +53,7 @@ import { MdPersonAddDisabled } from "react-icons/md";
// import { DatePicker } from "@mui/x-date-pickers/DatePicker";
import { ThemeMode } from "config";
// import { FaUserLarge } from "react-icons/fa6";
import { enqueueSnackbar } from "notistack";
import {
RightOutlined,
LeftOutlined,
@@ -79,6 +80,7 @@ import {
CheckCircleFilled,
ClockCircleFilled,
MinusCircleFilled,
DeleteFilled
} from "@ant-design/icons";
// import ChatDrawer from "sections/apps/chat/ChatDrawer";
// import ChatHistory from "sections/apps/chat/ChatHistory";
@@ -102,6 +104,7 @@ var utc = require('dayjs/plugin/utc')
dayjs.extend(utc)
import { DateRangePicker } from "mui-daterange-picker";
import {
addDays,
addMonths,
@@ -171,6 +174,8 @@ const Clients1 = () => {
const [contactno, setContactno] = useState("");
const ref = useRef(null);
const [open, setOpen] = React.useState(false);
const [open3, setOpen3] = React.useState(false);
const [packDays, setPackDays] = useState(0);
const [startDate, setStartDate] = useState("");
const [validDate, setValidDate] = useState("");
@@ -196,13 +201,18 @@ const Clients1 = () => {
const [datestatus,setDatestatus]=useState('Today');
const [tenid,setTenid]=useState('');
const [loading1,setLoading1]=useState(false)
const [loading1,setLoading1]=useState(false);
const [currentcustomerid,setCurrentcustomerid]=useState('')
const handleClickOpen = () => {
setOpen(true);
};
const handleClose = () => {
setOpen(false);
setOpen3(false);
};
const handleClose3 = () => {
setOpen3(false);
};
// const [anchorEl]=useState(null)
// const tenid = window.localStorage.getItem("tenantid");
@@ -351,6 +361,45 @@ if(tenid){
}
const removeclient = async () => {
setLoading(true)
try {
await axios.delete(`${process.env.REACT_APP_URL}/customers/delete/?customerid=${currentcustomerid}`)
.then((res) => {
if (res.data.status) {
enqueueSnackbar("Deleted Successfully", {
variant: 'success', anchorOrigin: { vertical: 'top', horizontal: 'right' },
autoHideDuration: 2000
})
setCurrentcustomerid('')
// fetchtable(localStorage.getItem('tenantid'))
}else{
enqueueSnackbar(res.data.message, {
variant: 'error', anchorOrigin: { vertical: 'top', horizontal: 'right' },
autoHideDuration: 2000
})
}
setLoading(false)
}).catch((err) => {
console.log(err)
enqueueSnackbar(err.message, {
variant: 'error', anchorOrigin: { vertical: 'top', horizontal: 'right' },
autoHideDuration: 2000
})
setLoading(false)
})
} catch (err) {
console.log(err);
setLoading(false)
}
}
const fetchtable = async (tid) => {
setLoading1(true)
try {
@@ -490,9 +539,77 @@ if(tenid){
setValidDate(formattedDate);
}, [packDays, startDate]);
function AlertCustomerDelete({
// title,
open, handleClose}) {
// const [deletepassword, setDeletepassword] = useState('');
return (
<Dialog
open={open}
onClose={() => handleClose(false)}
maxWidth="xs"
>
<DialogContent sx={{ mt: 2, my: 1 }}>
<Stack alignItems="center" spacing={3.5}>
<Avatar color="error" sx={{ width: 72, height: 72, fontSize: '1.75rem' }}>
<DeleteFilled />
</Avatar>
{/* <Grid >
<Chip label={orderid.slice(4)} variant="combined" color='warning' size='small' />
</Grid> */}
<Stack spacing={2}>
<Typography variant="h4" align="center">
Are you sure you want to Remove this Customer?
</Typography>
{/* <Typography variant="h4" align="center">
Please type in the order number to confirm.
</Typography> */}
{/* <TextField
type='text'
onChange={(e) => {
console.log(e.target.value)
setDeletepassword(e.target.value)
}}
error={deletepassword !== orderid.slice(4)}
value={deletepassword}
/> */}
</Stack>
<Stack direction="row" spacing={2} sx={{ width: 1 }}>
<Button fullWidth color="error" variant="contained" onClick={() => {
// if (deletepassword === orderid.slice(4)) {
// cancelorder();
removeclient()
handleClose(true);
// }
}} autoFocus>
Yes, Remove
</Button>
<Button fullWidth onClick={() => {
handleClose(false)
setCurrentcustomerid('')
}} color="secondary" variant="outlined">
No
</Button>
</Stack>
</Stack>
</DialogContent>
</Dialog>
);
}
return (
<>
{(loading || usernameload) && <Loader />}
<AlertCustomerDelete open={open3} handleClose={handleClose} />
<Grid container rowSpacing={2} columnSpacing={2.75}>
<Grid
item
@@ -821,7 +938,7 @@ if(tenid){
sx={{ width: "100%", p: 2 }}
>
<Stack direction={'row'} justifyContent={'flex-end'}>
<Typography variant='h6'>{users.length} Clients</Typography>
<Typography variant='h6'>{users.length} Customers</Typography>
</Stack>
</Box>
</MainCard>
@@ -857,7 +974,7 @@ if(tenid){
transition: theme.transitions.create("width", {
easing: theme.transitions.easing.easeOut,
duration: theme.transitions.duration.shorter + 200,
height: "100%",
// height: "100%",
}),
}}
>
@@ -1032,7 +1149,7 @@ if(tenid){
</>
)}
<IconButton
// onClick={handleClickSort}
onClick={handleClickSort}
size="large"
color="primary"
>
@@ -1063,17 +1180,20 @@ if(tenid){
<MenuItem onClick={handleCloseSort}>
<Button
variant="text"
onClick={handleClickOpen}
onClick={()=>{
setOpen3(true)
setCurrentcustomerid(tenid)
}}
>
{
<MdPersonAdd
<DeleteFilled
style={{
fontSize: "20px",
marginRight: "15px",
}}
/>
}{" "}
Add Membership
Delete
</Button>
{/* ======================================== || Add Membership dialog|| ======================================== */}
@@ -1247,7 +1367,7 @@ if(tenid){
</DialogActions>
</BootstrapDialog> */}
</MenuItem>
<MenuItem onClick={handleCloseSort}>
{/* <MenuItem onClick={handleCloseSort}>
<Button
variant="text"
// onClick={handleClickOpen}
@@ -1262,7 +1382,7 @@ if(tenid){
}{" "}
Disable
</Button>
</MenuItem>
</MenuItem>*/}
{/* <MenuItem onClick={handleCloseSort}>
<DeleteOutlined style={{ paddingRight: 8 }} />
<Typography>Delete</Typography>

View File

@@ -295,7 +295,7 @@ const Createclient = () => {
variant: 'success', anchorOrigin: { vertical: 'top', horizontal: 'right' },
autoHideDuration: 2000
})
navigate('/clients')
navigate('/customers')
// setTimeout(()=>{
// fetchprofiledetails(localStorage.getItem('appuserid'));