._.
This commit is contained in:
parent
cd978c05b3
commit
65853cf759
24
API/main.py
24
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')
|
||||
|
||||
BIN
WEB/app/public/img.png
Normal file
BIN
WEB/app/public/img.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
@ -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;
|
||||
}
|
||||
@ -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 && (
|
||||
<div className="birthday-icon">
|
||||
<img src={"/img.png"} alt={""} width="30px"/>
|
||||
<div className="tooltip">
|
||||
{getBirthdaysForDay(day).map(user => (
|
||||
<div key={user.id}>{user.last_name} {user.first_name}</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div key={index} className="empty-cell"></div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user