mirror of
https://github.com/LucasVbr/meeting-app.git
synced 2026-05-13 17:21:53 +00:00
fix(deleteImage): image not showing after deleted
This commit is contained in:
@@ -77,11 +77,9 @@ export default function ModalModifyImages(props) {
|
|||||||
|
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
newListImage.splice(index, 1);
|
newListImage.splice(index, 1);
|
||||||
setlistImage(newListImage);
|
setlistImage([...newListImage]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// setlistImage(listImage.filter((image) => image !== fileName));
|
|
||||||
|
|
||||||
const imageDeleteOptions = {
|
const imageDeleteOptions = {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
body: JSON.stringify({ fileName: fileName.split("/").pop() }),
|
body: JSON.stringify({ fileName: fileName.split("/").pop() }),
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export const config = {
|
|||||||
const deleteImage = async (req, res) => {
|
const deleteImage = async (req, res) => {
|
||||||
const body = await JSON.parse(req.body);
|
const body = await JSON.parse(req.body);
|
||||||
await fs.unlinkSync(`./public/imageUsers/${body.fileName}`);
|
await fs.unlinkSync(`./public/imageUsers/${body.fileName}`);
|
||||||
res.status(200).send("image deleted");
|
res.status(204).send({ message: "File deleted", file: body.fileName });
|
||||||
};
|
};
|
||||||
|
|
||||||
export default (req, res) => {
|
export default (req, res) => {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ const post = async (req, res) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
saveFile(files.file);
|
saveFile(files.file);
|
||||||
return res.status(201).send("image saved");
|
return res.status(201).send({ message: "File uploaded", file: files.file });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ export default function UserProfile() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Box bgColor={"purple.50"}>
|
<Box bgColor={"purple.50"}>
|
||||||
<Container justifyContent={"center"} maxWidth={"70rem"} mt={"1rem"}>
|
<Container justifyContent={"center"} maxW={"70rem"} mt={"1rem"}>
|
||||||
<Flex flexDirection={"column"} alignItems={"center"} gap={"1rem"}>
|
<Flex flexDirection={"column"} alignItems={"center"} gap={"1rem"}>
|
||||||
<Box width={"50%"}>
|
<Box width={"50%"}>
|
||||||
{userData.images ? (
|
{userData.images ? (
|
||||||
@@ -139,7 +139,7 @@ export default function UserProfile() {
|
|||||||
Modifiez les champs en les selectionnants
|
Modifiez les champs en les selectionnants
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<form onSubmit={handleSubmit(saveData)}>
|
<Box as="form" onSubmit={handleSubmit(saveData)} width={"80%"}>
|
||||||
<FormControl width={"100%"}>
|
<FormControl width={"100%"}>
|
||||||
<Flex justify={"space-between"} mb={"1rem"}>
|
<Flex justify={"space-between"} mb={"1rem"}>
|
||||||
<Box>
|
<Box>
|
||||||
@@ -355,7 +355,7 @@ export default function UserProfile() {
|
|||||||
</Button>
|
</Button>
|
||||||
</Center>
|
</Center>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</form>
|
</Box>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Container>
|
</Container>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
Reference in New Issue
Block a user