fix: keep Activos as file library only
Agent documents (calendar/copy/audit) belong in Calendario/ops, not the asset upload surface. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,23 +1,11 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { CheckCircle2 } from 'lucide-react';
|
|
||||||
import { createClient } from '@/lib/supabase/server';
|
import { createClient } from '@/lib/supabase/server';
|
||||||
import { redirect } from 'next/navigation';
|
import { redirect } from 'next/navigation';
|
||||||
import { resolveActiveTenant, restGet } from '@/lib/tenant-context';
|
import { resolveActiveTenant } from '@/lib/tenant-context';
|
||||||
import { isAgencyRole, userRole } from '@/lib/agency';
|
|
||||||
import AssetsLibrary from '@/components/AssetsLibrary';
|
import AssetsLibrary from '@/components/AssetsLibrary';
|
||||||
|
|
||||||
export const dynamic = 'force-dynamic';
|
export const dynamic = 'force-dynamic';
|
||||||
|
|
||||||
type Doc = {
|
|
||||||
id: string;
|
|
||||||
type?: string;
|
|
||||||
title?: string;
|
|
||||||
content?: string;
|
|
||||||
version?: number;
|
|
||||||
created_at?: string;
|
|
||||||
status?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default async function ActivosPage() {
|
export default async function ActivosPage() {
|
||||||
const supabase = await createClient();
|
const supabase = await createClient();
|
||||||
const {
|
const {
|
||||||
@@ -26,24 +14,6 @@ export default async function ActivosPage() {
|
|||||||
if (!user) redirect('/login');
|
if (!user) redirect('/login');
|
||||||
|
|
||||||
const ctx = await resolveActiveTenant(user);
|
const ctx = await resolveActiveTenant(user);
|
||||||
const agency = isAgencyRole(userRole(user));
|
|
||||||
let documents: Doc[] = [];
|
|
||||||
|
|
||||||
if (!ctx.portfolioWide && agency && ctx.viaView && ctx.tenantId) {
|
|
||||||
const tid = encodeURIComponent(ctx.tenantId);
|
|
||||||
const r = await restGet<Doc[]>(
|
|
||||||
`/rest/v1/documents?tenant_id=eq.${tid}&status=eq.approved&select=id,type,title,content,version,created_at,status&order=created_at.desc`
|
|
||||||
);
|
|
||||||
documents = r.data || [];
|
|
||||||
} else if (!ctx.portfolioWide) {
|
|
||||||
const { data, error } = await supabase
|
|
||||||
.from('documents')
|
|
||||||
.select('id,type,title,content,version,created_at,status')
|
|
||||||
.eq('status', 'approved')
|
|
||||||
.order('created_at', { ascending: false });
|
|
||||||
if (error) console.error('documents', error.message);
|
|
||||||
else documents = data ?? [];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ctx.portfolioWide) {
|
if (ctx.portfolioWide) {
|
||||||
return (
|
return (
|
||||||
@@ -64,41 +34,5 @@ export default async function ActivosPage() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return <AssetsLibrary tenantLabel={ctx.label} />;
|
||||||
<div className="space-y-10">
|
|
||||||
<AssetsLibrary tenantLabel={ctx.label} />
|
|
||||||
|
|
||||||
{documents.length > 0 && (
|
|
||||||
<section className="space-y-4">
|
|
||||||
<div>
|
|
||||||
<h3 className="text-lg font-semibold text-white">
|
|
||||||
Entregables de agentes
|
|
||||||
</h3>
|
|
||||||
<p className="text-xs text-gray-500 mt-1">
|
|
||||||
Textos/briefs aprobados en <code>documents</code> (Slack / ops).
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
||||||
{documents.map((doc) => (
|
|
||||||
<div
|
|
||||||
key={doc.id}
|
|
||||||
className="bg-[#111827] border border-gray-800 rounded-xl p-5"
|
|
||||||
>
|
|
||||||
<div className="flex items-center justify-between mb-3">
|
|
||||||
<span className="uppercase text-[10px] font-bold px-2 py-0.5 rounded bg-gray-800 text-gray-300">
|
|
||||||
{doc.type}
|
|
||||||
</span>
|
|
||||||
<span className="flex items-center gap-1 text-[11px] text-emerald-400">
|
|
||||||
<CheckCircle2 className="w-3 h-3" /> Aprobado
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<h4 className="font-bold text-white text-sm mb-2">{doc.title}</h4>
|
|
||||||
<p className="text-xs text-gray-400 line-clamp-3">{doc.content}</p>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user