diff --git a/app/AuthPage.jsx b/app/AuthPage.jsx index 86639fc..cdfb5b3 100644 --- a/app/AuthPage.jsx +++ b/app/AuthPage.jsx @@ -2,16 +2,19 @@ import React, { useState } from "react"; import { useRouter } from "next/navigation"; - +import { useAuth } from "../app/context/AuthContext"; const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; const AuthPage = () => { const router = useRouter(); + const { login } = useAuth(); + const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [rememberMe, setRememberMe] = useState(false); const [checkboxError, setCheckboxError] = useState(false); + const [authError, setAuthError] = useState(""); const isEmailValid = emailRegex.test(email); const isFormValid = isEmailValid && password.length > 0; @@ -19,24 +22,24 @@ const AuthPage = () => { const handleSubmit = (e) => { e.preventDefault(); - // проверка чекбокса if (!rememberMe) { setCheckboxError(true); return; } - setCheckboxError(false); if (!isFormValid) return; - console.log("Email:", email, "Password:", password, "Remember:", rememberMe); - router.push('./home'); + try { + login(email, password); // редирект сделает сам контекст + } catch (err) { + setAuthError(err.message); + } }; return (
- {/* Красный баннер ошибки по чекбоксу */} {checkboxError && (
{

Авторизация

- {/*

- как пользователь -

*/}
{/* Почта */} @@ -93,22 +93,34 @@ const AuthPage = () => { setRememberMe((prev) => !prev); if (!rememberMe) setCheckboxError(false); }} - className={`w-5 h-5 rounded-full border border-white flex items-center justify-center ${rememberMe ? "bg-white" : "bg-transparent" - }`} + className={`w-5 h-5 rounded-full border border-white flex items-center justify-center ${ + rememberMe ? "bg-white" : "bg-transparent" + }`} > {rememberMe && ( )}

- Подтверждаю, что я прочитал условия использования данного приложения + Подтверждаю, что я прочитал условия использования данного + приложения

+ {/* Ошибка авторизации */} + {authError && ( +

+ {authError} +

+ )} {/* Ссылки */}
- + + {/* Подсказка по тестовым логинам */} +
+

Тестовые аккаунты:

+

Пользователь: user@mail.com / user123

+

Волонтёр: vol@mail.com / vol123

+

Модератор: mod@mail.com / mod123

+
); diff --git a/app/components/TabBar.jsx b/app/components/TabBar.jsx index 8e5a0ac..6f5886b 100644 --- a/app/components/TabBar.jsx +++ b/app/components/TabBar.jsx @@ -2,41 +2,59 @@ import React from "react"; import { FaClock, FaNewspaper, FaHome, FaCog } from "react-icons/fa"; -import { useRouter } from "next/navigation"; +import { useRouter, usePathname } from "next/navigation"; +import { useAuth } from "../context/AuthContext"; const TabBar = () => { const router = useRouter(); + const pathname = usePathname(); + const { user } = useAuth(); + + if (!user) return null; // не показываем таббар, если не залогинен + + // маршруты по ролям + const routesByRole = { + user: [ + { key: "home", icon: FaHome, href: "/createRequest" }, + { key: "history", icon: FaClock, href: "/historyRequest" }, + { key: "news", icon: FaNewspaper, href: "/news" }, + { key: "profile", icon: FaCog, href: "/ProfilePage" }, + ], + volunteer: [ + { key: "home", icon: FaHome, href: "/mainValounter" }, + { key: "history", icon: FaClock, href: "/valounterHistoryRequest" }, + { key: "news", icon: FaNewspaper, href: "/volunteer/news" }, + { key: "profile", icon: FaCog, href: "/volunterProfile" }, + ], + moderator: [ + { key: "queue", icon: FaHome, href: "/moderator/home" }, + { key: "history", icon: FaClock, href: "/moderator/history" }, + { key: "news", icon: FaNewspaper, href: "/moderator/news" }, + { key: "profile", icon: FaCog, href: "/moderator/profile" }, + ], + }; + + const tabs = routesByRole[user.role] || []; return ( ); diff --git a/app/components/ValounterRequestDetailsModal.jsx b/app/components/ValounterRequestDetailsModal.jsx new file mode 100644 index 0000000..42fb195 --- /dev/null +++ b/app/components/ValounterRequestDetailsModal.jsx @@ -0,0 +1,153 @@ +import React, { useState } from "react"; +import { FaStar } from "react-icons/fa"; + +const RequestDetailsModal = ({ request, onClose }) => { + const isDone = request.status === "Выполнена"; + const isInProgress = request.status === "В процессе"; + + const [rating, setRating] = useState(0); + const [review, setReview] = useState(""); + + const handleStarClick = (value) => { + setRating(value); + }; + + const handleSubmit = () => { + console.log("Отправить отзыв:", { + id: request.id, + status: request.status, + rating, + review, + }); + onClose(); + }; + + return ( +
+ {/* Хедер */} +
+ +

+ Заявка от {request.createdAt} +

+ +
+ + {/* Карточка */} +
+
+ {/* Статус + дата/время */} +
+ + {request.status} + +
+

+ {request.date} +

+

+ {request.time} +

+
+
+ + {/* Название задачи */} +

+ {request.title} +

+ + {/* Полная информация о заявке */} +
+

ФИО: {request.fullName}

+

Адрес: {request.address}

+ {request.flat &&

Квартира: {request.flat}

} + {request.floor &&

Этаж: {request.floor}

} + {request.phone &&

Телефон: {request.phone}

} + {request.amount &&

Сумма: {request.amount}

} + {request.deadline &&

Выполнить до: {request.deadline}

} +
+ + {/* Описание / список покупок */} + {request.description && ( +
+

+ {request.description} +

+
+ )} + + {/* Блок отзыва + рейтинг — и для Выполнена, и для В процессе */} + {(isDone || isInProgress) && ( + <> +
+

+ Отзыв +

+