@bigbinary/neeto-commons-rn 1.8.5 → 2.0.3
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 +64 -0
- package/eslint-config/index.js +84 -17
- package/eslint-config/rules/no-dangling-constants.js +1 -1
- package/lib/typescript/api/app_version.d.ts +10 -0
- package/lib/typescript/api/app_version.d.ts.map +1 -0
- package/lib/typescript/api/auth.d.ts +26 -0
- package/lib/typescript/api/auth.d.ts.map +1 -0
- package/lib/typescript/api/global_roles.d.ts +10 -0
- package/lib/typescript/api/global_roles.d.ts.map +1 -0
- package/lib/typescript/api/notifications.d.ts +38 -0
- package/lib/typescript/api/notifications.d.ts.map +1 -0
- package/lib/typescript/api/organization_roles.d.ts +11 -0
- package/lib/typescript/api/organization_roles.d.ts.map +1 -0
- package/lib/typescript/api/profile.d.ts +15 -0
- package/lib/typescript/api/profile.d.ts.map +1 -0
- package/lib/typescript/api/team_members.d.ts +34 -0
- package/lib/typescript/api/team_members.d.ts.map +1 -0
- package/lib/typescript/auth/index.d.ts +3 -0
- package/lib/typescript/auth/index.d.ts.map +1 -0
- package/lib/typescript/components/AppVersion.d.ts +2 -0
- package/lib/typescript/components/AppVersion.d.ts.map +1 -0
- package/lib/typescript/components/BottomSheet.d.ts +9 -0
- package/lib/typescript/components/BottomSheet.d.ts.map +1 -0
- package/lib/typescript/components/BottomSheetMenu.d.ts +7 -0
- package/lib/typescript/components/BottomSheetMenu.d.ts.map +1 -0
- package/lib/typescript/components/ConfirmSheet.d.ts +15 -0
- package/lib/typescript/components/ConfirmSheet.d.ts.map +1 -0
- package/lib/typescript/components/EmptyView.d.ts +19 -0
- package/lib/typescript/components/EmptyView.d.ts.map +1 -0
- package/lib/typescript/components/Header/BaseHeader.d.ts +7 -0
- package/lib/typescript/components/Header/BaseHeader.d.ts.map +1 -0
- package/lib/typescript/components/Header/ScreenHeader.d.ts +7 -0
- package/lib/typescript/components/Header/ScreenHeader.d.ts.map +1 -0
- package/lib/typescript/components/Header.d.ts +22 -0
- package/lib/typescript/components/Header.d.ts.map +1 -0
- package/lib/typescript/components/HyperlinkText.d.ts +17 -0
- package/lib/typescript/components/HyperlinkText.d.ts.map +1 -0
- package/lib/typescript/components/LineLoader.d.ts +13 -0
- package/lib/typescript/components/LineLoader.d.ts.map +1 -0
- package/lib/typescript/components/NotificationIcon.d.ts +6 -0
- package/lib/typescript/components/NotificationIcon.d.ts.map +1 -0
- package/lib/typescript/components/NotificationPreferenceList.d.ts +14 -0
- package/lib/typescript/components/NotificationPreferenceList.d.ts.map +1 -0
- package/lib/typescript/components/OfflineScreen.d.ts +7 -0
- package/lib/typescript/components/OfflineScreen.d.ts.map +1 -0
- package/lib/typescript/components/OrganizationItem.d.ts +8 -0
- package/lib/typescript/components/OrganizationItem.d.ts.map +1 -0
- package/lib/typescript/components/SocialButton.d.ts +11 -0
- package/lib/typescript/components/SocialButton.d.ts.map +1 -0
- package/lib/typescript/components/TextWithUrl.d.ts +7 -0
- package/lib/typescript/components/TextWithUrl.d.ts.map +1 -0
- package/lib/typescript/components/ToggleSwitch.d.ts +8 -0
- package/lib/typescript/components/ToggleSwitch.d.ts.map +1 -0
- package/lib/typescript/components/WorkspaceSwitcherPane.d.ts +9 -0
- package/lib/typescript/components/WorkspaceSwitcherPane.d.ts.map +1 -0
- package/lib/typescript/components/constants.d.ts +7 -0
- package/lib/typescript/components/constants.d.ts.map +1 -0
- package/lib/typescript/components/index.d.ts +14 -0
- package/lib/typescript/components/index.d.ts.map +1 -0
- package/lib/typescript/config/axios/caseConversion.d.ts +4 -0
- package/lib/typescript/config/axios/caseConversion.d.ts.map +1 -0
- package/lib/typescript/config/axios/constants.d.ts +4 -0
- package/lib/typescript/config/axios/constants.d.ts.map +1 -0
- package/lib/typescript/config/axios/index.d.ts +13 -0
- package/lib/typescript/config/axios/index.d.ts.map +1 -0
- package/lib/typescript/config/axios/networkErrorHandler.d.ts +5 -0
- package/lib/typescript/config/axios/networkErrorHandler.d.ts.map +1 -0
- package/lib/typescript/config/axios/paramsSerializer.d.ts +3 -0
- package/lib/typescript/config/axios/paramsSerializer.d.ts.map +1 -0
- package/lib/typescript/config/axios/types.d.ts +10 -0
- package/lib/typescript/config/axios/types.d.ts.map +1 -0
- package/lib/typescript/config/bugsnag.d.ts +4 -0
- package/lib/typescript/config/bugsnag.d.ts.map +1 -0
- package/lib/typescript/config/dayjs.d.ts +23 -0
- package/lib/typescript/config/dayjs.d.ts.map +1 -0
- package/lib/typescript/config/googleSignin.d.ts +2 -0
- package/lib/typescript/config/googleSignin.d.ts.map +1 -0
- package/lib/typescript/config/index.d.ts +2 -0
- package/lib/typescript/config/index.d.ts.map +1 -0
- package/lib/typescript/config/validations.d.ts +2 -0
- package/lib/typescript/config/validations.d.ts.map +1 -0
- package/lib/typescript/constants/index.d.ts +8 -0
- package/lib/typescript/constants/index.d.ts.map +1 -0
- package/lib/typescript/contexts/index.d.ts +2 -0
- package/lib/typescript/contexts/index.d.ts.map +1 -0
- package/lib/typescript/contexts/localization.d.ts +26 -0
- package/lib/typescript/contexts/localization.d.ts.map +1 -0
- package/lib/typescript/helpers/asyncStore.d.ts +6 -0
- package/lib/typescript/helpers/asyncStore.d.ts.map +1 -0
- package/lib/typescript/helpers/index.d.ts +2 -0
- package/lib/typescript/helpers/index.d.ts.map +1 -0
- package/lib/typescript/helpers/keychain.d.ts +4 -0
- package/lib/typescript/helpers/keychain.d.ts.map +1 -0
- package/lib/typescript/helpers/notifications/apnsToken.d.ts +2 -0
- package/lib/typescript/helpers/notifications/apnsToken.d.ts.map +1 -0
- package/lib/typescript/helpers/notifications/constants.d.ts +5 -0
- package/lib/typescript/helpers/notifications/constants.d.ts.map +1 -0
- package/lib/typescript/helpers/notifications/getDeviceToken.d.ts +2 -0
- package/lib/typescript/helpers/notifications/getDeviceToken.d.ts.map +1 -0
- package/lib/typescript/helpers/notifications/index.d.ts +4 -0
- package/lib/typescript/helpers/notifications/index.d.ts.map +1 -0
- package/lib/typescript/helpers/notifications/registerBackgroundHandlers.d.ts +3 -0
- package/lib/typescript/helpers/notifications/registerBackgroundHandlers.d.ts.map +1 -0
- package/lib/typescript/helpers/notifications/types.d.ts +19 -0
- package/lib/typescript/helpers/notifications/types.d.ts.map +1 -0
- package/lib/typescript/helpers/notifications/usePushNotification.d.ts +7 -0
- package/lib/typescript/helpers/notifications/usePushNotification.d.ts.map +1 -0
- package/lib/typescript/helpers/scale.d.ts +2 -0
- package/lib/typescript/helpers/scale.d.ts.map +1 -0
- package/lib/typescript/helpers/utils.d.ts +5 -0
- package/lib/typescript/helpers/utils.d.ts.map +1 -0
- package/lib/typescript/hooks/index.d.ts +3 -0
- package/lib/typescript/hooks/index.d.ts.map +1 -0
- package/lib/typescript/hooks/query/queryKeys.d.ts +9 -0
- package/lib/typescript/hooks/query/queryKeys.d.ts.map +1 -0
- package/lib/typescript/hooks/query/useAppVersionApi.d.ts +2 -0
- package/lib/typescript/hooks/query/useAppVersionApi.d.ts.map +1 -0
- package/lib/typescript/hooks/query/useAuth.d.ts +27 -0
- package/lib/typescript/hooks/query/useAuth.d.ts.map +1 -0
- package/lib/typescript/hooks/query/useNotification.d.ts +19 -0
- package/lib/typescript/hooks/query/useNotification.d.ts.map +1 -0
- package/lib/typescript/hooks/query/useProfile.d.ts +9 -0
- package/lib/typescript/hooks/query/useProfile.d.ts.map +1 -0
- package/lib/typescript/hooks/query/useRolesApi.d.ts +4 -0
- package/lib/typescript/hooks/query/useRolesApi.d.ts.map +1 -0
- package/lib/typescript/hooks/query/useTeamMembersApi.d.ts +23 -0
- package/lib/typescript/hooks/query/useTeamMembersApi.d.ts.map +1 -0
- package/lib/typescript/hooks/useAppState.d.ts +2 -0
- package/lib/typescript/hooks/useAppState.d.ts.map +1 -0
- package/lib/typescript/hooks/usePushNotificationPermissions.d.ts +2 -0
- package/lib/typescript/hooks/usePushNotificationPermissions.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +9 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/initializers/index.d.ts +3 -0
- package/lib/typescript/initializers/index.d.ts.map +1 -0
- package/lib/typescript/initializers/logRocket.d.ts +2 -0
- package/lib/typescript/initializers/logRocket.d.ts.map +1 -0
- package/lib/typescript/localization/i18n.d.ts +4 -0
- package/lib/typescript/localization/i18n.d.ts.map +1 -0
- package/lib/typescript/localization/index.d.ts +7 -0
- package/lib/typescript/localization/index.d.ts.map +1 -0
- package/lib/typescript/navigation/navigationService.d.ts +14 -0
- package/lib/typescript/navigation/navigationService.d.ts.map +1 -0
- package/lib/typescript/navigation/screenNames.d.ts +10 -0
- package/lib/typescript/navigation/screenNames.d.ts.map +1 -0
- package/lib/typescript/navigation/stacks.d.ts +3 -0
- package/lib/typescript/navigation/stacks.d.ts.map +1 -0
- package/lib/typescript/navigation/types.d.ts +24 -0
- package/lib/typescript/navigation/types.d.ts.map +1 -0
- package/lib/typescript/providers/NeetoCommonsRNProvider.d.ts +14 -0
- package/lib/typescript/providers/NeetoCommonsRNProvider.d.ts.map +1 -0
- package/lib/typescript/providers/index.d.ts +2 -0
- package/lib/typescript/providers/index.d.ts.map +1 -0
- package/lib/typescript/screens/NotificationsScreen.d.ts +11 -0
- package/lib/typescript/screens/NotificationsScreen.d.ts.map +1 -0
- package/lib/typescript/screens/authentication/AuthOptions.d.ts +7 -0
- package/lib/typescript/screens/authentication/AuthOptions.d.ts.map +1 -0
- package/lib/typescript/screens/authentication/IncompleteOnboardingInfo.d.ts +4 -0
- package/lib/typescript/screens/authentication/IncompleteOnboardingInfo.d.ts.map +1 -0
- package/lib/typescript/screens/authentication/LoginScreen.d.ts +3 -0
- package/lib/typescript/screens/authentication/LoginScreen.d.ts.map +1 -0
- package/lib/typescript/screens/authentication/OTPVerificationScreen.d.ts +4 -0
- package/lib/typescript/screens/authentication/OTPVerificationScreen.d.ts.map +1 -0
- package/lib/typescript/screens/authentication/Organization.d.ts +11 -0
- package/lib/typescript/screens/authentication/Organization.d.ts.map +1 -0
- package/lib/typescript/screens/authentication/SubDomainScreen.d.ts +4 -0
- package/lib/typescript/screens/authentication/SubDomainScreen.d.ts.map +1 -0
- package/lib/typescript/screens/authentication/constants.d.ts +17 -0
- package/lib/typescript/screens/authentication/constants.d.ts.map +1 -0
- package/lib/typescript/screens/index.d.ts +11 -0
- package/lib/typescript/screens/index.d.ts.map +1 -0
- package/lib/typescript/screens/profile/ChatWidget.d.ts +3 -0
- package/lib/typescript/screens/profile/ChatWidget.d.ts.map +1 -0
- package/lib/typescript/screens/profile/ProfileScreen.d.ts +12 -0
- package/lib/typescript/screens/profile/ProfileScreen.d.ts.map +1 -0
- package/lib/typescript/screens/profile/UserData.d.ts +21 -0
- package/lib/typescript/screens/profile/UserData.d.ts.map +1 -0
- package/lib/typescript/screens/team_members/Add.d.ts +4 -0
- package/lib/typescript/screens/team_members/Add.d.ts.map +1 -0
- package/lib/typescript/screens/team_members/Card.d.ts +9 -0
- package/lib/typescript/screens/team_members/Card.d.ts.map +1 -0
- package/lib/typescript/screens/team_members/Checkbox.d.ts +11 -0
- package/lib/typescript/screens/team_members/Checkbox.d.ts.map +1 -0
- package/lib/typescript/screens/team_members/Edit.d.ts +5 -0
- package/lib/typescript/screens/team_members/Edit.d.ts.map +1 -0
- package/lib/typescript/screens/team_members/Email.d.ts +11 -0
- package/lib/typescript/screens/team_members/Email.d.ts.map +1 -0
- package/lib/typescript/screens/team_members/LoadingCard.d.ts +6 -0
- package/lib/typescript/screens/team_members/LoadingCard.d.ts.map +1 -0
- package/lib/typescript/screens/team_members/ProductSelect.d.ts +11 -0
- package/lib/typescript/screens/team_members/ProductSelect.d.ts.map +1 -0
- package/lib/typescript/screens/team_members/RolesRadioGroup.d.ts +14 -0
- package/lib/typescript/screens/team_members/RolesRadioGroup.d.ts.map +1 -0
- package/lib/typescript/screens/team_members/SaveButtons.d.ts +10 -0
- package/lib/typescript/screens/team_members/SaveButtons.d.ts.map +1 -0
- package/lib/typescript/screens/team_members/constants.d.ts +16 -0
- package/lib/typescript/screens/team_members/constants.d.ts.map +1 -0
- package/lib/typescript/screens/team_members/index.d.ts +16 -0
- package/lib/typescript/screens/team_members/index.d.ts.map +1 -0
- package/lib/typescript/screens/team_members/utils.d.ts +20 -0
- package/lib/typescript/screens/team_members/utils.d.ts.map +1 -0
- package/lib/typescript/slices/auth.d.ts +31 -0
- package/lib/typescript/slices/auth.d.ts.map +1 -0
- package/lib/typescript/slices/index.d.ts +6 -0
- package/lib/typescript/slices/index.d.ts.map +1 -0
- package/lib/typescript/store/hooks.d.ts +6 -0
- package/lib/typescript/store/hooks.d.ts.map +1 -0
- package/lib/typescript/store/index.d.ts +18 -0
- package/lib/typescript/store/index.d.ts.map +1 -0
- package/lib/typescript/store/utils.d.ts +8 -0
- package/lib/typescript/store/utils.d.ts.map +1 -0
- package/lib/typescript/utils/apiHelpers.d.ts +5 -0
- package/lib/typescript/utils/apiHelpers.d.ts.map +1 -0
- package/package.json +267 -70
- package/src/api/app_version.ts +24 -0
- package/src/api/auth.ts +68 -0
- package/src/api/global_roles.ts +15 -0
- package/src/api/notifications.ts +66 -0
- package/src/api/organization_roles.ts +17 -0
- package/src/api/profile.ts +17 -0
- package/src/api/team_members.ts +39 -0
- package/src/assets/images/apple-logo.svg +3 -0
- package/src/assets/images/google-logo.svg +6 -0
- package/src/auth/index.ts +2 -0
- package/src/components/AppVersion.ts +154 -0
- package/src/components/BottomSheet.ts +9 -0
- package/src/components/BottomSheetMenu.ts +6 -0
- package/src/components/ConfirmSheet.ts +15 -0
- package/src/components/EmptyView.tsx +40 -0
- package/src/components/Header/BaseHeader.ts +6 -0
- package/src/components/Header/ScreenHeader.ts +6 -0
- package/src/components/Header.tsx +139 -0
- package/src/components/HyperlinkText.tsx +34 -0
- package/src/components/LineLoader.tsx +23 -0
- package/src/components/NotificationIcon.tsx +53 -0
- package/src/components/NotificationPreferenceList.tsx +132 -0
- package/src/components/OfflineScreen.tsx +89 -0
- package/src/components/OrganizationItem.tsx +67 -0
- package/src/components/SocialButton.tsx +78 -0
- package/src/components/TextWithUrl.ts +6 -0
- package/src/components/ToggleSwitch.tsx +89 -0
- package/src/components/WorkspaceSwitcherPane.tsx +113 -0
- package/src/components/constants.ts +16 -0
- package/src/components/index.ts +13 -0
- package/src/config/axios/caseConversion.ts +60 -0
- package/src/config/axios/constants.ts +17 -0
- package/src/config/axios/index.ts +291 -0
- package/src/config/axios/networkErrorHandler.ts +47 -0
- package/src/config/axios/paramsSerializer.ts +9 -0
- package/src/config/axios/types.ts +13 -0
- package/src/config/bugsnag.ts +48 -0
- package/src/config/dayjs.ts +42 -0
- package/src/config/googleSignin.ts +36 -0
- package/src/config/index.ts +11 -0
- package/src/config/validations.ts +15 -0
- package/src/constants/index.ts +9 -0
- package/src/contexts/index.ts +4 -0
- package/src/contexts/localization.tsx +183 -0
- package/src/helpers/asyncStore.ts +39 -0
- package/src/helpers/index.ts +1 -0
- package/src/helpers/keychain.ts +46 -0
- package/src/helpers/notifications/apnsToken.ts +69 -0
- package/src/helpers/notifications/constants.ts +34 -0
- package/src/helpers/notifications/getDeviceToken.ts +17 -0
- package/src/helpers/notifications/index.ts +3 -0
- package/src/helpers/notifications/registerBackgroundHandlers.ts +62 -0
- package/src/helpers/notifications/types.ts +27 -0
- package/src/helpers/notifications/usePushNotification.ts +208 -0
- package/src/helpers/scale.ts +4 -0
- package/src/helpers/utils.ts +68 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/query/queryKeys.ts +8 -0
- package/src/hooks/query/useAppVersionApi.ts +12 -0
- package/src/hooks/query/useAuth.ts +253 -0
- package/src/hooks/query/useNotification.ts +130 -0
- package/src/hooks/query/useProfile.ts +21 -0
- package/src/hooks/query/useRolesApi.ts +25 -0
- package/src/hooks/query/useTeamMembersApi.ts +109 -0
- package/src/hooks/useAppState.ts +16 -0
- package/src/hooks/usePushNotificationPermissions.ts +111 -0
- package/src/index.ts +8 -0
- package/src/initializers/index.ts +3 -0
- package/src/initializers/logRocket.ts +25 -0
- package/src/localization/i18n.ts +19 -0
- package/src/localization/index.ts +14 -0
- package/src/navigation/navigationService.ts +37 -0
- package/src/navigation/screenNames.ts +11 -0
- package/src/navigation/stacks.tsx +30 -0
- package/src/navigation/types.ts +19 -0
- package/src/providers/NeetoCommonsRNProvider.tsx +77 -0
- package/src/providers/index.ts +1 -0
- package/src/screens/NotificationsScreen.tsx +290 -0
- package/src/screens/authentication/AuthOptions.tsx +254 -0
- package/src/screens/authentication/IncompleteOnboardingInfo.tsx +110 -0
- package/src/screens/authentication/LoginScreen.tsx +170 -0
- package/src/screens/authentication/OTPVerificationScreen.tsx +235 -0
- package/src/screens/authentication/Organization.tsx +102 -0
- package/src/screens/authentication/SubDomainScreen.tsx +176 -0
- package/src/screens/authentication/constants.ts +30 -0
- package/src/screens/index.ts +10 -0
- package/src/screens/profile/ChatWidget.tsx +8 -0
- package/src/screens/profile/ProfileScreen.tsx +251 -0
- package/src/screens/profile/UserData.tsx +92 -0
- package/src/screens/team_members/Add.tsx +248 -0
- package/src/screens/team_members/Card.tsx +124 -0
- package/src/screens/team_members/Checkbox.tsx +88 -0
- package/src/screens/team_members/Edit.tsx +171 -0
- package/src/screens/team_members/Email.tsx +59 -0
- package/src/screens/team_members/LoadingCard.tsx +75 -0
- package/src/screens/team_members/ProductSelect.tsx +218 -0
- package/src/screens/team_members/RolesRadioGroup.tsx +135 -0
- package/src/screens/team_members/SaveButtons.tsx +62 -0
- package/src/screens/team_members/constants.ts +33 -0
- package/src/screens/team_members/index.tsx +223 -0
- package/src/screens/team_members/utils.ts +84 -0
- package/src/slices/auth.ts +86 -0
- package/src/slices/index.ts +7 -0
- package/src/store/hooks.ts +8 -0
- package/src/store/index.ts +47 -0
- package/src/store/utils.ts +36 -0
- package/src/utils/apiHelpers.ts +7 -0
- package/types/assets.d.ts +38 -0
- package/types/neeto-icons-rn.d.ts +548 -0
- package/api/app_version.js +0 -1
- package/api/auth.js +0 -1
- package/api/global_roles.js +0 -1
- package/api/notifications.js +0 -1
- package/api/organization_roles.js +0 -1
- package/api/profile.js +0 -1
- package/api/team_members.js +0 -1
- package/auth/index.d.ts +0 -9
- package/auth/index.js +0 -1
- package/components/AppVersion.js +0 -1
- package/components/BottomSheet.js +0 -1
- package/components/BottomSheetMenu.js +0 -1
- package/components/ConfirmSheet.js +0 -1
- package/components/EmptyView.js +0 -1
- package/components/Header/BaseHeader.js +0 -1
- package/components/Header/ScreenHeader.js +0 -1
- package/components/Header.js +0 -1
- package/components/HyperlinkText.js +0 -1
- package/components/LineLoader.js +0 -1
- package/components/NotificationIcon.js +0 -1
- package/components/OfflineScreen.js +0 -1
- package/components/TextWithUrl.js +0 -1
- package/components/WorkspaceSwitcherPane.js +0 -1
- package/components/constants.js +0 -1
- package/components/index.js +0 -1
- package/config/axios/caseConversion.js +0 -1
- package/config/axios/constants.js +0 -1
- package/config/axios/index.js +0 -1
- package/config/axios/networkErrorHandler.js +0 -1
- package/config/axios/paramsSerializer.js +0 -1
- package/config/bugsnag.js +0 -1
- package/config/dayjs.js +0 -1
- package/config/googleSignin.js +0 -1
- package/config/index.js +0 -1
- package/config/validations.js +0 -1
- package/constants/index.d.ts +0 -5
- package/constants/index.js +0 -1
- package/contexts/index.js +0 -0
- package/contexts/localization.js +0 -1
- package/helpers/asyncStore.js +0 -1
- package/helpers/index.d.ts +0 -13
- package/helpers/index.js +0 -1
- package/helpers/keychain.d.ts +0 -4
- package/helpers/keychain.js +0 -1
- package/helpers/notifications/index.d.ts +0 -8
- package/helpers/notifications/index.js +0 -1
- package/helpers/notifications/usePushNotification.js +0 -1
- package/helpers/scale.js +0 -1
- package/helpers/utils.js +0 -1
- package/hooks/index.d.ts +0 -11
- package/hooks/index.js +0 -1
- package/hooks/query/constants.js +0 -1
- package/hooks/query/queryKeys.js +0 -1
- package/hooks/query/useAppVersionApi.js +0 -1
- package/hooks/query/useAuth.js +0 -1
- package/hooks/query/useNotification.js +0 -1
- package/hooks/query/useProfile.js +0 -1
- package/hooks/query/useRolesApi.js +0 -1
- package/hooks/query/useTeamMembersApi.js +0 -1
- package/hooks/useAppState.js +0 -1
- package/hooks/usePushNotificationPermissions.js +0 -1
- package/initializers/index.js +0 -1
- package/initializers/logRocket.js +0 -1
- package/localization/index.js +0 -1
- package/localization/translations/it.json +0 -13
- package/navigation/navigationService.js +0 -1
- package/navigation/screenNames.js +0 -1
- package/navigation/stacks.js +0 -1
- package/providers/NeetoCommonsRNProvider.js +0 -1
- package/providers/index.d.ts +0 -16
- package/providers/index.js +0 -1
- package/screens/NotificationsScreen.js +0 -1
- package/screens/authentication/AuthOptions.js +0 -1
- package/screens/authentication/IncompleteOnboardingInfo.js +0 -1
- package/screens/authentication/LoginScreen.js +0 -1
- package/screens/authentication/OTPVerificationScreen.js +0 -1
- package/screens/authentication/Organization.js +0 -1
- package/screens/authentication/SubDomainScreen.js +0 -1
- package/screens/authentication/constants.js +0 -1
- package/screens/index.js +0 -1
- package/screens/profile/ChatWidget.js +0 -1
- package/screens/profile/ProfileScreen.js +0 -1
- package/screens/profile/UserData.js +0 -1
- package/screens/team_members/Add.js +0 -1
- package/screens/team_members/Card.js +0 -1
- package/screens/team_members/Checkbox.js +0 -1
- package/screens/team_members/Edit.js +0 -1
- package/screens/team_members/Email.js +0 -1
- package/screens/team_members/LoadingCard.js +0 -1
- package/screens/team_members/ProductSelect.js +0 -1
- package/screens/team_members/RolesRadioGroup.js +0 -1
- package/screens/team_members/SaveButtons.js +0 -1
- package/screens/team_members/constants.js +0 -1
- package/screens/team_members/index.js +0 -1
- package/screens/team_members/utils.js +0 -1
- package/slices/auth.js +0 -1
- package/slices/index.js +0 -1
- package/store/index.d.ts +0 -7
- package/store/index.js +0 -1
- package/store/utils.js +0 -1
- package/utils/apiHelpers.js +0 -1
- /package/{assets → src/assets}/images/empty.svg +0 -0
- /package/{assets → src/assets}/images/wifi.png +0 -0
- /package/{localization → src/localization}/translations/en.json +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Linking } from "react-native";
|
|
2
|
+
|
|
3
|
+
import { isNotPresent } from "@bigbinary/neeto-cist";
|
|
4
|
+
import { equals, intersection } from "ramda";
|
|
5
|
+
import Config from "react-native-config";
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line no-console
|
|
8
|
+
const logError = (error: unknown) => console.error("Error in utils.js:", error);
|
|
9
|
+
|
|
10
|
+
export const toTitleCase = (str: string) =>
|
|
11
|
+
`${str.charAt(0).toUpperCase()}${str.substr(1).toLowerCase()}`;
|
|
12
|
+
|
|
13
|
+
export const openDeepLinkingUrl = async (url?: string | null) => {
|
|
14
|
+
if (!url) return;
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const scheme = `${Config.URL_SCHEME}://`;
|
|
18
|
+
let urlToOpen;
|
|
19
|
+
|
|
20
|
+
if (url.startsWith(scheme)) {
|
|
21
|
+
// Already using the custom scheme; don't touch it — replacing would
|
|
22
|
+
// corrupt web URLs embedded in its query params.
|
|
23
|
+
urlToOpen = url;
|
|
24
|
+
} else {
|
|
25
|
+
// Swap the web origin for the custom scheme. Host ends at "/", "?" or
|
|
26
|
+
// "#" so root URLs without a trailing slash keep their query string.
|
|
27
|
+
const domainRegex = /http[s]?:\/\/?[^/\s?#]+\/?/;
|
|
28
|
+
urlToOpen = url.replace(domainRegex, scheme);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// openURL rejects (instead of throwing) when the OS refuses the URL —
|
|
32
|
+
// e.g. iOS rejects while the app is backgrounded. An unhandled rejection
|
|
33
|
+
// here surfaces as a Bugsnag "Unable to open URL" error in every host app.
|
|
34
|
+
await Linking.openURL(urlToOpen);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
logError(error);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const debounce = <TArgs extends unknown[]>(
|
|
41
|
+
func: (...args: TArgs) => void,
|
|
42
|
+
delay = 300
|
|
43
|
+
) => {
|
|
44
|
+
let timer: ReturnType<typeof setTimeout>;
|
|
45
|
+
|
|
46
|
+
return (...args: TArgs) => {
|
|
47
|
+
clearTimeout(timer);
|
|
48
|
+
timer = setTimeout(() => {
|
|
49
|
+
// The previous `func.apply(this, args)` passed the module scope's
|
|
50
|
+
// `this`, which is always undefined here — the same receiver a plain
|
|
51
|
+
// call gives.
|
|
52
|
+
func(...args);
|
|
53
|
+
}, delay);
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const hasPermission = (
|
|
58
|
+
allPermissions: string[] = [],
|
|
59
|
+
requiredPermissions?: string | string[]
|
|
60
|
+
) => {
|
|
61
|
+
if (isNotPresent(requiredPermissions)) return true;
|
|
62
|
+
|
|
63
|
+
const permissions = Array.isArray(requiredPermissions)
|
|
64
|
+
? requiredPermissions
|
|
65
|
+
: [requiredPermissions as string];
|
|
66
|
+
|
|
67
|
+
return equals(intersection(allPermissions, permissions), permissions);
|
|
68
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
|
|
3
|
+
import { queryKeys } from "./queryKeys";
|
|
4
|
+
|
|
5
|
+
import appVersionApi from "../../api/app_version";
|
|
6
|
+
|
|
7
|
+
export const useFetchAppVersionApi = () =>
|
|
8
|
+
useQuery({
|
|
9
|
+
queryKey: [queryKeys.APP_VERSION],
|
|
10
|
+
queryFn: appVersionApi.fetch,
|
|
11
|
+
select: ({ data }) => data,
|
|
12
|
+
});
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { useRef } from "react";
|
|
2
|
+
|
|
3
|
+
import { Alert, Toast } from "@bigbinary/neetoui-rn";
|
|
4
|
+
import { GoogleSignin } from "@react-native-google-signin/google-signin";
|
|
5
|
+
import { useNavigation, type NavigationProp } from "@react-navigation/native";
|
|
6
|
+
import { useMutation } from "@tanstack/react-query";
|
|
7
|
+
import { type AxiosError } from "axios";
|
|
8
|
+
import { useDispatch } from "react-redux";
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
generateOTPAPI,
|
|
12
|
+
loginWithAppleAPI,
|
|
13
|
+
loginWithGoogleAPI,
|
|
14
|
+
fetchOrganizationDetailsAPI,
|
|
15
|
+
verifyOTPAPI,
|
|
16
|
+
} from "../../api/auth";
|
|
17
|
+
import { type ApiErrorData, getErrorMessage } from "../../config/axios";
|
|
18
|
+
import { isNetworkError } from "../../config/axios/networkErrorHandler";
|
|
19
|
+
import { bugsnagErrorHandler } from "../../config/bugsnag";
|
|
20
|
+
import { useLocalization } from "../../contexts/localization";
|
|
21
|
+
import { setItem } from "../../helpers/asyncStore";
|
|
22
|
+
import { setSecureValue, removeSecureValue } from "../../helpers/keychain";
|
|
23
|
+
import { SCREEN_NAMES } from "../../navigation/screenNames";
|
|
24
|
+
import { type CommonsParamList } from "../../navigation/types";
|
|
25
|
+
import { MAX_RETRY_ATTEMPTS } from "../../screens/authentication/constants";
|
|
26
|
+
import {
|
|
27
|
+
loginUserAction,
|
|
28
|
+
setOrganizations,
|
|
29
|
+
type Organization,
|
|
30
|
+
} from "../../slices/auth";
|
|
31
|
+
|
|
32
|
+
export const useAuth = () => {
|
|
33
|
+
const dispatch = useDispatch();
|
|
34
|
+
const { strings } = useLocalization();
|
|
35
|
+
const navigation = useNavigation<NavigationProp<CommonsParamList>>();
|
|
36
|
+
const last504ReportTimeRef = useRef<number | null>(null);
|
|
37
|
+
|
|
38
|
+
const selectOrganization = async ({
|
|
39
|
+
organization,
|
|
40
|
+
}: {
|
|
41
|
+
organization: Organization;
|
|
42
|
+
}) => {
|
|
43
|
+
const {
|
|
44
|
+
auth_token,
|
|
45
|
+
email,
|
|
46
|
+
subdomain,
|
|
47
|
+
name,
|
|
48
|
+
id,
|
|
49
|
+
organization_name,
|
|
50
|
+
profile_image_url,
|
|
51
|
+
} = organization;
|
|
52
|
+
|
|
53
|
+
const userAuth = {
|
|
54
|
+
authToken: auth_token,
|
|
55
|
+
email,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
await setItem("email", email);
|
|
59
|
+
await setSecureValue("userAuth", JSON.stringify(userAuth));
|
|
60
|
+
|
|
61
|
+
dispatch(
|
|
62
|
+
loginUserAction({
|
|
63
|
+
name,
|
|
64
|
+
email,
|
|
65
|
+
id,
|
|
66
|
+
subdomain,
|
|
67
|
+
organization_name,
|
|
68
|
+
profile_image_url,
|
|
69
|
+
})
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const login = async ({
|
|
74
|
+
organizations,
|
|
75
|
+
}: {
|
|
76
|
+
organizations: Organization[];
|
|
77
|
+
}) => {
|
|
78
|
+
if (organizations.length > 0) {
|
|
79
|
+
dispatch(setOrganizations({ organizations }));
|
|
80
|
+
if (organizations.length > 1) {
|
|
81
|
+
navigation.navigate(SCREEN_NAMES.SubDomain, {
|
|
82
|
+
organizations,
|
|
83
|
+
});
|
|
84
|
+
} else {
|
|
85
|
+
await selectOrganization({ organization: organizations[0] });
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
const signedInUsingGoogle = GoogleSignin.hasPreviousSignIn();
|
|
89
|
+
|
|
90
|
+
if (signedInUsingGoogle) {
|
|
91
|
+
await GoogleSignin.signOut();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
await removeSecureValue("userAuth");
|
|
95
|
+
|
|
96
|
+
Alert.show({
|
|
97
|
+
title: strings.commons.alertMessage.noWorkspaceFoundTitle,
|
|
98
|
+
description: strings.commons.alertMessage.noWorkspaceFoundMessage,
|
|
99
|
+
isCancelable: false,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const verifyOTPWithRetry = async (params: {
|
|
105
|
+
code: string;
|
|
106
|
+
userId: string;
|
|
107
|
+
}) => {
|
|
108
|
+
let attempt = 0;
|
|
109
|
+
let lastError: unknown = null;
|
|
110
|
+
let delay = 1000;
|
|
111
|
+
|
|
112
|
+
while (attempt < MAX_RETRY_ATTEMPTS) {
|
|
113
|
+
try {
|
|
114
|
+
return await verifyOTPAPI(params);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
const status = (error as AxiosError)?.response?.status;
|
|
117
|
+
|
|
118
|
+
if (status === 504) {
|
|
119
|
+
attempt++;
|
|
120
|
+
if (attempt < MAX_RETRY_ATTEMPTS) {
|
|
121
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
122
|
+
delay *= 2;
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
lastError = error;
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
throw lastError;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const handleVerifyOTPError = (error: AxiosError<ApiErrorData>) => {
|
|
136
|
+
const status = error?.response?.status;
|
|
137
|
+
|
|
138
|
+
if (status === 504) {
|
|
139
|
+
Toast.show({
|
|
140
|
+
type: "error",
|
|
141
|
+
text2:
|
|
142
|
+
strings.commons.errors.axios.serverTimeout ||
|
|
143
|
+
"Server is taking too long to respond. Please try again.",
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
if (
|
|
147
|
+
!last504ReportTimeRef.current ||
|
|
148
|
+
Date.now() - last504ReportTimeRef.current > 60000
|
|
149
|
+
) {
|
|
150
|
+
bugsnagErrorHandler(
|
|
151
|
+
new Error("504 Gateway Timeout on /api/mobile/v1/verify_otp"),
|
|
152
|
+
"verify_otp_504"
|
|
153
|
+
);
|
|
154
|
+
last504ReportTimeRef.current = Date.now();
|
|
155
|
+
}
|
|
156
|
+
} else if (isNetworkError(error)) {
|
|
157
|
+
Toast.show({
|
|
158
|
+
type: "error",
|
|
159
|
+
text2:
|
|
160
|
+
strings.commons.errors.axios.networkError ||
|
|
161
|
+
"Please check your internet connection and try again",
|
|
162
|
+
});
|
|
163
|
+
} else {
|
|
164
|
+
Toast.show({
|
|
165
|
+
type: "error",
|
|
166
|
+
text2: getErrorMessage(error?.response?.data, error),
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
bugsnagErrorHandler(error, "verify_otp_error");
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
return {
|
|
174
|
+
selectOrganization,
|
|
175
|
+
useGenerateOTPMutation: () =>
|
|
176
|
+
useMutation<
|
|
177
|
+
string,
|
|
178
|
+
AxiosError<ApiErrorData>,
|
|
179
|
+
{ email: string; showCodeSentToast?: boolean }
|
|
180
|
+
>({
|
|
181
|
+
mutationFn: generateOTPAPI,
|
|
182
|
+
onSuccess: (userId, { email, showCodeSentToast = false }) => {
|
|
183
|
+
navigation.navigate(SCREEN_NAMES.OTPVerification, {
|
|
184
|
+
email,
|
|
185
|
+
userId,
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
if (showCodeSentToast) {
|
|
189
|
+
Toast.show({
|
|
190
|
+
type: "success",
|
|
191
|
+
text2: strings.commons.verificationScreen.resent,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
}),
|
|
196
|
+
|
|
197
|
+
useVerifyOTPMutation: () =>
|
|
198
|
+
useMutation({
|
|
199
|
+
mutationFn: verifyOTPWithRetry,
|
|
200
|
+
onSuccess: ({ data: { organizations } }) => {
|
|
201
|
+
login({ organizations });
|
|
202
|
+
},
|
|
203
|
+
onError: handleVerifyOTPError,
|
|
204
|
+
}),
|
|
205
|
+
useLoginViaGoogleMutation: () =>
|
|
206
|
+
useMutation({
|
|
207
|
+
mutationFn: ({ serverAuthCode }: { serverAuthCode: string }) =>
|
|
208
|
+
loginWithGoogleAPI({ serverAuthCode }),
|
|
209
|
+
onSuccess: ({ data: { organizations } }) => {
|
|
210
|
+
login({ organizations });
|
|
211
|
+
},
|
|
212
|
+
}),
|
|
213
|
+
|
|
214
|
+
useLoginViaAppleMutation: () =>
|
|
215
|
+
useMutation({
|
|
216
|
+
mutationFn: ({
|
|
217
|
+
authorizationCode,
|
|
218
|
+
identityToken,
|
|
219
|
+
}: {
|
|
220
|
+
authorizationCode: string;
|
|
221
|
+
identityToken: string;
|
|
222
|
+
}) => loginWithAppleAPI({ authorizationCode, identityToken }),
|
|
223
|
+
onSuccess: ({ data: { organizations } }) => {
|
|
224
|
+
login({ organizations });
|
|
225
|
+
},
|
|
226
|
+
}),
|
|
227
|
+
|
|
228
|
+
useSelectOrganizationMutation: () =>
|
|
229
|
+
useMutation({
|
|
230
|
+
mutationFn: async ({
|
|
231
|
+
organization,
|
|
232
|
+
}: {
|
|
233
|
+
organization: Organization;
|
|
234
|
+
}) => {
|
|
235
|
+
const { subdomain } = organization;
|
|
236
|
+
const { data } = await fetchOrganizationDetailsAPI({ subdomain });
|
|
237
|
+
|
|
238
|
+
// PATCH: For the apps which does not support organization details API updates
|
|
239
|
+
// is_onboard will be set to true
|
|
240
|
+
const is_onboard = data?.organization?.is_onboard ?? true;
|
|
241
|
+
|
|
242
|
+
if (is_onboard) {
|
|
243
|
+
await selectOrganization({ organization });
|
|
244
|
+
} else {
|
|
245
|
+
navigation.navigate(SCREEN_NAMES.UnBoarded, {
|
|
246
|
+
name: organization.organization_name,
|
|
247
|
+
subdomain: organization.subdomain,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
}),
|
|
252
|
+
};
|
|
253
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
useMutation,
|
|
5
|
+
useInfiniteQuery,
|
|
6
|
+
useQueryClient,
|
|
7
|
+
} from "@tanstack/react-query";
|
|
8
|
+
import notifee from "react-native-notify-kit";
|
|
9
|
+
|
|
10
|
+
import { queryKeys } from "./queryKeys";
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
registerDeviceTokenAPI,
|
|
14
|
+
markReadUnReadNotificationAPI,
|
|
15
|
+
deleteDeviceTokenAPI,
|
|
16
|
+
fetchNotificationsAPI,
|
|
17
|
+
markAllNotificationsReadAPI,
|
|
18
|
+
} from "../../api/notifications";
|
|
19
|
+
import { bugsnagErrorHandler } from "../../config/bugsnag";
|
|
20
|
+
import { STORAGE_KEYS, DEFAULT_PAGE_SIZE } from "../../constants";
|
|
21
|
+
import { removeItem, setItem } from "../../helpers/asyncStore";
|
|
22
|
+
import { removeSecureValue } from "../../helpers/keychain";
|
|
23
|
+
import { logoutUserAction } from "../../slices/auth";
|
|
24
|
+
import { useAppDispatch } from "../../store/hooks";
|
|
25
|
+
|
|
26
|
+
export const useNotification = () => {
|
|
27
|
+
const dispatch = useAppDispatch();
|
|
28
|
+
const queryClient = useQueryClient();
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
useRegisterTokenMutation: () =>
|
|
32
|
+
useMutation({
|
|
33
|
+
mutationFn: registerDeviceTokenAPI,
|
|
34
|
+
onSuccess: (_, response) => {
|
|
35
|
+
setItem(STORAGE_KEYS.DEVICE_TOKEN, response.device.device_token);
|
|
36
|
+
},
|
|
37
|
+
onError: error => {
|
|
38
|
+
bugsnagErrorHandler(JSON.stringify(error), "notification");
|
|
39
|
+
},
|
|
40
|
+
}),
|
|
41
|
+
useFetchNotifications: () => {
|
|
42
|
+
const prevBadgeRef = useRef<number | null>(null);
|
|
43
|
+
|
|
44
|
+
const query = useInfiniteQuery({
|
|
45
|
+
queryKey: [queryKeys.NOTIFICATIONS],
|
|
46
|
+
queryFn: ({ pageParam }) =>
|
|
47
|
+
fetchNotificationsAPI({
|
|
48
|
+
page: pageParam,
|
|
49
|
+
}),
|
|
50
|
+
initialPageParam: 1,
|
|
51
|
+
getNextPageParam: (lastPage, pages) => {
|
|
52
|
+
const currPage = pages.length;
|
|
53
|
+
|
|
54
|
+
if (!lastPage?.data?.notifications) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const totalNotifications = lastPage.data.total_count;
|
|
59
|
+
const fetchedNotificationsCount =
|
|
60
|
+
(currPage - 1) * DEFAULT_PAGE_SIZE +
|
|
61
|
+
lastPage.data.notifications.length;
|
|
62
|
+
|
|
63
|
+
const hasNextPage = fetchedNotificationsCount < totalNotifications;
|
|
64
|
+
|
|
65
|
+
return hasNextPage ? currPage + 1 : undefined;
|
|
66
|
+
},
|
|
67
|
+
select: data => ({
|
|
68
|
+
unreadNotifications: data.pages?.[0]?.data?.unread_count || 0,
|
|
69
|
+
totalNotifications: data.pages?.[0]?.data?.total_count || 0,
|
|
70
|
+
notifications:
|
|
71
|
+
data.pages
|
|
72
|
+
.map(({ data: { notifications } }) => notifications)
|
|
73
|
+
.flat() || [],
|
|
74
|
+
}),
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const unreadCount = query.data?.unreadNotifications ?? 0;
|
|
78
|
+
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
if (prevBadgeRef.current !== unreadCount) {
|
|
81
|
+
prevBadgeRef.current = unreadCount;
|
|
82
|
+
notifee.setBadgeCount(unreadCount);
|
|
83
|
+
}
|
|
84
|
+
}, [unreadCount]);
|
|
85
|
+
|
|
86
|
+
return query;
|
|
87
|
+
},
|
|
88
|
+
useMarkReadUnreadNotification: () =>
|
|
89
|
+
useMutation({
|
|
90
|
+
// The result is returned, not fired and forgotten, so onSuccess runs
|
|
91
|
+
// after the server confirms rather than racing the request.
|
|
92
|
+
mutationFn: ({
|
|
93
|
+
notificationId,
|
|
94
|
+
readAt,
|
|
95
|
+
}: {
|
|
96
|
+
notificationId: string;
|
|
97
|
+
readAt: string | null;
|
|
98
|
+
}) => markReadUnReadNotificationAPI({ notificationId, readAt }),
|
|
99
|
+
onSuccess: async () => {
|
|
100
|
+
queryClient.invalidateQueries({
|
|
101
|
+
queryKey: [queryKeys.NOTIFICATIONS],
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// Was a silent no-op on Android before — getApplicationIconBadgeNumber
|
|
105
|
+
// had no Android implementation. Works on both platforms now.
|
|
106
|
+
const count = await notifee.getBadgeCount();
|
|
107
|
+
await notifee.setBadgeCount(Math.max(0, count - 1));
|
|
108
|
+
},
|
|
109
|
+
}),
|
|
110
|
+
useDeleteTokenMutation: () =>
|
|
111
|
+
useMutation({
|
|
112
|
+
mutationFn: (notificationDeviceId: string) =>
|
|
113
|
+
deleteDeviceTokenAPI({ notificationDeviceId }),
|
|
114
|
+
onSettled: async () => {
|
|
115
|
+
removeItem(STORAGE_KEYS.DEVICE_TOKEN);
|
|
116
|
+
dispatch(logoutUserAction());
|
|
117
|
+
await removeSecureValue("userAuth");
|
|
118
|
+
},
|
|
119
|
+
}),
|
|
120
|
+
useMarkAllReadNotification: () =>
|
|
121
|
+
useMutation({
|
|
122
|
+
mutationFn: markAllNotificationsReadAPI,
|
|
123
|
+
onSuccess: () => {
|
|
124
|
+
queryClient.invalidateQueries({
|
|
125
|
+
queryKey: [queryKeys.NOTIFICATIONS],
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
}),
|
|
129
|
+
};
|
|
130
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
|
|
3
|
+
import { queryKeys } from "./queryKeys";
|
|
4
|
+
|
|
5
|
+
import { getProfileApi } from "../../api/profile";
|
|
6
|
+
import { useAppSelector } from "../../store/hooks";
|
|
7
|
+
|
|
8
|
+
export const useFetchProfileDetails = (options = {}) => {
|
|
9
|
+
const isLoggedIn = useAppSelector(store => store.auth.isLoggedIn);
|
|
10
|
+
|
|
11
|
+
return useQuery({
|
|
12
|
+
queryKey: [queryKeys.PROFILE],
|
|
13
|
+
queryFn: () => getProfileApi(),
|
|
14
|
+
select: ({ data }) => ({
|
|
15
|
+
...data?.user,
|
|
16
|
+
permissionNames: data?.user?.permissions?.map(p => p.name) ?? [],
|
|
17
|
+
}),
|
|
18
|
+
enabled: isLoggedIn,
|
|
19
|
+
...options,
|
|
20
|
+
});
|
|
21
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { groupBy, prop, reverse } from "ramda";
|
|
3
|
+
|
|
4
|
+
import { queryKeys } from "./queryKeys";
|
|
5
|
+
|
|
6
|
+
import globalRolesApi from "../../api/global_roles";
|
|
7
|
+
import organizationRolesApi from "../../api/organization_roles";
|
|
8
|
+
|
|
9
|
+
const useFetchRoles = (options = {}) =>
|
|
10
|
+
useQuery({
|
|
11
|
+
queryKey: [queryKeys.ROLES],
|
|
12
|
+
queryFn: organizationRolesApi.fetch,
|
|
13
|
+
select: response => reverse(response?.data?.organization_roles ?? []),
|
|
14
|
+
...options,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const useFetchGlobalRoles = (options = {}) =>
|
|
18
|
+
useQuery({
|
|
19
|
+
queryKey: [queryKeys.GLOBAL_ROLES],
|
|
20
|
+
queryFn: globalRolesApi.fetch,
|
|
21
|
+
select: response => groupBy(prop("app_name"), response?.data ?? []),
|
|
22
|
+
...options,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export { useFetchRoles, useFetchGlobalRoles };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useInfiniteQuery,
|
|
3
|
+
useMutation,
|
|
4
|
+
useQueryClient,
|
|
5
|
+
} from "@tanstack/react-query";
|
|
6
|
+
|
|
7
|
+
import { queryKeys } from "./queryKeys";
|
|
8
|
+
|
|
9
|
+
import teamMembersApi from "../../api/team_members";
|
|
10
|
+
import { DEFAULT_PAGE_SIZE } from "../../constants";
|
|
11
|
+
import { logoutUserAction } from "../../slices/auth";
|
|
12
|
+
import { useAppDispatch, useAppSelector } from "../../store/hooks";
|
|
13
|
+
|
|
14
|
+
const getSearchParams = (searchTerm: string) => [
|
|
15
|
+
{
|
|
16
|
+
conditions: [
|
|
17
|
+
{
|
|
18
|
+
type: "text",
|
|
19
|
+
rule: "contains",
|
|
20
|
+
node: "first_name,last_name,email",
|
|
21
|
+
value: searchTerm,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const useFetchTeamMembers = (searchTerm = "") =>
|
|
28
|
+
useInfiniteQuery({
|
|
29
|
+
queryKey: [queryKeys.TEAM_MEMBERS, searchTerm],
|
|
30
|
+
queryFn: ({ pageParam }) => {
|
|
31
|
+
const params: Record<string, unknown> = {
|
|
32
|
+
page: pageParam,
|
|
33
|
+
page_size: DEFAULT_PAGE_SIZE,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
if (searchTerm) {
|
|
37
|
+
params.neeto_filters = getSearchParams(searchTerm);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return teamMembersApi.fetch(params);
|
|
41
|
+
},
|
|
42
|
+
initialPageParam: 1,
|
|
43
|
+
getNextPageParam: (lastPage, pages) => {
|
|
44
|
+
const currPage = pages?.length ?? 0;
|
|
45
|
+
const totalMembers = lastPage?.data?.members_count ?? 0;
|
|
46
|
+
const fetchedMembersCount =
|
|
47
|
+
(currPage - 1) * DEFAULT_PAGE_SIZE +
|
|
48
|
+
(lastPage?.data?.members?.length ?? 0);
|
|
49
|
+
|
|
50
|
+
return fetchedMembersCount >= totalMembers ? undefined : currPage + 1;
|
|
51
|
+
},
|
|
52
|
+
select: data => data.pages.flatMap(({ data: { members = [] } }) => members),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
interface MutationCallbacks {
|
|
56
|
+
onSuccess?: () => void;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
type TeamMemberPayload = Record<string, unknown>;
|
|
60
|
+
|
|
61
|
+
const useCreateMember = ({ onSuccess }: MutationCallbacks) => {
|
|
62
|
+
const queryClient = useQueryClient();
|
|
63
|
+
|
|
64
|
+
return useMutation({
|
|
65
|
+
mutationFn: ({ payload }: { payload: TeamMemberPayload }) =>
|
|
66
|
+
teamMembersApi.create(payload),
|
|
67
|
+
onSuccess: () => {
|
|
68
|
+
queryClient.invalidateQueries({ queryKey: [queryKeys.TEAM_MEMBERS] });
|
|
69
|
+
onSuccess?.();
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const useUpdateTeamMember = ({ onSuccess }: MutationCallbacks) => {
|
|
75
|
+
const queryClient = useQueryClient();
|
|
76
|
+
|
|
77
|
+
return useMutation({
|
|
78
|
+
mutationFn: ({ id, payload }: { id: string; payload: TeamMemberPayload }) =>
|
|
79
|
+
teamMembersApi.update(id, { ...payload, active: true }),
|
|
80
|
+
onSuccess: () => {
|
|
81
|
+
queryClient.invalidateQueries({ queryKey: [queryKeys.TEAM_MEMBERS] });
|
|
82
|
+
onSuccess?.();
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const useRemoveTeamMember = () => {
|
|
88
|
+
const queryClient = useQueryClient();
|
|
89
|
+
const userId = useAppSelector(store => store.auth?.userId || "");
|
|
90
|
+
const dispatch = useAppDispatch();
|
|
91
|
+
|
|
92
|
+
return useMutation({
|
|
93
|
+
mutationFn: ({ id }: { id: string }) =>
|
|
94
|
+
teamMembersApi.update(id, { is_active: false }),
|
|
95
|
+
onSuccess: (_, { id }) => {
|
|
96
|
+
queryClient.invalidateQueries({ queryKey: [queryKeys.TEAM_MEMBERS] });
|
|
97
|
+
if (id === userId) {
|
|
98
|
+
dispatch(logoutUserAction());
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export {
|
|
105
|
+
useFetchTeamMembers,
|
|
106
|
+
useCreateMember,
|
|
107
|
+
useUpdateTeamMember,
|
|
108
|
+
useRemoveTeamMember,
|
|
109
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { AppState } from "react-native";
|
|
3
|
+
|
|
4
|
+
export const useAppState = () => {
|
|
5
|
+
const [appState, setAppState] = useState(AppState.currentState);
|
|
6
|
+
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const changeListener = AppState.addEventListener("change", setAppState);
|
|
9
|
+
|
|
10
|
+
return () => {
|
|
11
|
+
changeListener.remove();
|
|
12
|
+
};
|
|
13
|
+
}, []);
|
|
14
|
+
|
|
15
|
+
return appState;
|
|
16
|
+
};
|