@oxyhq/services 5.5.8 → 5.6.0
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/README.md +16 -2
- package/lib/commonjs/core/index.js +69 -82
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/index.js +24 -183
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/node/index.js +0 -2
- package/lib/commonjs/node/index.js.map +1 -1
- package/lib/commonjs/ui/components/FollowButton.js +100 -229
- package/lib/commonjs/ui/components/FollowButton.js.map +1 -1
- package/lib/commonjs/ui/components/OxyPayButton.js +131 -0
- package/lib/commonjs/ui/components/OxyPayButton.js.map +1 -0
- package/lib/commonjs/ui/components/OxyProvider.js +41 -198
- package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
- package/lib/commonjs/ui/components/OxySignInButton.js +15 -2
- package/lib/commonjs/ui/components/OxySignInButton.js.map +1 -1
- package/lib/commonjs/ui/components/icon/FAIRWalletIcon.js +66 -0
- package/lib/commonjs/ui/components/icon/FAIRWalletIcon.js.map +1 -0
- package/lib/commonjs/ui/components/icon/index.js +7 -0
- package/lib/commonjs/ui/components/icon/index.js.map +1 -1
- package/lib/commonjs/ui/components/index.js +7 -0
- package/lib/commonjs/ui/components/index.js.map +1 -1
- package/lib/commonjs/ui/components/internal/GroupedPillButtons.js +14 -7
- package/lib/commonjs/ui/components/internal/GroupedPillButtons.js.map +1 -1
- package/lib/commonjs/ui/components/internal/PinInput.js +108 -0
- package/lib/commonjs/ui/components/internal/PinInput.js.map +1 -0
- package/lib/commonjs/ui/components/internal/TextField.js +20 -0
- package/lib/commonjs/ui/components/internal/TextField.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +26 -23
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/hooks/index.js +2 -15
- package/lib/commonjs/ui/hooks/index.js.map +1 -1
- package/lib/commonjs/ui/hooks/useFollow.js +52 -136
- package/lib/commonjs/ui/hooks/useFollow.js.map +1 -1
- package/lib/commonjs/ui/hooks/useSessionSocket.js +52 -0
- package/lib/commonjs/ui/hooks/useSessionSocket.js.map +1 -0
- package/lib/commonjs/ui/index.js +8 -191
- package/lib/commonjs/ui/index.js.map +1 -1
- package/lib/commonjs/ui/navigation/OxyRouter.js +52 -60
- package/lib/commonjs/ui/navigation/OxyRouter.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountCenterScreen.js +18 -30
- package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountOverviewScreen.js +4 -22
- package/lib/commonjs/ui/screens/AccountOverviewScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js +6 -14
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +37 -66
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AppInfoScreen.js +21 -44
- package/lib/commonjs/ui/screens/AppInfoScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/FeedbackScreen.js +44 -23
- package/lib/commonjs/ui/screens/FeedbackScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/FileManagementScreen.js +59 -78
- package/lib/commonjs/ui/screens/FileManagementScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/PaymentGatewayScreen.js +1588 -0
- package/lib/commonjs/ui/screens/PaymentGatewayScreen.js.map +1 -0
- package/lib/commonjs/ui/screens/PremiumSubscriptionScreen.js +22 -36
- package/lib/commonjs/ui/screens/PremiumSubscriptionScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/RecoverAccountScreen.js +269 -0
- package/lib/commonjs/ui/screens/RecoverAccountScreen.js.map +1 -0
- package/lib/commonjs/ui/screens/SessionManagementScreen.js +47 -69
- package/lib/commonjs/ui/screens/SessionManagementScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SignInScreen.js +99 -333
- package/lib/commonjs/ui/screens/SignInScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SignUpScreen.js +136 -340
- package/lib/commonjs/ui/screens/SignUpScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/internal/SignInPasswordStep.js +192 -0
- package/lib/commonjs/ui/screens/internal/SignInPasswordStep.js.map +1 -0
- package/lib/commonjs/ui/screens/internal/SignInUsernameStep.js +135 -0
- package/lib/commonjs/ui/screens/internal/SignInUsernameStep.js.map +1 -0
- package/lib/commonjs/ui/screens/internal/SignUpIdentityStep.js +108 -0
- package/lib/commonjs/ui/screens/internal/SignUpIdentityStep.js.map +1 -0
- package/lib/commonjs/ui/screens/internal/SignUpSecurityStep.js +126 -0
- package/lib/commonjs/ui/screens/internal/SignUpSecurityStep.js.map +1 -0
- package/lib/commonjs/ui/screens/internal/SignUpSummaryStep.js +84 -0
- package/lib/commonjs/ui/screens/internal/SignUpSummaryStep.js.map +1 -0
- package/lib/commonjs/ui/screens/internal/SignUpWelcomeStep.js +59 -0
- package/lib/commonjs/ui/screens/internal/SignUpWelcomeStep.js.map +1 -0
- package/lib/commonjs/ui/screens/karma/KarmaRewardsScreen.js +15 -2
- package/lib/commonjs/ui/screens/karma/KarmaRewardsScreen.js.map +1 -1
- package/lib/commonjs/ui/stores/authStore.js +31 -0
- package/lib/commonjs/ui/stores/authStore.js.map +1 -0
- package/lib/commonjs/ui/stores/followStore.js +124 -0
- package/lib/commonjs/ui/stores/followStore.js.map +1 -0
- package/lib/commonjs/ui/styles/index.js +0 -11
- package/lib/commonjs/ui/styles/index.js.map +1 -1
- package/lib/commonjs/ui/utils/confirmAction.js +28 -0
- package/lib/commonjs/ui/utils/confirmAction.js.map +1 -0
- package/lib/module/core/index.js +69 -81
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/index.js +14 -17
- package/lib/module/index.js.map +1 -1
- package/lib/module/node/index.js +0 -3
- package/lib/module/node/index.js.map +1 -1
- package/lib/module/ui/components/FollowButton.js +100 -229
- package/lib/module/ui/components/FollowButton.js.map +1 -1
- package/lib/module/ui/components/OxyPayButton.js +125 -0
- package/lib/module/ui/components/OxyPayButton.js.map +1 -0
- package/lib/module/ui/components/OxyProvider.js +42 -199
- package/lib/module/ui/components/OxyProvider.js.map +1 -1
- package/lib/module/ui/components/OxySignInButton.js +15 -2
- package/lib/module/ui/components/OxySignInButton.js.map +1 -1
- package/lib/module/ui/components/icon/FAIRWalletIcon.js +60 -0
- package/lib/module/ui/components/icon/FAIRWalletIcon.js.map +1 -0
- package/lib/module/ui/components/icon/index.js +1 -0
- package/lib/module/ui/components/icon/index.js.map +1 -1
- package/lib/module/ui/components/index.js +1 -0
- package/lib/module/ui/components/index.js.map +1 -1
- package/lib/module/ui/components/internal/GroupedPillButtons.js +15 -8
- package/lib/module/ui/components/internal/GroupedPillButtons.js.map +1 -1
- package/lib/module/ui/components/internal/PinInput.js +103 -0
- package/lib/module/ui/components/internal/PinInput.js.map +1 -0
- package/lib/module/ui/components/internal/TextField.js +20 -0
- package/lib/module/ui/components/internal/TextField.js.map +1 -1
- package/lib/module/ui/context/OxyContext.js +26 -23
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/hooks/index.js +1 -2
- package/lib/module/ui/hooks/index.js.map +1 -1
- package/lib/module/ui/hooks/useFollow.js +52 -137
- package/lib/module/ui/hooks/useFollow.js.map +1 -1
- package/lib/module/ui/hooks/useSessionSocket.js +47 -0
- package/lib/module/ui/hooks/useSessionSocket.js.map +1 -0
- package/lib/module/ui/index.js +2 -13
- package/lib/module/ui/index.js.map +1 -1
- package/lib/module/ui/navigation/OxyRouter.js +53 -61
- package/lib/module/ui/navigation/OxyRouter.js.map +1 -1
- package/lib/module/ui/screens/AccountCenterScreen.js +6 -18
- package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountOverviewScreen.js +5 -23
- package/lib/module/ui/screens/AccountOverviewScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountSettingsScreen.js +7 -15
- package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountSwitcherScreen.js +38 -67
- package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/module/ui/screens/AppInfoScreen.js +22 -45
- package/lib/module/ui/screens/AppInfoScreen.js.map +1 -1
- package/lib/module/ui/screens/FeedbackScreen.js +44 -23
- package/lib/module/ui/screens/FeedbackScreen.js.map +1 -1
- package/lib/module/ui/screens/FileManagementScreen.js +59 -78
- package/lib/module/ui/screens/FileManagementScreen.js.map +1 -1
- package/lib/module/ui/screens/PaymentGatewayScreen.js +1583 -0
- package/lib/module/ui/screens/PaymentGatewayScreen.js.map +1 -0
- package/lib/module/ui/screens/PremiumSubscriptionScreen.js +23 -37
- package/lib/module/ui/screens/PremiumSubscriptionScreen.js.map +1 -1
- package/lib/module/ui/screens/RecoverAccountScreen.js +263 -0
- package/lib/module/ui/screens/RecoverAccountScreen.js.map +1 -0
- package/lib/module/ui/screens/SessionManagementScreen.js +47 -69
- package/lib/module/ui/screens/SessionManagementScreen.js.map +1 -1
- package/lib/module/ui/screens/SignInScreen.js +100 -334
- package/lib/module/ui/screens/SignInScreen.js.map +1 -1
- package/lib/module/ui/screens/SignUpScreen.js +137 -341
- package/lib/module/ui/screens/SignUpScreen.js.map +1 -1
- package/lib/module/ui/screens/internal/SignInPasswordStep.js +186 -0
- package/lib/module/ui/screens/internal/SignInPasswordStep.js.map +1 -0
- package/lib/module/ui/screens/internal/SignInUsernameStep.js +129 -0
- package/lib/module/ui/screens/internal/SignInUsernameStep.js.map +1 -0
- package/lib/module/ui/screens/internal/SignUpIdentityStep.js +102 -0
- package/lib/module/ui/screens/internal/SignUpIdentityStep.js.map +1 -0
- package/lib/module/ui/screens/internal/SignUpSecurityStep.js +120 -0
- package/lib/module/ui/screens/internal/SignUpSecurityStep.js.map +1 -0
- package/lib/module/ui/screens/internal/SignUpSummaryStep.js +79 -0
- package/lib/module/ui/screens/internal/SignUpSummaryStep.js.map +1 -0
- package/lib/module/ui/screens/internal/SignUpWelcomeStep.js +54 -0
- package/lib/module/ui/screens/internal/SignUpWelcomeStep.js.map +1 -0
- package/lib/module/ui/screens/karma/KarmaRewardsScreen.js +16 -3
- package/lib/module/ui/screens/karma/KarmaRewardsScreen.js.map +1 -1
- package/lib/module/ui/stores/authStore.js +27 -0
- package/lib/module/ui/stores/authStore.js.map +1 -0
- package/lib/module/ui/stores/followStore.js +120 -0
- package/lib/module/ui/stores/followStore.js.map +1 -0
- package/lib/module/ui/styles/index.js +0 -1
- package/lib/module/ui/styles/index.js.map +1 -1
- package/lib/module/ui/utils/confirmAction.js +25 -0
- package/lib/module/ui/utils/confirmAction.js.map +1 -0
- package/lib/typescript/core/index.d.ts +28 -10
- package/lib/typescript/core/index.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +5 -4
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/models/secureSession.d.ts +0 -1
- package/lib/typescript/models/secureSession.d.ts.map +1 -1
- package/lib/typescript/node/index.d.ts +0 -1
- package/lib/typescript/node/index.d.ts.map +1 -1
- package/lib/typescript/ui/components/FollowButton.d.ts +1 -77
- package/lib/typescript/ui/components/FollowButton.d.ts.map +1 -1
- package/lib/typescript/ui/components/OxyPayButton.d.ts +29 -0
- package/lib/typescript/ui/components/OxyPayButton.d.ts.map +1 -0
- package/lib/typescript/ui/components/OxyProvider.d.ts.map +1 -1
- package/lib/typescript/ui/components/OxySignInButton.d.ts.map +1 -1
- package/lib/typescript/ui/components/icon/FAIRWalletIcon.d.ts +8 -0
- package/lib/typescript/ui/components/icon/FAIRWalletIcon.d.ts.map +1 -0
- package/lib/typescript/ui/components/icon/index.d.ts +1 -0
- package/lib/typescript/ui/components/icon/index.d.ts.map +1 -1
- package/lib/typescript/ui/components/index.d.ts +1 -0
- package/lib/typescript/ui/components/index.d.ts.map +1 -1
- package/lib/typescript/ui/components/internal/GroupedPillButtons.d.ts.map +1 -1
- package/lib/typescript/ui/components/internal/PinInput.d.ts +12 -0
- package/lib/typescript/ui/components/internal/PinInput.d.ts.map +1 -0
- package/lib/typescript/ui/components/internal/TextField.d.ts +1 -0
- package/lib/typescript/ui/components/internal/TextField.d.ts.map +1 -1
- package/lib/typescript/ui/context/OxyContext.d.ts +0 -1
- package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/index.d.ts +1 -2
- package/lib/typescript/ui/hooks/index.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useFollow.d.ts +14 -15
- package/lib/typescript/ui/hooks/useFollow.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useSessionSocket.d.ts +11 -0
- package/lib/typescript/ui/hooks/useSessionSocket.d.ts.map +1 -0
- package/lib/typescript/ui/index.d.ts +2 -5
- package/lib/typescript/ui/index.d.ts.map +1 -1
- package/lib/typescript/ui/navigation/OxyRouter.d.ts.map +1 -1
- package/lib/typescript/ui/navigation/types.d.ts +5 -23
- package/lib/typescript/ui/navigation/types.d.ts.map +1 -1
- package/lib/typescript/ui/screens/AccountCenterScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/AccountOverviewScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/AccountSwitcherScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/AppInfoScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/FeedbackScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/FileManagementScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/PaymentGatewayScreen.d.ts +27 -0
- package/lib/typescript/ui/screens/PaymentGatewayScreen.d.ts.map +1 -0
- package/lib/typescript/ui/screens/PremiumSubscriptionScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/RecoverAccountScreen.d.ts +8 -0
- package/lib/typescript/ui/screens/RecoverAccountScreen.d.ts.map +1 -0
- package/lib/typescript/ui/screens/SessionManagementScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/SignInScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/SignUpScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/internal/SignInPasswordStep.d.ts +27 -0
- package/lib/typescript/ui/screens/internal/SignInPasswordStep.d.ts.map +1 -0
- package/lib/typescript/ui/screens/internal/SignInUsernameStep.d.ts +26 -0
- package/lib/typescript/ui/screens/internal/SignInUsernameStep.d.ts.map +1 -0
- package/lib/typescript/ui/screens/internal/SignUpIdentityStep.d.ts +20 -0
- package/lib/typescript/ui/screens/internal/SignUpIdentityStep.d.ts.map +1 -0
- package/lib/typescript/ui/screens/internal/SignUpSecurityStep.d.ts +24 -0
- package/lib/typescript/ui/screens/internal/SignUpSecurityStep.d.ts.map +1 -0
- package/lib/typescript/ui/screens/internal/SignUpSummaryStep.d.ts +15 -0
- package/lib/typescript/ui/screens/internal/SignUpSummaryStep.d.ts.map +1 -0
- package/lib/typescript/ui/screens/internal/SignUpWelcomeStep.d.ts +13 -0
- package/lib/typescript/ui/screens/internal/SignUpWelcomeStep.d.ts.map +1 -0
- package/lib/typescript/ui/screens/karma/KarmaRewardsScreen.d.ts.map +1 -1
- package/lib/typescript/ui/stores/authStore.d.ts +14 -0
- package/lib/typescript/ui/stores/authStore.d.ts.map +1 -0
- package/lib/typescript/ui/stores/followStore.d.ts +15 -0
- package/lib/typescript/ui/stores/followStore.d.ts.map +1 -0
- package/lib/typescript/ui/styles/index.d.ts +0 -1
- package/lib/typescript/ui/styles/index.d.ts.map +1 -1
- package/lib/typescript/ui/utils/confirmAction.d.ts +7 -0
- package/lib/typescript/ui/utils/confirmAction.d.ts.map +1 -0
- package/package.json +12 -7
- package/src/core/index.ts +78 -88
- package/src/index.ts +8 -45
- package/src/models/secureSession.ts +1 -2
- package/src/node/index.ts +0 -3
- package/src/ui/components/FollowButton.tsx +100 -322
- package/src/ui/components/OxyPayButton.tsx +133 -0
- package/src/ui/components/OxyProvider.tsx +39 -201
- package/src/ui/components/OxySignInButton.tsx +13 -2
- package/src/ui/components/icon/FAIRWalletIcon.tsx +49 -0
- package/src/ui/components/icon/index.ts +1 -0
- package/src/ui/components/index.ts +1 -0
- package/src/ui/components/internal/GroupedPillButtons.tsx +12 -8
- package/src/ui/components/internal/PinInput.tsx +102 -0
- package/src/ui/components/internal/TextField.tsx +9 -0
- package/src/ui/context/OxyContext.tsx +26 -26
- package/src/ui/hooks/index.ts +1 -2
- package/src/ui/hooks/useFollow.ts +58 -129
- package/src/ui/hooks/useSessionSocket.ts +50 -0
- package/src/ui/index.ts +2 -37
- package/src/ui/navigation/OxyRouter.tsx +47 -63
- package/src/ui/navigation/types.ts +5 -26
- package/src/ui/screens/AccountCenterScreen.tsx +12 -21
- package/src/ui/screens/AccountOverviewScreen.tsx +6 -30
- package/src/ui/screens/AccountSettingsScreen.tsx +7 -22
- package/src/ui/screens/AccountSwitcherScreen.tsx +46 -88
- package/src/ui/screens/AppInfoScreen.tsx +27 -47
- package/src/ui/screens/FeedbackScreen.tsx +34 -19
- package/src/ui/screens/FileManagementScreen.tsx +293 -321
- package/src/ui/screens/PaymentGatewayScreen.tsx +1315 -0
- package/src/ui/screens/PremiumSubscriptionScreen.tsx +109 -124
- package/src/ui/screens/RecoverAccountScreen.tsx +260 -0
- package/src/ui/screens/SessionManagementScreen.tsx +65 -137
- package/src/ui/screens/SignInScreen.tsx +89 -283
- package/src/ui/screens/SignUpScreen.tsx +138 -291
- package/src/ui/screens/internal/SignInPasswordStep.tsx +179 -0
- package/src/ui/screens/internal/SignInUsernameStep.tsx +139 -0
- package/src/ui/screens/internal/SignUpIdentityStep.tsx +114 -0
- package/src/ui/screens/internal/SignUpSecurityStep.tsx +132 -0
- package/src/ui/screens/internal/SignUpSummaryStep.tsx +66 -0
- package/src/ui/screens/internal/SignUpWelcomeStep.tsx +52 -0
- package/src/ui/screens/karma/KarmaRewardsScreen.tsx +13 -3
- package/src/ui/stores/authStore.ts +24 -0
- package/src/ui/stores/followStore.ts +80 -0
- package/src/ui/styles/index.ts +0 -1
- package/src/ui/utils/confirmAction.ts +23 -0
- package/lib/commonjs/ui/components/bottomSheet/index.js +0 -37
- package/lib/commonjs/ui/components/bottomSheet/index.js.map +0 -1
- package/lib/commonjs/ui/hooks/useAuthFetch.js +0 -216
- package/lib/commonjs/ui/hooks/useAuthFetch.js.map +0 -1
- package/lib/commonjs/ui/hooks/useOxyFollow.js +0 -190
- package/lib/commonjs/ui/hooks/useOxyFollow.js.map +0 -1
- package/lib/commonjs/ui/screens/BillingManagementScreen.js +0 -636
- package/lib/commonjs/ui/screens/BillingManagementScreen.js.map +0 -1
- package/lib/commonjs/ui/store/index.js +0 -67
- package/lib/commonjs/ui/store/index.js.map +0 -1
- package/lib/commonjs/ui/store/setupOxyStore.js +0 -63
- package/lib/commonjs/ui/store/setupOxyStore.js.map +0 -1
- package/lib/commonjs/ui/store/slices/authSlice.js +0 -56
- package/lib/commonjs/ui/store/slices/authSlice.js.map +0 -1
- package/lib/commonjs/ui/store/slices/followSlice.js +0 -238
- package/lib/commonjs/ui/store/slices/followSlice.js.map +0 -1
- package/lib/commonjs/ui/store/slices/index.js +0 -129
- package/lib/commonjs/ui/store/slices/index.js.map +0 -1
- package/lib/commonjs/ui/store/slices/types.js +0 -19
- package/lib/commonjs/ui/store/slices/types.js.map +0 -1
- package/lib/commonjs/ui/styles/shadows.js +0 -123
- package/lib/commonjs/ui/styles/shadows.js.map +0 -1
- package/lib/commonjs/utils/polyfills.js +0 -42
- package/lib/commonjs/utils/polyfills.js.map +0 -1
- package/lib/module/ui/components/bottomSheet/index.js +0 -5
- package/lib/module/ui/components/bottomSheet/index.js.map +0 -1
- package/lib/module/ui/hooks/useAuthFetch.js +0 -211
- package/lib/module/ui/hooks/useAuthFetch.js.map +0 -1
- package/lib/module/ui/hooks/useOxyFollow.js +0 -186
- package/lib/module/ui/hooks/useOxyFollow.js.map +0 -1
- package/lib/module/ui/screens/BillingManagementScreen.js +0 -631
- package/lib/module/ui/screens/BillingManagementScreen.js.map +0 -1
- package/lib/module/ui/store/index.js +0 -33
- package/lib/module/ui/store/index.js.map +0 -1
- package/lib/module/ui/store/setupOxyStore.js +0 -59
- package/lib/module/ui/store/setupOxyStore.js.map +0 -1
- package/lib/module/ui/store/slices/authSlice.js +0 -48
- package/lib/module/ui/store/slices/authSlice.js.map +0 -1
- package/lib/module/ui/store/slices/followSlice.js +0 -232
- package/lib/module/ui/store/slices/followSlice.js.map +0 -1
- package/lib/module/ui/store/slices/index.js +0 -11
- package/lib/module/ui/store/slices/index.js.map +0 -1
- package/lib/module/ui/store/slices/types.js +0 -15
- package/lib/module/ui/store/slices/types.js.map +0 -1
- package/lib/module/ui/styles/shadows.js +0 -119
- package/lib/module/ui/styles/shadows.js.map +0 -1
- package/lib/module/utils/polyfills.js +0 -36
- package/lib/module/utils/polyfills.js.map +0 -1
- package/lib/typescript/types/react-redux.d.ts +0 -5
- package/lib/typescript/ui/components/bottomSheet/index.d.ts +0 -4
- package/lib/typescript/ui/components/bottomSheet/index.d.ts.map +0 -1
- package/lib/typescript/ui/hooks/useAuthFetch.d.ts +0 -34
- package/lib/typescript/ui/hooks/useAuthFetch.d.ts.map +0 -1
- package/lib/typescript/ui/hooks/useOxyFollow.d.ts +0 -81
- package/lib/typescript/ui/hooks/useOxyFollow.d.ts.map +0 -1
- package/lib/typescript/ui/screens/BillingManagementScreen.d.ts +0 -5
- package/lib/typescript/ui/screens/BillingManagementScreen.d.ts.map +0 -1
- package/lib/typescript/ui/store/index.d.ts +0 -27
- package/lib/typescript/ui/store/index.d.ts.map +0 -1
- package/lib/typescript/ui/store/setupOxyStore.d.ts +0 -29
- package/lib/typescript/ui/store/setupOxyStore.d.ts.map +0 -1
- package/lib/typescript/ui/store/slices/authSlice.d.ts +0 -32
- package/lib/typescript/ui/store/slices/authSlice.d.ts.map +0 -1
- package/lib/typescript/ui/store/slices/followSlice.d.ts +0 -120
- package/lib/typescript/ui/store/slices/followSlice.d.ts.map +0 -1
- package/lib/typescript/ui/store/slices/index.d.ts +0 -9
- package/lib/typescript/ui/store/slices/index.d.ts.map +0 -1
- package/lib/typescript/ui/store/slices/types.d.ts +0 -16
- package/lib/typescript/ui/store/slices/types.d.ts.map +0 -1
- package/lib/typescript/ui/styles/shadows.d.ts +0 -233
- package/lib/typescript/ui/styles/shadows.d.ts.map +0 -1
- package/lib/typescript/utils/polyfills.d.ts +0 -6
- package/lib/typescript/utils/polyfills.d.ts.map +0 -1
- package/src/__tests__/backend-middleware.test.ts +0 -209
- package/src/__tests__/polyfills.test.ts +0 -30
- package/src/__tests__/setup.ts +0 -43
- package/src/__tests__/ui/hooks/useAuthFetch.test.ts +0 -70
- package/src/__tests__/ui/hooks/useOxyFollow.test.tsx +0 -92
- package/src/__tests__/ui/screens/AccountSettingsScreen.test.tsx +0 -112
- package/src/__tests__/ui/store/setupOxyStore.test.ts +0 -50
- package/src/__tests__/validate-structure.js +0 -91
- package/src/__tests__/validation.js +0 -42
- package/src/types/react-redux.d.ts +0 -5
- package/src/ui/components/bottomSheet/index.tsx +0 -14
- package/src/ui/hooks/useAuthFetch.ts +0 -238
- package/src/ui/hooks/useOxyFollow.ts +0 -188
- package/src/ui/screens/BillingManagementScreen.tsx +0 -589
- package/src/ui/store/index.ts +0 -36
- package/src/ui/store/setupOxyStore.ts +0 -58
- package/src/ui/store/slices/authSlice.ts +0 -43
- package/src/ui/store/slices/followSlice.ts +0 -207
- package/src/ui/store/slices/index.ts +0 -31
- package/src/ui/store/slices/types.ts +0 -33
- package/src/ui/styles/shadows.ts +0 -112
- package/src/utils/polyfills.ts +0 -34
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Simple file structure validation for the new Redux architecture
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const fs = require('fs');
|
|
6
|
-
const path = require('path');
|
|
7
|
-
|
|
8
|
-
const requiredFiles = [
|
|
9
|
-
'src/ui/store/setupOxyStore.ts',
|
|
10
|
-
'src/ui/store/slices/authSlice.ts',
|
|
11
|
-
'src/ui/store/slices/followSlice.ts',
|
|
12
|
-
'src/ui/store/slices/types.ts',
|
|
13
|
-
'src/ui/store/slices/index.ts',
|
|
14
|
-
'src/ui/hooks/useOxyFollow.ts',
|
|
15
|
-
'docs/redux-integration.md',
|
|
16
|
-
'docs/migration-guide-redux.md',
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
const requiredExports = [
|
|
20
|
-
'setupOxyStore',
|
|
21
|
-
'authSlice',
|
|
22
|
-
'followSlice',
|
|
23
|
-
'authReducer',
|
|
24
|
-
'followReducer',
|
|
25
|
-
'useOxyFollow',
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
console.log('🔍 Validating new Redux architecture...\n');
|
|
29
|
-
|
|
30
|
-
// Check required files exist
|
|
31
|
-
let filesValid = true;
|
|
32
|
-
for (const file of requiredFiles) {
|
|
33
|
-
const fullPath = path.join(__dirname, '..', '..', file);
|
|
34
|
-
if (fs.existsSync(fullPath)) {
|
|
35
|
-
console.log(`✅ ${file}`);
|
|
36
|
-
} else {
|
|
37
|
-
console.log(`❌ ${file} - MISSING`);
|
|
38
|
-
filesValid = false;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Check key exports in files
|
|
43
|
-
const setupOxyStoreFile = path.join(__dirname, '..', 'ui', 'store', 'setupOxyStore.ts');
|
|
44
|
-
if (fs.existsSync(setupOxyStoreFile)) {
|
|
45
|
-
const content = fs.readFileSync(setupOxyStoreFile, 'utf8');
|
|
46
|
-
if (content.includes('export function setupOxyStore')) {
|
|
47
|
-
console.log('✅ setupOxyStore function exported');
|
|
48
|
-
} else {
|
|
49
|
-
console.log('❌ setupOxyStore function not found');
|
|
50
|
-
filesValid = false;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const indexFile = path.join(__dirname, '..', 'ui', 'index.ts');
|
|
55
|
-
if (fs.existsSync(indexFile)) {
|
|
56
|
-
const content = fs.readFileSync(indexFile, 'utf8');
|
|
57
|
-
const exportsFound = requiredExports.filter(exp => content.includes(exp));
|
|
58
|
-
console.log(`✅ Exports found in ui/index.ts: ${exportsFound.join(', ')}`);
|
|
59
|
-
|
|
60
|
-
if (exportsFound.length < requiredExports.length) {
|
|
61
|
-
const missing = requiredExports.filter(exp => !exportsFound.includes(exp));
|
|
62
|
-
console.log(`⚠️ Missing exports: ${missing.join(', ')}`);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Check main index file
|
|
67
|
-
const mainIndexFile = path.join(__dirname, '..', 'index.ts');
|
|
68
|
-
if (fs.existsSync(mainIndexFile)) {
|
|
69
|
-
const content = fs.readFileSync(mainIndexFile, 'utf8');
|
|
70
|
-
if (content.includes('setupOxyStore')) {
|
|
71
|
-
console.log('✅ setupOxyStore exported from main index');
|
|
72
|
-
} else {
|
|
73
|
-
console.log('❌ setupOxyStore not exported from main index');
|
|
74
|
-
filesValid = false;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
console.log('\n' + '='.repeat(50));
|
|
79
|
-
if (filesValid) {
|
|
80
|
-
console.log('🎉 All validations passed! New Redux architecture is properly implemented.');
|
|
81
|
-
console.log('\nKey features:');
|
|
82
|
-
console.log('- ✅ Framework-agnostic Redux integration');
|
|
83
|
-
console.log('- ✅ Tree-shakable with setupOxyStore.pick()');
|
|
84
|
-
console.log('- ✅ Individual slice exports');
|
|
85
|
-
console.log('- ✅ External store support');
|
|
86
|
-
console.log('- ✅ Backward compatibility');
|
|
87
|
-
console.log('- ✅ Comprehensive documentation');
|
|
88
|
-
} else {
|
|
89
|
-
console.log('❌ Some validations failed. Please check the missing files/exports.');
|
|
90
|
-
process.exit(1);
|
|
91
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Simple validation test for the new Redux architecture
|
|
3
|
-
* This test can be run to ensure the refactoring works correctly
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { configureStore } from '@reduxjs/toolkit';
|
|
7
|
-
|
|
8
|
-
// Test that setupOxyStore can be imported and used
|
|
9
|
-
try {
|
|
10
|
-
const { setupOxyStore } = require('../ui/store/setupOxyStore');
|
|
11
|
-
|
|
12
|
-
console.log('✅ setupOxyStore imported successfully');
|
|
13
|
-
|
|
14
|
-
// Test basic usage
|
|
15
|
-
const reducers = setupOxyStore();
|
|
16
|
-
console.log('✅ setupOxyStore() returns reducers:', Object.keys(reducers));
|
|
17
|
-
|
|
18
|
-
// Test tree-shaking
|
|
19
|
-
const authOnly = setupOxyStore.pick('auth');
|
|
20
|
-
console.log('✅ Tree-shaking works:', Object.keys(authOnly));
|
|
21
|
-
|
|
22
|
-
// Test with configureStore
|
|
23
|
-
const store = configureStore({
|
|
24
|
-
reducer: {
|
|
25
|
-
...setupOxyStore(),
|
|
26
|
-
custom: (state = { test: true }) => state,
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const state = store.getState();
|
|
31
|
-
console.log('✅ Store integration works:', Object.keys(state));
|
|
32
|
-
|
|
33
|
-
// Test individual exports
|
|
34
|
-
const { authSlice, followSlice } = require('../ui/store/slices');
|
|
35
|
-
console.log('✅ Individual slices exported:', authSlice.name, followSlice.name);
|
|
36
|
-
|
|
37
|
-
console.log('\n🎉 All tests passed! The new Redux architecture is working correctly.');
|
|
38
|
-
|
|
39
|
-
} catch (error) {
|
|
40
|
-
console.error('❌ Test failed:', error);
|
|
41
|
-
process.exit(1);
|
|
42
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// Re-export bottom sheet components from @gorhom/bottom-sheet
|
|
2
|
-
export {
|
|
3
|
-
BottomSheetModal,
|
|
4
|
-
BottomSheetBackdrop,
|
|
5
|
-
BottomSheetModalProvider,
|
|
6
|
-
BottomSheetView,
|
|
7
|
-
BottomSheetScrollView,
|
|
8
|
-
} from '@gorhom/bottom-sheet';
|
|
9
|
-
|
|
10
|
-
export type {
|
|
11
|
-
BottomSheetModalProps,
|
|
12
|
-
BottomSheetBackdropProps,
|
|
13
|
-
} from '@gorhom/bottom-sheet';
|
|
14
|
-
export type { BottomSheetModalMethods as BottomSheetModalRef } from '@gorhom/bottom-sheet/lib/typescript/types';
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zero Config Authenticated Fetch Hook
|
|
3
|
-
*
|
|
4
|
-
* Simple hook that provides fetch-like API with automatic authentication
|
|
5
|
-
* Leverages the existing useOxy hook and OxyProvider infrastructure
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
* const authFetch = useAuthFetch();
|
|
9
|
-
* const response = await authFetch('/api/protected');
|
|
10
|
-
* const data = await authFetch.get('/api/users');
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { useCallback } from 'react';
|
|
14
|
-
import { useOxy } from '../context/OxyContext';
|
|
15
|
-
|
|
16
|
-
export interface AuthFetchOptions extends Omit<RequestInit, 'body'> {
|
|
17
|
-
body?: any; // Allow any type for body, we'll JSON.stringify if needed
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface AuthFetchAPI {
|
|
21
|
-
// Main fetch function (drop-in replacement)
|
|
22
|
-
(input: RequestInfo | URL, init?: AuthFetchOptions): Promise<Response>;
|
|
23
|
-
|
|
24
|
-
// Convenience methods for JSON APIs
|
|
25
|
-
get: (endpoint: string, options?: AuthFetchOptions) => Promise<any>;
|
|
26
|
-
post: (endpoint: string, data?: any, options?: AuthFetchOptions) => Promise<any>;
|
|
27
|
-
put: (endpoint: string, data?: any, options?: AuthFetchOptions) => Promise<any>;
|
|
28
|
-
delete: (endpoint: string, options?: AuthFetchOptions) => Promise<any>;
|
|
29
|
-
|
|
30
|
-
// Access to auth state and methods
|
|
31
|
-
isAuthenticated: boolean;
|
|
32
|
-
user: any;
|
|
33
|
-
login: (username: string, password: string) => Promise<any>;
|
|
34
|
-
logout: () => Promise<void>;
|
|
35
|
-
signUp: (username: string, email: string, password: string) => Promise<any>;
|
|
36
|
-
|
|
37
|
-
// API configuration
|
|
38
|
-
setApiUrl: (url: string) => void;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Hook that provides authenticated fetch functionality
|
|
43
|
-
* Uses the existing OxyServices instance from useOxy context
|
|
44
|
-
*/
|
|
45
|
-
export function useAuthFetch(): AuthFetchAPI {
|
|
46
|
-
const { oxyServices, isAuthenticated, user, login, logout, signUp, activeSessionId, setApiUrl } = useOxy();
|
|
47
|
-
|
|
48
|
-
// Validate that we have the required dependencies
|
|
49
|
-
if (!oxyServices) {
|
|
50
|
-
throw new Error('useAuthFetch requires OxyServices to be initialized. Make sure your app is wrapped with OxyProvider.');
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Main fetch function with automatic auth headers
|
|
54
|
-
const authFetch = useCallback(async (input: RequestInfo | URL, init?: AuthFetchOptions): Promise<Response> => {
|
|
55
|
-
if (!oxyServices) {
|
|
56
|
-
throw new Error('OxyServices not initialized. Make sure to wrap your app in OxyProvider.');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const url = resolveURL(input, oxyServices.getBaseURL());
|
|
60
|
-
const options = await addAuthHeaders(init, oxyServices, activeSessionId || undefined, isAuthenticated);
|
|
61
|
-
|
|
62
|
-
try {
|
|
63
|
-
let response = await fetch(url, options);
|
|
64
|
-
|
|
65
|
-
// Handle token expiry and automatic refresh
|
|
66
|
-
if (response.status === 401 && isAuthenticated) {
|
|
67
|
-
// Try to refresh token if we have refresh capability
|
|
68
|
-
if (oxyServices.refreshTokens) {
|
|
69
|
-
try {
|
|
70
|
-
await oxyServices.refreshTokens();
|
|
71
|
-
const retryOptions = await addAuthHeaders(init, oxyServices, activeSessionId || undefined, isAuthenticated);
|
|
72
|
-
response = await fetch(url, retryOptions);
|
|
73
|
-
} catch (refreshError) {
|
|
74
|
-
// Refresh failed, throw authentication error
|
|
75
|
-
const error = new Error('Authentication expired. Please login again.') as any;
|
|
76
|
-
error.status = 401;
|
|
77
|
-
error.code = 'AUTH_EXPIRED';
|
|
78
|
-
throw error;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return response;
|
|
84
|
-
} catch (error) {
|
|
85
|
-
// Re-throw with additional context if needed
|
|
86
|
-
if (error instanceof Error) {
|
|
87
|
-
throw error;
|
|
88
|
-
}
|
|
89
|
-
throw new Error('Request failed');
|
|
90
|
-
}
|
|
91
|
-
}, [oxyServices, activeSessionId, isAuthenticated]);
|
|
92
|
-
|
|
93
|
-
// JSON convenience methods
|
|
94
|
-
const get = useCallback(async (endpoint: string, options?: AuthFetchOptions) => {
|
|
95
|
-
const response = await authFetch(endpoint, { ...options, method: 'GET' });
|
|
96
|
-
return handleJsonResponse(response);
|
|
97
|
-
}, [authFetch]);
|
|
98
|
-
|
|
99
|
-
const post = useCallback(async (endpoint: string, data?: any, options?: AuthFetchOptions) => {
|
|
100
|
-
const response = await authFetch(endpoint, {
|
|
101
|
-
...options,
|
|
102
|
-
method: 'POST',
|
|
103
|
-
headers: {
|
|
104
|
-
'Content-Type': 'application/json',
|
|
105
|
-
...options?.headers
|
|
106
|
-
},
|
|
107
|
-
body: data ? JSON.stringify(data) : undefined
|
|
108
|
-
});
|
|
109
|
-
return handleJsonResponse(response);
|
|
110
|
-
}, [authFetch]);
|
|
111
|
-
|
|
112
|
-
const put = useCallback(async (endpoint: string, data?: any, options?: AuthFetchOptions) => {
|
|
113
|
-
const response = await authFetch(endpoint, {
|
|
114
|
-
...options,
|
|
115
|
-
method: 'PUT',
|
|
116
|
-
headers: {
|
|
117
|
-
'Content-Type': 'application/json',
|
|
118
|
-
...options?.headers
|
|
119
|
-
},
|
|
120
|
-
body: data ? JSON.stringify(data) : undefined
|
|
121
|
-
});
|
|
122
|
-
return handleJsonResponse(response);
|
|
123
|
-
}, [authFetch]);
|
|
124
|
-
|
|
125
|
-
const del = useCallback(async (endpoint: string, options?: AuthFetchOptions) => {
|
|
126
|
-
const response = await authFetch(endpoint, { ...options, method: 'DELETE' });
|
|
127
|
-
return handleJsonResponse(response);
|
|
128
|
-
}, [authFetch]);
|
|
129
|
-
|
|
130
|
-
// Attach convenience methods and auth state to the main function
|
|
131
|
-
const fetchWithMethods = authFetch as AuthFetchAPI;
|
|
132
|
-
fetchWithMethods.get = get;
|
|
133
|
-
fetchWithMethods.post = post;
|
|
134
|
-
fetchWithMethods.put = put;
|
|
135
|
-
fetchWithMethods.delete = del;
|
|
136
|
-
fetchWithMethods.isAuthenticated = isAuthenticated;
|
|
137
|
-
fetchWithMethods.user = user;
|
|
138
|
-
fetchWithMethods.login = login;
|
|
139
|
-
fetchWithMethods.logout = logout;
|
|
140
|
-
fetchWithMethods.signUp = signUp;
|
|
141
|
-
fetchWithMethods.setApiUrl = setApiUrl;
|
|
142
|
-
|
|
143
|
-
return fetchWithMethods;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Helper functions
|
|
148
|
-
*/
|
|
149
|
-
|
|
150
|
-
function resolveURL(input: RequestInfo | URL, baseURL: string): string {
|
|
151
|
-
if (!baseURL) {
|
|
152
|
-
throw new Error('Base URL not configured. Please provide a baseURL in OxyServices configuration.');
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const url = input.toString();
|
|
156
|
-
|
|
157
|
-
// If it's already a full URL (http/https), return as is
|
|
158
|
-
if (url.startsWith('http://') || url.startsWith('https://')) {
|
|
159
|
-
return url;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Normalize base URL (remove trailing slash)
|
|
163
|
-
const normalizedBaseURL = baseURL.replace(/\/$/, '');
|
|
164
|
-
|
|
165
|
-
// If URL starts with /, it's relative to base URL
|
|
166
|
-
if (url.startsWith('/')) {
|
|
167
|
-
return `${normalizedBaseURL}${url}`;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Otherwise, append to base URL with /
|
|
171
|
-
return `${normalizedBaseURL}/${url}`;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
async function addAuthHeaders(init?: AuthFetchOptions, oxyServices?: any, activeSessionId?: string, isAuthenticated?: boolean): Promise<RequestInit> {
|
|
175
|
-
const headers = new Headers(init?.headers);
|
|
176
|
-
|
|
177
|
-
// Add auth header if user is authenticated
|
|
178
|
-
if (isAuthenticated && oxyServices && !headers.has('Authorization')) {
|
|
179
|
-
try {
|
|
180
|
-
// First try to get regular JWT access token
|
|
181
|
-
let accessToken = oxyServices.getAccessToken?.();
|
|
182
|
-
|
|
183
|
-
// If no JWT token but we have a secure session, try to get token from session
|
|
184
|
-
if (!accessToken && activeSessionId) {
|
|
185
|
-
try {
|
|
186
|
-
const tokenData = await oxyServices.getTokenBySession(activeSessionId);
|
|
187
|
-
accessToken = tokenData.accessToken;
|
|
188
|
-
} catch (error) {
|
|
189
|
-
// Silent fail - will attempt request without token
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
if (accessToken) {
|
|
194
|
-
headers.set('Authorization', `Bearer ${accessToken}`);
|
|
195
|
-
}
|
|
196
|
-
} catch (error) {
|
|
197
|
-
// Silent fail - will attempt request without token
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
const body = init?.body;
|
|
202
|
-
const processedBody = body && typeof body === 'object' && !(body instanceof FormData) && !(body instanceof URLSearchParams)
|
|
203
|
-
? JSON.stringify(body)
|
|
204
|
-
: body;
|
|
205
|
-
|
|
206
|
-
return {
|
|
207
|
-
...init,
|
|
208
|
-
headers,
|
|
209
|
-
body: processedBody
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
async function handleJsonResponse(response: Response): Promise<any> {
|
|
214
|
-
if (!response.ok) {
|
|
215
|
-
let errorMessage = `HTTP ${response.status}: ${response.statusText}`;
|
|
216
|
-
|
|
217
|
-
try {
|
|
218
|
-
const errorData = await response.json();
|
|
219
|
-
errorMessage = errorData.message || errorData.error || errorMessage;
|
|
220
|
-
} catch {
|
|
221
|
-
// Ignore JSON parsing errors
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
const error = new Error(errorMessage) as any;
|
|
225
|
-
error.status = response.status;
|
|
226
|
-
error.response = response;
|
|
227
|
-
throw error;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
try {
|
|
231
|
-
return await response.json();
|
|
232
|
-
} catch {
|
|
233
|
-
// If response isn't JSON, return the response itself
|
|
234
|
-
return response;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
export default useAuthFetch;
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { useDispatch, useSelector } from 'react-redux';
|
|
2
|
-
import { useCallback, useMemo } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
toggleFollowUser,
|
|
5
|
-
setFollowingStatus,
|
|
6
|
-
clearFollowError,
|
|
7
|
-
fetchFollowStatus,
|
|
8
|
-
followSelectors
|
|
9
|
-
} from '../store/slices/followSlice';
|
|
10
|
-
import type { FollowState } from '../store/slices/types';
|
|
11
|
-
import { useOxy } from '../context/OxyContext';
|
|
12
|
-
|
|
13
|
-
// Generic type for state that includes follow slice
|
|
14
|
-
interface StateWithFollow {
|
|
15
|
-
follow: FollowState;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Memoized selector to prevent unnecessary re-renders
|
|
19
|
-
const createFollowSelector = (userId: string) => (state: StateWithFollow) => ({
|
|
20
|
-
isFollowing: followSelectors.selectIsUserFollowed(state, userId),
|
|
21
|
-
isLoading: followSelectors.selectIsUserLoading(state, userId),
|
|
22
|
-
error: followSelectors.selectUserError(state, userId),
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// Memoized selector for multiple users
|
|
26
|
-
const createMultipleFollowSelector = (userIds: string[]) => (state: StateWithFollow) => {
|
|
27
|
-
const followData: Record<string, { isFollowing: boolean; isLoading: boolean; error: string | null }> = {};
|
|
28
|
-
|
|
29
|
-
for (const userId of userIds) {
|
|
30
|
-
followData[userId] = {
|
|
31
|
-
isFollowing: followSelectors.selectIsUserFollowed(state, userId),
|
|
32
|
-
isLoading: followSelectors.selectIsUserLoading(state, userId),
|
|
33
|
-
error: followSelectors.selectUserError(state, userId),
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const followState = state.follow;
|
|
38
|
-
return {
|
|
39
|
-
followData,
|
|
40
|
-
isAnyLoading: userIds.some(uid => followState.loadingUsers[uid]),
|
|
41
|
-
hasAnyError: userIds.some(uid => followState.errors[uid]),
|
|
42
|
-
allFollowing: userIds.every(uid => followState.followingUsers[uid]),
|
|
43
|
-
allNotFollowing: userIds.every(uid => !followState.followingUsers[uid]),
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Custom hook for managing follow/unfollow functionality
|
|
49
|
-
* Works with any Redux store that includes the Oxy follow reducer
|
|
50
|
-
* Optimized to prevent unnecessary re-renders
|
|
51
|
-
* Can handle both single user and multiple users
|
|
52
|
-
*/
|
|
53
|
-
export const useOxyFollow = (userId?: string | string[]) => {
|
|
54
|
-
const dispatch = useDispatch();
|
|
55
|
-
const { oxyServices } = useOxy();
|
|
56
|
-
|
|
57
|
-
// Memoize user IDs to prevent recreation on every render
|
|
58
|
-
const userIds = useMemo(() => {
|
|
59
|
-
return Array.isArray(userId) ? userId : userId ? [userId] : [];
|
|
60
|
-
}, [userId]);
|
|
61
|
-
|
|
62
|
-
const isSingleUser = typeof userId === 'string';
|
|
63
|
-
|
|
64
|
-
// Memoize selectors to prevent recreation
|
|
65
|
-
const singleUserSelector = useMemo(() => {
|
|
66
|
-
return isSingleUser && userId ? createFollowSelector(userId) : null;
|
|
67
|
-
}, [isSingleUser, userId]);
|
|
68
|
-
|
|
69
|
-
const multipleUserSelector = useMemo(() => {
|
|
70
|
-
return !isSingleUser ? createMultipleFollowSelector(userIds) : null;
|
|
71
|
-
}, [isSingleUser, userIds]);
|
|
72
|
-
|
|
73
|
-
// Use appropriate selector based on mode
|
|
74
|
-
const singleUserData = useSelector(singleUserSelector || (() => ({ isFollowing: false, isLoading: false, error: null })));
|
|
75
|
-
const multipleUserData = useSelector(multipleUserSelector || (() => ({
|
|
76
|
-
followData: {},
|
|
77
|
-
isAnyLoading: false,
|
|
78
|
-
hasAnyError: false,
|
|
79
|
-
allFollowing: false,
|
|
80
|
-
allNotFollowing: true
|
|
81
|
-
})));
|
|
82
|
-
|
|
83
|
-
// Memoized callbacks to prevent recreation on every render
|
|
84
|
-
const toggleFollow = useCallback(async () => {
|
|
85
|
-
if (!isSingleUser || !userId) throw new Error('toggleFollow is only available for single user mode');
|
|
86
|
-
|
|
87
|
-
try {
|
|
88
|
-
const result = await dispatch(toggleFollowUser({
|
|
89
|
-
userId,
|
|
90
|
-
oxyServices,
|
|
91
|
-
isCurrentlyFollowing: singleUserData.isFollowing
|
|
92
|
-
})).unwrap();
|
|
93
|
-
return result;
|
|
94
|
-
} catch (error) {
|
|
95
|
-
throw error;
|
|
96
|
-
}
|
|
97
|
-
}, [dispatch, userId, oxyServices, singleUserData.isFollowing, isSingleUser]);
|
|
98
|
-
|
|
99
|
-
const setFollowStatus = useCallback((following: boolean) => {
|
|
100
|
-
if (!isSingleUser || !userId) throw new Error('setFollowStatus is only available for single user mode');
|
|
101
|
-
dispatch(setFollowingStatus({ userId, isFollowing: following }));
|
|
102
|
-
}, [dispatch, userId, isSingleUser]);
|
|
103
|
-
|
|
104
|
-
const fetchStatus = useCallback(async () => {
|
|
105
|
-
if (!isSingleUser || !userId) throw new Error('fetchStatus is only available for single user mode');
|
|
106
|
-
|
|
107
|
-
try {
|
|
108
|
-
await dispatch(fetchFollowStatus({ userId, oxyServices })).unwrap();
|
|
109
|
-
} catch (error) {
|
|
110
|
-
console.warn(`Failed to fetch follow status for user ${userId}:`, error);
|
|
111
|
-
}
|
|
112
|
-
}, [dispatch, userId, oxyServices, isSingleUser]);
|
|
113
|
-
|
|
114
|
-
const clearError = useCallback(() => {
|
|
115
|
-
if (!isSingleUser || !userId) throw new Error('clearError is only available for single user mode');
|
|
116
|
-
dispatch(clearFollowError(userId));
|
|
117
|
-
}, [dispatch, userId, isSingleUser]);
|
|
118
|
-
|
|
119
|
-
// Multiple user callbacks
|
|
120
|
-
const toggleFollowForUser = useCallback(async (targetUserId: string) => {
|
|
121
|
-
const currentState = multipleUserData.followData[targetUserId]?.isFollowing ?? false;
|
|
122
|
-
try {
|
|
123
|
-
const result = await dispatch(toggleFollowUser({
|
|
124
|
-
userId: targetUserId,
|
|
125
|
-
oxyServices,
|
|
126
|
-
isCurrentlyFollowing: currentState
|
|
127
|
-
})).unwrap();
|
|
128
|
-
return result;
|
|
129
|
-
} catch (error) {
|
|
130
|
-
throw error;
|
|
131
|
-
}
|
|
132
|
-
}, [dispatch, oxyServices, multipleUserData.followData]);
|
|
133
|
-
|
|
134
|
-
const setFollowStatusForUser = useCallback((targetUserId: string, following: boolean) => {
|
|
135
|
-
dispatch(setFollowingStatus({ userId: targetUserId, isFollowing: following }));
|
|
136
|
-
}, [dispatch]);
|
|
137
|
-
|
|
138
|
-
const fetchStatusForUser = useCallback(async (targetUserId: string) => {
|
|
139
|
-
try {
|
|
140
|
-
await dispatch(fetchFollowStatus({ userId: targetUserId, oxyServices })).unwrap();
|
|
141
|
-
} catch (error) {
|
|
142
|
-
console.warn(`Failed to fetch follow status for user ${targetUserId}:`, error);
|
|
143
|
-
}
|
|
144
|
-
}, [dispatch, oxyServices]);
|
|
145
|
-
|
|
146
|
-
const fetchAllStatuses = useCallback(async () => {
|
|
147
|
-
const promises = userIds.map(uid =>
|
|
148
|
-
dispatch(fetchFollowStatus({ userId: uid, oxyServices })).unwrap().catch((error: any) => {
|
|
149
|
-
console.warn(`Failed to fetch follow status for user ${uid}:`, error);
|
|
150
|
-
})
|
|
151
|
-
);
|
|
152
|
-
await Promise.all(promises);
|
|
153
|
-
}, [dispatch, userIds, oxyServices]);
|
|
154
|
-
|
|
155
|
-
const clearErrorForUser = useCallback((targetUserId: string) => {
|
|
156
|
-
dispatch(clearFollowError(targetUserId));
|
|
157
|
-
}, [dispatch]);
|
|
158
|
-
|
|
159
|
-
// Return appropriate interface based on mode
|
|
160
|
-
if (isSingleUser && userId) {
|
|
161
|
-
return {
|
|
162
|
-
isFollowing: singleUserData.isFollowing,
|
|
163
|
-
isLoading: singleUserData.isLoading,
|
|
164
|
-
error: singleUserData.error,
|
|
165
|
-
toggleFollow,
|
|
166
|
-
setFollowStatus,
|
|
167
|
-
fetchStatus,
|
|
168
|
-
clearError,
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return {
|
|
173
|
-
followData: multipleUserData.followData,
|
|
174
|
-
toggleFollowForUser,
|
|
175
|
-
setFollowStatusForUser,
|
|
176
|
-
fetchStatusForUser,
|
|
177
|
-
fetchAllStatuses,
|
|
178
|
-
clearErrorForUser,
|
|
179
|
-
// Helper methods
|
|
180
|
-
isAnyLoading: multipleUserData.isAnyLoading,
|
|
181
|
-
hasAnyError: multipleUserData.hasAnyError,
|
|
182
|
-
allFollowing: multipleUserData.allFollowing,
|
|
183
|
-
allNotFollowing: multipleUserData.allNotFollowing,
|
|
184
|
-
};
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
// Backward compatibility alias
|
|
188
|
-
export const useFollow = useOxyFollow;
|