import { useCallback } from "react"; import { activityApi } from "../api/activity"; import { useCompany } from "../context/CompanyContext"; import { useApi } from "../hooks/useApi"; import { formatDate } from "../lib/utils"; import { Card, CardContent } from "@/components/ui/card"; export function Activity() { const { selectedCompanyId } = useCompany(); const fetcher = useCallback(() => { if (!selectedCompanyId) return Promise.resolve([]); return activityApi.list(selectedCompanyId); }, [selectedCompanyId]); const { data, loading, error } = useApi(fetcher); if (!selectedCompanyId) { return
Select a company first.
; } return (Loading...
} {error &&{error.message}
} {data && data.length === 0 &&No activity yet.
} {data && data.length > 0 && ({event.entityType} {event.entityId}