FIX - erreur infinite loading

This commit is contained in:
Eddi3_As 2025-03-13 21:48:15 -04:00
parent b7a7962435
commit 1c16e06319
3 changed files with 7 additions and 6 deletions

View file

@ -124,7 +124,7 @@ const ImageDialog: React.FC<Props> = ({ galleryOpen, setDialogOpen, setImageLink
<IconButton onClick={() => onCopy(obj.id)} size="small" data-testid={`copy-button-${obj.id}`}>
<ContentCopyIcon fontSize="small" />
</IconButton>
<IconButton onClick={() => handleDelete(obj.id)} size="small" color="secondary" data-testid={`delete-button-${obj.id}`}>
<IconButton onClick={() => handleDelete(obj.id)} size="small" color="primary" data-testid={`delete-button-${obj.id}`}>
<DeleteIcon fontSize="small" />
</IconButton>
{copiedId === obj.id && <span style={{ marginLeft: 8, color: "green" }}>Copié!</span>}

View file

@ -144,13 +144,14 @@ class ApiService {
}
public getUserID(): string {
const objectStr = localStorage.getItem("jwt");
const token = localStorage.getItem("jwt");
if (!objectStr) {
if (!token) {
return "";
}
const jsonObj = JSON.parse(objectStr);
const jsonObj = jwtDecode(token) as { userId: string };
if (!jsonObj.userId) {
return "";
}
@ -1259,8 +1260,8 @@ public async login(email: string, password: string): Promise<any> {
if (result.status !== 200) {
throw new Error(`La suppression de l'image a échoué. Status: ${result.status}`);
}
const deleted = result.data.delete;
const deleted = result.data.deleted;
return deleted;
} catch (error) {

View file

@ -14,6 +14,6 @@ router.post("/upload", jwt.authenticate, upload.single('image'), asyncHandler(im
router.get("/get/:id", asyncHandler(images.get));
router.get("/getImages", asyncHandler(images.getImages));
router.get("/getUserImages", asyncHandler(images.getUserImages));
router.get("/delete", asyncHandler(images.delete));
router.delete("/delete", asyncHandler(images.delete));
module.exports = router;