irongit

'delete works and added actions menu'

huncholanehuncholaneauthored
parent b39f746commit 4091e1d9cd13a15b3396086c69442952b80c5435Browse files

4 files changed, +476 -573

+284-322Client/src/views/admin/meeting/View.js
@@ -1,339 +1,301 @@
1-import {
2- Box,
3- Button,
4- Flex,
5- Grid,
6- GridItem,
7- Heading,
8- Text,
9-} from "@chakra-ui/react";
10-import Card from "components/card/Card";
11-import { HSeparator } from "components/separator/Separator";
12-import Spinner from "components/spinner/Spinner";
13-import moment from "moment";
14-import { useEffect, useState } from "react";
15-import { IoIosArrowBack } from "react-icons/io";
16-import { Link, useNavigate, useParams } from "react-router-dom";
17-import { HasAccess } from "../../../redux/accessUtils";
18-import { getApi } from "services/api";
19-import { DeleteIcon } from "@chakra-ui/icons";
20-import { deleteApi } from "services/api";
21-import CommonDeleteModel from "components/commonDeleteModel";
22-import { FaFilePdf } from "react-icons/fa";
23-import html2pdf from "html2pdf.js";
1+import { Box, Button, Flex, Grid, GridItem, Heading, Menu, MenuButton, MenuDivider, MenuItem, MenuList, Text } from '@chakra-ui/react';
2+import Card from 'components/card/Card';
3+import { HSeparator } from 'components/separator/Separator';
4+import Spinner from 'components/spinner/Spinner';
5+import moment from 'moment';
6+import { useEffect, useState } from 'react';
7+import { IoIosArrowBack } from 'react-icons/io';
8+import { Link, useNavigate, useParams } from 'react-router-dom';
9+import { HasAccess } from '../../../redux/accessUtils';
10+import { getApi } from 'services/api';
11+import { AddIcon, ChevronDownIcon, DeleteIcon, EditIcon } from '@chakra-ui/icons';
12+import { deleteApi } from 'services/api';
13+import CommonDeleteModel from 'components/commonDeleteModel';
14+import { FaFilePdf } from 'react-icons/fa';
15+import html2pdf from 'html2pdf.js';
2416 const View = () => {
25- const param = useParams();
17+ const param = useParams();
2618
27- const [data, setData] = useState();
28- const [deleteMany, setDeleteMany] = useState(false);
29- const user = JSON.parse(localStorage.getItem("user"));
30- const [isLoding, setIsLoding] = useState(false);
31- const [loading, setLoading] = useState(false);
32- const navigate = useNavigate();
33- const params = useParams();
19+ const [data, setData] = useState();
20+ const [deleteMany, setDeleteMany] = useState(false);
21+ const user = JSON.parse(localStorage.getItem('user'));
22+ const [isLoding, setIsLoding] = useState(false);
23+ const [loading, setLoading] = useState(false);
24+ const navigate = useNavigate();
25+ const params = useParams();
3426
35- const fetchData = async () => {
36- setIsLoding(true);
37- let response = await getApi("api/meeting/view/", param.id);
38- setData(response?.data);
39- setIsLoding(false);
40- };
27+ const fetchData = async () => {
28+ setIsLoding(true);
29+ let response = await getApi('api/meeting/view/', param.id);
30+ setData(response?.data);
31+ setIsLoding(false);
32+ };
4133
42- useEffect(() => {
43- fetchData();
44- }, []);
34+ useEffect(() => {
35+ fetchData();
36+ }, []);
4537
46- const generatePDF = () => {
47- setLoading(true);
48- const element = document.getElementById("reports");
49- const hideBtn = document.getElementById("hide-btn");
50- if (element) {
51- hideBtn.style.display = "none";
52- html2pdf()
53- .from(element)
54- .set({
55- margin: [0, 0, 0, 0],
56- filename: `Meeting_Details_${moment().format("DD-MM-YYYY")}.pdf`,
57- image: { type: "jpeg", quality: 0.98 },
58- html2canvas: { scale: 2, useCORS: true, allowTaint: true },
59- jsPDF: { unit: "in", format: "letter", orientation: "portrait" },
60- })
61- .save()
62- .then(() => {
63- setLoading(false);
64- hideBtn.style.display = "";
65- });
66- // }, 500);
67- } else {
68- console.error("Element with ID 'reports' not found.");
69- setLoading(false);
70- }
71- };
38+ const handleClick = () => {};
7239
73- const handleDeleteMeeting = async (ids) => {
74- try {
75- setIsLoding(true);
76- let response = await deleteApi("api/meeting/delete/", params.id);
77- if (response.status === 200) {
78- setDeleteMany(false);
79- navigate(-1);
80- }
81- } catch (error) {
82- console.log(error);
83- } finally {
84- setIsLoding(false);
85- }
86- };
40+ const setEdit = () => {};
8741
88- const [permission, contactAccess, leadAccess] = HasAccess([
89- "Meetings",
90- "Contacts",
91- "Leads",
92- ]);
42+ const setDeleteManyModel = () => {};
9343
94- return (
95- <>
96- {isLoding ? (
97- <Flex justifyContent={"center"} alignItems={"center"} width="100%">
98- <Spinner />
99- </Flex>
100- ) : (
44+ const generatePDF = () => {
45+ setLoading(true);
46+ const element = document.getElementById('reports');
47+ const hideBtn = document.getElementById('hide-btn');
48+ if (element) {
49+ hideBtn.style.display = 'none';
50+ html2pdf()
51+ .from(element)
52+ .set({
53+ margin: [0, 0, 0, 0],
54+ filename: `Meeting_Details_${moment().format('DD-MM-YYYY')}.pdf`,
55+ image: { type: 'jpeg', quality: 0.98 },
56+ html2canvas: { scale: 2, useCORS: true, allowTaint: true },
57+ jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait' },
58+ })
59+ .save()
60+ .then(() => {
61+ setLoading(false);
62+ hideBtn.style.display = '';
63+ });
64+ // }, 500);
65+ } else {
66+ console.error("Element with ID 'reports' not found.");
67+ setLoading(false);
68+ }
69+ };
70+
71+ const handleDeleteMeeting = async (ids) => {
72+ try {
73+ setIsLoding(true);
74+ let response = await deleteApi('api/meeting/delete/', params.id);
75+ if (response.status === 200) {
76+ setDeleteMany(false);
77+ navigate(-1);
78+ }
79+ } catch (error) {
80+ console.log(error);
81+ } finally {
82+ setIsLoding(false);
83+ }
84+ };
85+
86+ const [permission, contactAccess, leadAccess] = HasAccess(['Meetings', 'Contacts', 'Leads']);
87+
88+ return (
10189 <>
102- <Grid templateColumns="repeat(4, 1fr)" gap={3} id="reports">
103- <GridItem colSpan={{ base: 4 }}>
104- <Heading size="lg" m={3}>
105- {data?.agenda || ""}
106- </Heading>
107- </GridItem>
108- <GridItem colSpan={{ base: 4 }}>
109- <Card>
110- <Grid gap={4}>
111- <GridItem colSpan={2}>
112- <Box>
113- <Flex justifyContent={"space-between"}>
114- <Heading size="md" mb={3}>
115- Meeting Details
116- </Heading>
117- <Box id="hide-btn">
118- <Button
119- leftIcon={<FaFilePdf />}
120- size="sm"
121- variant="brand"
122- onClick={generatePDF}
123- disabled={loading}
124- >
125- {loading ? "Please Wait..." : "Print as PDF"}
126- </Button>
127- <Button
128- leftIcon={<IoIosArrowBack />}
129- size="sm"
130- variant="brand"
131- onClick={() => navigate(-1)}
132- style={{ marginLeft: 10 }}
133- >
134- Back
135- </Button>
136- </Box>
137- </Flex>
138- <HSeparator />
139- </Box>
140- </GridItem>
141- <GridItem colSpan={{ base: 2, md: 1 }}>
142- <Text
143- fontSize="sm"
144- fontWeight="bold"
145- color={"blackAlpha.900"}
146- >
147- {" "}
148- Agenda{" "}
149- </Text>
150- <Text>{data?.agenda ? data?.agenda : " - "}</Text>
151- </GridItem>
152- <GridItem colSpan={{ base: 2, md: 1 }}>
153- <Text
154- fontSize="sm"
155- fontWeight="bold"
156- color={"blackAlpha.900"}
157- >
158- {" "}
159- Created By{" "}
160- </Text>
161- <Text>
162- {/* this was a typo, createdByName -> createByName to keep the same as others */}
163- {data?.createByName ? data?.createByName : " - "}
164- </Text>
165- </GridItem>
90+ {isLoding ? (
91+ <Flex justifyContent={'center'} alignItems={'center'} width="100%">
92+ <Spinner />
93+ </Flex>
94+ ) : (
95+ <>
96+ <Grid templateColumns="repeat(4, 1fr)" gap={3} id="reports">
97+ <GridItem colSpan={{ base: 4 }}>
98+ <Heading size="lg" m={3}>
99+ {data?.agenda || ''}
100+ </Heading>
101+ </GridItem>
102+ <GridItem colSpan={{ base: 4 }}>
103+ <Card>
104+ <Grid gap={4}>
105+ <GridItem colSpan={2}>
106+ <Box>
107+ <Flex justifyContent={'space-between'}>
108+ <Heading size="md" mb={3}>
109+ Meeting Details
110+ </Heading>
111+ <Flex id="hide-btn">
112+ <Menu>
113+ {(user.role === 'superAdmin' || permission?.create || permission?.update || permission?.delete) && (
114+ <MenuButton variant="outline" colorScheme="blackAlpha" size="sm" va mr={2.5} as={Button} rightIcon={<ChevronDownIcon />}>
115+ Actions
116+ </MenuButton>
117+ )}
118+ <MenuDivider />
119+ <MenuList minWidth={2}>
120+ {(user.role === 'superAdmin' || permission?.create) && (
121+ <MenuItem onClick={() => handleClick()} alignItems={'start'} color={'blue'} icon={<AddIcon />}>
122+ Add
123+ </MenuItem>
124+ )}
125+ {(user.role === 'superAdmin' || permission?.update) && (
126+ <MenuItem onClick={() => setEdit(true)} alignItems={'start'} icon={<EditIcon />}>
127+ Edit
128+ </MenuItem>
129+ )}
130+ <MenuItem
131+ onClick={generatePDF}
132+ alignItems={'start'}
133+ icon={<FaFilePdf />}
134+ display={'flex'}
135+ style={{
136+ alignItems: 'center',
137+ }}>
138+ Print as PDF
139+ </MenuItem>
140+
141+ {(user.role === 'superAdmin' || permission?.delete) && (
142+ <>
143+ <MenuDivider />
144+ <MenuItem alignItems={'start'} onClick={() => setDeleteManyModel(true)} color={'red'} icon={<DeleteIcon />}>
145+ Delete
146+ </MenuItem>
147+ </>
148+ )}
149+ </MenuList>
150+ </Menu>
151+ <Button leftIcon={<IoIosArrowBack />} size="sm" variant="brand" onClick={() => navigate(-1)} style={{ marginLeft: 10 }}>
152+ Back
153+ </Button>
154+ </Flex>
155+ </Flex>
156+ <HSeparator />
157+ </Box>
158+ </GridItem>
159+ <GridItem colSpan={{ base: 2, md: 1 }}>
160+ <Text fontSize="sm" fontWeight="bold" color={'blackAlpha.900'}>
161+ {' '}
162+ Agenda{' '}
163+ </Text>
164+ <Text>{data?.agenda ? data?.agenda : ' - '}</Text>
165+ </GridItem>
166+ <GridItem colSpan={{ base: 2, md: 1 }}>
167+ <Text fontSize="sm" fontWeight="bold" color={'blackAlpha.900'}>
168+ {' '}
169+ Created By{' '}
170+ </Text>
171+ <Text>
172+ {/* this was a typo, createdByName -> createByName to keep the same as others */}
173+ {data?.createByName ? data?.createByName : ' - '}
174+ </Text>
175+ </GridItem>
166176
167- <GridItem colSpan={{ base: 2, md: 1 }}>
168- <Text
169- fontSize="sm"
170- fontWeight="bold"
171- color={"blackAlpha.900"}
172- >
173- {" "}
174- DateTime{" "}
175- </Text>
176- <Text>
177- {" "}
178- {data?.dateTime
179- ? moment(data?.dateTime).format("DD-MM-YYYY h:mma ")
180- : " - "}{" "}
181- [{data?.dateTime ? moment(data?.dateTime).toNow() : " - "}
182- ]
183- </Text>
184- </GridItem>
185- <GridItem colSpan={{ base: 2, md: 1 }}>
186- <Text
187- fontSize="sm"
188- fontWeight="bold"
189- color={"blackAlpha.900"}
190- >
191- {" "}
192- Timestamp{" "}
193- </Text>
194- <Text>
195- {" "}
196- {data?.timestamp
197- ? moment(data?.timestamp).format("DD-MM-YYYY h:mma ")
198- : " - "}{" "}
199- [
200- {data?.timestamp
201- ? moment(data?.timestamp).toNow()
202- : " - "}
203- ]
204- </Text>
205- </GridItem>
206- <GridItem colSpan={{ base: 2, md: 1 }}>
207- <Text
208- fontSize="sm"
209- fontWeight="bold"
210- color={"blackAlpha.900"}
211- >
212- {" "}
213- Location{" "}
214- </Text>
215- <Text>{data?.location ? data?.location : " - "}</Text>
216- </GridItem>
217- <GridItem colSpan={{ base: 2, md: 1 }}>
218- <Text
219- fontSize="sm"
220- fontWeight="bold"
221- color={"blackAlpha.900"}
222- >
223- {" "}
224- Notes{" "}
225- </Text>
226- <Text>{data?.notes ? data?.notes : " - "}</Text>
227- </GridItem>
228- <GridItem colSpan={{ base: 2, md: 1 }}>
229- <Text
230- fontSize="sm"
231- fontWeight="bold"
232- color={"blackAlpha.900"}
233- >
234- {" "}
235- Attendes{" "}
236- </Text>
237- {data?.related === "Contact" && contactAccess?.view
238- ? data?.attendes &&
239- data?.attendes.map((item) => {
240- return (
241- <Link to={`/contactView/${item._id}`}>
242- <Text
243- color="brand.600"
244- sx={{
245- "&:hover": {
246- color: "blue.500",
247- textDecoration: "underline",
248- },
249- }}
250- >
251- {item.firstName + " " + item.lastName}
252- </Text>
253- </Link>
254- );
255- })
256- : data?.related === "Lead" && leadAccess?.view
257- ? data?.attendesLead &&
258- data?.attendesLead.map((item) => {
259- return (
260- <Link to={`/leadView/${item._id}`}>
261- <Text
262- color="brand.600"
263- sx={{
264- "&:hover": {
265- color: "blue.500",
266- textDecoration: "underline",
267- },
268- }}
269- >
270- {item.leadName}
271- </Text>
272- </Link>
273- );
274- })
275- : data?.related === "contact"
276- ? data?.attendes &&
277- data?.attendes.map((item) => {
278- return (
279- <Text color="blackAlpha.900">
280- {item.firstName + " " + item.lastName}
281- </Text>
282- );
283- })
284- : data?.related === "lead"
285- ? data?.attendesLead &&
286- data?.attendesLead.map((item) => {
287- return (
288- <Text color="blackAlpha.900">{item.leadName}</Text>
289- );
290- })
291- : "-"}
292- </GridItem>
293- {/* <Grid templateColumns={'repeat(2, 1fr)'} gap={4} id="reports">
177+ <GridItem colSpan={{ base: 2, md: 1 }}>
178+ <Text fontSize="sm" fontWeight="bold" color={'blackAlpha.900'}>
179+ {' '}
180+ DateTime{' '}
181+ </Text>
182+ <Text>
183+ {' '}
184+ {data?.dateTime ? moment(data?.dateTime).format('DD-MM-YYYY h:mma ') : ' - '} [{data?.dateTime ? moment(data?.dateTime).toNow() : ' - '}]
185+ </Text>
186+ </GridItem>
187+ <GridItem colSpan={{ base: 2, md: 1 }}>
188+ <Text fontSize="sm" fontWeight="bold" color={'blackAlpha.900'}>
189+ {' '}
190+ Timestamp{' '}
191+ </Text>
192+ <Text>
193+ {' '}
194+ {data?.timestamp ? moment(data?.timestamp).format('DD-MM-YYYY h:mma ') : ' - '} [{data?.timestamp ? moment(data?.timestamp).toNow() : ' - '}]
195+ </Text>
196+ </GridItem>
197+ <GridItem colSpan={{ base: 2, md: 1 }}>
198+ <Text fontSize="sm" fontWeight="bold" color={'blackAlpha.900'}>
199+ {' '}
200+ Location{' '}
201+ </Text>
202+ <Text>{data?.location ? data?.location : ' - '}</Text>
203+ </GridItem>
204+ <GridItem colSpan={{ base: 2, md: 1 }}>
205+ <Text fontSize="sm" fontWeight="bold" color={'blackAlpha.900'}>
206+ {' '}
207+ Notes{' '}
208+ </Text>
209+ <Text>{data?.notes ? data?.notes : ' - '}</Text>
210+ </GridItem>
211+ <GridItem colSpan={{ base: 2, md: 1 }}>
212+ <Text fontSize="sm" fontWeight="bold" color={'blackAlpha.900'}>
213+ {' '}
214+ Attendes{' '}
215+ </Text>
216+ {data?.related === 'Contact' && contactAccess?.view
217+ ? data?.attendes &&
218+ data?.attendes.map((item) => {
219+ return (
220+ <Link to={`/contactView/${item._id}`}>
221+ <Text
222+ color="brand.600"
223+ sx={{
224+ '&:hover': {
225+ color: 'blue.500',
226+ textDecoration: 'underline',
227+ },
228+ }}>
229+ {item.firstName + ' ' + item.lastName}
230+ </Text>
231+ </Link>
232+ );
233+ })
234+ : data?.related === 'Lead' && leadAccess?.view
235+ ? data?.attendesLead &&
236+ data?.attendesLead.map((item) => {
237+ return (
238+ <Link to={`/leadView/${item._id}`}>
239+ <Text
240+ color="brand.600"
241+ sx={{
242+ '&:hover': {
243+ color: 'blue.500',
244+ textDecoration: 'underline',
245+ },
246+ }}>
247+ {item.leadName}
248+ </Text>
249+ </Link>
250+ );
251+ })
252+ : data?.related === 'contact'
253+ ? data?.attendes &&
254+ data?.attendes.map((item) => {
255+ return <Text color="blackAlpha.900">{item.firstName + ' ' + item.lastName}</Text>;
256+ })
257+ : data?.related === 'lead'
258+ ? data?.attendesLead &&
259+ data?.attendesLead.map((item) => {
260+ return <Text color="blackAlpha.900">{item.leadName}</Text>;
261+ })
262+ : '-'}
263+ </GridItem>
264+ {/* <Grid templateColumns={'repeat(2, 1fr)'} gap={4} id="reports">
294265
295266 </Grid> */}
296- </Grid>
297- </Card>
298- </GridItem>
299- </Grid>
300- {(user.role === "superAdmin" ||
301- permission?.update ||
302- permission?.delete) && (
303- <Card mt={3}>
304- <Grid templateColumns="repeat(6, 1fr)" gap={1}>
305- <GridItem colStart={6}>
306- <Flex justifyContent={"right"}>
307- {user.role === "superAdmin" || permission?.delete ? (
308- <Button
309- size="sm"
310- style={{ background: "red.800" }}
311- onClick={() => setDeleteMany(true)}
312- leftIcon={<DeleteIcon />}
313- colorScheme="red"
314- >
315- Delete
316- </Button>
317- ) : (
318- ""
267+ </Grid>
268+ </Card>
269+ </GridItem>
270+ </Grid>
271+ {(user.role === 'superAdmin' || permission?.update || permission?.delete) && (
272+ <Card mt={3}>
273+ <Grid templateColumns="repeat(6, 1fr)" gap={1}>
274+ <GridItem colStart={6}>
275+ <Flex justifyContent={'right'}>
276+ {(permission?.update || user?.role === 'superAdmin') && (
277+ <Button size="sm" onClick={() => setEdit(true)} leftIcon={<EditIcon />} mr={2.5} variant="outline" colorScheme="green">
278+ Edit
279+ </Button>
280+ )}
281+ {user.role === 'superAdmin' || permission?.delete ? (
282+ <Button size="sm" style={{ background: 'red.800' }} onClick={() => setDeleteMany(true)} leftIcon={<DeleteIcon />} colorScheme="red">
283+ Delete
284+ </Button>
285+ ) : (
286+ ''
287+ )}
288+ </Flex>
289+ </GridItem>
290+ </Grid>
291+ </Card>
319292 )}
320- </Flex>
321- </GridItem>
322- </Grid>
323- </Card>
324- )}
293+ </>
294+ )}
295+ {/* Delete model */}
296+ <CommonDeleteModel isOpen={deleteMany} onClose={() => setDeleteMany(false)} type="Meetings" handleDeleteData={handleDeleteMeeting} ids={params.id} />
325297 </>
326- )}
327- {/* Delete model */}
328- <CommonDeleteModel
329- isOpen={deleteMany}
330- onClose={() => setDeleteMany(false)}
331- type="Meetings"
332- handleDeleteData={handleDeleteMeeting}
333- ids={params.id}
334- />
335- </>
336- );
298+ );
337299 };
338300
339301 export default View;
+160-247Client/src/views/admin/meeting/meetingView.js
@@ -1,259 +1,172 @@
1-import { CloseIcon, DeleteIcon, EditIcon, ViewIcon } from "@chakra-ui/icons";
2-import {
3- DrawerFooter,
4- Flex,
5- Grid,
6- GridItem,
7- IconButton,
8- Modal,
9- ModalBody,
10- ModalContent,
11- ModalHeader,
12- ModalOverlay,
13- Text,
14-} from "@chakra-ui/react";
15-import Spinner from "components/spinner/Spinner";
16-import moment from "moment";
17-import { useEffect, useState } from "react";
18-import { BiLink } from "react-icons/bi";
19-import { Link } from "react-router-dom";
20-import { getApi } from "services/api";
1+import { CloseIcon, DeleteIcon, EditIcon, ViewIcon } from '@chakra-ui/icons';
2+import { DrawerFooter, Flex, Grid, GridItem, IconButton, Modal, ModalBody, ModalContent, ModalHeader, ModalOverlay, Text } from '@chakra-ui/react';
3+import Spinner from 'components/spinner/Spinner';
4+import moment from 'moment';
5+import { useEffect, useState } from 'react';
6+import { BiLink } from 'react-icons/bi';
7+import { Link } from 'react-router-dom';
8+import { getApi } from 'services/api';
219 // import DeleteTask from './components/deleteTask'
22-import { useNavigate } from "react-router-dom";
23-import { HasAccess } from "../../../redux/accessUtils";
10+import { useNavigate } from 'react-router-dom';
11+import { HasAccess } from '../../../redux/accessUtils';
2412
2513 const MeetingView = (props) => {
26- const { onClose, isOpen, info, fetchData, setAction, action, access } = props;
27- const [data, setData] = useState();
28- const [edit, setEdit] = useState(false);
29- const [deleteModel, setDelete] = useState(false);
30- const user = JSON.parse(localStorage.getItem("user"));
31- const [isLoding, setIsLoding] = useState(false);
32- const navigate = useNavigate();
14+ const { onClose, isOpen, info, fetchData, setAction, action, access } = props;
15+ const [data, setData] = useState();
16+ const [edit, setEdit] = useState(false);
17+ const [deleteModel, setDelete] = useState(false);
18+ const user = JSON.parse(localStorage.getItem('user'));
19+ const [isLoding, setIsLoding] = useState(false);
20+ const navigate = useNavigate();
3321
34- const fetchViewData = async () => {
35- if (info) {
36- setIsLoding(true);
37- let result = await getApi(
38- "api/meeting/view/",
39- info?.event ? info?.event?.id : info
40- );
41- setData(result?.data);
42- setIsLoding(false);
43- }
44- };
22+ const fetchViewData = async () => {
23+ if (info) {
24+ setIsLoding(true);
25+ let result = await getApi('api/meeting/view/', info?.event ? info?.event?.id : info);
26+ setData(result?.data);
27+ setIsLoding(false);
28+ }
29+ };
4530
46- useEffect(() => {
47- fetchViewData();
48- }, [action, info]);
31+ useEffect(() => {
32+ fetchViewData();
33+ }, [action, info]);
4934
50- const [contactAccess, leadAccess] = HasAccess(["Contacts", "Leads"]);
35+ const [contactAccess, leadAccess] = HasAccess(['Contacts', 'Leads']);
5136
52- const handleViewOpen = () => {
53- if (info?.event) {
54- navigate(`/view/${info?.event?.id}`);
55- } else {
56- navigate(`/view/${info}`);
57- }
58- };
59- return (
60- <Modal isOpen={isOpen} size={"md"} isCentered>
61- <ModalOverlay />
62- <ModalContent height={"70%"}>
63- <ModalHeader justifyContent="space-between" display="flex">
64- Meeting
65- <IconButton onClick={() => onClose(false)} icon={<CloseIcon />} />
66- </ModalHeader>
67- {isLoding ? (
68- <Flex
69- justifyContent={"center"}
70- alignItems={"center"}
71- mb={30}
72- width="100%"
73- >
74- <Spinner />
75- </Flex>
76- ) : (
77- <>
78- <ModalBody overflowY={"auto"}>
79- <Grid templateColumns="repeat(12, 1fr)" gap={3}>
80- <GridItem colSpan={{ base: 12, md: 6 }}>
81- <Text
82- fontSize="sm"
83- fontWeight="bold"
84- color={"blackAlpha.900"}
85- >
86- {" "}
87- Agenda{" "}
88- </Text>
89- <Text>{data?.agenda ? data?.agenda : " - "}</Text>
90- </GridItem>
91- <GridItem colSpan={{ base: 12, md: 6 }}>
92- <Text
93- fontSize="sm"
94- fontWeight="bold"
95- color={"blackAlpha.900"}
96- >
97- {" "}
98- Date&Time{" "}
99- </Text>
100- <Text>
101- {data?.dateTime
102- ? moment(data?.dateTime).format("lll ")
103- : " - "}
104- </Text>
105- </GridItem>
106- <GridItem colSpan={{ base: 12, md: 6 }}>
107- <Text
108- fontSize="sm"
109- fontWeight="bold"
110- color={"blackAlpha.900"}
111- >
112- {" "}
113- Created By{" "}
114- </Text>
115- <Text>{data?.createdByName ? data?.createdByName : "-"}</Text>
116- </GridItem>
117- <GridItem colSpan={{ base: 12, md: 6 }}>
118- <Text
119- fontSize="sm"
120- fontWeight="bold"
121- color={"blackAlpha.900"}
122- >
123- {" "}
124- Related{" "}
125- </Text>
126- <Text>{data?.related ? data?.related : "-"}</Text>
127- </GridItem>
128- <GridItem colSpan={{ base: 12, md: 6 }}>
129- <Text
130- fontSize="sm"
131- fontWeight="bold"
132- color={"blackAlpha.900"}
133- >
134- {" "}
135- Location{" "}
136- </Text>
137- <Text>{data?.location ? data?.location : "-"}</Text>
138- </GridItem>
139- <GridItem colSpan={{ base: 12, md: 6 }}>
140- <Text
141- fontSize="sm"
142- fontWeight="bold"
143- color={"blackAlpha.900"}
144- >
145- {" "}
146- Notes{" "}
147- </Text>
148- <Text>{data?.notes ? data?.notes : "-"}</Text>
149- </GridItem>
150- <GridItem colSpan={{ base: 12, md: 6 }}>
151- <Text
152- fontSize="sm"
153- fontWeight="bold"
154- color={"blackAlpha.900"}
155- >
156- {" "}
157- attendes{" "}
158- </Text>
159- {data?.related === "Contact" && contactAccess?.view
160- ? data?.attendes &&
161- data?.attendes.map((item) => {
162- return (
163- <Link to={`/contactView/${item._id}`}>
164- <Text
165- color="brand.600"
166- sx={{
167- "&:hover": {
168- color: "blue.500",
169- textDecoration: "underline",
170- },
171- }}
172- >
173- {item.firstName + " " + item.lastName}
174- </Text>
175- </Link>
176- );
177- })
178- : data?.related === "Lead" && leadAccess?.view
179- ? data?.attendesLead &&
180- data?.attendesLead.map((item) => {
181- return (
182- <Link to={`/leadView/${item._id}`}>
183- <Text
184- color="brand.600"
185- sx={{
186- "&:hover": {
187- color: "blue.500",
188- textDecoration: "underline",
189- },
190- }}
191- >
192- {item.leadName}
193- </Text>
194- </Link>
195- );
196- })
197- : data?.related === "Contact"
198- ? data?.attendes &&
199- data?.attendes.map((item) => {
200- return (
201- <Text color="blackAlpha.900">
202- {item.firstName + " " + item.lastName}
203- </Text>
204- );
205- })
206- : data?.related === "Lead"
207- ? data?.attendesLead &&
208- data?.attendesLead.map((item) => {
209- return (
210- <Text color="blackAlpha.900">{item.leadName}</Text>
211- );
212- })
213- : "-"}
214- </GridItem>
215- </Grid>
216- </ModalBody>
217- <DrawerFooter>
218- {access?.view && (
219- <IconButton
220- variant="outline"
221- colorScheme={"green"}
222- onClick={() => handleViewOpen()}
223- borderRadius="10px"
224- size="md"
225- icon={<ViewIcon />}
226- />
227- )}
228- {access?.update && (
229- <IconButton
230- variant="outline"
231- onClick={() => setEdit(true)}
232- ml={3}
233- borderRadius="10px"
234- size="md"
235- icon={<EditIcon />}
236- />
237- )}
238- {access?.delete && (
239- <IconButton
240- colorScheme="red"
241- onClick={() => setDelete(true)}
242- ml={3}
243- borderRadius="10px"
244- size="md"
245- icon={<DeleteIcon />}
246- />
247- )}
37+ const handleViewOpen = () => {
38+ if (info?.event) {
39+ navigate(`/view/${info?.event?.id}`);
40+ } else {
41+ navigate(`/view/${info}`);
42+ }
43+ };
44+ return (
45+ <Modal isOpen={isOpen} size={'md'} isCentered>
46+ <ModalOverlay />
47+ <ModalContent height={'70%'}>
48+ <ModalHeader justifyContent="space-between" display="flex">
49+ Meeting
50+ <IconButton onClick={() => onClose(false)} icon={<CloseIcon />} />
51+ </ModalHeader>
52+ {isLoding ? (
53+ <Flex justifyContent={'center'} alignItems={'center'} mb={30} width="100%">
54+ <Spinner />
55+ </Flex>
56+ ) : (
57+ <>
58+ <ModalBody overflowY={'auto'}>
59+ <Grid templateColumns="repeat(12, 1fr)" gap={3}>
60+ <GridItem colSpan={{ base: 12, md: 6 }}>
61+ <Text fontSize="sm" fontWeight="bold" color={'blackAlpha.900'}>
62+ {' '}
63+ Agenda{' '}
64+ </Text>
65+ <Text>{data?.agenda ? data?.agenda : ' - '}</Text>
66+ </GridItem>
67+ <GridItem colSpan={{ base: 12, md: 6 }}>
68+ <Text fontSize="sm" fontWeight="bold" color={'blackAlpha.900'}>
69+ {' '}
70+ Date&Time{' '}
71+ </Text>
72+ <Text>{data?.dateTime ? moment(data?.dateTime).format('lll ') : ' - '}</Text>
73+ </GridItem>
74+ <GridItem colSpan={{ base: 12, md: 6 }}>
75+ <Text fontSize="sm" fontWeight="bold" color={'blackAlpha.900'}>
76+ {' '}
77+ Created By{' '}
78+ </Text>
79+ <Text>{data?.createdByName ? data?.createdByName : '-'}</Text>
80+ </GridItem>
81+ <GridItem colSpan={{ base: 12, md: 6 }}>
82+ <Text fontSize="sm" fontWeight="bold" color={'blackAlpha.900'}>
83+ {' '}
84+ Related{' '}
85+ </Text>
86+ <Text>{data?.related ? data?.related : '-'}</Text>
87+ </GridItem>
88+ <GridItem colSpan={{ base: 12, md: 6 }}>
89+ <Text fontSize="sm" fontWeight="bold" color={'blackAlpha.900'}>
90+ {' '}
91+ Location{' '}
92+ </Text>
93+ <Text>{data?.location ? data?.location : '-'}</Text>
94+ </GridItem>
95+ <GridItem colSpan={{ base: 12, md: 6 }}>
96+ <Text fontSize="sm" fontWeight="bold" color={'blackAlpha.900'}>
97+ {' '}
98+ Notes{' '}
99+ </Text>
100+ <Text>{data?.notes ? data?.notes : '-'}</Text>
101+ </GridItem>
102+ <GridItem colSpan={{ base: 12, md: 6 }}>
103+ <Text fontSize="sm" fontWeight="bold" color={'blackAlpha.900'}>
104+ {' '}
105+ attendes{' '}
106+ </Text>
107+ {data?.related === 'Contact' && contactAccess?.view
108+ ? data?.attendes &&
109+ data?.attendes.map((item) => {
110+ return (
111+ <Link to={`/contactView/${item._id}`}>
112+ <Text
113+ color="brand.600"
114+ sx={{
115+ '&:hover': {
116+ color: 'blue.500',
117+ textDecoration: 'underline',
118+ },
119+ }}>
120+ {item.firstName + ' ' + item.lastName}
121+ </Text>
122+ </Link>
123+ );
124+ })
125+ : data?.related === 'Lead' && leadAccess?.view
126+ ? data?.attendesLead &&
127+ data?.attendesLead.map((item) => {
128+ return (
129+ <Link to={`/leadView/${item._id}`}>
130+ <Text
131+ color="brand.600"
132+ sx={{
133+ '&:hover': {
134+ color: 'blue.500',
135+ textDecoration: 'underline',
136+ },
137+ }}>
138+ {item.leadName}
139+ </Text>
140+ </Link>
141+ );
142+ })
143+ : data?.related === 'Contact'
144+ ? data?.attendes &&
145+ data?.attendes.map((item) => {
146+ return <Text color="blackAlpha.900">{item.firstName + ' ' + item.lastName}</Text>;
147+ })
148+ : data?.related === 'Lead'
149+ ? data?.attendesLead &&
150+ data?.attendesLead.map((item) => {
151+ return <Text color="blackAlpha.900">{item.leadName}</Text>;
152+ })
153+ : '-'}
154+ </GridItem>
155+ </Grid>
156+ </ModalBody>
157+ <DrawerFooter>
158+ {access?.view && <IconButton variant="outline" colorScheme={'green'} onClick={() => handleViewOpen()} borderRadius="10px" size="md" icon={<ViewIcon />} />}
159+ {access?.update && <IconButton variant="outline" onClick={() => setEdit(true)} ml={3} borderRadius="10px" size="md" icon={<EditIcon />} />}
160+ {access?.delete && <IconButton colorScheme="red" onClick={() => setDelete(true)} ml={3} borderRadius="10px" size="md" icon={<DeleteIcon />} />}
248161
249- {/*
162+ {/*
250163 <DeleteTask fetchData={props.fetchData} isOpen={deleteModel} onClose={setDelete} viewClose={onClose} url='api/task/delete/' method='one' id={info?.event ? info?.event?.id : info} /> */}
251- </DrawerFooter>
252- </>
253- )}
254- </ModalContent>
255- </Modal>
256- );
164+ </DrawerFooter>
165+ </>
166+ )}
167+ </ModalContent>
168+ </Modal>
169+ );
257170 };
258171
259172 export default MeetingView;
+2-2server/controllers/meeting/_routes.js
@@ -10,7 +10,7 @@ router.post("/add", auth, meeting.add);
1010 router.get("/view/:id", auth, meeting.view);
1111 // router.put("/edit/:id", auth, meeting.edit);
1212 // router.put("/changeStatus/:id", auth, meeting.changeStatus);
13-// router.delete("/delete/:id", auth, meeting.deleteData);
14-// router.post("/deleteMany", auth, meeting.deleteMany);
13+router.delete("/delete/:id", auth, meeting.deleteData);
14+router.post("/deleteMany", auth, meeting.deleteMany);
1515
1616 module.exports = router;
+30-2server/controllers/meeting/meeting.js
@@ -61,8 +61,36 @@ const view = async (req, res) => {
6161 }
6262 };
6363
64-const deleteData = async (req, res) => {};
64+const deleteData = async (req, res) => {
65+ try {
66+ const result = await MeetingHistory.findByIdAndUpdate(req.params.id, {
67+ deleted: true,
68+ });
69+ res.status(200).json({ message: "done", result });
70+ } catch (err) {
71+ res.status(404).json({ message: "error", err });
72+ }
73+};
6574
66-const deleteMany = async (req, res) => {};
75+const deleteMany = async (req, res) => {
76+ try {
77+ const result = await MeetingHistory.updateMany(
78+ { _id: { $in: req.body } },
79+ { $set: { deleted: true } }
80+ );
81+
82+ if (result?.matchedCount > 0 && result?.modifiedCount > 0) {
83+ return res
84+ .status(200)
85+ .json({ message: "Meeting History Removed successfully", result });
86+ } else {
87+ return res
88+ .status(404)
89+ .json({ success: false, message: "Failed to remove tasks" });
90+ }
91+ } catch (err) {
92+ return res.status(404).json({ success: false, message: "error", err });
93+ }
94+};
6795
6896 module.exports = { add, index, view, deleteData, deleteMany };