complated
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import AdsLogo from '@/assets/images/one_click.png';
|
||||
import { useTheme } from '@/components/ThemeContext';
|
||||
import { useGlobalRefresh } from '@/components/ui/RefreshContext';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { Image } from 'expo-image';
|
||||
import { useRouter } from 'expo-router';
|
||||
import {
|
||||
Award,
|
||||
@@ -8,6 +10,7 @@ import {
|
||||
BookAIcon,
|
||||
ChevronRight,
|
||||
HandCoins,
|
||||
LucideIcon,
|
||||
Megaphone,
|
||||
Package,
|
||||
Settings,
|
||||
@@ -19,6 +22,11 @@ import { ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-nati
|
||||
import { RefreshControl } from 'react-native-gesture-handler';
|
||||
import { user_api } from '../lib/api';
|
||||
|
||||
interface SectionType {
|
||||
title: string;
|
||||
items: { icon: LucideIcon; label: string; route: string; badge?: number; image?: any }[];
|
||||
}
|
||||
|
||||
export default function Profile() {
|
||||
const router = useRouter();
|
||||
const { onRefresh, refreshing } = useGlobalRefresh();
|
||||
@@ -36,7 +44,7 @@ export default function Profile() {
|
||||
queryFn: () => user_api.getMe(),
|
||||
});
|
||||
|
||||
const sections = [
|
||||
const sections: SectionType[] = [
|
||||
{
|
||||
title: 'Shaxsiy',
|
||||
items: [
|
||||
@@ -53,17 +61,17 @@ export default function Profile() {
|
||||
{
|
||||
title: 'Faoliyat',
|
||||
items: [
|
||||
{ icon: Megaphone, label: "E'lonlar", route: '/profile/my-ads' },
|
||||
{ icon: Megaphone, label: "E'lonlar", image: AdsLogo, route: '/profile/my-ads' },
|
||||
{ icon: Award, label: 'Bonuslar', route: '/profile/bonuses' },
|
||||
{ icon: Package, label: 'Xizmatlar', route: '/profile/products' },
|
||||
...(me?.data.data.can_create_referral
|
||||
? [
|
||||
{
|
||||
icon: HandCoins,
|
||||
label: 'Refferallarim',
|
||||
route: '/profile/my-referrals',
|
||||
},
|
||||
]
|
||||
{
|
||||
icon: HandCoins,
|
||||
label: 'Refferallarim',
|
||||
route: '/profile/my-referrals',
|
||||
},
|
||||
]
|
||||
: []),
|
||||
],
|
||||
},
|
||||
@@ -79,6 +87,7 @@ export default function Profile() {
|
||||
return (
|
||||
<ScrollView
|
||||
style={[styles.content, isDark ? styles.darkBg : styles.lightBg]}
|
||||
contentContainerStyle={{ paddingBottom: 90 }}
|
||||
refreshControl={
|
||||
<RefreshControl
|
||||
refreshing={refreshing}
|
||||
@@ -107,17 +116,32 @@ export default function Profile() {
|
||||
>
|
||||
<item.icon size={24} color="#3b82f6" />
|
||||
|
||||
{item.badge && (
|
||||
{item?.badge && (
|
||||
<View style={styles.badge}>
|
||||
<Text style={styles.badgeText}>{item.badge}</Text>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
|
||||
<Text style={[styles.cardLabel, isDark ? styles.darkText : styles.lightText]}>
|
||||
{t(item.label)}
|
||||
</Text>
|
||||
|
||||
<View style={{ flex: 1 }}>
|
||||
{item.image ? (
|
||||
<View style={{ flex: 1 }}>
|
||||
<Image
|
||||
source={item.image}
|
||||
style={{ width: '60%', height: 40 }}
|
||||
contentFit="contain"
|
||||
/>
|
||||
<Text style={[styles.cardLabel, isDark ? styles.darkText : styles.lightText, { fontSize: 14, marginTop: 4, fontWeight: '500' }]}>
|
||||
{t("Bir Zumda Jonatish")}
|
||||
</Text>
|
||||
</View>
|
||||
) : (
|
||||
<View>
|
||||
<Text style={[styles.cardLabel, isDark ? styles.darkText : styles.lightText]}>
|
||||
{t(item.label)}
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
<ChevronRight size={20} color={isDark ? '#64748b' : '#94a3b8'} />
|
||||
</TouchableOpacity>
|
||||
))}
|
||||
@@ -131,7 +155,7 @@ export default function Profile() {
|
||||
const styles = StyleSheet.create({
|
||||
content: {
|
||||
flex: 1,
|
||||
marginBottom: 50,
|
||||
paddingBottom: 120,
|
||||
},
|
||||
|
||||
darkBg: {
|
||||
|
||||
Reference in New Issue
Block a user