fix: 8 improvements — calendar overlaps, legend, nav, tech tasks photos/sort/modal, hk history active maintenance

This commit is contained in:
2026-03-24 19:32:46 +03:00
parent 8b55bc58f1
commit 9a2e45b4c4
5 changed files with 162 additions and 73 deletions

View File

@@ -134,8 +134,16 @@ export function HousekeepingPage() {
useEffect(() => {
if (activeTab !== 'history' || !slug) return
setHistoryLoading(true)
api.housekeeping.list(slug, { status: 'done', date: historyDate })
.then(setHistoryTasks)
Promise.all([
api.housekeeping.list(slug, { status: 'done', date: historyDate }),
api.housekeeping.list(slug, { category: 'maintenance', status: 'active', date: historyDate }),
]).then(([done, activeMaint]) => {
const merged = [...done]
for (const t of activeMaint) {
if (!merged.some(x => x.id === t.id)) merged.push(t)
}
setHistoryTasks(merged)
})
.catch(console.error)
.finally(() => setHistoryLoading(false))
}, [activeTab, historyDate, slug])
@@ -866,6 +874,7 @@ function TaskCard({ task, onStatusChange, onReport }: {
function HistoryCard({ task }: { task: HousekeepingTask }) {
const taskAny = task as unknown as Record<string, string>
const isMaintenance = task.type === 'maintenance' || (taskAny.category === 'maintenance')
const isActive = task.status === 'pending' || task.status === 'in_progress'
const completedTime = task.completedAt
? new Date(task.completedAt).toLocaleTimeString('ru-RU', { hour: '2-digit', minute: '2-digit' })
@@ -879,10 +888,10 @@ function HistoryCard({ task }: { task: HousekeepingTask }) {
const photos = task.photos ?? []
return (
<div className={cn('card p-3.5 opacity-90', isMaintenance && 'border-l-4 border-l-orange-400 dark:border-l-orange-500')}>
<div className={cn('card p-3.5', isMaintenance && 'border-l-4 border-l-orange-400 dark:border-l-orange-500', !isActive && 'opacity-90')}>
<div className="flex items-start gap-3">
{isMaintenance
? <Wrench size={16} className="text-orange-500 shrink-0 mt-0.5" />
? <Wrench size={16} className={cn('shrink-0 mt-0.5', isActive ? 'text-orange-400' : 'text-orange-500')} />
: <CheckCircle2 size={16} className="text-emerald-500 shrink-0 mt-0.5" />
}
<div className="flex-1 min-w-0">
@@ -894,7 +903,17 @@ function HistoryCard({ task }: { task: HousekeepingTask }) {
<Badge className={PRIORITY_COLORS[task.priority] ?? PRIORITY_COLORS.medium}>
{PRIORITY_LABELS[task.priority] ?? task.priority}
</Badge>
{isActive && isMaintenance && (
<span className="text-[10px] font-semibold px-1.5 py-0.5 rounded bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-300">
{task.status === 'in_progress' ? 'В работе' : 'Ожидает'}
</span>
)}
</div>
{isActive && isMaintenance && (
<p className="text-[11px] text-amber-700 dark:text-amber-400 mt-1 flex items-center gap-1">
<AlertTriangle size={10} className="shrink-0" /> Замечание по номеру тех. задача не выполнена
</p>
)}
{task.notes && (
<p className="text-xs text-slate-600 dark:text-slate-300 mt-1.5 bg-slate-50 dark:bg-slate-700/40 rounded-lg px-2 py-1.5">
{task.notes}