From 2c6b4db07a85f88877171289471cdb42d6afaa90 Mon Sep 17 00:00:00 2001 From: camilovegag Date: Tue, 28 May 2024 11:43:34 +0200 Subject: [PATCH] Show lead author at results table --- .../tables/results-table/ResultsTable.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/berlin/src/components/tables/results-table/ResultsTable.tsx b/packages/berlin/src/components/tables/results-table/ResultsTable.tsx index e003d713..1b661914 100644 --- a/packages/berlin/src/components/tables/results-table/ResultsTable.tsx +++ b/packages/berlin/src/components/tables/results-table/ResultsTable.tsx @@ -1,5 +1,9 @@ // React and third-party libraries import { useMemo } from 'react'; +import { useQuery } from '@tanstack/react-query'; + +// API +import { fetchOptionUsers } from 'api'; // Store import { useAppStore } from '../../../store'; @@ -44,6 +48,12 @@ function ResultsTable({ $expanded, option, onClick }: ResultsTableProps) { return score % 1 === 0 ? score.toFixed(0) : score.toFixed(3); }, [option.pluralityScore]); + const { data: optionUsers } = useQuery({ + queryKey: ['option', option.id, 'users'], + queryFn: () => fetchOptionUsers(option.id || ''), + enabled: !!option.id, + }); + return ( {option.allocatedFunding} ARB} {option.optionSubTitle} + + Lead Author: {optionUsers?.user?.firstName} {optionUsers?.user?.lastName} + Distinct voters: {option.distinctUsers}