update
This commit is contained in:
24
src/Components/ImageViewer.jsx
Normal file
24
src/Components/ImageViewer.jsx
Normal file
@@ -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 (
|
||||
<>
|
||||
{/* <Button onClick={onOpen}>Open Modal</Button> */}
|
||||
|
||||
<Modal size={'xl'} isCentered isOpen={isOpen} onClose={onClose}>
|
||||
<ModalOverlay />
|
||||
<ModalContent>
|
||||
{/* <ModalCloseButton /> */}
|
||||
<ModalBody p={4} >
|
||||
<Image rounded={6} w={'100%'} h={'100%'} src={"https://admin.tanami.betadelivery.com/" + src} />
|
||||
</ModalBody>
|
||||
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default ImageViewer
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
>
|
||||
<Box as="span">View</Box> <ExternalLinkIcon />
|
||||
<Box
|
||||
// onClick={() => {
|
||||
// setImageSrc(item?.artifactPathName);
|
||||
// onOpenImageViewer();
|
||||
// }}
|
||||
as="span"
|
||||
cursor={'pointer'}
|
||||
>
|
||||
View
|
||||
</Box>{" "}
|
||||
<ExternalLinkIcon />
|
||||
</Link>
|
||||
</Badge>
|
||||
</Text>
|
||||
@@ -398,6 +411,13 @@ const IOArtifacts = ({ enableNextTab, index, data }) => {
|
||||
alertHandler={() => handleDeleteVideo(actionId)}
|
||||
isLoading={isLoadingBtn}
|
||||
/>
|
||||
|
||||
<ImageViewer
|
||||
isOpen={isOpenImageViewer}
|
||||
onClose={onCloseImageViewer}
|
||||
onOpen={onOpenImageViewer}
|
||||
src={imageSrc}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -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] ========================
|
||||
|
||||
Reference in New Issue
Block a user