import { format } from "date-fns" import { AlertTriangle, Clock } from "lucide-react" import { Button } from "@/components/ui/button" import { Card, CardContent } from "@/components/ui/card" import { MoodBadge } from "@/components/mood/mood-badge" import { useDiscardQueued, useQueuedEntries, useRetryQueued, } from "@/hooks/use-outbox" import { isStuck } from "@/lib/outbox-sync" import { contentPreview } from "@/lib/entry-preview" import type { QueuedEntry } from "@/lib/store/outbox" /** * Entries written on this device that the server has not taken yet. They are * shown with the journal so that logging offline still looks like it worked. */ export function PendingEntries() { const { data: queued = [] } = useQueuedEntries() if (!queued.length) return null return (

Not sent yet

{queued.map((entry) => ( ))}
) } function PendingEntryCard({ queued }: { queued: QueuedEntry }) { const retry = useRetryQueued() const discard = useDiscardQueued() const stuck = isStuck(queued) const note = contentPreview(queued.draft.content) return ( {queued.draft.mood !== null && }
{stuck ? ( {format(new Date(queued.draft.loggedAt), "MMM d, h:mm a")}
{note && (

{note}

)} {stuck && ( <> {queued.lastError && (

{queued.lastError}

)}
)}
) }