All checks were successful
Deploy / deploy (push) Successful in 3m8s
Big design pass across Home + tokens + components. — globals.css: new data-* palette (cool/warm/hot/good/info/rose/violet/mood) with theme-aware variants, .grain overlay utility, .num-display typography helper, .hit-zone 44px wrapper, .eyebrow label, .focus-card base, focus-visible outline-offset 3px, space/touch scale vars. — FocusCard.tsx: context engine — пять состояний (morning-outfit, tram-imminent, event-upcoming, countdown, bill-due, night, quiet). Auto-rotates by hour + live data. 96px display numbers, accent-mixed surfaces, grain overlay. — CountdownCard.tsx + /api/countdowns: rotating 8s list, persistent /data/tablet-countdowns.json, full CRUD. Default seeded with Токио. — HomeTab: replaced plain Weather hero with FocusCard, added Row 4 with CountdownCard. Pulls trams + countdowns for the Focus context. — Swipe between tabs: pointer-level detection on <main>, data-swipe-ignore bails out inside modals + note swipe-to-delete + voice overlay. — Touch-target sweep: TopBar HA dot → 44px hit-zone, sensor chip 44px min-height, forecast day buttons 92px min, DeviceCard toggle 60x36, CalendarTab prev/next/close/list all 44x44, NotesTab buttons 44x44, TimerHomeWidget + 44x44, WeatherDayModal chevrons 48x48, close 48. — Hardcoded hex → data-* tokens: TopBar sensors, TransportWidget routes (via color-mix), DeviceCard full rewrite (per-kind accent, glass removed in favor of color-mix surfaces + proper mock-state treatment), NotesTab palette refreshed to match dark theme. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
98 lines
2.8 KiB
TypeScript
98 lines
2.8 KiB
TypeScript
export const dynamic = 'force-dynamic'
|
|
import { NextResponse } from 'next/server'
|
|
import * as fs from 'fs'
|
|
|
|
const DATA_DIR = fs.existsSync('/data') ? '/data' : '/tmp'
|
|
const COUNTDOWNS_PATH = `${DATA_DIR}/tablet-countdowns.json`
|
|
|
|
export interface Countdown {
|
|
id: string
|
|
label: string
|
|
date: string // YYYY-MM-DD
|
|
emoji?: string
|
|
color?: string // hex or data-* token name (e.g. "data-rose")
|
|
note?: string
|
|
createdAt: string
|
|
updatedAt: string
|
|
}
|
|
|
|
const DEFAULT_COUNTDOWNS: Countdown[] = [
|
|
{
|
|
id: 'tokyo',
|
|
label: 'Токио',
|
|
date: '2026-10-15',
|
|
emoji: '🗼',
|
|
color: 'data-rose',
|
|
createdAt: new Date().toISOString(),
|
|
updatedAt: new Date().toISOString(),
|
|
},
|
|
]
|
|
|
|
function load(): Countdown[] {
|
|
try {
|
|
if (fs.existsSync(COUNTDOWNS_PATH)) {
|
|
return JSON.parse(fs.readFileSync(COUNTDOWNS_PATH, 'utf-8'))
|
|
}
|
|
// первая загрузка — создать дефолтный файл
|
|
save(DEFAULT_COUNTDOWNS)
|
|
return DEFAULT_COUNTDOWNS
|
|
} catch {
|
|
return []
|
|
}
|
|
}
|
|
|
|
function save(list: Countdown[]) {
|
|
try {
|
|
fs.writeFileSync(COUNTDOWNS_PATH, JSON.stringify(list, null, 2))
|
|
} catch {}
|
|
}
|
|
|
|
export async function GET() {
|
|
const all = load()
|
|
// сортируем по дате возрастания
|
|
const sorted = [...all].sort((a, b) => a.date.localeCompare(b.date))
|
|
return NextResponse.json({ countdowns: sorted })
|
|
}
|
|
|
|
export async function POST(req: Request) {
|
|
const body = await req.json()
|
|
if (!body.label || !body.date) {
|
|
return NextResponse.json({ error: 'label_and_date_required' }, { status: 400 })
|
|
}
|
|
const list = load()
|
|
const cd: Countdown = {
|
|
id: Date.now().toString(36) + Math.random().toString(36).slice(2, 6),
|
|
label: String(body.label).slice(0, 60),
|
|
date: String(body.date).slice(0, 10),
|
|
emoji: body.emoji?.slice(0, 4) || undefined,
|
|
color: body.color || undefined,
|
|
note: body.note?.slice(0, 200) || undefined,
|
|
createdAt: new Date().toISOString(),
|
|
updatedAt: new Date().toISOString(),
|
|
}
|
|
list.push(cd)
|
|
save(list)
|
|
return NextResponse.json({ countdown: cd })
|
|
}
|
|
|
|
export async function PUT(req: Request) {
|
|
const body = await req.json()
|
|
const { id, ...updates } = body
|
|
if (!id) return NextResponse.json({ error: 'id_required' }, { status: 400 })
|
|
const list = load()
|
|
const idx = list.findIndex(c => c.id === id)
|
|
if (idx < 0) return NextResponse.json({ error: 'not_found' }, { status: 404 })
|
|
list[idx] = { ...list[idx], ...updates, id, updatedAt: new Date().toISOString() }
|
|
save(list)
|
|
return NextResponse.json({ countdown: list[idx] })
|
|
}
|
|
|
|
export async function DELETE(req: Request) {
|
|
const url = new URL(req.url)
|
|
const id = url.searchParams.get('id')
|
|
if (!id) return NextResponse.json({ error: 'id_required' }, { status: 400 })
|
|
const list = load().filter(c => c.id !== id)
|
|
save(list)
|
|
return NextResponse.json({ ok: true })
|
|
}
|