Add admin slideshow, horizontal animated calendar, and weather strip
This commit is contained in:
+57
-1
@@ -121,6 +121,32 @@ export async function initSchema() {
|
||||
created_at TIMESTAMP DEFAULT NOW()
|
||||
);
|
||||
`);
|
||||
|
||||
await db.query(`
|
||||
CREATE TABLE IF NOT EXISTS slides (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title VARCHAR(255),
|
||||
subtitle TEXT,
|
||||
image_id INTEGER REFERENCES images(id) ON DELETE SET NULL,
|
||||
image_url VARCHAR(500),
|
||||
active BOOLEAN DEFAULT TRUE,
|
||||
sort_order INTEGER DEFAULT 0,
|
||||
created_at TIMESTAMP DEFAULT NOW()
|
||||
);
|
||||
`);
|
||||
|
||||
await db.query(`
|
||||
CREATE TABLE IF NOT EXISTS calendar_events (
|
||||
id SERIAL PRIMARY KEY,
|
||||
date DATE NOT NULL,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
type VARCHAR(50) NOT NULL CHECK (type IN ('holiday', 'season', 'weather', 'event')),
|
||||
description TEXT,
|
||||
color VARCHAR(50) DEFAULT '#E8A849',
|
||||
active BOOLEAN DEFAULT TRUE,
|
||||
created_at TIMESTAMP DEFAULT NOW()
|
||||
);
|
||||
`);
|
||||
}
|
||||
|
||||
export async function seed() {
|
||||
@@ -196,10 +222,40 @@ export async function seed() {
|
||||
['user', 'COFFEE5', '$5 off any coffee tasting']
|
||||
);
|
||||
}
|
||||
|
||||
const { rows: calendarRows } = await db.query(`SELECT id FROM calendar_events`);
|
||||
if (calendarRows.length === 0) {
|
||||
const thisYear = new Date().getFullYear();
|
||||
await db.query(
|
||||
`INSERT INTO calendar_events (date, title, type, description, color) VALUES
|
||||
($1, $2, $3, $4, $5), ($6, $7, $8, $9, $10), ($11, $12, $13, $14, $15),
|
||||
($16, $17, $18, $19, $20), ($21, $22, $23, $24, $25), ($26, $27, $28, $29, $30),
|
||||
($31, $32, $33, $34, $35), ($36, $37, $38, $39, $40), ($41, $42, $43, $44, $45),
|
||||
($46, $47, $48, $49, $50), ($51, $52, $53, $54, $55)`,
|
||||
[
|
||||
`${thisYear}-01-01`, 'New Year', 'holiday', 'Start the year in the Andes.', '#E8A849',
|
||||
`${thisYear}-02-14`, 'Valentine', 'holiday', 'Special dinner menu.', '#D94B73',
|
||||
`${thisYear}-03-20`, 'Spring Equinox', 'season', 'Blooming highlands.', '#7CB342',
|
||||
`${thisYear}-06-21`, 'Summer Solstice', 'season', 'Longest days of the year.', '#E8A849',
|
||||
`${thisYear}-09-22`, 'Fall Equinox', 'season', 'Harvest colors.', '#A6683C',
|
||||
`${thisYear}-10-31`, 'Halloween', 'holiday', 'Costume dinner party.', '#9C27B0',
|
||||
`${thisYear}-11-02`, 'Day of the Dead', 'holiday', 'Traditional altar and meal.', '#FF9800',
|
||||
`${thisYear}-12-21`, 'Winter Solstice', 'season', 'Cozy fires and clear skies.', '#4FC3F7',
|
||||
`${thisYear}-12-25`, 'Christmas', 'holiday', 'Holiday feast.', '#C62828',
|
||||
`${thisYear}-12-31`, 'New Year Eve', 'holiday', 'Countdown dinner.', '#E8A849',
|
||||
`${thisYear}-06-28`, 'Sunny 22°C', 'weather', 'Typical Otavalo dry season day.', '#FFD54F',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
const { rows: siteRows } = await db.query(`SELECT key FROM config WHERE key = 'tagline'`);
|
||||
if (siteRows.length === 0) {
|
||||
await db.query(`INSERT INTO config (key, value) VALUES ($1, $2)`, ['tagline', 'Hotel · Restaurant · Andean Highlands']);
|
||||
}
|
||||
}
|
||||
|
||||
export async function resetDatabase() {
|
||||
await db.query('DROP TABLE IF EXISTS reviews, places, menu_items, rooms, config, benefits, offers, coupons, reservations, images, users CASCADE');
|
||||
await db.query('DROP TABLE IF EXISTS reviews, places, menu_items, rooms, config, benefits, offers, coupons, reservations, images, users, slides, calendar_events CASCADE');
|
||||
await initSchema();
|
||||
await seed();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user