sendou.ink/hooks/sr.ts
2020-12-19 15:28:57 +02:00

17 lines
430 B
TypeScript

import { GetAllSalmonRunRecordsData } from "prisma/queries/getAllSalmonRunRecords";
import useSWR from "swr";
export function useSalmonRunRecords() {
const { data = [] } = useSWR<GetAllSalmonRunRecordsData>("/api/sr/records");
console.log({ data });
return {
data: data.filter((record) => record.approved),
pendingCount: data.reduce(
(acc, record) => (!record.approved ? ++acc : acc),
0
),
};
}