Admin panel shows a prominent open/closed toggle above the tabs. When closed, the shop displays a branded closure message and the checkout API returns 503. The closure state persists in data/store-status.json. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
25 lines
608 B
TypeScript
25 lines
608 B
TypeScript
import { promises as fs } from 'fs'
|
|
import path from 'path'
|
|
|
|
const FILE = path.join(process.cwd(), 'data', 'store-status.json')
|
|
|
|
export interface StoreStatus {
|
|
closed: boolean
|
|
message: string
|
|
}
|
|
|
|
const DEFAULT: StoreStatus = { closed: false, message: '' }
|
|
|
|
export async function getStoreStatus(): Promise<StoreStatus> {
|
|
try {
|
|
const raw = await fs.readFile(FILE, 'utf8')
|
|
return { ...DEFAULT, ...JSON.parse(raw) }
|
|
} catch {
|
|
return { ...DEFAULT }
|
|
}
|
|
}
|
|
|
|
export async function setStoreStatus(status: StoreStatus): Promise<void> {
|
|
await fs.writeFile(FILE, JSON.stringify(status, null, 2))
|
|
}
|