-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d622a9b
commit 5258430
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/components/molecules/event/eventViewCount/EventViewCount.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |