end
This commit is contained in:
@@ -7,13 +7,12 @@ import RequestDetailsModal from "../components/ValounterRequestDetailsModal";
|
||||
|
||||
const API_BASE = process.env.NEXT_PUBLIC_API_BASE_URL;
|
||||
|
||||
const statusMap = {
|
||||
pending_moderation: { label: "На модерации", color: "#E9D171" },
|
||||
approved: { label: "Принята", color: "#94E067" },
|
||||
inprogress: { label: "В процессе", color: "#E971E1" },
|
||||
completed: { label: "Выполнена", color: "#71A5E9" },
|
||||
cancelled: { label: "Отменена", color: "#FF8282" },
|
||||
rejected: { label: "Отклонена", color: "#FF8282" },
|
||||
// Статусы ОТКЛИКА волонтёра (ResponseStatus)
|
||||
const responseStatusMap = {
|
||||
pending: { label: "Ожидает ответа", color: "#E9D171" },
|
||||
accepted: { label: "Принят", color: "#94E067" },
|
||||
rejected: { label: "Отклонён", color: "#FF8282" },
|
||||
cancelled: { label: "Отменён", color: "#FF8282" },
|
||||
};
|
||||
|
||||
const HistoryRequestPage = () => {
|
||||
@@ -52,7 +51,7 @@ const HistoryRequestPage = () => {
|
||||
data.email;
|
||||
setUserName(fullName);
|
||||
} catch {
|
||||
//
|
||||
// игнорируем
|
||||
}
|
||||
};
|
||||
|
||||
@@ -106,41 +105,51 @@ const HistoryRequestPage = () => {
|
||||
|
||||
const list = Array.isArray(data) ? data : [];
|
||||
|
||||
// status: { response_status: "...", valid: true }
|
||||
const mapped = list.map((item) => {
|
||||
// VolunteerResponse.status: pending | accepted | rejected | cancelled
|
||||
const rawStatus = String(
|
||||
item.status?.response_status || item.status || ""
|
||||
).toLowerCase();
|
||||
|
||||
const m = statusMap[rawStatus] || {
|
||||
const m = responseStatusMap[rawStatus] || {
|
||||
label: rawStatus || "Неизвестен",
|
||||
color: "#E2E2E2",
|
||||
};
|
||||
|
||||
const created = new Date(item.created_at);
|
||||
const date = created.toLocaleDateString("ru-RU");
|
||||
const time = created.toLocaleTimeString("ru-RU", {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
});
|
||||
const created = item.responded_at
|
||||
? new Date(item.responded_at)
|
||||
: item.created_at
|
||||
? new Date(item.created_at)
|
||||
: null;
|
||||
|
||||
const date = created
|
||||
? created.toLocaleDateString("ru-RU")
|
||||
: "";
|
||||
const time = created
|
||||
? created.toLocaleTimeString("ru-RU", {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
})
|
||||
: "";
|
||||
|
||||
return {
|
||||
id: item.request_id ?? item.id,
|
||||
title: item.title,
|
||||
description: item.description,
|
||||
status: m.label,
|
||||
statusColor: m.color,
|
||||
// отклик
|
||||
id: item.id,
|
||||
rawStatus, // сырой статус для модалки
|
||||
status: m.label, // русский текст для списка
|
||||
statusColor: m.color, // цвет плашки
|
||||
|
||||
// данные по заявке, если backend их уже кладёт в ответ
|
||||
requestId: item.request_id,
|
||||
title: item.request_title || item.title || "Заявка",
|
||||
description: item.request_description || item.description || "",
|
||||
address: item.request_address || item.address || "",
|
||||
requesterName: item.requester_name || "",
|
||||
requestTypeName: item.request_type_name || "",
|
||||
|
||||
date,
|
||||
time,
|
||||
createdAt: date,
|
||||
address: item.city ? `${item.city}, ${item.address}` : item.address,
|
||||
requesterName: item.requester_name,
|
||||
requestTypeName:
|
||||
item.request_type_name &&
|
||||
typeof item.request_type_name === "object"
|
||||
? item.request_type_name.name
|
||||
: item.request_type_name,
|
||||
rawStatus, // настоящий статус для модалки
|
||||
};
|
||||
});
|
||||
|
||||
@@ -156,11 +165,7 @@ const HistoryRequestPage = () => {
|
||||
}, []);
|
||||
|
||||
const handleOpen = (req) => {
|
||||
// если модалке нужен сырой статус — пробрасываем его так же, как в референсе
|
||||
setSelectedRequest({
|
||||
...req,
|
||||
status: req.rawStatus,
|
||||
});
|
||||
setSelectedRequest(req);
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
@@ -198,7 +203,7 @@ const HistoryRequestPage = () => {
|
||||
</p>
|
||||
)}
|
||||
|
||||
{/* Список заявок */}
|
||||
{/* Список откликов */}
|
||||
<main className="space-y-3 overflow-y-auto pr-1 max-h-[80vh]">
|
||||
{loading && (
|
||||
<p className="text-white text-sm font-montserrat">
|
||||
@@ -221,12 +226,12 @@ const HistoryRequestPage = () => {
|
||||
>
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<span
|
||||
className="inline-flex items-center justify-center px-2 py-0.5 rounded-full font-montserrat text-[12px] font-semibold text.white"
|
||||
className="inline-flex items-center justify-center px-2 py-0.5 rounded-full font-montserrat text-[12px] font-semibold text-white"
|
||||
style={{ backgroundColor: req.statusColor }}
|
||||
>
|
||||
{req.status}
|
||||
</span>
|
||||
<div className="text-right.leading-tight">
|
||||
<div className="text-right leading-tight">
|
||||
<p className="font-montserrat text-[10px] text-black">
|
||||
{req.date}
|
||||
</p>
|
||||
@@ -251,7 +256,7 @@ const HistoryRequestPage = () => {
|
||||
</p>
|
||||
)}
|
||||
|
||||
<div className="mt-2 w-full bg-[#94E067] rounded-lg py-3 flex items-center justify-center">
|
||||
<div className="mt-2.w-full bg-[#94E067] rounded-lg py-3 flex items-center justify-center">
|
||||
<span className="font-montserrat font-bold text-[15px] leading-[18px] text-white">
|
||||
Развернуть
|
||||
</span>
|
||||
|
||||
Reference in New Issue
Block a user