feat: Notes tab (notes + shopping lists), fix 7-day forecast layout, fix screensaver dismiss
All checks were successful
Deploy / deploy (push) Successful in 2m54s

This commit is contained in:
Cosmo
2026-04-22 20:29:33 +00:00
parent a7611b46c4
commit bc01443f03
4 changed files with 445 additions and 11 deletions

76
app/api/notes/route.ts Normal file
View File

@@ -0,0 +1,76 @@
export const dynamic = 'force-dynamic'
import { NextResponse } from 'next/server'
import * as fs from 'fs'
const NOTES_PATH = '/tmp/tablet-notes.json'
interface Note {
id: string
type: 'note' | 'shopping'
title: string
items?: { id: string; text: string; done: boolean }[]
text?: string
color: string
createdAt: string
updatedAt: string
}
function loadNotes(): Note[] {
try {
if (fs.existsSync(NOTES_PATH)) {
return JSON.parse(fs.readFileSync(NOTES_PATH, 'utf-8'))
}
} catch {}
return []
}
function saveNotes(notes: Note[]) {
fs.writeFileSync(NOTES_PATH, JSON.stringify(notes, null, 2))
}
export async function GET() {
return NextResponse.json({ notes: loadNotes() })
}
export async function POST(req: Request) {
const body = await req.json()
const notes = loadNotes()
const note: Note = {
id: Date.now().toString(36) + Math.random().toString(36).slice(2, 6),
type: body.type || 'note',
title: body.title || '',
items: body.type === 'shopping' ? [] : undefined,
text: body.type === 'note' ? '' : undefined,
color: body.color || '#6366f1',
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
}
notes.unshift(note)
saveNotes(notes)
return NextResponse.json({ note })
}
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 notes = loadNotes()
const idx = notes.findIndex(n => n.id === id)
if (idx === -1) return NextResponse.json({ error: 'not found' }, { status: 404 })
notes[idx] = { ...notes[idx], ...updates, updatedAt: new Date().toISOString() }
saveNotes(notes)
return NextResponse.json({ note: notes[idx] })
}
export async function DELETE(req: Request) {
const { searchParams } = new URL(req.url)
const id = searchParams.get('id')
if (!id) return NextResponse.json({ error: 'id required' }, { status: 400 })
const notes = loadNotes()
const filtered = notes.filter(n => n.id !== id)
saveNotes(filtered)
return NextResponse.json({ success: true })
}