Skip to content

Commit

Permalink
fix(linter): router types
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisCusihuaman committed Nov 18, 2023
1 parent e59072f commit 715c643
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
6 changes: 4 additions & 2 deletions src/screens/chat/chat-screen.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Displays the chat

import type { RouteProp } from '@react-navigation/native';
import { useRoute } from '@react-navigation/native';
import React from 'react';
import { ScrollView } from 'react-native-gesture-handler';
Expand All @@ -10,6 +11,7 @@ import ChatBody from './chat-body';
import ChatHeader from './chat-header';
import ChatInput from './chat-input';
import type { ChatBase } from './chat-list-screen';
import type { ChatStackParamList } from './chat-navigator';

// export type ChatUser = {
// id: number;
Expand All @@ -21,8 +23,8 @@ import type { ChatBase } from './chat-list-screen';
// };

const ChatScreen = () => {
const params: ChatBase = useRoute().params?.chat;

const route = useRoute<RouteProp<ChatStackParamList, 'ChatScreen'>>();
const params: ChatBase = route.params?.chat;
return (
<View className="p:2 flex h-screen flex-1 flex-col justify-between sm:p-6">
<ScrollView>
Expand Down
7 changes: 5 additions & 2 deletions src/screens/profile/interaction-view.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import type { RouteProp } from '@react-navigation/native';
import { useRoute } from '@react-navigation/native';
import React from 'react';
import { View } from 'react-native';

import type { UserType } from '@/core/auth/utils';

import UserList from '../users/user-list';
import type { ProfileStackParamList } from './profile-navigator';

const InteractionScreen = () => {
const users: UserType[] = useRoute().params?.users;

const route =
useRoute<RouteProp<ProfileStackParamList, 'Followers' | 'Following'>>();
const users: UserType[] = route.params?.users || [];
return (
<View>
<UserList users={users} />
Expand Down
5 changes: 3 additions & 2 deletions src/screens/profile/profile-screen.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { RouteProp} from '@react-navigation/native';

Check failure on line 1 in src/screens/profile/profile-screen.tsx

View workflow job for this annotation

GitHub Actions / Lint TS (eslint, prettier)

Insert `·`
import { useRoute } from '@react-navigation/native';
import axios from 'axios';
import React from 'react';
Expand All @@ -6,6 +7,7 @@ import { ScrollView } from 'react-native-gesture-handler';
import { getUserState } from '@/core';
import { FocusAwareStatusBar, View } from '@/ui';

import type { ProfileStackParamList } from './profile-navigator';
import ProfileSnapsView from './profile-snaps-view';
import ProfileScreenView from './profile-view';

Expand All @@ -19,10 +21,9 @@ const ProfileScreen = () => {
// Obtengo los datos guardados en la memoria interna del telefono

// First, get the route params unconditionally
const route = useRoute();
const route = useRoute<RouteProp<ProfileStackParamList, 'UserProfile'>>();
const routeUser = route.params?.user;

// Then, derive userData based on whether routeUser is defined
const userData = routeUser ? routeUser : getUserState();

const [userFollowerCount, setUserFollowerCount] = React.useState<number>(0);
Expand Down
4 changes: 2 additions & 2 deletions src/screens/search/search-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ const whenSearch = async (
const responseC = await fetch(
`https://api-content-discovery-luiscusihuaman.cloud.okteto.net/api/filter/content?user_id=${currentUser?.id}&content=${data.content}`
);
const snapsFromContent: Snap[] = await responseC.json();
const snapsFromContent = await responseC.json();
navigate('SnapList', { snaps: snapsFromContent.snaps });
}
if (data.hashtag && data.hashtag.trim() !== '') {
const responseH = await fetch(
`https://api-content-discovery-luiscusihuaman.cloud.okteto.net/api/filter/hashtag?user_id=${currentUser?.id}&hashtag=${data.hashtag}`
);
const snapFromHashtags: Snap[] = await responseH.json();
const snapFromHashtags = await responseH.json();
navigate('SnapList', { snaps: snapFromHashtags.snaps });
}
};
Expand Down
6 changes: 4 additions & 2 deletions src/screens/search/snap-list.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { RouteProp } from '@react-navigation/native';
import { useNavigation, useRoute } from '@react-navigation/native';
import axios from 'axios';
import React from 'react';
Expand All @@ -7,13 +8,14 @@ import type { Snap } from '@/api';
import { EmptyList, FocusAwareStatusBar, View } from '@/ui';

import { Card } from '../feed/card';
import type { SearchStackParamList } from './search-navigator';

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

const SnapList = () => {
const snaps: Snap[] = useRoute().params?.snaps;

const route = useRoute<RouteProp<SearchStackParamList, 'SnapList'>>();
const snaps: Snap[] = route.params?.snaps;
const { navigate } = useNavigation();

const client = axios.create({
Expand Down
6 changes: 4 additions & 2 deletions src/screens/search/users.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import type { RouteProp } from '@react-navigation/native';
import { useRoute } from '@react-navigation/native';
import React from 'react';
import { View } from 'react-native';

import type { UserType } from '@/core/auth/utils';

import UserList from '../users/user-list';
import type { SearchStackParamList } from './search-navigator';

const Users = () => {
const users: UserType[] = useRoute().params?.users;

const route = useRoute<RouteProp<SearchStackParamList, 'Users'>>();
const users: UserType[] = route.params?.users || [];
return (
<View>
<UserList users={users} />
Expand Down

0 comments on commit 715c643

Please sign in to comment.