This commit is contained in:
2024-08-26 12:11:38 +05:30
parent 79bcf851d9
commit b713845df6
3 changed files with 25 additions and 4 deletions

View File

@@ -37,7 +37,7 @@ import { current } from "@reduxjs/toolkit";
import { TABLE_PAGINATION } from "../../../Constants/Paginations";
import { removeTrailingZeros } from "../../../Constants/Constants";
const formatDate = (date) => new Date(date).toLocaleDateString(); // Simple date formatter
export const formatDate = (date) => new Date(date).toLocaleDateString(); // Simple date formatter
const DepositRequest = () => {
const navigate = useNavigate();

View File

@@ -84,6 +84,7 @@ const IOArtifactsAdd = ({
const onSubmit = async (data) => {
console.log("hit");
setIsLoading(true);
const formData = new FormData();
formData.append("artifactName", data.artifactName);
@@ -95,6 +96,7 @@ const IOArtifactsAdd = ({
data: formData,
id: found?.id,
});
if (res?.data?.statusCode === 200) {
toast({
render: () => <ToastBox message={res?.data?.message} />,
@@ -108,6 +110,20 @@ const IOArtifactsAdd = ({
artifactName: "",
artifactPathName: "",
});
} else{
toast({
render: () => <ToastBox message={"Something went wronng"} error="error" />,
});
setFile(null);
setIsLoading(false);
setAlert(false);
setPreview(null);
onClose();
reset({
artifactName: "",
artifactPathName: "",
});
}
if (res?.error) {
@@ -184,6 +200,11 @@ const IOArtifactsAdd = ({
}
}
const handleAlertClose = () =>{
setAlert(false)
setIsLoading(false)
}
return (
<>
@@ -225,7 +246,7 @@ const IOArtifactsAdd = ({
<FormLabel fontSize={"sm"}>Artifact Image</FormLabel>
<Input
type="file"
accept="image/*"
accept=".jpg,.jpeg,.png"
onChange={handleFileChange}
fontSize={"sm"}
size={"sm"}
@@ -296,7 +317,7 @@ const IOArtifactsAdd = ({
</Drawer>
<CustomAlertDialog
isOpen={alert}
onClose={() => setAlert(false)}
onClose={handleAlertClose}
alertHandler={handleSave}
message={"Are you sure you want to add this artifact?"}
isLoading={loading}

View File

@@ -108,7 +108,7 @@ console.log(transaction);
"Date": (
<Box w={"auto"} isTruncated={true}>
<Text as={"span"} color={"teal.900"}>
{item.transactionDate}
{formatDate(item.transactionDate)}
</Text>
</Box>
),