feat: un miembro puede pertenecer a más de un grupo
- Nuevo modelo `Person` (`people`): contacto y notas por profe, con teléfono único (índice parcial `people_owner_phone_key`). `Attendee` pasa a ser la membresía (`group_id` + `person_id`, único por grupo). - La cuenta de la app de alumnos se vincula a la persona (`student_account_people`): una sola cuenta ve todos sus grupos. - Migración unifica attendees del mismo profe y teléfono, y fusiona sus cuentas de alumno (conserva la usada más recientemente). - `POST /groups/:gid/attendees/:aid/add-to-group` y `GET /people/lookup` para detectar personas existentes al cargar; el alta responde `409 person_exists` y acepta `personId`. Bulk, lista de espera y preinscripciones vinculan solas. - El límite del plan cuenta personas con al menos un grupo activo. - Web: "Agregar a otro grupo", sección "También está en" en la ficha y aviso "Ya tenés a esta persona" en el alta individual. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
import type { PrismaClient } from '@generated/prisma/client';
|
||||
import type { StudentAccessDto } from '@gruperly/shared';
|
||||
|
||||
export type StudentAccessStatusDb = Pick<PrismaClient, 'studentAccountAttendee'>;
|
||||
export type StudentAccessStatusDb = Pick<PrismaClient, 'studentAccountPerson'>;
|
||||
|
||||
/* Passive state for the attendee's card: active (a live session) > invited
|
||||
(a pending invitation) > expired (invited before, nothing alive) > not invited. */
|
||||
(a pending invitation) > expired (invited before, nothing alive) > not invited.
|
||||
It is the person's access, so every group of theirs shows the same state. */
|
||||
export async function computeStudentAccess(
|
||||
db: StudentAccessStatusDb,
|
||||
attendeeId: string,
|
||||
personId: string,
|
||||
now: Date,
|
||||
): Promise<StudentAccessDto> {
|
||||
const link = await db.studentAccountAttendee.findFirst({
|
||||
where: { attendeeId },
|
||||
const link = await db.studentAccountPerson.findFirst({
|
||||
where: { personId },
|
||||
orderBy: { createdAt: 'asc' },
|
||||
select: {
|
||||
account: {
|
||||
|
||||
Reference in New Issue
Block a user