Skip to content

Commit

Permalink
Implemented save story button
Browse files Browse the repository at this point in the history
  • Loading branch information
jjstnlee committed Apr 8, 2024
1 parent 507523a commit e67c29e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/app/(tabs)/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
10 changes: 8 additions & 2 deletions src/components/ContentCard/ContentCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand All @@ -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 (
Expand Down Expand Up @@ -60,7 +66,7 @@ function ContentCard({
<View style={styles.buttons}>
<View>
<TouchableOpacity
onPress={() => null}
onPress={() => saveStory()}
style={{ flexDirection: 'row' }}
>
<Image
Expand Down

0 comments on commit e67c29e

Please sign in to comment.