Skip to content

Commit

Permalink
feat: add vote count
Browse files Browse the repository at this point in the history
  • Loading branch information
Skczu committed Oct 23, 2022
1 parent 93684c9 commit b0f2c82
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion components/composited/ProjectCard/ProjectCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Text } from '../../generic/Text/Text';
import { VoteButton } from '../../generic/VoteButton/VoteButton';
import { ProjectInfoList } from './ProjectInfoList';
import { Project } from '../../../validators/Project';
import { useUserVoted } from '../../../hooks/useProjectUpvotes';
import { useProjectUpvotes, useUserVoted } from '../../../hooks/useProjectUpvotes';
import { formatCurrency } from '../../../utils/currency';
import { useVoteProject } from '../../../hooks/useVoteProject';
import { useUser } from '../../../hooks/useUser';
Expand All @@ -22,6 +22,9 @@ export const ProjectCard = ({ project }: ProjectCardProps) => {
const { data: user } = useUser();
const { data: voted } = useUserVoted(project.id as number);
const vote = useVoteProject(project.id as number);
const votes = useProjectUpvotes(project.id as number);

const voteCount = votes.data?.length ?? 0;

const toggleExpanded = useCallback(() => setExpanded((p) => !p), []);

Expand Down Expand Up @@ -61,6 +64,10 @@ export const ProjectCard = ({ project }: ProjectCardProps) => {
label: 'Miejsce',
value: project.place,
},
{
label: 'Ilość głosów',
value: voteCount.toString(),
},
]}
/>
<div className="flex justify-between items-center mt-3">
Expand Down

0 comments on commit b0f2c82

Please sign in to comment.