convert to TS component eventList + context
This commit is contained in:
@@ -51,7 +51,7 @@ export function formatDateLetter(d: string | Date | null | undefined): string {
|
||||
}
|
||||
|
||||
|
||||
export function formatDateLetterJS(d: string): string {
|
||||
/*export function formatDateLetterJS(d: string): string {
|
||||
const monthNames = [
|
||||
"Janvier", "Février", "Mars", "Avril", "Mai", "Juin",
|
||||
"Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
|
||||
@@ -61,5 +61,5 @@ export function formatDateLetterJS(d: string): string {
|
||||
if (!year || !month || !day) return "Date invalide";
|
||||
|
||||
return `${day} ${monthNames[parseInt(month, 10) - 1]} ${year}`;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
import fetchWrapper from "../fetchWrapper";
|
||||
import getXSRFToken from "../getXSRF.js";
|
||||
|
||||
export default async function deleteProfilePhoto(): Promise<{ status: number; ok: boolean; data?: any; error?: string }> {
|
||||
try {
|
||||
const response = await fetchWrapper("/api/profile-photo", null, "DELETE");
|
||||
return { status: response.status || 0, ok: response.status >= 200 && response.status < 300, data: response.data };
|
||||
const csrfToken = await getXSRFToken();
|
||||
const response = await fetch(`${import.meta.env.VITE_API_URL}/api/profile-photo`, {
|
||||
method: "DELETE",
|
||||
headers: { "X-XSRF-TOKEN": decodeURIComponent(csrfToken) },
|
||||
credentials: "include",
|
||||
});
|
||||
|
||||
const status = response.status;
|
||||
let data = null;
|
||||
try {
|
||||
data = await response.json();
|
||||
} catch (e) {
|
||||
// Pas de JSON dans la réponse
|
||||
}
|
||||
|
||||
return { status, ok: response.ok, data };
|
||||
} catch (err: any) {
|
||||
return { status: 0, ok: false, error: err?.message || "Network error" };
|
||||
return { status: 0, ok: false, error: err?.message || "Erreur réseau" };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user