This commit is contained in:
2024-05-17 17:25:57 +05:30
parent 4897b69d97
commit b87e02497d
12 changed files with 462 additions and 93 deletions

View File

@@ -112,26 +112,26 @@ export const addNews = Yup.object().shape({
}
}
)
.test("file_formate", "Image file has unsupported format.", (files) => {
// // console.log(files[0].type)
// .test("file_formate", "Image file has unsupported format.", (files) => {
// // // console.log(files[0].type)
const SUPPORTED_FORMATS = [
"image/jpeg",
"image/png",
"image/gif",
"image/tiff",
"image/svg+xml",
];
try {
if (files.length !== 0) {
setPreviewImage(URL.createObjectURL(files[0]));
return files && SUPPORTED_FORMATS.includes(files[0].type);
}
return true;
} catch (error) {
return false;
}
})
// const SUPPORTED_FORMATS = [
// "image/jpeg",
// "image/png",
// "image/gif",
// "image/tiff",
// "image/svg+xml",
// ];
// try {
// if (files.length !== 0) {
// setPreviewImage(URL.createObjectURL(files[0]));
// return files && SUPPORTED_FORMATS.includes(files[0].type);
// }
// return true;
// } catch (error) {
// return false;
// }
// })
.optional(),
});
@@ -161,26 +161,26 @@ export const editNews = Yup.object().shape({
}
}
)
.test("file_formate", "Image file has unsupported format.", (files) => {
// // console.log(files[0].type)
// .test("file_formate", "Image file has unsupported format.", (files) => {
// // // console.log(files[0].type)
const SUPPORTED_FORMATS = [
"image/jpeg",
"image/png",
"image/gif",
"image/tiff",
"image/svg+xml",
];
try {
if (files.length !== 0) {
setPreviewImage(URL.createObjectURL(files[0]));
return files && SUPPORTED_FORMATS.includes(files[0].type);
}
return true;
} catch (error) {
return false;
}
})
// const SUPPORTED_FORMATS = [
// "image/jpeg",
// "image/png",
// "image/gif",
// "image/tiff",
// "image/svg+xml",
// ];
// try {
// if (files.length !== 0) {
// setPreviewImage(URL.createObjectURL(files[0]));
// return files && SUPPORTED_FORMATS.includes(files[0].type);
// }
// return true;
// } catch (error) {
// return false;
// }
// })
.optional(),
});
@@ -213,26 +213,26 @@ export const addEvents = Yup.object().shape({
}
}
)
.test("file_formate", "Image file has unsupported format.", (files) => {
// // console.log(files[0].type)
// .test("file_formate", "Image file has unsupported format.", (files) => {
// // // console.log(files[0].type)
const SUPPORTED_FORMATS = [
"image/jpeg",
"image/png",
"image/gif",
"image/tiff",
"image/svg+xml",
];
try {
if (files.length !== 0) {
setPreviewImage(URL.createObjectURL(files[0]));
return files && SUPPORTED_FORMATS.includes(files[0].type);
}
return true;
} catch (error) {
return false;
}
})
// const SUPPORTED_FORMATS = [
// "image/jpeg",
// "image/png",
// "image/gif",
// "image/tiff",
// "image/svg+xml",
// ];
// try {
// if (files.length !== 0) {
// setPreviewImage(URL.createObjectURL(files[0]));
// return files && SUPPORTED_FORMATS.includes(files[0].type);
// }
// return true;
// } catch (error) {
// return false;
// }
// })
.optional(),
});