Skip to content
This repository was archived by the owner on Oct 20, 2025. It is now read-only.

Commit 7d7c64e

Browse files
committed
Add Report Screens
1 parent 3de31f2 commit 7d7c64e

File tree

2 files changed

+237
-0
lines changed

2 files changed

+237
-0
lines changed

app/(auth)/report/profile/[id].jsx

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import { useQuery } from '@tanstack/react-query'
2+
import * as Burnt from 'burnt'
3+
import { Link, Stack, router, useLocalSearchParams, useRouter } from 'expo-router'
4+
import { ActivityIndicator, Alert, Pressable, ScrollView } from 'react-native'
5+
import { FlatList } from 'react-native-gesture-handler'
6+
import { SafeAreaView } from 'react-native-safe-area-context'
7+
import FeatherIcon from 'src/components/common/FeatherIcon'
8+
import { getReportRules, postReportProfile } from 'src/requests'
9+
import { Separator, Text, View, XStack, YStack } from 'tamagui'
10+
11+
export default function Screen() {
12+
const { id } = useLocalSearchParams()
13+
const router = useRouter()
14+
15+
const {
16+
data: reasons,
17+
isPending,
18+
isError,
19+
error,
20+
} = useQuery({
21+
queryKey: ['reportRules'],
22+
queryFn: getReportRules,
23+
})
24+
25+
if (isPending) {
26+
return (
27+
<SafeAreaView flex={1}>
28+
<View justifyContent="center" alignItems="center" flexGrow={1}>
29+
<ActivityIndicator />
30+
</View>
31+
</SafeAreaView>
32+
)
33+
}
34+
35+
if (isError) {
36+
return (
37+
<View flexGrow={1}>
38+
<Text>Error: {error.message}</Text>
39+
</View>
40+
)
41+
}
42+
43+
const RenderItem = ({ item }) => {
44+
return (
45+
<View px="$5" py="$3" bg="$gray2" mb="$1">
46+
<Pressable onPress={() => handleReport(item.key)}>
47+
<XStack justifyContent="space-between" alignItems="center">
48+
<Text fontWeight="bold">{item.message}</Text>
49+
<FeatherIcon name="chevron-right" size={20} />
50+
</XStack>
51+
</Pressable>
52+
</View>
53+
)
54+
}
55+
56+
const handleReport = (item) => {
57+
const params = {
58+
report_type: item,
59+
reported_profile_id: id,
60+
}
61+
Alert.alert('Confirm Report', 'Are you sure you want to report this account?', [
62+
{
63+
text: 'Cancel',
64+
style: 'cancel',
65+
},
66+
{
67+
text: 'Report',
68+
style: 'destructive',
69+
onPress: () => sendReport(params),
70+
},
71+
])
72+
}
73+
74+
const sendReport = async (params) => {
75+
try {
76+
await postReportProfile(params)
77+
.then(() => {
78+
Burnt.toast({
79+
title: 'Report Sent!',
80+
preset: 'done',
81+
from: 'bottom',
82+
haptic: 'success',
83+
message: 'Thanks for reporting.',
84+
})
85+
})
86+
.catch((error) => {})
87+
.finally(() => {
88+
router.back()
89+
})
90+
} catch (e) {
91+
router.back()
92+
}
93+
}
94+
95+
return (
96+
<SafeAreaView style={{ flex: 1, backgroundColor: '#fff' }} edges={['right', 'left']}>
97+
<Stack.Screen
98+
options={{
99+
headerShown: true,
100+
headerBackTitle: 'Back',
101+
headerTitle: 'Report Account',
102+
headerBackTitleStyle: {
103+
color: 'white',
104+
},
105+
}}
106+
/>
107+
<FlatList
108+
data={reasons}
109+
renderItem={RenderItem}
110+
contentContainerStyle={{ flex: 1 }}
111+
showsVerticalScrollIndicator={false}
112+
/>
113+
</SafeAreaView>
114+
)
115+
}

app/(auth)/report/video/[id].jsx

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import { useQuery } from '@tanstack/react-query'
2+
import * as Burnt from 'burnt'
3+
import { Link, Stack, router, useLocalSearchParams, useRouter } from 'expo-router'
4+
import { StatusBar } from 'expo-status-bar'
5+
import { useCallback } from 'react'
6+
import { ActivityIndicator, Alert, Pressable, ScrollView, StyleSheet } from 'react-native'
7+
import { FlatList } from 'react-native-gesture-handler'
8+
import { SafeAreaView } from 'react-native-safe-area-context'
9+
import FeatherIcon from 'src/components/common/FeatherIcon'
10+
import { getReportRules, postReportVideo } from 'src/requests'
11+
import { Separator, Text, View, XStack, YStack } from 'tamagui'
12+
13+
export default function Screen() {
14+
const { id } = useLocalSearchParams()
15+
const router = useRouter()
16+
17+
const {
18+
data: reasons,
19+
isPending,
20+
isError,
21+
error,
22+
} = useQuery({
23+
queryKey: ['reportRules'],
24+
queryFn: getReportRules,
25+
})
26+
27+
if (isPending) {
28+
return (
29+
<SafeAreaView flex={1}>
30+
<View justifyContent="center" alignItems="center" flexGrow={1}>
31+
<ActivityIndicator />
32+
</View>
33+
</SafeAreaView>
34+
)
35+
}
36+
37+
if (isError) {
38+
return (
39+
<View flexGrow={1}>
40+
<Text>Error: {error.message}</Text>
41+
</View>
42+
)
43+
}
44+
45+
const RenderItem = ({ item }) => {
46+
return (
47+
<View px="$5" py="$3" bg="$gray2" mb="$1">
48+
<Pressable onPress={() => handleReport(item.key)}>
49+
<XStack justifyContent="space-between" alignItems="center">
50+
<Text fontWeight="bold">{item.message}</Text>
51+
<FeatherIcon name="chevron-right" size={20} />
52+
</XStack>
53+
</Pressable>
54+
</View>
55+
)
56+
}
57+
58+
const handleReport = (item) => {
59+
const params = {
60+
report_type: item,
61+
reported_video_id: id,
62+
}
63+
Alert.alert('Confirm Report', 'Are you sure you want to report this video?', [
64+
{
65+
text: 'Cancel',
66+
style: 'cancel',
67+
},
68+
{
69+
text: 'Report',
70+
style: 'destructive',
71+
onPress: () => sendReport(params),
72+
},
73+
])
74+
}
75+
76+
const sendReport = async (params) => {
77+
try {
78+
await postReportVideo(params)
79+
.then(() => {
80+
Burnt.toast({
81+
title: 'Report Sent!',
82+
preset: 'done',
83+
from: 'bottom',
84+
haptic: 'success',
85+
message: 'Thanks for reporting.',
86+
})
87+
})
88+
.catch((error) => {
89+
router.back()
90+
})
91+
.finally(() => {
92+
router.back()
93+
})
94+
} catch (e) {
95+
router.back()
96+
}
97+
}
98+
99+
return (
100+
<SafeAreaView style={{ flex: 1 }} edges={['right', 'left']}>
101+
<Stack.Screen
102+
options={{
103+
headerShown: true,
104+
headerBackTitle: 'Back',
105+
headerTitle: 'Report Loop',
106+
headerBackTitleStyle: {
107+
color: 'white',
108+
},
109+
}}
110+
/>
111+
<StatusBar animated={true} barStyle={'light-content'} />
112+
<View bg="white" flexGrow={1}>
113+
<FlatList
114+
data={reasons}
115+
renderItem={RenderItem}
116+
contentContainerStyle={{ flex: 1 }}
117+
showsVerticalScrollIndicator={false}
118+
/>
119+
</View>
120+
</SafeAreaView>
121+
)
122+
}

0 commit comments

Comments
 (0)