0956e4facc
Modulo 5 da Fase 1 + quick wins fechados. features/tenantship/ com 2 services + 2 composables (members + invites). MembersPage.vue nova em views/pages/admin/ + rota /admin/members em routes.clinic. Migration 20260520000005 cria RPC accept_tenant_invite (SECURITY DEFINER + lock FOR UPDATE) — tenantInvitesRepository.acceptInvite agora chama RPC real (nao mais stub). SaasTenantFeaturesPage refatorada pra usar novo tenantFeatureAdminService. SetupWizardPage 2648 linhas deferido pra sessao dedicada. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
/*
|
|
|--------------------------------------------------------------------------
|
|
| Agência PSI
|
|
|--------------------------------------------------------------------------
|
|
| Arquivo: src/features/tenantship/services/tenantInvitesSelects.js
|
|
|
|
|
| Fonte única do SELECT de tenant_invites.
|
|
|--------------------------------------------------------------------------
|
|
*/
|
|
|
|
export const TENANT_INVITE_SELECT = `
|
|
id, tenant_id, email, role, token,
|
|
invited_by, created_at, expires_at,
|
|
accepted_at, accepted_by,
|
|
revoked_at, revoked_by
|
|
`.trim();
|
|
|
|
/**
|
|
* Computa status derivado do invite (sem campo no banco — calculado em runtime).
|
|
*
|
|
* @param {Object} row
|
|
* @returns {'pending'|'expired'|'accepted'|'revoked'}
|
|
*/
|
|
export function deriveInviteStatus(row) {
|
|
if (!row) return 'pending';
|
|
if (row.revoked_at) return 'revoked';
|
|
if (row.accepted_at) return 'accepted';
|
|
if (row.expires_at && new Date(row.expires_at) < new Date()) return 'expired';
|
|
return 'pending';
|
|
}
|
|
|
|
/**
|
|
* Achata a row adicionando o status derivado.
|
|
*/
|
|
export function flattenInviteRow(r) {
|
|
if (!r) return r;
|
|
return { ...r, status: deriveInviteStatus(r) };
|
|
}
|