Display & Delete in love list

This commit is contained in:
2024-10-11 19:08:52 +02:00
parent b702bc629c
commit 1077400260
23 changed files with 644 additions and 523 deletions
+36
View File
@@ -0,0 +1,36 @@
import { useEffect, useState } from 'react';
export const useData = () => {
const [isLoading, setIsLoading] = useState(true);
const [userData, setUserData] = useState(null);
useEffect(() => {
(async () => {
const token = localStorage.getItem('token');
const request = await fetch('/api/user', {
method: 'GET',
headers: {
Authorization: token,
},
});
const response = await request.json();
const formattedResponse = {
...response,
createdat: new Date(response.createdat).toLocaleDateString(
'fr-FR'
),
};
setIsLoading(false);
setUserData(formattedResponse);
})();
}, []);
return {
isLoading,
userData,
};
};