← Public packages
@kentcdodds/photo-portfolio
A fast, photo-first portfolio site you update by chatting with your agent: galleries, about, contact, and one-step rollback.
Files
import { storageKeys, type SiteStorage } from './site-store.ts'
/** Newest inquiries kept in storage; older ones roll off. */
export const maxStoredInquiries = 500
/** Notification emails per UTC day, so a spam burst can't flood her inbox. */
export const maxNotificationsPerDay = 30
export type Inquiry = {
id: string
receivedAt: string
name: string
email: string
phone?: string
sessionType?: string
preferredDate?: string
message: string
notified: boolean
}
export async function listInquiries(
storage: SiteStorage,
): Promise<Array<Inquiry>> {
const stored = await storage.get(storageKeys.inquiries)
return Array.isArray(stored) ? (stored as Array<Inquiry>) : []
}
export async function saveInquiry(storage: SiteStorage, inquiry: Inquiry) {
const existing = await listInquiries(storage)
await storage.set(
storageKeys.inquiries,
[inquiry, ...existing].slice(0, maxStoredInquiries),
)
}
/** Count one notification against today's budget; false once the budget is spent. */
export async function claimNotification(storage: SiteStorage, now: string) {
const day = now.slice(0, 10)
const budget = (await storage.get(storageKeys.notificationBudget)) as {
day: string
sent: number
} | null
const sent = budget?.day === day ? budget.sent : 0
if (sent >= maxNotificationsPerDay) return false
await storage.set(storageKeys.notificationBudget, { day, sent: sent + 1 })
return true
}