diff --git a/src/app/(tabs)/home/index.tsx b/src/app/(tabs)/home/index.tsx index 81341d7..f45cf3d 100644 --- a/src/app/(tabs)/home/index.tsx +++ b/src/app/(tabs)/home/index.tsx @@ -132,6 +132,7 @@ function HomeScreen() { title={story.title} author={story.author_name} authorImage={story.author_image} + storyId={story.id} pressFunction={() => router.push({ pathname: '/story', @@ -161,6 +162,7 @@ function HomeScreen() { title={story.title} author={story.author_name} authorImage={story.author_image} + storyId={story.id} pressFunction={() => router.push({ pathname: '/story', diff --git a/src/components/ContentCard/ContentCard.tsx b/src/components/ContentCard/ContentCard.tsx index 4301cb9..145769a 100644 --- a/src/components/ContentCard/ContentCard.tsx +++ b/src/components/ContentCard/ContentCard.tsx @@ -8,13 +8,16 @@ import { } from 'react-native'; import styles from './styles'; +import { addUserStoryToReadingList } from '../../queries/savedStories'; import globalStyles from '../../styles/globalStyles'; +import { useSession } from '../../utils/AuthContext'; type ContentCardProps = { title: string; author: string; image: string; authorImage: string; + storyId: number; pressFunction: (event: GestureResponderEvent) => void; }; @@ -23,10 +26,13 @@ function ContentCard({ author, image, authorImage, + storyId, pressFunction, }: ContentCardProps) { + const { user } = useSession(); + const saveStory = () => { - console.log("testing '+' icon does something for story " + title); + addUserStoryToReadingList(user?.id, storyId); }; return ( @@ -60,7 +66,7 @@ function ContentCard({ null} + onPress={() => saveStory()} style={{ flexDirection: 'row' }} >