const express = require('express'); const prisma = require('../config/db'); const router = express.Router(); // GET /api/calendar — all seasonal restrictions router.get('/', async (req, res, next) => { try { const restrictions = await prisma.seasonalRestriction.findMany({ include: { state: { select: { name: true, abbr: true } } }, orderBy: [{ startMonth: 'asc' }, { state: { name: 'asc' } }], }); res.json(restrictions); } catch (err) { next(err); } }); // GET /api/calendar/:stateAbbr router.get('/:stateAbbr', async (req, res, next) => { try { const abbr = req.params.stateAbbr.toUpperCase(); const state = await prisma.state.findUnique({ where: { abbr }, include: { seasonalRestrictions: true }, }); if (!state) return res.status(404).json({ error: `State '${abbr}' not found.` }); res.json(state.seasonalRestrictions); } catch (err) { next(err); } }); module.exports = router;