Skip to content

Commit

Permalink
✨ add event view count component
Browse files Browse the repository at this point in the history
  • Loading branch information
FredrikMorstad committed Dec 3, 2023
1 parent d622a9b commit 5258430
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/components/molecules/event/eventViewCount/EventViewCount.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Center, Heading, Text } from '@chakra-ui/react';
import { getPageVisit } from 'api';
import Icon from 'components/atoms/icons/icon';
import { useEffect, useState } from 'react';

const EventViewCount: React.FC<{ page: string }> = ({ page }) => {
const [views, setViews] = useState<number | undefined>();

const fetchPageVisist = async () => {
const response = await getPageVisit(page);
setViews(response.visits);
};

useEffect(() => {
fetchPageVisist();
}, []);

return (
<Center
w="100%"
height="20%"
borderRadius="lg"
border="1px"
borderColor="#fffff"
textAlign="center"
flexDir="column">
<Heading size="sm" m=".5rem">
Antall besøk
</Heading>
<Center dir="column" textAlign="center">
<Icon size={2} type="eye" />
<Text p={0} m={0} ml=".5rem">
{views ?? 'N/A'}
</Text>
</Center>
</Center>
);
};

export default EventViewCount;

0 comments on commit 5258430

Please sign in to comment.