diff --git a/API/main.py b/API/main.py index 50059cb..b92c816 100644 --- a/API/main.py +++ b/API/main.py @@ -332,6 +332,30 @@ def get_events(): return resp +@app.route('/users_birthdays') +def get_users_birthday(): + resp = [] + + with connect() as session: + employees = session.query(User).all() + + for employee in employees: + resp.append( + { + 'id': employee.id, + 'first_name': employee.first_name, + 'last_name': employee.last_name, + 'patronymic': employee.patronymic, + 'email': employee.email, + 'phone': employee.work_phone, + 'post': employee.post.title, + 'birthday': str(employee.birthday) + } + ) + + return resp + + def main(): init_db() app.run('0.0.0.0') diff --git a/WEB/app/public/img.png b/WEB/app/public/img.png new file mode 100644 index 0000000..2281d50 Binary files /dev/null and b/WEB/app/public/img.png differ diff --git a/WEB/app/src/app/app.css b/WEB/app/src/app/app.css index f9d3c74..a17733c 100644 --- a/WEB/app/src/app/app.css +++ b/WEB/app/src/app/app.css @@ -190,3 +190,16 @@ font-weight: bold; color: black; } + +.birthday-icon .tooltip { + display: none; +} + +.birthday-icon:hover .tooltip { + display: block; + background: white; + padding: 10px; + z-index: 1001; + position: absolute; + border: 1px solid black; +} \ No newline at end of file diff --git a/WEB/app/src/app/components/сalendar.js b/WEB/app/src/app/components/сalendar.js index a74cdb3..46a6756 100644 --- a/WEB/app/src/app/components/сalendar.js +++ b/WEB/app/src/app/components/сalendar.js @@ -1,14 +1,38 @@ 'use client'; -import { useState } from "react"; +import {useEffect, useState} from "react"; const Calendar = () => { const [currentDate, setCurrentDate] = useState(new Date()); - const today = new Date(); // Текущая дата (для сравнения) + const [birthdays, setBirthdays] = useState([]); + const today = new Date(); const year = currentDate.getFullYear(); const month = currentDate.getMonth(); + useEffect(() => { + fetchBirthdays(); + }, [year, month]); + + const fetchBirthdays = async () => { + try { + const response = await fetch("http://localhost:5000/users_birthdays"); + if (response.ok) { + const data = await response.json(); + setBirthdays(data); + } + } catch (error) { + console.error("Ошибка загрузки дней рождений:", error); + } + }; + + const getBirthdaysForDay = (day) => { + return birthdays.filter((user) => { + const birthday = new Date(user.birthday); + return birthday.getDate() === day && birthday.getMonth() === month; + }); + }; + const prevMonth = () => setCurrentDate(new Date(year, month - 1, 1)); const nextMonth = () => setCurrentDate(new Date(year, month + 1, 1)); @@ -49,6 +73,16 @@ const Calendar = () => { }`} > {day} + {getBirthdaysForDay(day).length > 0 && ( +
+ {""} +
+ {getBirthdaysForDay(day).map(user => ( +
{user.last_name} {user.first_name}
+ ))} +
+
+ )} ) : (