From 1c17b149e261caf23faa9f7e990fa9c7de860714 Mon Sep 17 00:00:00 2001 From: siddheshmorewdi Date: Mon, 29 Jul 2024 12:20:17 +0530 Subject: [PATCH] update --- src/Components/ImageViewer.jsx | 24 +++++++++++++ src/Constants/Constants.js | 32 +++++++++++++++++ .../IO_Management/CreateIO/IOArtifacts.jsx | 34 +++++++++++++++---- src/Pages/Master/Sponser/AddSponser.jsx | 9 ++++- 4 files changed, 91 insertions(+), 8 deletions(-) create mode 100644 src/Components/ImageViewer.jsx diff --git a/src/Components/ImageViewer.jsx b/src/Components/ImageViewer.jsx new file mode 100644 index 0000000..717bc15 --- /dev/null +++ b/src/Components/ImageViewer.jsx @@ -0,0 +1,24 @@ +import { Button, Image, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay, useDisclosure } from '@chakra-ui/react' +import React from 'react' + +const ImageViewer = ({src, isOpen, onClose}) => { + +return ( + <> + {/* */} + + + + + {/* */} + + + + + + + + ) +} + +export default ImageViewer \ No newline at end of file diff --git a/src/Constants/Constants.js b/src/Constants/Constants.js index ead0967..f00e1aa 100644 --- a/src/Constants/Constants.js +++ b/src/Constants/Constants.js @@ -1,3 +1,6 @@ + +import dns from "node:dns" + export const getFileNameFromPath = (filePath) => { const parts = filePath?.split("/"); return parts?.[parts?.length - 1]; @@ -10,3 +13,32 @@ export function debounce(func, delay) { debounceTimer = setTimeout(() => func.apply(this, args), delay); }; } + + + +async function resolveMx(domain, recordType) { + return new Promise((resolve, reject) => { + dns.resolveMx(domain, (err, mxRecords) => { + if (err) { + reject(err); + return; + } + const addresses = mxRecords.map((mxRecord) => mxRecord.exchange); + resolve(addresses); + }); + }); +} +// Async function to check email address validity +export async function checkEmailValidity(email) { + try { + const domain = email?.split("@")[1]; + const addresses = await resolveMx(domain, "MX"); + + if (addresses && addresses?.length > 0) { + return true; + } + return false; // No MX record exists + } catch (err) { + return false; // Error occurred + } +} diff --git a/src/Pages/IO_Management/CreateIO/IOArtifacts.jsx b/src/Pages/IO_Management/CreateIO/IOArtifacts.jsx index ec243fd..626a2a8 100644 --- a/src/Pages/IO_Management/CreateIO/IOArtifacts.jsx +++ b/src/Pages/IO_Management/CreateIO/IOArtifacts.jsx @@ -29,6 +29,7 @@ import { useGetIOByIdQuery, } from "../../../Services/io.service"; import { getFileNameFromPath } from "../../../Constants/Constants"; +import ImageViewer from "../../../Components/ImageViewer"; const IOArtifacts = ({ enableNextTab, index, data }) => { const params = useParams(); @@ -54,6 +55,7 @@ const IOArtifacts = ({ enableNextTab, index, data }) => { const [actionId, setActionId] = useState(false); const [mouseEntered, setMouseEntered] = useState(false); const [mouseEnteredId, setMouseEnteredId] = useState(""); + const [imageSrc, setImageSrc] = useState(false); const { isOpen, onOpen, onClose } = useDisclosure(); const [deleteVideoArtifacts] = useDeleteVideoArtifactsMutation(); @@ -65,6 +67,12 @@ const IOArtifacts = ({ enableNextTab, index, data }) => { onClose: onCloseVideo, } = useDisclosure(); + const { + isOpen: isOpenImageViewer, + onOpen: onOpenImageViewer, + onClose: onCloseImageViewer, + } = useDisclosure(); + useEffect(() => { // Simulate loading const timer = setTimeout(() => { @@ -123,12 +131,7 @@ const IOArtifacts = ({ enableNextTab, index, data }) => { } }; - const tableHeadRow = [ - "Sr.no", - "File Name", - "View image", - "Action", - ]; + const tableHeadRow = ["Sr.no", "File Name", "View image", "Action"]; const extractedArray = IObyID?.data?.artifactsImage?.map((item, index) => ({ "Sr.no": ( @@ -172,7 +175,17 @@ const IOArtifacts = ({ enableNextTab, index, data }) => { } isExternal > - View + { + // setImageSrc(item?.artifactPathName); + // onOpenImageViewer(); + // }} + as="span" + cursor={'pointer'} + > + View + {" "} + @@ -398,6 +411,13 @@ const IOArtifacts = ({ enableNextTab, index, data }) => { alertHandler={() => handleDeleteVideo(actionId)} isLoading={isLoadingBtn} /> + + ); }; diff --git a/src/Pages/Master/Sponser/AddSponser.jsx b/src/Pages/Master/Sponser/AddSponser.jsx index f16c526..1ca49c1 100644 --- a/src/Pages/Master/Sponser/AddSponser.jsx +++ b/src/Pages/Master/Sponser/AddSponser.jsx @@ -11,13 +11,20 @@ import {useCreateSponserMutation,useGetSponserByIdQuery,useUpdateSponserMutation import ToastBox from "../../../Components/ToastBox"; import FullscreenLoaders from "../../../Components/Loaders/FullscreenLoaders"; import CustomAlertDialog from "../../../Components/CustomAlertDialog"; +import { checkEmailValidity } from "../../../Constants/Constants"; // ======================= [validation] ========================= export const addSponser = yup.object().shape({ sponsorName: yup.string().required("Sponser name is required"), sponsorNameArabic: yup.string().required("Sponser name is required"), - // email: yup.string().email("Must be a valid email").required("Email is required"), + email: yup.string().email("Must be a valid email").notRequired(), +// .test("emailValidity", "Email address is invalid", async function (value) { +// if (!value) { +// return true; // Allow if the field is empty +// } +// return await checkEmailValidity(value); +// }), }); // ==================== [debounce] ========================