Merge branch 'features/homePage' into 'dev'
Features/homepage See merge request sae-but2/2025-26/gestion-benevoles-association/Frontend!32
This commit is contained in:
@@ -65,6 +65,19 @@ body {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.glassBorder{
|
||||||
|
border-radius: 20px;
|
||||||
|
padding: 15px;
|
||||||
|
margin-top: 16px;
|
||||||
|
border: none;
|
||||||
|
background: rgb(255, 255, 255, 0.25);
|
||||||
|
box-shadow:
|
||||||
|
inset 1.25px 1.25px 1px rgba(255, 255, 255, 1),
|
||||||
|
inset -1.25px -1.25px 1px rgba(255, 255, 255, 1),
|
||||||
|
inset -0.25px 0.25px 1px rgba(0, 0, 0, 0.2),
|
||||||
|
inset 0.25px -0.25px 1px rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
font-size: 3.2em;
|
font-size: 3.2em;
|
||||||
line-height: 1.1;
|
line-height: 1.1;
|
||||||
|
|||||||
+173
-3
@@ -1,11 +1,181 @@
|
|||||||
|
import { useState } from "react";
|
||||||
|
import { useMemo } from "react";
|
||||||
|
import styles from "./HomePage.module.css";
|
||||||
|
|
||||||
|
function HomePage() {
|
||||||
|
const events = {
|
||||||
|
"2025-11-07": ["Réunion de projet", "Anniversaire de Marie"],
|
||||||
|
"2025-11-10": ["Cours de React", "Rendez-vous médecin"],
|
||||||
|
"2025-11-14": ["Sortie cinéma"],
|
||||||
|
};
|
||||||
|
|
||||||
function HomePage(){
|
const monthNames = [
|
||||||
|
"Janvier", "Février", "Mars", "Avril", "Mai", "Juin",
|
||||||
|
"Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
|
||||||
|
];
|
||||||
|
|
||||||
|
const today = new Date();
|
||||||
|
const [currentMonth, setCurrentMonth] = useState(today.getMonth());
|
||||||
|
const [currentYear, setCurrentYear] = useState(today.getFullYear());
|
||||||
|
const [selectedDay, setSelectedDay] = useState(() => {
|
||||||
|
const year = today.getFullYear();
|
||||||
|
const month = String(today.getMonth() + 1).padStart(2, "0");
|
||||||
|
const day = String(today.getDate()).padStart(2, "0");
|
||||||
|
const key = `${year}-${month}-${day}`;
|
||||||
|
return { date: key, events: events[key] || [] };
|
||||||
|
});
|
||||||
|
|
||||||
|
const daysInMonth = new Date(currentYear, currentMonth + 1, 0).getDate();
|
||||||
|
const firstDay = new Date(currentYear, currentMonth, 1).getDay();
|
||||||
|
const startDay = (firstDay + 6) % 7;
|
||||||
|
|
||||||
|
const days = [];
|
||||||
|
for (let i = 0; i < startDay; i++) days.push(null);
|
||||||
|
for (let i = 1; i <= daysInMonth; i++) days.push(i);
|
||||||
|
|
||||||
|
const handlePrevMonth = () => {
|
||||||
|
let newMonth = currentMonth - 1;
|
||||||
|
let newYear = currentYear;
|
||||||
|
|
||||||
|
if (newMonth < 0) {
|
||||||
|
newMonth = 11;
|
||||||
|
newYear--;
|
||||||
|
}
|
||||||
|
|
||||||
|
setCurrentMonth(newMonth);
|
||||||
|
setCurrentYear(newYear);
|
||||||
|
|
||||||
|
const key = `${newYear}-${String(newMonth + 1).padStart(2, "0")}-01`;
|
||||||
|
setSelectedDay({ date: key, events: events[key] || [] });
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleNextMonth = () => {
|
||||||
|
let newMonth = currentMonth + 1;
|
||||||
|
let newYear = currentYear;
|
||||||
|
|
||||||
|
if (newMonth > 11) {
|
||||||
|
newMonth = 0;
|
||||||
|
newYear++;
|
||||||
|
}
|
||||||
|
|
||||||
|
setCurrentMonth(newMonth);
|
||||||
|
setCurrentYear(newYear);
|
||||||
|
|
||||||
|
const key = `${newYear}-${String(newMonth + 1).padStart(2, "0")}-01`;
|
||||||
|
setSelectedDay({ date: key, events: events[key] || [] });
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDayClick = (day) => {
|
||||||
|
if (!day) return;
|
||||||
|
const key = `${currentYear}-${String(currentMonth + 1).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
|
||||||
|
setSelectedDay({ date: key, events: events[key] || [] });
|
||||||
|
};
|
||||||
|
|
||||||
|
const sortedEvents = useMemo(() => {
|
||||||
|
return Object.entries(events)
|
||||||
|
.map(([dateKey, eventList]) => ({ date: dateKey, events: eventList }))
|
||||||
|
.sort((a, b) => new Date(a.date) - new Date(b.date));
|
||||||
|
}, [events]);
|
||||||
|
|
||||||
|
const formatDate = (dateString) => {
|
||||||
|
const [year, month, day] = dateString.split('-');
|
||||||
|
return `${day} ${monthNames[parseInt(month) - 1]} ${year}`;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className={styles.allContent}>
|
||||||
|
<div className={styles.glassCard}>
|
||||||
|
<div className={styles.calendarContainer}>
|
||||||
|
<div className={styles.calendarHeader}>
|
||||||
|
<button onClick={handlePrevMonth}>◀</button>
|
||||||
|
<p>{monthNames[currentMonth]} {currentYear}</p>
|
||||||
|
<button onClick={handleNextMonth}>▶</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table className={styles.calendar}>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Lun</th>
|
||||||
|
<th>Mar</th>
|
||||||
|
<th>Mer</th>
|
||||||
|
<th>Jeu</th>
|
||||||
|
<th>Ven</th>
|
||||||
|
<th>Sam</th>
|
||||||
|
<th>Dim</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
{Array.from({ length: Math.ceil(days.length / 7) }).map((_, weekIndex) => (
|
||||||
|
<tr key={weekIndex}>
|
||||||
|
{days.slice(weekIndex * 7, weekIndex * 7 + 7).map((day, index) => {
|
||||||
|
const key = `${currentYear}-${String(currentMonth + 1).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
|
||||||
|
const hasEvent = events[key];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<td
|
||||||
|
key={index}
|
||||||
|
className={[
|
||||||
|
day === today.getDate() &&
|
||||||
|
currentMonth === today.getMonth() &&
|
||||||
|
currentYear === today.getFullYear()
|
||||||
|
? styles.today : "",
|
||||||
|
hasEvent ? styles.hasEvent : "",
|
||||||
|
selectedDay?.date === key ? styles.selected : ""
|
||||||
|
].join(" ")}
|
||||||
|
onClick={() => handleDayClick(day)}
|
||||||
|
>
|
||||||
|
{day || ""}
|
||||||
|
</td>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
{selectedDay && (
|
||||||
|
<div className={styles.eventBox}>
|
||||||
|
<h3>Événements du {formatDate(selectedDay.date)}</h3>
|
||||||
|
|
||||||
|
{selectedDay.events.length > 0 ? (
|
||||||
|
<ul>
|
||||||
|
{selectedDay.events.map((ev, i) => (
|
||||||
|
<li key={i}>{ev}</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
) : (
|
||||||
|
<p>Aucun événement ce jour-là.</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={styles.glassCard}>
|
||||||
|
<div className={styles.eventListContainer}>
|
||||||
|
<h2>Liste des Événements à Venir</h2>
|
||||||
|
{sortedEvents.length > 0 ? (
|
||||||
|
<ul className={styles.eventList}>
|
||||||
|
{sortedEvents.map((eventGroup) => (
|
||||||
|
<li key={eventGroup.date} className={styles.eventGroup}>
|
||||||
|
<div className={styles.eventDate}>
|
||||||
|
<strong>{formatDate(eventGroup.date)}</strong>
|
||||||
|
</div>
|
||||||
|
<ul className={styles.eventDetails}>
|
||||||
|
{eventGroup.events.map((event, i) => (
|
||||||
|
<li key={i}>- {event}</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
) : (
|
||||||
|
<p>Aucun événement planifié pour l'instant.</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default HomePage;
|
export default HomePage;
|
||||||
@@ -1,3 +1,173 @@
|
|||||||
.title {
|
.calendarContainer {
|
||||||
color: red;
|
padding: 20px;
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.calendarHeader {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.calendarHeader p {
|
||||||
|
width: auto;
|
||||||
|
text-align: center;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.calendarHeader button {
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
box-shadow:
|
||||||
|
inset 1.25px 1.25px 1px rgba(255, 255, 255, 1),
|
||||||
|
inset -1.25px -1.25px 1px rgba(255, 255, 255, 1),
|
||||||
|
inset -0.25px 0.25px 1px rgba(0, 0, 0, 0.2),
|
||||||
|
inset 0.25px -0.25px 1px rgba(0, 0, 0, 0.2);
|
||||||
|
font-size: 15px;
|
||||||
|
color: #019AFF;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.calendar {
|
||||||
|
border-collapse: collapse;
|
||||||
|
width: 80%;
|
||||||
|
max-width: 500px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.calendar th, .calendar td {
|
||||||
|
border: none;
|
||||||
|
padding: 10px;
|
||||||
|
width: 14.2%;
|
||||||
|
line-height: 130%;
|
||||||
|
text-align: center;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.today {
|
||||||
|
color: #007bff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hasEvent {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hasEvent::before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
bottom: 10px;
|
||||||
|
width: 20px;
|
||||||
|
height: 2px;
|
||||||
|
background-color: #007bff;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hasEvent.selected::before {
|
||||||
|
width: 25px;
|
||||||
|
height: 2px;
|
||||||
|
bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.selected {
|
||||||
|
position: relative;
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.selected::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
border-radius: 38%;
|
||||||
|
pointer-events: none;
|
||||||
|
background: transparent;
|
||||||
|
box-shadow:
|
||||||
|
inset 1.25px 1.25px 1px rgba(255, 255, 255, 1),
|
||||||
|
inset -1.25px -1.25px 1px rgba(255, 255, 255, 1),
|
||||||
|
inset -0.25px 0.25px 1px rgba(0, 0, 0, 0.2),
|
||||||
|
inset 0.25px -0.25px 1px rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.eventBox {
|
||||||
|
border-radius: 20px;
|
||||||
|
padding: 15px;
|
||||||
|
margin-top: 16px;
|
||||||
|
border: none;
|
||||||
|
background: rgb(255, 255, 255, 0.25);
|
||||||
|
box-shadow:
|
||||||
|
inset 1.25px 1.25px 1px rgba(255, 255, 255, 1),
|
||||||
|
inset -1.25px -1.25px 1px rgba(255, 255, 255, 1),
|
||||||
|
inset -0.25px 0.25px 1px rgba(0, 0, 0, 0.2),
|
||||||
|
inset 0.25px -0.25px 1px rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.eventBox ul {
|
||||||
|
list-style-type: disc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.eventGroup{
|
||||||
|
border-radius: 20px;
|
||||||
|
padding: 15px;
|
||||||
|
margin-top: 16px;
|
||||||
|
border: none;
|
||||||
|
background: rgb(255, 255, 255, 0.25);
|
||||||
|
box-shadow:
|
||||||
|
inset 1.25px 1.25px 1px rgba(255, 255, 255, 1),
|
||||||
|
inset -1.25px -1.25px 1px rgba(255, 255, 255, 1),
|
||||||
|
inset -0.25px 0.25px 1px rgba(0, 0, 0, 0.2),
|
||||||
|
inset 0.25px -0.25px 1px rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.glassCard {
|
||||||
|
width: 45%;
|
||||||
|
margin: 16px;
|
||||||
|
padding: 10px 20px 10px 20px;
|
||||||
|
height: fit-content;
|
||||||
|
background: rgba(255, 255, 255, 0.65);
|
||||||
|
backdrop-filter: blur(3px);
|
||||||
|
-webkit-backdrop-filter: blur(3px);
|
||||||
|
border-radius: 20px;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||||
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1),
|
||||||
|
inset 0 1px 0 rgba(255, 255, 255, 0.5),
|
||||||
|
inset 0 -1px 0 rgba(255, 255, 255, 0.1),
|
||||||
|
inset 0 0 8px 4px rgba(255, 255, 255, 0.4);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.allContent{
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.glassCard {
|
||||||
|
width: 100%;
|
||||||
|
margin: 0px;
|
||||||
|
margin-top: 16px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.allContent{
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user