diff --git a/src/app/(tabs)/home/index.tsx b/src/app/(tabs)/home/index.tsx index 2b26287..b3c3e2b 100644 --- a/src/app/(tabs)/home/index.tsx +++ b/src/app/(tabs)/home/index.tsx @@ -95,6 +95,7 @@ function HomeScreen() { {featuredStories.map(story => ( (); + + useEffect(() => { + (async () => { + const temp = await fetchAllReactionsToStory(id); + if (temp != null) { + setReactions(temp); + return; + } + setReactions([]); + })(); + }); + return ( @@ -73,7 +89,7 @@ function ContentCard({ {/* heart, clap, muscle, cry, ??? */} - 14{/*change number to work*/} + {reactions?.length} diff --git a/src/components/PreviewCard/PreviewCard.tsx b/src/components/PreviewCard/PreviewCard.tsx index 71d6d05..ddb5671 100644 --- a/src/components/PreviewCard/PreviewCard.tsx +++ b/src/components/PreviewCard/PreviewCard.tsx @@ -1,4 +1,5 @@ import * as cheerio from 'cheerio'; +import { Image } from 'expo-image'; import { GestureResponderEvent, Pressable, @@ -7,16 +8,19 @@ import { View, } from 'react-native'; import Emoji from 'react-native-emoji'; -import { Image } from 'expo-image'; import styles from './styles'; import globalStyles from '../../styles/globalStyles'; import SaveStoryButton from '../SaveStoryButton/SaveStoryButton'; +import { useEffect, useState } from 'react'; +import { fetchAllReactionsToStory } from '../../queries/reactions'; +import { Reactions } from '../../queries/types'; const placeholderImage = 'https://gwn-uploads.s3.amazonaws.com/wp-content/uploads/2021/10/10120952/Girls-Write-Now-logo-avatar.png'; type PreviewCardProps = { + id: number; title: string; image: string; storyId: number; @@ -28,6 +32,7 @@ type PreviewCardProps = { }; function PreviewCard({ + id, title, image, storyId, @@ -37,6 +42,18 @@ function PreviewCard({ tags, pressFunction, }: PreviewCardProps) { + const [reactions, setReactions] = useState(); + useEffect(() => { + (async () => { + const temp = await fetchAllReactionsToStory(id); + if (temp != null) { + setReactions(temp); + return; + } + setReactions([]); + })(); + }); + return ( @@ -85,7 +102,7 @@ function PreviewCard({ {/* heart, clap, muscle, cry, ??? */} - 14{/*change number to work*/} + {reactions?.length} diff --git a/tsconfig.json b/tsconfig.json index a0863d0..e55b0e4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "expo/tsconfig.base", "compilerOptions": { + "module": "esnext", "strict": true, "jsx": "react-jsx" }