diff --git a/i18n/locales/en.json b/i18n/locales/en.json index 73c372d..4f63dfb 100644 --- a/i18n/locales/en.json +++ b/i18n/locales/en.json @@ -206,5 +206,7 @@ "Bir Zumda Jonatish": "Express Send Info", "Hammasi": "All", "Bekor qilish": "Cancel", - "Barchasi o'qildi": "Mark All as Read" + "Barchasi o'qildi": "Mark All as Read", + "Hisobni o'chirish": "Delete account", + "Rostdan ham hisobingizni o‘chirmoqchimisiz?": "Are you sure you want to delete your account?" } diff --git a/i18n/locales/ru.json b/i18n/locales/ru.json index e5ef3bd..fe621c5 100644 --- a/i18n/locales/ru.json +++ b/i18n/locales/ru.json @@ -205,5 +205,7 @@ "Bir Zumda Jonatish": "Экспресс Рассылки Инфо", "Hammasi": "Все", "Bekor qilish": "Отменить", - "Barchasi o'qildi": "Отметить все как прочитанное" + "Barchasi o'qildi": "Отметить все как прочитанное", + "Hisobni o'chirish": "Удалить аккаунт", + "Rostdan ham hisobingizni o'chirmoqchimisiz?": "Вы уверены, что хотите удалить свой аккаунт?" } diff --git a/i18n/locales/uz.json b/i18n/locales/uz.json index be70d69..fe72c06 100644 --- a/i18n/locales/uz.json +++ b/i18n/locales/uz.json @@ -205,5 +205,7 @@ "Bir Zumda Jonatish": "Bir Zumda Jonatish", "Hammasi": "Hammasi", "Bekor qilish": "Bekor qilish", - "Barchasi o'qildi": "Barchasi o'qildi" + "Barchasi o'qildi": "Barchasi o'qildi", + "Hisobni o'chirish": "Hisobni o'chirish", + "Rostdan ham hisobingizni o'chirmoqchimisiz?": "Rostdan ham hisobingizni o'chirmoqchimisiz?" } diff --git a/screens/profile/ui/ProfileScreen.tsx b/screens/profile/ui/ProfileScreen.tsx index 86733e3..bbc46bc 100644 --- a/screens/profile/ui/ProfileScreen.tsx +++ b/screens/profile/ui/ProfileScreen.tsx @@ -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() { 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} > - - - + + {item?.badge && ( {item.badge} )} + {item.image ? ( @@ -130,25 +159,46 @@ export default function Profile() { style={{ width: '60%', height: 40 }} contentFit="contain" /> - - {t("Bir Zumda Jonatish")} + + {t('Bir Zumda Jonatish')} ) : ( - + {t(item.label)} )} - + + + ))} - ))} - + )) + } + ); }