Switch calendar events to isArchived model

This commit is contained in:
Ruslan Bakiev
2026-02-19 16:58:49 +07:00
parent 1047d5cb3f
commit f6fd11b3c4
9 changed files with 306 additions and 118 deletions

View File

@@ -120,7 +120,7 @@ type PendingChange =
start: string;
end: string | null;
note: string | null;
status: string | null;
isArchived: boolean;
}
| {
id: string;
@@ -195,7 +195,7 @@ async function buildCrmSnapshot(input: SnapshotOptions) {
take: 4,
},
events: {
select: { id: true, title: true, startsAt: true, endsAt: true, status: true },
select: { id: true, title: true, startsAt: true, endsAt: true, isArchived: true },
orderBy: { startsAt: "asc" },
where: { startsAt: { gte: new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000) } },
take: 4,
@@ -276,7 +276,7 @@ async function buildCrmSnapshot(input: SnapshotOptions) {
title: e.title,
startsAt: iso(e.startsAt),
endsAt: iso(e.endsAt ?? e.startsAt),
status: e.status,
isArchived: e.isArchived,
note: e.note,
contact: e.contact?.name ?? null,
})),
@@ -327,7 +327,7 @@ async function buildCrmSnapshot(input: SnapshotOptions) {
title: e.title,
startsAt: iso(e.startsAt),
endsAt: iso(e.endsAt ?? e.startsAt),
status: e.status,
isArchived: e.isArchived,
})),
deals: c.deals.map((d) => ({
id: d.id,
@@ -507,7 +507,7 @@ export async function runLangGraphCrmAgentFor(input: {
start: z.string().optional(),
end: z.string().optional(),
note: z.string().optional(),
status: z.string().optional(),
archived: z.boolean().optional(),
channel: z.enum(["Telegram", "WhatsApp", "Instagram", "Phone", "Email"]).optional(),
kind: z.enum(["message", "call"]).optional(),
direction: z.enum(["in", "out"]).optional(),
@@ -547,7 +547,7 @@ export async function runLangGraphCrmAgentFor(input: {
startsAt: new Date(change.start),
endsAt: change.end ? new Date(change.end) : null,
note: change.note,
status: change.status,
isArchived: change.isArchived,
},
});
applied.push({ id: change.id, type: change.type, detail: `created event ${created.id}` });
@@ -775,7 +775,7 @@ export async function runLangGraphCrmAgentFor(input: {
start: iso(start),
end: end && !Number.isNaN(end.getTime()) ? iso(end) : null,
note: (raw.note ?? "").trim() || null,
status: (raw.status ?? "").trim() || null,
isArchived: Boolean(raw.archived),
});
if (raw.mode === "apply") {