M6: notices/conversations foundation — selects + repositories
Modulo 6 da Fase 1. noticesSelects.js extrai os 2 selects do noticeService (GLOBAL_NOTICE_SELECT, NOTICE_DISMISSAL_SELECT) + noticeService passa a usa-los (zero select inline). Conversations ganha foundation: 3 services (_tenantGuards, conversationsSelects, conversationsRepository). Channel factory (WhatsApp/SMS/Email) e composables ficam pra sessao dedicada — escopo M6 era so destravar o supabase.from() inline. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
// Serviço central de acesso ao Supabase para Global Notices
|
||||
|
||||
import { supabase } from '@/lib/supabase/client';
|
||||
import { GLOBAL_NOTICE_SELECT, NOTICE_DISMISSAL_SELECT } from './noticesSelects';
|
||||
|
||||
// ── Leitura ────────────────────────────────────────────────────
|
||||
|
||||
@@ -28,7 +29,7 @@ import { supabase } from '@/lib/supabase/client';
|
||||
export async function fetchActiveNotices() {
|
||||
const now = new Date().toISOString();
|
||||
|
||||
const { data, error } = await supabase.from('global_notices').select('*').eq('is_active', true).or(`starts_at.is.null,starts_at.lte.${now}`).or(`ends_at.is.null,ends_at.gte.${now}`).order('priority', { ascending: false });
|
||||
const { data, error } = await supabase.from('global_notices').select(GLOBAL_NOTICE_SELECT).eq('is_active', true).or(`starts_at.is.null,starts_at.lte.${now}`).or(`ends_at.is.null,ends_at.gte.${now}`).order('priority', { ascending: false });
|
||||
|
||||
if (error) throw error;
|
||||
return data || [];
|
||||
@@ -38,7 +39,7 @@ export async function fetchActiveNotices() {
|
||||
* Busca todos os notices (sem filtro de ativo) — para o painel admin.
|
||||
*/
|
||||
export async function fetchAllNotices() {
|
||||
const { data, error } = await supabase.from('global_notices').select('*').order('priority', { ascending: false }).order('created_at', { ascending: false });
|
||||
const { data, error } = await supabase.from('global_notices').select(GLOBAL_NOTICE_SELECT).order('priority', { ascending: false }).order('created_at', { ascending: false });
|
||||
|
||||
if (error) throw error;
|
||||
return data || [];
|
||||
@@ -77,7 +78,7 @@ export async function loadUserDismissals() {
|
||||
} = await supabase.auth.getUser();
|
||||
if (!user?.id) return [];
|
||||
|
||||
const { data } = await supabase.from('notice_dismissals').select('notice_id, version').eq('user_id', user.id);
|
||||
const { data } = await supabase.from('notice_dismissals').select(NOTICE_DISMISSAL_SELECT).eq('user_id', user.id);
|
||||
|
||||
return data || [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user