Merge branch 'dev' into refactor/filesName
# Conflicts: # src/pages/Login/components/LoginForm/loginForm.jsx
This commit is contained in:
commit
41d59b336b
11 files changed
+224
-170
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import styles from "./HomePage.module.css";
|
||||
import Calendar from "./components/Calendar/Calendar.jsx";
|
||||
import EventList from "./components/EventList/EventList.tsx";
|
||||
import EventList from "./components/EventList/EventList";
|
||||
|
||||
function HomePage() {
|
||||
|
||||
|
||||
@@ -4,10 +4,11 @@ import {formatDateLetterJS} from "../../../../utils/date/formatDateLetter.js";
|
||||
import Button from "../../../../components/ui/Button/Button";
|
||||
import {AuthContext} from "../../../../contexts/Auth/AuthContext.ts";
|
||||
|
||||
function Calendar() {
|
||||
|
||||
function
|
||||
Calendar() {
|
||||
const { user } = useContext(AuthContext);
|
||||
|
||||
const calendarUrl = `${import.meta.env.VITE_API_URL}/api/export/ics/${user.id}`;
|
||||
|
||||
const monthNames = [
|
||||
"Janvier", "Février", "Mars", "Avril", "Mai", "Juin",
|
||||
@@ -17,17 +18,17 @@ function Calendar() {
|
||||
const today = new Date();
|
||||
|
||||
const [currentMonth, setCurrentMonth] = useState(today.getMonth());
|
||||
const [currentYear] = useState(today.getFullYear());
|
||||
const [currentYear, setCurrentYear] = useState(today.getFullYear());
|
||||
const [selectedDay, setSelectedDay] = useState(null);
|
||||
|
||||
const eventsByDate = useMemo(() => {
|
||||
if (!user?.tasks) return {};
|
||||
return user.tasks.reduce((acc, task) => {
|
||||
if (!task?.start) return acc;
|
||||
return user.tasks.reduce((eventsByDate, task) => {
|
||||
if (!task?.start) return eventsByDate;
|
||||
const dateKey = task.start.split(" ")[0];
|
||||
if (!acc[dateKey]) acc[dateKey] = [];
|
||||
acc[dateKey].push(task);
|
||||
return acc;
|
||||
if (!eventsByDate[dateKey]) eventsByDate[dateKey] = [];
|
||||
eventsByDate[dateKey].push(task);
|
||||
return eventsByDate;
|
||||
}, {});
|
||||
}, [user]);
|
||||
|
||||
@@ -66,9 +67,31 @@ function Calendar() {
|
||||
<div className={styles.calendarContainer}>
|
||||
|
||||
<div className={styles.calendarHeader}>
|
||||
<button onClick={() => setCurrentMonth(m => m === 0 ? 11 : m - 1)}>◀</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
if (currentMonth === 0) {
|
||||
setCurrentMonth(11);
|
||||
setCurrentYear(y => y - 1);
|
||||
} else {
|
||||
setCurrentMonth(m => m - 1);
|
||||
}
|
||||
}}
|
||||
>
|
||||
◀
|
||||
</button>
|
||||
<p>{monthNames[currentMonth]} {currentYear}</p>
|
||||
<button onClick={() => setCurrentMonth(m => m === 11 ? 0 : m + 1)}>▶</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
if (currentMonth === 11) {
|
||||
setCurrentMonth(0);
|
||||
setCurrentYear(y => y + 1);
|
||||
} else {
|
||||
setCurrentMonth(m => m + 1);
|
||||
}
|
||||
}}
|
||||
>
|
||||
▶
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<table className={styles.calendar}>
|
||||
@@ -128,15 +151,18 @@ function Calendar() {
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<Button className={styles.exportbtn}
|
||||
variant={"primary"}
|
||||
<div className={`${styles.exportbox} glassBorder`}>
|
||||
<p><b>votre lien d'agenda:</b> {calendarUrl}</p>
|
||||
<Button className={styles.exportbtn}
|
||||
onClick={() => {
|
||||
window.location.href =
|
||||
`http://localhost/api/export/ics/${user.id}`;
|
||||
window.open(
|
||||
"https://calendar.google.com/calendar/u/0/r/settings/addbyurl"
|
||||
);
|
||||
}}
|
||||
>
|
||||
Exporter mon agenda
|
||||
</Button>
|
||||
>
|
||||
Exporter
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -150,10 +150,22 @@
|
||||
display: none;
|
||||
}
|
||||
|
||||
.exportbtn{
|
||||
.exportbox{
|
||||
width: 100%;
|
||||
padding: 15px;
|
||||
margin-top: 16px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.exportbtn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
max-height: 30px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.glassCard {
|
||||
width: 100%;
|
||||
|
||||
@@ -68,9 +68,12 @@ h2{
|
||||
}
|
||||
|
||||
.eventTasks {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
list-style: none;
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.taskDate{
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
|
||||
Reference in new issue
Block a user