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:
@@ -1,4 +1,4 @@
|
||||
import type { ProblemDetails } from '@gruperly/shared';
|
||||
import type { PlanFeature, ProblemDetails } from '@gruperly/shared';
|
||||
import { notFoundProblem } from './problem-details';
|
||||
import { PROBLEM_DOMAIN } from './problem-domain';
|
||||
|
||||
@@ -248,13 +248,16 @@ export function planLimitReachedProblem(limit: PlanLimitKind, max: number): Prob
|
||||
});
|
||||
}
|
||||
|
||||
/** A Pro-only feature: charging students with Mercado Pago or WhatsApp automations. */
|
||||
export function planFeatureRequiredProblem(feature: 'mpCharges' | 'whatsappAutomations'): ProblemDetails {
|
||||
const PLAN_FEATURE_DETAIL: Record<PlanFeature, string> = {
|
||||
mpCharges: 'Cobrar con Mercado Pago está disponible en el plan Pro.',
|
||||
whatsappAutomations: 'Los mensajes automáticos de WhatsApp están disponibles en el plan Pro.',
|
||||
kidsGroups: 'Los grupos de chicos con adulto a cargo están disponibles en el plan Pro.',
|
||||
};
|
||||
|
||||
/** A feature the owner's plan does not include (Mercado Pago, WhatsApp automations, kids groups). */
|
||||
export function planFeatureRequiredProblem(feature: PlanFeature): ProblemDetails {
|
||||
return paymentRequiredProblem({
|
||||
detail:
|
||||
feature === 'mpCharges'
|
||||
? 'Cobrar con Mercado Pago está disponible en el plan Pro.'
|
||||
: 'Los mensajes automáticos de WhatsApp están disponibles en el plan Pro.',
|
||||
detail: PLAN_FEATURE_DETAIL[feature],
|
||||
code: 'plan_feature_required',
|
||||
params: { feature },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user