diff --git a/components/Dashboard/FormPane.tsx b/components/Dashboard/FormPane.tsx index 9f3008f8..ed9a9603 100644 --- a/components/Dashboard/FormPane.tsx +++ b/components/Dashboard/FormPane.tsx @@ -12,7 +12,7 @@ import { TooltipProvider, TooltipTrigger, } from '@/components/ui/tooltip' -import { useListForms } from '@/hooks/query/form' +import {useGetFormResponsesByProjectId, useListForms} from '@/hooks/query/form' import { useSelectedProject } from '@/hooks/query/project' import { cn } from '@/lib/utils' import { @@ -45,6 +45,7 @@ const actionButtons = [ }, ] + const FormPane: React.FC = () => { const { project } = useSelectedProject() const { forms } = useListForms(project?.id) @@ -105,6 +106,16 @@ const FormPane: React.FC = () => { } } + const projectId = project?.id || "" + const { data: formResponses } = useGetFormResponsesByProjectId(projectId) + + const getResponseCount = (formId: string) => { + if (formResponses && formResponses.pages[0].getFormResponsesByProjectId) { + return formResponses.pages[0].getFormResponsesByProjectId?.length; + } + return 0; + }; + return (
{forms?.map((form, index) => ( @@ -140,7 +151,11 @@ const FormPane: React.FC = () => { {form?.name} - 0 responses. Created{' '} + + {getResponseCount(form?.id || '')}{' '} + {getResponseCount(form?.id || '') === 1 ? 'response' : 'responses'}. + + Created{' '} {form?.createdAt && formatToLocalDateTime(form?.createdAt)}