Добавлены изменения для PWA

This commit is contained in:
mi
2026-07-21 18:49:21 +03:00
parent 627371b221
commit cc0163eb94
22 changed files with 592 additions and 208 deletions
+50 -78
View File
@@ -1,89 +1,70 @@
import { useNavigate, useParams } from 'react-router';
import { ArrowLeft, Calendar, FileText, CheckCircle, EyeOff, Clock } from 'lucide-react';
import { ArrowLeft, Calendar, AlertCircle, Bell, CheckCircle, EyeOff, Clock } from 'lucide-react';
import { companyMessages, dismissMessage } from '../data/companyMessages';
interface NotificationData {
id: string;
type: 'urgent' | 'reminder';
icon: React.ReactNode;
title: string;
description: string;
fullContent: string;
deadline?: string;
steps?: string[];
function getIcon(type: 'urgent' | 'reminder' | 'info', className = 'w-5 h-5') {
if (type === 'urgent') return <AlertCircle className={className} />;
if (type === 'reminder') return <Calendar className={className} />;
return <Bell className={className} />;
}
const notificationDetails: Record<string, NotificationData> = {
'1': {
id: '1',
type: 'urgent',
icon: <Calendar className="w-6 h-6" />,
title: 'Продление патента через 14 дней',
description: 'Не забудьте подать документы заранее',
fullContent: 'Ваш патент на работу истекает 19 июня 2026 года. Рекомендуем начать процесс продления заранее, чтобы избежать перерыва в легальном статусе.',
deadline: '19 июня 2026',
steps: [
'Подготовьте пакет документов (паспорт, миграционная карта, текущий патент)',
'Оплатите госпошлину и НДФЛ',
'Подайте документы в МФЦ или МВД',
'Получите новый патент в течение 10 рабочих дней'
]
},
'2': {
id: '2',
type: 'reminder',
icon: <FileText className="w-6 h-6" />,
title: 'Проверьте статус РВП',
description: 'Возможно, уже готово к получению',
fullContent: 'Прошло более 6 месяцев с момента подачи документов на РВП. Рекомендуем проверить готовность документа на сайте МВД или обратиться в отделение лично.',
steps: [
'Зайдите на сайт гувм.мвд.рф',
'Проверьте статус по номеру заявления',
'При готовности запишитесь на получение',
'Подготовьте документы для получения РВП'
]
}
};
function typeStyle(type: 'urgent' | 'reminder' | 'info') {
if (type === 'urgent') return {
wrapper: 'bg-destructive/10 text-destructive',
deadline: 'bg-destructive/6 border-destructive/20',
deadlineText: 'text-destructive',
step: 'bg-destructive/10 text-destructive',
};
if (type === 'reminder') return {
wrapper: 'bg-primary/10 text-primary',
deadline: 'bg-primary/5 border-primary/20',
deadlineText: 'text-primary',
step: 'bg-primary/10 text-primary',
};
return {
wrapper: 'bg-muted text-muted-foreground',
deadline: 'bg-muted border-border',
deadlineText: 'text-foreground',
step: 'bg-muted text-muted-foreground',
};
}
export function NotificationDetail() {
const navigate = useNavigate();
const { id } = useParams();
const notification = id ? notificationDetails[id] : null;
const notification = id ? companyMessages.find(m => m.id === id) : null;
if (!notification) {
return (
<div className="flex flex-col items-center justify-center h-full p-4">
<p className="text-muted-foreground">Уведомление не найдено</p>
<button
onClick={() => navigate('/')}
className="mt-4 text-primary font-medium"
>
<button onClick={() => navigate('/')} className="mt-4 text-primary font-medium">
Вернуться на главную
</button>
</div>
);
}
const style = typeStyle(notification.type);
const handleComplete = () => {
// В реальном приложении здесь будет логика отметки уведомления как выполненного
dismissMessage(notification.id);
navigate('/');
};
const handleHide = () => {
// В реальном приложении здесь будет логика скрытия уведомления
dismissMessage(notification.id);
navigate('/');
};
const handleLater = () => {
// В реальном приложении здесь будет логика напоминания позже
navigate('/');
};
const handleLater = () => navigate('/');
return (
<div className="flex flex-col h-full">
{/* Хедер с кнопкой назад */}
{/* Хедер */}
<div className="flex items-center gap-3 px-4 py-3 border-b border-border/40">
<button
onClick={() => navigate('/')}
onClick={() => navigate(-1)}
className="p-1.5 -ml-1.5 hover:bg-muted/50 rounded-lg transition-colors"
>
<ArrowLeft className="w-5 h-5" />
@@ -96,12 +77,8 @@ export function NotificationDetail() {
<div className="p-4 space-y-4">
{/* Иконка и заголовок */}
<div className="flex items-start gap-3">
<div className={`flex items-center justify-center w-12 h-12 rounded-full flex-shrink-0 ${
notification.type === 'urgent'
? 'bg-primary/10 text-primary'
: 'bg-muted text-muted-foreground'
}`}>
{notification.icon}
<div className={`flex items-center justify-center w-12 h-12 rounded-full flex-shrink-0 ${style.wrapper}`}>
{getIcon(notification.type, 'w-6 h-6')}
</div>
<div className="flex-1 min-w-0 pt-1">
<h2 className="font-semibold text-base mb-1">{notification.title}</h2>
@@ -109,13 +86,13 @@ export function NotificationDetail() {
</div>
</div>
{/* Срок, если есть */}
{/* Дедлайн */}
{notification.deadline && (
<div className="bg-primary/5 border border-primary/20 rounded-lg p-3">
<div className={`border rounded-lg p-3 ${style.deadline}`}>
<div className="flex items-center gap-2 text-sm">
<Calendar className="w-4 h-4 text-primary" />
<Calendar className={`w-4 h-4 ${style.deadlineText}`} />
<span className="font-medium">Срок:</span>
<span className="text-primary font-semibold">{notification.deadline}</span>
<span className={`font-semibold ${style.deadlineText}`}>{notification.deadline}</span>
</div>
</div>
)}
@@ -123,24 +100,20 @@ export function NotificationDetail() {
{/* Полное описание */}
<div className="space-y-2">
<h3 className="font-medium text-sm">Подробности</h3>
<p className="text-sm text-foreground/90 leading-relaxed">
{notification.fullContent}
</p>
<p className="text-sm text-foreground/90 leading-relaxed">{notification.fullContent}</p>
</div>
{/* Шаги к действию */}
{/* Шаги */}
{notification.steps && notification.steps.length > 0 && (
<div className="space-y-2">
<h3 className="font-medium text-sm">Что нужно сделать</h3>
<div className="space-y-2">
{notification.steps.map((step, index) => (
<div key={index} className="flex gap-2.5">
<div className="flex items-center justify-center w-5 h-5 rounded-full bg-primary/10 text-primary text-xs font-medium flex-shrink-0 mt-0.5">
{index + 1}
{notification.steps.map((step, i) => (
<div key={i} className="flex gap-2.5">
<div className={`flex items-center justify-center w-5 h-5 rounded-full text-xs font-medium flex-shrink-0 mt-0.5 ${style.step}`}>
{i + 1}
</div>
<p className="text-sm text-foreground/90 leading-relaxed flex-1">
{step}
</p>
<p className="text-sm text-foreground/90 leading-relaxed flex-1">{step}</p>
</div>
))}
</div>
@@ -149,7 +122,7 @@ export function NotificationDetail() {
</div>
</div>
{/* Кнопки управления */}
{/* Кнопки */}
<div className="border-t border-border/40 p-4 space-y-2 bg-background">
<button
onClick={handleComplete}
@@ -167,13 +140,12 @@ export function NotificationDetail() {
<Clock className="w-4 h-4" />
Сделаю позже
</button>
<button
onClick={handleHide}
className="flex-1 bg-muted text-muted-foreground rounded-lg px-4 py-2.5 text-sm font-medium flex items-center justify-center gap-2 hover:bg-muted/80 transition-colors"
>
<EyeOff className="w-4 h-4" />
Скрыть уведомление
Скрыть
</button>
</div>
</div>