delete account added

This commit is contained in:
Samandar Turgunboyev
2026-02-17 14:21:07 +05:00
parent 4b9e6de904
commit 0c9e0811ea
4 changed files with 74 additions and 18 deletions

View File

@@ -14,21 +14,32 @@ import {
Megaphone,
Package,
Settings,
Trash2,
User,
Users,
Users
} from 'lucide-react-native';
import { useTranslation } from 'react-i18next';
import { ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import { Alert, ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
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 }[];
items: {
icon: LucideIcon;
label: string;
route?: string;
badge?: number;
image?: any;
isDestructive?: boolean;
}[];
}
import { useAuth } from '@/components/AuthProvider';
export default function Profile() {
const router = useRouter();
const { logout } = useAuth();
const { onRefresh, refreshing } = useGlobalRefresh();
const { isDark } = useTheme();
const { t } = useTranslation();
@@ -80,6 +91,10 @@ export default function Profile() {
items: [
{ icon: Settings, label: 'Sozlamalar', route: '/profile/settings' },
{ icon: BookAIcon, label: "Foydalanish qo'llanmasi", route: '/profile/manual' },
{
icon: Trash2,
label: "Hisobni o'chirish",
},
],
},
];
@@ -108,20 +123,34 @@ export default function Profile() {
<TouchableOpacity
key={idx}
style={[styles.card, isDark ? styles.darkCard : styles.lightCard]}
onPress={() => router.push(item.route as any)}
onPress={() => {
if (item.label === "Hisobni o'chirish") {
Alert.alert(
t("Hisobni o'chirish"),
t("Rostdan ham hisobingizni o'chirmoqchimisiz?"),
[
{ text: t('Bekor qilish'), style: 'cancel' },
{ text: t("O'chirish"), onPress: () => logout(), style: 'destructive' },
]
);
} else {
router.push(item.route as any);
}
}}
activeOpacity={0.7}
>
<View
style={[styles.iconContainer, isDark ? styles.darkIconBg : styles.lightIconBg]}
>
<item.icon size={24} color="#3b82f6" />
<View style={[styles.iconContainer, isDark ? styles.darkIconBg : styles.lightIconBg]}>
<item.icon
size={24}
color={item.label === "Hisobni o'chirish" ? '#ef4444' : '#3b82f6'}
/>
{item?.badge && (
<View style={styles.badge}>
<Text style={styles.badgeText}>{item.badge}</Text>
</View>
)}
</View>
<View style={{ flex: 1 }}>
{item.image ? (
<View style={{ flex: 1 }}>
@@ -130,25 +159,46 @@ export default function Profile() {
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
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]}>
<Text
style={[
styles.cardLabel,
item.label === "Hisobni o'chirish"
? { color: '#ef4444' }
: isDark
? styles.darkText
: styles.lightText,
]}
>
{t(item.label)}
</Text>
</View>
)}
</View>
<ChevronRight size={20} color={isDark ? '#64748b' : '#94a3b8'} />
<ChevronRight
size={20}
color={item.label === "Hisobni o'chirish" ? '#ef4444' : isDark ? '#64748b' : '#94a3b8'}
/>
</TouchableOpacity>
))}
</View>
</View>
))}
</ScrollView>
))
}
</ScrollView >
);
}