fix(image Name): switched index of image with Date().getTime()

This commit is contained in:
Laurian-Dufrechou
2023-03-31 16:40:23 +02:00
parent ae33f29c94
commit 2dfe2cac7b
+4 -5
View File
@@ -143,7 +143,6 @@ export default function ModalModifyImages(props) {
<GridItem key={index}>
<Flex direction={"column"} gap={"1rem"}>
<Image src={image} />
{index === listImage.length - 1 ? (
<Button
id={"" + index}
colorScheme={"red"}
@@ -153,9 +152,6 @@ export default function ModalModifyImages(props) {
>
Supprimer l'image
</Button>
) : (
<></>
)}
</Flex>
</GridItem>
))}
@@ -166,11 +162,14 @@ export default function ModalModifyImages(props) {
height={"100%"}
accept={"image/png, image/jpeg, image/webp"}
onInput={({ target }) => {
const date = new Date();
const time = date.getTime();
const file = target.files[0];
const extension = file.name.split(".").pop();
const newFile = new File(
[file],
`${user.id}_${listImage.length}.${extension}`,
`${user.id}_${time}.${extension}`,
{
type: file.type,
}