Merge branch 'dev' into features/notifications
# Conflicts: # package-lock.json # package.json # src/components/Header/Header.jsx
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
export function formatDateLetter(d) {
|
||||
const monthNames = [
|
||||
"Janvier", "Février", "Mars", "Avril", "Mai", "Juin",
|
||||
"Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
|
||||
];
|
||||
|
||||
const [datePart, timePart] = d.split(' ');
|
||||
const [year, month, day] = datePart.split('-');
|
||||
const [hours, minutes] = timePart.split(':');
|
||||
|
||||
return `${day} ${monthNames[parseInt(month, 10) - 1]} ${year} à ${hours}:${minutes}`;
|
||||
}
|
||||
|
||||
|
||||
export function formatDateLetterJS(d) {
|
||||
const monthNames = [
|
||||
"Janvier", "Février", "Mars", "Avril", "Mai", "Juin",
|
||||
"Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
|
||||
];
|
||||
const [year, month, day] = d.split('-');
|
||||
return `${day} ${monthNames[parseInt(month) - 1]} ${year}`;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { expect, test } from 'vitest';
|
||||
import formatDateLetter from './formatDateLetter';
|
||||
|
||||
const date = "2025-11-07"
|
||||
const res = "07 Novembre 2025"
|
||||
|
||||
test("Format Date Letter", () => {
|
||||
expect(formatDateLetter(date)).toBe(res);
|
||||
})
|
||||
@@ -1,6 +1,6 @@
|
||||
import getXSRFToken from "../getXSRF.js";
|
||||
|
||||
export default async function createEvent(name, description) {
|
||||
export default async function createEvent(name, description, start, end) {
|
||||
const csrfToken = await getXSRFToken();
|
||||
|
||||
try {
|
||||
@@ -12,7 +12,7 @@ export default async function createEvent(name, description) {
|
||||
'X-XSRF-TOKEN': csrfToken,
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ name, description }),
|
||||
body: JSON.stringify({ name, description, start, end }),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default async function getUserById (id) {
|
||||
export default async function getUserById(id) {
|
||||
try {
|
||||
const res = await fetch(`http://${import.meta.env.VITE_API_URL}/api/users/${id}`, {
|
||||
method: 'GET',
|
||||
@@ -9,12 +9,15 @@ export default async function getUserById (id) {
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
if (res.status === 404) {
|
||||
return { error: 'not_found' };
|
||||
}
|
||||
throw new Error(`Erreur serveur : ${res.status}`);
|
||||
}
|
||||
|
||||
return await res.json();
|
||||
} catch (err) {
|
||||
console.error('Erreur :', err);
|
||||
return null;
|
||||
return { error: 'server_error' };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user