@umituz/react-native-settings 4.23.85 → 4.23.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/domains/about/presentation/hooks/useAboutInfo.ts +1 -1
- package/src/domains/faqs/presentation/screens/FAQScreen.tsx +1 -1
- package/src/domains/feedback/presentation/components/FeedbackForm.styles.ts +1 -1
- package/src/domains/feedback/presentation/components/FeedbackForm.tsx +11 -4
- package/src/domains/gamification/components/GamificationScreen/GamificationScreen.tsx +1 -6
- package/src/domains/gamification/store/gamificationStore.ts +6 -7
- package/src/domains/localization/infrastructure/storage/LocalizationStore.ts +50 -181
- package/src/domains/localization/infrastructure/storage/localizationStoreUtils.ts +182 -0
- package/src/domains/notifications/infrastructure/utils/dev.ts +3 -3
- package/src/domains/notifications/reminders/presentation/components/ReminderForm.constants.ts +1 -1
- package/src/domains/notifications/reminders/presentation/components/ReminderForm.tsx +52 -46
- package/src/infrastructure/types/commonComponentTypes.ts +142 -0
- package/src/infrastructure/utils/async/core.ts +109 -0
- package/src/infrastructure/utils/async/debounceAndBatch.ts +69 -0
- package/src/infrastructure/utils/async/index.ts +8 -0
- package/src/infrastructure/utils/async/retryAndTimeout.ts +57 -0
- package/src/infrastructure/utils/configFactory.ts +101 -0
- package/src/infrastructure/utils/errorHandlers.ts +249 -0
- package/src/infrastructure/utils/index.ts +5 -0
- package/src/infrastructure/utils/memoComparisonUtils.ts +0 -2
- package/src/infrastructure/utils/memoUtils.ts +10 -2
- package/src/infrastructure/utils/styleTokens.ts +132 -0
- package/src/infrastructure/utils/validation/core.ts +42 -0
- package/src/infrastructure/utils/validation/formValidators.ts +82 -0
- package/src/infrastructure/utils/validation/index.ts +37 -0
- package/src/infrastructure/utils/validation/numericValidators.ts +66 -0
- package/src/infrastructure/utils/validation/passwordValidator.ts +53 -0
- package/src/infrastructure/utils/validation/textValidators.ts +118 -0
- package/src/presentation/hooks/useSettingsScreenConfig.ts +32 -79
- package/src/presentation/navigation/SettingsStackNavigator.tsx +1 -24
- package/src/presentation/navigation/hooks/useSettingsScreens.ts +1 -1
- package/src/presentation/utils/config-creators/base-configs.ts +54 -42
- package/src/presentation/utils/faqTranslator.ts +31 -0
- package/src/presentation/utils/index.ts +6 -1
- package/src/presentation/utils/screenFactory.ts +1 -1
- package/src/presentation/utils/settingsConfigFactory.ts +89 -0
- package/src/presentation/utils/useAuthHandlers.ts +98 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth Handlers Hook
|
|
3
|
+
* Centralized authentication-related handlers for settings screen
|
|
4
|
+
* FIXED: Added proper error logging and user feedback
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { useCallback } from "react";
|
|
8
|
+
import { Linking, Alert } from "react-native";
|
|
9
|
+
import {
|
|
10
|
+
useAuth,
|
|
11
|
+
useAccountManagement,
|
|
12
|
+
useAuthModalStore,
|
|
13
|
+
} from "@umituz/react-native-auth";
|
|
14
|
+
import { AlertService } from "@umituz/react-native-design-system";
|
|
15
|
+
import { useLocalization } from "../../domains/localization";
|
|
16
|
+
import type { AppInfo } from "../navigation/types";
|
|
17
|
+
|
|
18
|
+
declare const __DEV__: boolean;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Hook that provides authentication-related handlers
|
|
22
|
+
*/
|
|
23
|
+
export const useAuthHandlers = (appInfo: AppInfo) => {
|
|
24
|
+
const { t } = useLocalization();
|
|
25
|
+
const { signOut } = useAuth();
|
|
26
|
+
const { deleteAccount } = useAccountManagement();
|
|
27
|
+
const { showAuthModal } = useAuthModalStore();
|
|
28
|
+
|
|
29
|
+
const handleRatePress = useCallback(async () => {
|
|
30
|
+
const url = appInfo.appStoreUrl;
|
|
31
|
+
if (!url) {
|
|
32
|
+
// FIXED: Provide feedback when URL is missing
|
|
33
|
+
Alert.alert(t("common.error"), "App store URL not configured");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
const canOpen = await Linking.canOpenURL(url);
|
|
39
|
+
if (!canOpen) {
|
|
40
|
+
// FIXED: Provide feedback when URL cannot be opened
|
|
41
|
+
Alert.alert(
|
|
42
|
+
t("common.error"),
|
|
43
|
+
"Unable to open app store. Please check your device settings."
|
|
44
|
+
);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
await Linking.openURL(url);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
// FIXED: Log actual error for debugging
|
|
50
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
51
|
+
console.error("[useAuthHandlers] Failed to open app store:", error);
|
|
52
|
+
}
|
|
53
|
+
Alert.alert(t("common.error"), "Failed to open app store");
|
|
54
|
+
}
|
|
55
|
+
}, [appInfo.appStoreUrl, t]);
|
|
56
|
+
|
|
57
|
+
const handleSignOut = useCallback(async () => {
|
|
58
|
+
try {
|
|
59
|
+
await signOut();
|
|
60
|
+
} catch (error) {
|
|
61
|
+
// FIXED: Log actual error for debugging
|
|
62
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
63
|
+
console.error("[useAuthHandlers] Sign out failed:", error);
|
|
64
|
+
}
|
|
65
|
+
AlertService.createErrorAlert(
|
|
66
|
+
t("common.error"),
|
|
67
|
+
t("auth.errors.unknownError")
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}, [signOut, t]);
|
|
71
|
+
|
|
72
|
+
const handleDeleteAccount = useCallback(async () => {
|
|
73
|
+
try {
|
|
74
|
+
await deleteAccount();
|
|
75
|
+
} catch (error) {
|
|
76
|
+
// FIXED: Log actual error for debugging
|
|
77
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
78
|
+
console.error("[useAuthHandlers] Delete account failed:", error);
|
|
79
|
+
}
|
|
80
|
+
AlertService.createErrorAlert(
|
|
81
|
+
t("common.error"),
|
|
82
|
+
t("settings.account.deleteError")
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}, [deleteAccount, t]);
|
|
86
|
+
|
|
87
|
+
const handleSignIn = useCallback(() => {
|
|
88
|
+
// FIXED: Remove empty callback - pass undefined instead
|
|
89
|
+
showAuthModal(undefined, "login");
|
|
90
|
+
}, [showAuthModal]);
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
handleRatePress,
|
|
94
|
+
handleSignOut,
|
|
95
|
+
handleDeleteAccount,
|
|
96
|
+
handleSignIn,
|
|
97
|
+
};
|
|
98
|
+
};
|