feat: conectar Tablero CDC a Supabase empresarial

This commit is contained in:
2026-06-01 09:27:26 -04:00
parent a88f106eec
commit c546f59009
8 changed files with 69 additions and 69 deletions
+1 -1
View File
@@ -108,7 +108,7 @@ export function ProjectDialog({ open, onOpenChange, project }: Props) {
return match?.[1] ?? "";
};
// BU → Country Manager automático desde Supabase app_lists, con fallback local.
// BU → Country Manager automático desde Supabase tablero_cdc_app_lists, con fallback local.
const onBU = (bu: string) => {
const cleanBu = canonicalOptionLabel(bu);
setForm((f) => ({ ...f, bu: cleanBu, cm: getCountryManager(cleanBu) }));
+3 -3
View File
@@ -137,7 +137,7 @@ export async function loadAppLists() {
try {
const { data, error } = await supabase
.from("app_lists")
.from("tablero_cdc_app_lists")
.select("category, value, label, sort_order, is_active")
.eq("is_active", true)
.order("category", { ascending: true })
@@ -180,12 +180,12 @@ function startAppListsRealtime() {
appListsRealtimeChannel = supabase
.channel("tablero-cdc-app-lists")
.on("postgres_changes", { event: "*", schema: "public", table: "app_lists" }, () =>
.on("postgres_changes", { event: "*", schema: "public", table: "tablero_cdc_app_lists" }, () =>
scheduleRealtimeRefresh(),
)
.subscribe((status) => {
if (status === "CHANNEL_ERROR" || status === "TIMED_OUT") {
console.warn("Supabase Realtime no pudo suscribirse a app_lists:", status);
console.warn("Supabase Realtime no pudo suscribirse a tablero_cdc_app_lists:", status);
}
});
}
+8 -8
View File
@@ -294,12 +294,12 @@ function startProjectsRealtime() {
.channel("tablero-cdc-projects")
.on(
"postgres_changes",
{ event: "*", schema: "public", table: "projects" },
{ event: "*", schema: "public", table: "tablero_cdc_projects" },
() => scheduleRealtimeRefresh(),
)
.on(
"postgres_changes",
{ event: "*", schema: "public", table: "project_links" },
{ event: "*", schema: "public", table: "tablero_cdc_project_links" },
() => scheduleRealtimeRefresh(),
)
.subscribe((status) => {
@@ -323,7 +323,7 @@ function stopProjectsRealtime() {
async function replaceProjectLinks(projectId: string, project: Pick<Project, "propuestaLinks" | "afLinks">) {
const { error: deleteError } = await supabase
.from("project_links")
.from("tablero_cdc_project_links")
.delete()
.eq("project_id", projectId);
@@ -333,7 +333,7 @@ async function replaceProjectLinks(projectId: string, project: Pick<Project, "pr
if (linkRows.length === 0) return;
const { error: insertError } = await supabase.from("project_links").insert(linkRows);
const { error: insertError } = await supabase.from("tablero_cdc_project_links").insert(linkRows);
if (insertError) throw insertError;
}
@@ -359,7 +359,7 @@ async function loadProjects() {
brief_link,
created_at,
extra_data,
project_links (
project_links:tablero_cdc_project_links (
id,
link_type,
url,
@@ -368,7 +368,7 @@ async function loadProjects() {
`;
const { data, error } = await supabase
.from("projects")
.from("tablero_cdc_projects")
.select(selectColumns)
.order("created_at", { ascending: false });
@@ -399,7 +399,7 @@ async function addProject(project: Project) {
};
const { data, error } = await supabase
.from("projects")
.from("tablero_cdc_projects")
.insert(insertPayload)
.select("id")
.single();
@@ -447,7 +447,7 @@ async function updateProject(id: string, patch: Partial<Project>) {
updated_by: userId,
};
const { error } = await supabase.from("projects").update(updatePayload).eq("id", id);
const { error } = await supabase.from("tablero_cdc_projects").update(updatePayload).eq("id", id);
if (error) {
setError(error.message);