mirror of
https://github.com/fsolla/teqo.git
synced 2026-12-04 06:43:08 +00:00
- runSyncPass bidirecional: regra do relógio decide direção (Google mais novo aplica título/horário; Teqo re-asserta), cancelamento via showDeleted + snapshot lastSeenEventIds, registro no updates feed - webhook público /campanha/agenda/google-webhook/[secret] fail-closed (secret + X-Goog headers constant-time), canal lazy sem cron (ensure em toda passada, renovação com id novo + stop do antigo) - migration hand-written (campos de canal/snapshot em googleCalendarSync); mutationKind dedicado libera título via Google sem quebrar slug canônico - UI: seção 'Edições pelo Google' no dialog + autor 'Google Calendar' no feed - testes: unit (reverse mapping, validação webhook), int (motor bidirecional com stub, 10 cenários), e2e (webhook 404 fail-closed)
58 lines
2 KiB
TypeScript
58 lines
2 KiB
TypeScript
import { MessageSquareTextIcon } from 'lucide-react'
|
|
|
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
|
|
import { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from '@/components/ui/Empty'
|
|
import { formatBahiaDateTimeLabel } from '@/lib/campaignTime'
|
|
import { GOOGLE_REVERSE_EDIT_BODY_PREFIX } from '@/lib/googleCalendarReverseEdit'
|
|
import type { ActivityUpdateViewModel } from '@/utilities/activityViewModels'
|
|
|
|
const UpdateCard = ({ update }: { update: ActivityUpdateViewModel }) => {
|
|
// C115 — reverse-direction records carry no campaign author; the body
|
|
// prefix attributes the entry to Google Calendar.
|
|
const googleRecord = update.body.startsWith(GOOGLE_REVERSE_EDIT_BODY_PREFIX)
|
|
return (
|
|
<article>
|
|
<Card>
|
|
<CardHeader>
|
|
<CardTitle className="text-base">
|
|
{update.authorName ?? (googleRecord ? 'Google Calendar' : 'Autor removido')}
|
|
</CardTitle>
|
|
<p className="text-sm text-muted-foreground">
|
|
{update.createdAt ? formatBahiaDateTimeLabel(update.createdAt) : ''}
|
|
</p>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<p className="whitespace-pre-wrap">{update.body}</p>
|
|
</CardContent>
|
|
</Card>
|
|
</article>
|
|
)
|
|
}
|
|
|
|
export const ActivityUpdateFeed = ({ updates }: { updates: ActivityUpdateViewModel[] }) => {
|
|
if (!updates.length) {
|
|
return (
|
|
<Empty className="border">
|
|
<EmptyHeader>
|
|
<EmptyMedia variant="icon">
|
|
<MessageSquareTextIcon aria-hidden="true" />
|
|
</EmptyMedia>
|
|
<EmptyTitle>Nenhuma atualização registrada</EmptyTitle>
|
|
<EmptyDescription>
|
|
Envie o primeiro reporte para iniciar o histórico cronológico desta atividade.
|
|
</EmptyDescription>
|
|
</EmptyHeader>
|
|
</Empty>
|
|
)
|
|
}
|
|
|
|
const sortedUpdates = [...updates].reverse()
|
|
|
|
return (
|
|
<div className="flex flex-col gap-4">
|
|
{sortedUpdates.map((update, index) => (
|
|
<UpdateCard key={update.id ?? index} update={update} />
|
|
))}
|
|
</div>
|
|
)
|
|
}
|