small fixes
This commit is contained in:
@@ -64,12 +64,10 @@ async function createRecord(collection: string, data: any): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
// Seed a default season (Holidays) per family so the family-admin season
|
||||
// picker always has at least one option. "Term time" is intentionally NOT
|
||||
// auto-seeded — it's a UK-school-specific term that not every family wants,
|
||||
// and force-seeding it meant a deleted "Term time" kept coming back on every
|
||||
// boot. Families that want it can add it themselves.
|
||||
// Only seeds when a family has zero seasons, so user deletions stick.
|
||||
// Seed two default seasons (Term + Holidays) per family so the family-admin
|
||||
// season picker always has options from day one and they can tick either on/off.
|
||||
// Only seeds when a family has zero seasons, so user deletions stick (a deleted
|
||||
// default never comes back on boot as long as at least one season remains).
|
||||
async function ensureDefaultSeasons(): Promise<void> {
|
||||
const famsCol = await getCollection('fams');
|
||||
if (!famsCol) return;
|
||||
@@ -78,7 +76,10 @@ async function ensureDefaultSeasons(): Promise<void> {
|
||||
headers: { Authorization: `Bearer ${t}` }
|
||||
});
|
||||
const fams = (await famsRes.json()).items || [];
|
||||
const defaults = [{ name: 'Holidays', color: '#f59e0b', active: true }];
|
||||
const defaults = [
|
||||
{ name: 'Term', color: '#6366f1', active: true },
|
||||
{ name: 'Holidays', color: '#f59e0b', active: true }
|
||||
];
|
||||
for (const fam of fams) {
|
||||
const sRes = await fetch(
|
||||
`${PB_ENDPOINT}/api/collections/seasons/records?filter=(famId='${fam.id}')&fields=name&perPage=200`,
|
||||
|
||||
Reference in New Issue
Block a user