feat(groups): kids groups with an adult in charge
- Add the `kidsGroups` plan feature (Pro) and `Group.audience` (ADULTS | KIDS); creating or switching a group to KIDS requires the feature, existing KIDS groups keep working after a downgrade. - Model the adult in charge as a Person linked through `person_guardians`; migrate the old guardian_name/guardian_phone columns and drop them. - Kids quick add: kid + guardian form, guardian lookup by phone to pick an existing kid or add a sibling; backend rejects KIDS adds without guardian. - Attendee page: "Adulto a cargo" section with siblings, editable via PATCH /groups/:gid/attendees/:aid/guardian. - Contact phone (WhatsApp jobs, attention, student access invite, students at risk, attendee actions) prefers the guardian's phone. - Edit group screen (PATCH /groups/:gid, owner only); switching back to ADULTS is blocked while kids have no phone of their own. - Hide bulk import in KIDS groups until it carries guardian data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,8 @@ model Group {
|
||||
// Weekly WhatsApp automations, off until the teacher turns them on.
|
||||
autoPaymentReminders Boolean @default(false) @map("auto_payment_reminders")
|
||||
autoReengagement Boolean @default(false) @map("auto_reengagement")
|
||||
// KIDS: each student is a kid and the contact is the adult in charge.
|
||||
audience GroupAudience @default(ADULTS)
|
||||
inviteToken String? @unique(map: "groups_inviteToken_key") @map("invite_token")
|
||||
createdById String @map("created_by_id")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
@@ -31,6 +33,11 @@ model Group {
|
||||
@@map("groups")
|
||||
}
|
||||
|
||||
enum GroupAudience {
|
||||
ADULTS
|
||||
KIDS
|
||||
}
|
||||
|
||||
enum WeekDay {
|
||||
MONDAY
|
||||
TUESDAY
|
||||
@@ -83,8 +90,6 @@ model Person {
|
||||
fullName String @map("full_name")
|
||||
email String?
|
||||
phone String?
|
||||
guardianName String? @map("guardian_name")
|
||||
guardianPhone String? @map("guardian_phone")
|
||||
notes String?
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
@@ -92,11 +97,31 @@ model Person {
|
||||
owner User @relation("OwnerPeople", fields: [createdById], references: [id], onDelete: Cascade)
|
||||
attendees Attendee[]
|
||||
studentAccounts StudentAccountPerson[]
|
||||
// As a kid: the adult in charge (one in v1, enforced by the code).
|
||||
guardians PersonGuardian[] @relation("GuardianChild")
|
||||
// As the adult in charge: their kids. An adult has no memberships of their own.
|
||||
children PersonGuardian[] @relation("GuardianAdult")
|
||||
|
||||
@@index([createdById])
|
||||
@@map("people")
|
||||
}
|
||||
|
||||
// A kid (`child`) and the adult in charge (`guardian`), both people of the same
|
||||
// teacher. The adult is who gets the messages and signs in to the student app;
|
||||
// siblings share the same adult, so their phone is not duplicated on each kid.
|
||||
model PersonGuardian {
|
||||
childId String @map("child_id")
|
||||
guardianId String @map("guardian_id")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
child Person @relation("GuardianChild", fields: [childId], references: [id], onDelete: Cascade)
|
||||
guardian Person @relation("GuardianAdult", fields: [guardianId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@id([childId, guardianId])
|
||||
@@index([guardianId])
|
||||
@@map("person_guardians")
|
||||
}
|
||||
|
||||
// Membership of a person in a group. Status, attendance, fees and the absence
|
||||
// link (`notifyToken`) are per group.
|
||||
model Attendee {
|
||||
|
||||
Reference in New Issue
Block a user