import React, { FC, Fragment, useCallback } from 'react'; import { useModals } from '@mantine/modals'; import useSWR from 'swr'; import { useFetch } from '@gitroom/helpers/utils/custom.fetch'; import { useT } from '@gitroom/react/translation/get.transation.service.client'; export const StatisticsModal: FC<{ postId: string; }> = (props) => { const { postId } = props; const modals = useModals(); const t = useT(); const fetch = useFetch(); const loadStatistics = useCallback(async () => { return (await fetch(`/posts/${postId}/statistics`)).json(); }, [postId]); const closeAll = useCallback(() => { modals.closeAll(); }, []); const { data, isLoading } = useSWR( `/posts/${postId}/statistics`, loadStatistics ); return (