Skip to content

Commit

Permalink
feat: added snap view
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisParedes1 committed Nov 12, 2023
1 parent 64f61cb commit 2631d26
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 27 deletions.
5 changes: 3 additions & 2 deletions src/navigation/feed-navigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import * as React from 'react';

import { AddSnap, Feed, Snap } from '@/screens';
import { Pressable, Text } from '@/ui';

import { UserType } from '@/core/auth/utils';
import type { Snap as SnapType } from '@/api';
import { GoToLogout } from './auth-navigator';

export type FeedStackParamList = {
Feed: undefined;
Snap: { id: number };
Snap: { snap: SnapType };
AddSnap: undefined;
Auth: undefined;
};
Expand Down
2 changes: 0 additions & 2 deletions src/screens/feed/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ export const Card = ({ snap, client, onPress = () => {} }: Props) => {
day: '2-digit',
});

// const user: UserType = get_user(snap.author).then((user) => user);

const [user, setUser] = useState<UserType>();

// Pido la cantidad de followers
Expand Down
Empty file.
3 changes: 2 additions & 1 deletion src/screens/feed/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const BASE_INTERACTION_URL =

export const Feed = () => {
const currentUser = getUserState();

const { data, isLoading, isError } = useSnaps({
variables: { user_id: currentUser?.id },
});
Expand All @@ -39,7 +40,7 @@ export const Feed = () => {
<Card
snap={item}
client={client}
onPress={() => navigate('Snap', { id: item.id })}
onPress={() => navigate('Snap', { snap: item })}
/>
);
}
Expand Down
21 changes: 21 additions & 0 deletions src/screens/feed/snap-view.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Snap } from '@/api';
import { UserType } from '@/core/auth/utils';
import { Image, Input, Text, TouchableOpacity, View } from '@/ui';
import { Card } from '../feed/card';
import axios from 'axios';

const BASE_INTERACTION_URL =
'https://api-content-discovery-luiscusihuaman.cloud.okteto.net/api/interactions/';

export const SnapView = ({ snap }: { snap: Snap }) => {
const client = axios.create({
baseURL: BASE_INTERACTION_URL,
});

return (
<View>
<Card snap={snap} client={client} />
<Text>Aca van comentarios</Text>
</View>
);
};
45 changes: 24 additions & 21 deletions src/screens/feed/snap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,39 @@ import * as React from 'react';
import { useSnap } from '@/api';
import type { RouteProp } from '@/navigation/types';
import { ActivityIndicator, FocusAwareStatusBar, Text, View } from '@/ui';
import { SnapView } from './snap-view';

export const Snap = () => {
const { params } = useRoute<RouteProp<'Snap'>>();

const { data, isLoading, isError } = useSnap({
variables: { tweet_id: params.id },
});
const data = params.snap;

if (isLoading) {
return (
<View className="flex-1 justify-center">
<ActivityIndicator />
</View>
);
}
if (isError) {
return (
<View className="flex-1 justify-center">
<FocusAwareStatusBar />
<Text variant="md" className="text-center">
Error loading post
</Text>
</View>
);
}
// const { data, isLoading, isError } = useSnap({
// variables: { tweet_id: params.id },
// });

// if (snap) {
// return (
// <View className="flex-1 justify-center">
// <ActivityIndicator />
// </View>
// );
// }
// if (isError) {
// return (
// <View className="flex-1 justify-center">
// <FocusAwareStatusBar />
// <Text variant="md" className="text-center">
// Error loading post
// </Text>
// </View>
// );
// }

return (
<View className="flex-1 ">
<FocusAwareStatusBar />
<Text variant="md">{data.content} </Text>
<SnapView snap={data}></SnapView>
</View>
);
};
2 changes: 1 addition & 1 deletion src/screens/profile/my-snaps-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const MySnapsView = ({ data }: { data: Snap[] }) => {
<Card
snap={item}
client={client}
onPress={() => navigate('Snap', { id: item.id })}
onPress={() => navigate('Snap', { snap: item })}
/>
);
}
Expand Down

0 comments on commit 2631d26

Please sign in to comment.