@bigbinary/neeto-commons-rn 1.8.4 → 2.0.2
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 +366 -0
- package/eslint-config/rules/no-dangling-constants.js +35 -0
- package/eslint-config/rules/no-redundant-string-templates.js +85 -0
- 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 -71
- 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,111 @@
|
|
|
1
|
+
import { useEffect, useState, useCallback } from "react";
|
|
2
|
+
import { AppState, Platform } from "react-native";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
RESULTS,
|
|
6
|
+
checkNotifications,
|
|
7
|
+
requestNotifications,
|
|
8
|
+
type PermissionStatus,
|
|
9
|
+
} from "react-native-permissions";
|
|
10
|
+
|
|
11
|
+
import { bugsnagErrorHandler } from "../config/bugsnag";
|
|
12
|
+
import { STORAGE_KEYS } from "../constants";
|
|
13
|
+
import { getItem, setItem } from "../helpers/asyncStore";
|
|
14
|
+
|
|
15
|
+
export const usePushNotificationPermissions = () => {
|
|
16
|
+
const [appState, setAppState] = useState(AppState.currentState);
|
|
17
|
+
const [notificationPermission, setNotificationPermission] = useState(false);
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const subscription = AppState.addEventListener("change", nextAppState => {
|
|
21
|
+
setAppState(nextAppState);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return () => {
|
|
25
|
+
subscription?.remove();
|
|
26
|
+
};
|
|
27
|
+
}, []);
|
|
28
|
+
|
|
29
|
+
const checkNotificationPermission = useCallback(async (): Promise<{
|
|
30
|
+
isGranted: boolean;
|
|
31
|
+
status?: PermissionStatus;
|
|
32
|
+
}> => {
|
|
33
|
+
try {
|
|
34
|
+
if (Platform.OS === "android" && Platform.Version < 33) {
|
|
35
|
+
return { isGranted: true };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const { status } = await checkNotifications();
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
isGranted: status === RESULTS.GRANTED,
|
|
42
|
+
status,
|
|
43
|
+
};
|
|
44
|
+
} catch (error) {
|
|
45
|
+
bugsnagErrorHandler(JSON.stringify(error), "notification");
|
|
46
|
+
|
|
47
|
+
return { isGranted: false };
|
|
48
|
+
}
|
|
49
|
+
}, []);
|
|
50
|
+
|
|
51
|
+
const requestNotificationPermission = useCallback(async () => {
|
|
52
|
+
try {
|
|
53
|
+
const permissionRequested = await getItem(
|
|
54
|
+
STORAGE_KEYS.NOTIFICATION_PERMISSION_REQUESTED
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
if (permissionRequested !== null) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const { status } = await requestNotifications([
|
|
62
|
+
"alert",
|
|
63
|
+
"sound",
|
|
64
|
+
"badge",
|
|
65
|
+
]);
|
|
66
|
+
|
|
67
|
+
if (status === RESULTS.GRANTED) {
|
|
68
|
+
await setItem(STORAGE_KEYS.NOTIFICATION_PERMISSION_REQUESTED, true);
|
|
69
|
+
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
await setItem(STORAGE_KEYS.NOTIFICATION_PERMISSION_REQUESTED, false);
|
|
73
|
+
|
|
74
|
+
return false;
|
|
75
|
+
} catch (error) {
|
|
76
|
+
bugsnagErrorHandler(JSON.stringify(error), "notification");
|
|
77
|
+
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}, []);
|
|
81
|
+
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
const handlePermissions = async () => {
|
|
84
|
+
try {
|
|
85
|
+
const { isGranted, status } = await checkNotificationPermission();
|
|
86
|
+
|
|
87
|
+
if (isGranted) {
|
|
88
|
+
setNotificationPermission(true);
|
|
89
|
+
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (status === RESULTS.DENIED) {
|
|
94
|
+
const granted = await requestNotificationPermission();
|
|
95
|
+
setNotificationPermission(granted);
|
|
96
|
+
} else {
|
|
97
|
+
setNotificationPermission(false);
|
|
98
|
+
}
|
|
99
|
+
} catch (error) {
|
|
100
|
+
bugsnagErrorHandler(JSON.stringify(error), "notification");
|
|
101
|
+
setNotificationPermission(false);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
if (appState === "active") {
|
|
106
|
+
handlePermissions();
|
|
107
|
+
}
|
|
108
|
+
}, [appState, checkNotificationPermission, requestNotificationPermission]);
|
|
109
|
+
|
|
110
|
+
return [notificationPermission];
|
|
111
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import LogRocket from "@logrocket/react-native";
|
|
2
|
+
import Config from "react-native-config";
|
|
3
|
+
|
|
4
|
+
import { Store } from "../store";
|
|
5
|
+
|
|
6
|
+
export const logRocket = () => {
|
|
7
|
+
if (!Config.LOG_ROCKET_API_KEY || __DEV__) return;
|
|
8
|
+
|
|
9
|
+
const { isLoggedIn, userId, name, email, subdomain } = Store.getState().auth;
|
|
10
|
+
|
|
11
|
+
LogRocket.init(Config.LOG_ROCKET_API_KEY);
|
|
12
|
+
|
|
13
|
+
if (!isLoggedIn) {
|
|
14
|
+
//End the current session gracefully during logout
|
|
15
|
+
LogRocket.shutdown();
|
|
16
|
+
// Reinitialize LogRocket to capture the login screen after logout
|
|
17
|
+
LogRocket.init(Config.LOG_ROCKET_API_KEY);
|
|
18
|
+
} else {
|
|
19
|
+
LogRocket.identify(userId, {
|
|
20
|
+
name,
|
|
21
|
+
email,
|
|
22
|
+
organization: subdomain,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import i18next, { type i18n as I18nInstance } from "i18next";
|
|
2
|
+
import { initReactI18next } from "react-i18next";
|
|
3
|
+
|
|
4
|
+
// Annotated rather than inferred: the emitted declaration has to be able to
|
|
5
|
+
// name this type without pointing back into node_modules.
|
|
6
|
+
const i18n: I18nInstance = i18next.createInstance();
|
|
7
|
+
|
|
8
|
+
// initAsync: false makes init synchronous, so the provider can build the
|
|
9
|
+
// strings facade on first render without a loading state. i18next 25 renamed
|
|
10
|
+
// this from initImmediate; the old name was silently ignored.
|
|
11
|
+
i18n.use(initReactI18next).init({
|
|
12
|
+
lng: "en",
|
|
13
|
+
fallbackLng: "en",
|
|
14
|
+
resources: {},
|
|
15
|
+
interpolation: { escapeValue: false },
|
|
16
|
+
initAsync: false,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export { i18n };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import en from "./translations/en.json";
|
|
2
|
+
|
|
3
|
+
// The English catalog is the source of truth for the key set; other locales
|
|
4
|
+
// are partial overlays on top of it.
|
|
5
|
+
export type CommonsCatalog = typeof en;
|
|
6
|
+
|
|
7
|
+
const strings: { en: CommonsCatalog } & Record<
|
|
8
|
+
string,
|
|
9
|
+
Partial<CommonsCatalog>
|
|
10
|
+
> = {
|
|
11
|
+
en,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { strings };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { type NavigationContainerRef } from "@react-navigation/native";
|
|
4
|
+
|
|
5
|
+
// The host app owns the route tree, so commons can only describe it as
|
|
6
|
+
// "some route name, with some params".
|
|
7
|
+
type AnyParamList = Record<string, object | undefined>;
|
|
8
|
+
|
|
9
|
+
type NavigationRef =
|
|
10
|
+
React.RefObject<NavigationContainerRef<AnyParamList> | null>;
|
|
11
|
+
|
|
12
|
+
interface ResetRoute {
|
|
13
|
+
name: string;
|
|
14
|
+
params?: object;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const navigationRef: NavigationRef =
|
|
18
|
+
React.createRef<NavigationContainerRef<AnyParamList>>();
|
|
19
|
+
|
|
20
|
+
// The host app's NavigationContainer ref. Held as the ref object itself (not a
|
|
21
|
+
// copy of `.current`) so reads stay live no matter when the container mounts.
|
|
22
|
+
let hostNavigationRef = navigationRef;
|
|
23
|
+
|
|
24
|
+
export const setHostNavigationRef = (ref?: NavigationRef | null) => {
|
|
25
|
+
if (ref) hostNavigationRef = ref;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export function navigate(name: string, params?: object) {
|
|
29
|
+
hostNavigationRef.current?.navigate(name, params);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function reset(routes: ResetRoute | ResetRoute[]) {
|
|
33
|
+
hostNavigationRef.current?.reset({
|
|
34
|
+
index: 0,
|
|
35
|
+
routes: Array.isArray(routes) ? routes : [routes],
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Disabling this rule as we don't want to mix SCREEN_NAMES with constants
|
|
2
|
+
/* eslint-disable @bigbinary/neeto/no-dangling-constants */
|
|
3
|
+
export const SCREEN_NAMES = {
|
|
4
|
+
Login: "Login",
|
|
5
|
+
OTPVerification: "OTPVerification",
|
|
6
|
+
SubDomain: "SubDomain",
|
|
7
|
+
UnBoarded: "UnBoarded",
|
|
8
|
+
ChatWidget: "ChatWidget",
|
|
9
|
+
AddTeamMemberScreen: "AddTeamMemberScreen",
|
|
10
|
+
EditTeamMemberScreen: "EditTeamMemberScreen",
|
|
11
|
+
} as const;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { createNativeStackNavigator } from "@react-navigation/native-stack";
|
|
4
|
+
|
|
5
|
+
import { SCREEN_NAMES } from "./screenNames";
|
|
6
|
+
import { type CommonsParamList } from "./types";
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
IncompleteOnboardingInfo,
|
|
10
|
+
OTPVerificationScreen,
|
|
11
|
+
SubDomainScreen,
|
|
12
|
+
LoginScreen,
|
|
13
|
+
} from "../screens";
|
|
14
|
+
|
|
15
|
+
const Stack = createNativeStackNavigator<CommonsParamList>();
|
|
16
|
+
|
|
17
|
+
export const AuthStack = () => (
|
|
18
|
+
<Stack.Navigator screenOptions={{ headerShown: false }}>
|
|
19
|
+
<Stack.Screen component={LoginScreen} name={SCREEN_NAMES.Login} />
|
|
20
|
+
<Stack.Screen
|
|
21
|
+
component={OTPVerificationScreen}
|
|
22
|
+
name={SCREEN_NAMES.OTPVerification}
|
|
23
|
+
/>
|
|
24
|
+
<Stack.Screen component={SubDomainScreen} name={SCREEN_NAMES.SubDomain} />
|
|
25
|
+
<Stack.Screen
|
|
26
|
+
component={IncompleteOnboardingInfo}
|
|
27
|
+
name={SCREEN_NAMES.UnBoarded}
|
|
28
|
+
/>
|
|
29
|
+
</Stack.Navigator>
|
|
30
|
+
);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type NativeStackScreenProps } from "@react-navigation/native-stack";
|
|
2
|
+
|
|
3
|
+
import { type TeamMember } from "../api/team_members";
|
|
4
|
+
import { type Organization } from "../slices/auth";
|
|
5
|
+
|
|
6
|
+
// The screens commons itself registers. A host app's navigator is a superset
|
|
7
|
+
// of this; commons only ever navigates to its own routes.
|
|
8
|
+
export type CommonsParamList = {
|
|
9
|
+
Login: undefined;
|
|
10
|
+
OTPVerification: { email: string; userId: string };
|
|
11
|
+
SubDomain: { organizations: Organization[] };
|
|
12
|
+
UnBoarded: { name: string; subdomain: string };
|
|
13
|
+
ChatWidget: undefined;
|
|
14
|
+
AddTeamMemberScreen: undefined;
|
|
15
|
+
EditTeamMemberScreen: { member: TeamMember };
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type CommonsScreenProps<T extends keyof CommonsParamList> =
|
|
19
|
+
NativeStackScreenProps<CommonsParamList, T>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
useEffect,
|
|
3
|
+
useLayoutEffect,
|
|
4
|
+
useRef,
|
|
5
|
+
type ReactNode,
|
|
6
|
+
} from "react";
|
|
7
|
+
|
|
8
|
+
import { type NavigationContainerRef } from "@react-navigation/native";
|
|
9
|
+
import { Provider } from "react-redux";
|
|
10
|
+
import { type Reducer } from "redux";
|
|
11
|
+
import { PersistGate } from "redux-persist/integration/react";
|
|
12
|
+
|
|
13
|
+
import { initializeConfigs } from "../config";
|
|
14
|
+
import {
|
|
15
|
+
LocalizationProvider,
|
|
16
|
+
type HostStrings,
|
|
17
|
+
} from "../contexts/localization";
|
|
18
|
+
import {
|
|
19
|
+
navigationRef,
|
|
20
|
+
setHostNavigationRef,
|
|
21
|
+
} from "../navigation/navigationService";
|
|
22
|
+
import { setAppName } from "../slices/auth";
|
|
23
|
+
import { Persistor, Store } from "../store";
|
|
24
|
+
import { updateRootReducer } from "../store/utils";
|
|
25
|
+
|
|
26
|
+
initializeConfigs();
|
|
27
|
+
|
|
28
|
+
export interface NeetoCommonsRNProviderProps {
|
|
29
|
+
appName: string;
|
|
30
|
+
hostNavigationRef?: React.RefObject<NavigationContainerRef<
|
|
31
|
+
Record<string, object | undefined>
|
|
32
|
+
> | null>;
|
|
33
|
+
hostStrings?: HostStrings;
|
|
34
|
+
hostRootReducer: Record<string, Reducer>;
|
|
35
|
+
blacklistedReducers?: string[];
|
|
36
|
+
children?: ReactNode;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const NeetoCommonsRNProvider = ({
|
|
40
|
+
appName,
|
|
41
|
+
hostNavigationRef,
|
|
42
|
+
hostStrings,
|
|
43
|
+
hostRootReducer,
|
|
44
|
+
blacklistedReducers,
|
|
45
|
+
children,
|
|
46
|
+
}: NeetoCommonsRNProviderProps) => {
|
|
47
|
+
const prevReducersRef = useRef<Record<string, Reducer> | null>(null);
|
|
48
|
+
const prevBlacklistRef = useRef<string[] | undefined>(undefined);
|
|
49
|
+
if (
|
|
50
|
+
prevReducersRef.current !== hostRootReducer ||
|
|
51
|
+
prevBlacklistRef.current !== blacklistedReducers
|
|
52
|
+
) {
|
|
53
|
+
prevReducersRef.current = hostRootReducer;
|
|
54
|
+
prevBlacklistRef.current = blacklistedReducers;
|
|
55
|
+
updateRootReducer({ reducers: hostRootReducer, blacklistedReducers });
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
useLayoutEffect(() => {
|
|
59
|
+
setHostNavigationRef(hostNavigationRef);
|
|
60
|
+
|
|
61
|
+
return () => setHostNavigationRef(navigationRef);
|
|
62
|
+
}, [hostNavigationRef]);
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
Store.dispatch(setAppName({ appName }));
|
|
66
|
+
}, [appName]);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<Provider store={Store}>
|
|
70
|
+
<PersistGate loading={null} persistor={Persistor}>
|
|
71
|
+
<LocalizationProvider hostStrings={hostStrings}>
|
|
72
|
+
{children}
|
|
73
|
+
</LocalizationProvider>
|
|
74
|
+
</PersistGate>
|
|
75
|
+
</Provider>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NeetoCommonsRNProvider } from "./NeetoCommonsRNProvider";
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import React, { useMemo, type ComponentType, type ReactElement } from "react";
|
|
2
|
+
import {
|
|
3
|
+
ActivityIndicator,
|
|
4
|
+
SectionList,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
type StyleProp,
|
|
7
|
+
type ViewStyle,
|
|
8
|
+
} from "react-native";
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
Container,
|
|
12
|
+
Divider,
|
|
13
|
+
Loader,
|
|
14
|
+
ParentView,
|
|
15
|
+
Touchable,
|
|
16
|
+
Typography,
|
|
17
|
+
lightTheme,
|
|
18
|
+
} from "@bigbinary/neetoui-rn";
|
|
19
|
+
import dayjs from "dayjs";
|
|
20
|
+
|
|
21
|
+
import { type NotificationItem } from "../api/notifications";
|
|
22
|
+
import { EmptyView, Header } from "../components";
|
|
23
|
+
import { dateTimeFormats } from "../constants";
|
|
24
|
+
import { formatDateTime } from "../helpers";
|
|
25
|
+
import { moderateScale } from "../helpers/scale";
|
|
26
|
+
import { openDeepLinkingUrl } from "../helpers/utils";
|
|
27
|
+
import { useLocalization } from "../hooks";
|
|
28
|
+
import { useNotification } from "../hooks/query/useNotification";
|
|
29
|
+
|
|
30
|
+
/** One day's worth of notifications, as the SectionList consumes them. */
|
|
31
|
+
interface NotificationSection {
|
|
32
|
+
title: string;
|
|
33
|
+
data: NotificationItem[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const renderFooter = () => (
|
|
37
|
+
<Container style={styles.footer}>
|
|
38
|
+
<ActivityIndicator color={lightTheme.colors.palette.grey800} size="small" />
|
|
39
|
+
</Container>
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
interface NotificationListItemProps {
|
|
43
|
+
notification: NotificationItem;
|
|
44
|
+
CustomNotificationContent?: ComponentType<{
|
|
45
|
+
notification: NotificationItem;
|
|
46
|
+
}> | null;
|
|
47
|
+
itemStyles?: StyleProp<ViewStyle>;
|
|
48
|
+
markAllLoading?: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const NotificationListItem = ({
|
|
52
|
+
notification,
|
|
53
|
+
CustomNotificationContent = null,
|
|
54
|
+
itemStyles = {},
|
|
55
|
+
markAllLoading,
|
|
56
|
+
}: NotificationListItemProps) => {
|
|
57
|
+
const { useMarkReadUnreadNotification } = useNotification();
|
|
58
|
+
|
|
59
|
+
const { mutate: markReadUnreadNotification } =
|
|
60
|
+
useMarkReadUnreadNotification();
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<>
|
|
64
|
+
<Touchable
|
|
65
|
+
disabled={markAllLoading}
|
|
66
|
+
style={[
|
|
67
|
+
styles.item,
|
|
68
|
+
notification.read_at ? styles.itemRead : styles.itemUnread,
|
|
69
|
+
itemStyles,
|
|
70
|
+
]}
|
|
71
|
+
onPress={() => {
|
|
72
|
+
if (!notification.read_at) {
|
|
73
|
+
markReadUnreadNotification({
|
|
74
|
+
readAt: dayjs().toISOString(),
|
|
75
|
+
notificationId: notification.id,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
openDeepLinkingUrl(notification.url);
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
{CustomNotificationContent ? (
|
|
82
|
+
<CustomNotificationContent {...{ notification }} />
|
|
83
|
+
) : (
|
|
84
|
+
<>
|
|
85
|
+
<Typography size="s" style={styles.itemBody} weight="medium">
|
|
86
|
+
{notification.body}
|
|
87
|
+
</Typography>
|
|
88
|
+
<Container style={styles.itemTitleRow}>
|
|
89
|
+
<Typography
|
|
90
|
+
color={lightTheme.colors.palette.grey500}
|
|
91
|
+
size="s"
|
|
92
|
+
style={styles.itemTitle}
|
|
93
|
+
weight="regular"
|
|
94
|
+
>
|
|
95
|
+
{notification.title}
|
|
96
|
+
</Typography>
|
|
97
|
+
</Container>
|
|
98
|
+
<Typography
|
|
99
|
+
color={lightTheme.colors.palette.grey500}
|
|
100
|
+
size="xs"
|
|
101
|
+
style={styles.itemTimestamp}
|
|
102
|
+
weight="regular"
|
|
103
|
+
>
|
|
104
|
+
{formatDateTime.fromNow(notification.created_at)}
|
|
105
|
+
</Typography>
|
|
106
|
+
</>
|
|
107
|
+
)}
|
|
108
|
+
</Touchable>
|
|
109
|
+
<Divider
|
|
110
|
+
orientation="horizontal"
|
|
111
|
+
style={styles.itemDivider}
|
|
112
|
+
thickness={1}
|
|
113
|
+
/>
|
|
114
|
+
</>
|
|
115
|
+
);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export interface NotificationsScreenProps {
|
|
119
|
+
CustomNotificationContent?: ComponentType<{
|
|
120
|
+
notification: NotificationItem;
|
|
121
|
+
}> | null;
|
|
122
|
+
itemStyles?: StyleProp<ViewStyle>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export const NotificationsScreen = ({
|
|
126
|
+
CustomNotificationContent = null,
|
|
127
|
+
itemStyles = [],
|
|
128
|
+
}: NotificationsScreenProps) => {
|
|
129
|
+
const { useFetchNotifications, useMarkAllReadNotification } =
|
|
130
|
+
useNotification();
|
|
131
|
+
|
|
132
|
+
const {
|
|
133
|
+
data: { notifications, totalNotifications } = {},
|
|
134
|
+
isPending: isNotificationsLoading,
|
|
135
|
+
refetch: refetchSubmissions,
|
|
136
|
+
isRefetching: notificationsRefetching,
|
|
137
|
+
fetchNextPage,
|
|
138
|
+
hasNextPage,
|
|
139
|
+
isFetchingNextPage,
|
|
140
|
+
} = useFetchNotifications();
|
|
141
|
+
|
|
142
|
+
const { mutate: markAllRead, isPending: isMarkingAllRead } =
|
|
143
|
+
useMarkAllReadNotification();
|
|
144
|
+
const { strings } = useLocalization();
|
|
145
|
+
const markAllLoading = isMarkingAllRead || notificationsRefetching;
|
|
146
|
+
|
|
147
|
+
const unreadNotifications = useMemo(
|
|
148
|
+
() => notifications?.filter(n => !n.read_at) || [],
|
|
149
|
+
[notifications]
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
const sectionedNotifications = useMemo(
|
|
153
|
+
() =>
|
|
154
|
+
notifications?.reduce<NotificationSection[]>((sections, notification) => {
|
|
155
|
+
const title = dayjs(notification.created_at).format(
|
|
156
|
+
dateTimeFormats.dateWeek
|
|
157
|
+
);
|
|
158
|
+
const sectionExists = sections.find(section => section.title === title);
|
|
159
|
+
if (!sectionExists) {
|
|
160
|
+
sections.push({
|
|
161
|
+
title,
|
|
162
|
+
data: [notification],
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
return sections;
|
|
166
|
+
}
|
|
167
|
+
sectionExists.data.push(notification);
|
|
168
|
+
|
|
169
|
+
return sections;
|
|
170
|
+
}, []),
|
|
171
|
+
[notifications]
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
const handleMarkAllAsRead = () =>
|
|
175
|
+
markAllRead(undefined, {
|
|
176
|
+
// eslint-disable-next-line no-console
|
|
177
|
+
onError: e => console.error("mark-all-read failed", e),
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
return (
|
|
181
|
+
<ParentView barStyle="dark-content">
|
|
182
|
+
<Header
|
|
183
|
+
canGoBack
|
|
184
|
+
isLoading={markAllLoading}
|
|
185
|
+
showMarkAllOption={unreadNotifications.length > 0}
|
|
186
|
+
title="Notifications"
|
|
187
|
+
onMarkAllAsRead={handleMarkAllAsRead}
|
|
188
|
+
/>
|
|
189
|
+
{isNotificationsLoading ? (
|
|
190
|
+
<Container style={styles.loaderWrapper}>
|
|
191
|
+
<Loader />
|
|
192
|
+
</Container>
|
|
193
|
+
) : (
|
|
194
|
+
<SectionList
|
|
195
|
+
keyExtractor={({ id }, index) => id + index}
|
|
196
|
+
refreshing={notificationsRefetching}
|
|
197
|
+
sections={sectionedNotifications || []}
|
|
198
|
+
// Both slots receive `false` rather than null while the condition is
|
|
199
|
+
// unmet; VirtualizedList only tests them for truthiness, so nothing
|
|
200
|
+
// renders — as before. React's types admit only a component/element.
|
|
201
|
+
ListEmptyComponent={
|
|
202
|
+
(totalNotifications === 0 && (
|
|
203
|
+
<EmptyView
|
|
204
|
+
title={strings.commons.notificationScreen.empty.title}
|
|
205
|
+
/>
|
|
206
|
+
)) as unknown as ReactElement
|
|
207
|
+
}
|
|
208
|
+
ListFooterComponent={
|
|
209
|
+
(isFetchingNextPage && renderFooter) as unknown as ComponentType
|
|
210
|
+
}
|
|
211
|
+
renderItem={({ item: notification }) => (
|
|
212
|
+
<NotificationListItem
|
|
213
|
+
{...{
|
|
214
|
+
notification,
|
|
215
|
+
CustomNotificationContent,
|
|
216
|
+
itemStyles,
|
|
217
|
+
markAllLoading,
|
|
218
|
+
}}
|
|
219
|
+
/>
|
|
220
|
+
)}
|
|
221
|
+
renderSectionHeader={({ section: { title } }) => (
|
|
222
|
+
// `flexDirection="col"` is not a React Native value; it resolved
|
|
223
|
+
// to the default `column`, which is what the style now states.
|
|
224
|
+
<Container style={styles.sectionHeader}>
|
|
225
|
+
<Typography
|
|
226
|
+
color={lightTheme.colors.palette.grey700}
|
|
227
|
+
size="xs"
|
|
228
|
+
style={styles.sectionHeaderText}
|
|
229
|
+
weight="medium"
|
|
230
|
+
>
|
|
231
|
+
{title}
|
|
232
|
+
</Typography>
|
|
233
|
+
</Container>
|
|
234
|
+
)}
|
|
235
|
+
onEndReached={() => hasNextPage && fetchNextPage()}
|
|
236
|
+
onEndReachedThreshold={0.2}
|
|
237
|
+
onRefresh={refetchSubmissions}
|
|
238
|
+
/>
|
|
239
|
+
)}
|
|
240
|
+
</ParentView>
|
|
241
|
+
);
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
const styles = StyleSheet.create({
|
|
245
|
+
footer: {
|
|
246
|
+
marginBottom: moderateScale(3),
|
|
247
|
+
marginTop: moderateScale(2),
|
|
248
|
+
},
|
|
249
|
+
item: {
|
|
250
|
+
paddingHorizontal: moderateScale(16),
|
|
251
|
+
paddingVertical: moderateScale(12),
|
|
252
|
+
},
|
|
253
|
+
itemRead: {
|
|
254
|
+
backgroundColor: lightTheme.colors.white,
|
|
255
|
+
},
|
|
256
|
+
itemUnread: {
|
|
257
|
+
backgroundColor: lightTheme.colors.palette.purple200,
|
|
258
|
+
},
|
|
259
|
+
itemBody: {
|
|
260
|
+
marginBottom: moderateScale(4),
|
|
261
|
+
},
|
|
262
|
+
itemTitleRow: {
|
|
263
|
+
flexDirection: "row",
|
|
264
|
+
justifyContent: "space-between",
|
|
265
|
+
paddingTop: moderateScale(1),
|
|
266
|
+
},
|
|
267
|
+
itemTitle: {
|
|
268
|
+
flex: 1,
|
|
269
|
+
},
|
|
270
|
+
itemTimestamp: {
|
|
271
|
+
alignSelf: "flex-end",
|
|
272
|
+
},
|
|
273
|
+
itemDivider: {
|
|
274
|
+
backgroundColor: lightTheme.colors.palette.grey200,
|
|
275
|
+
},
|
|
276
|
+
loaderWrapper: {
|
|
277
|
+
alignItems: "center",
|
|
278
|
+
justifyContent: "center",
|
|
279
|
+
flex: 1,
|
|
280
|
+
},
|
|
281
|
+
sectionHeader: {
|
|
282
|
+
flexDirection: "column",
|
|
283
|
+
},
|
|
284
|
+
sectionHeaderText: {
|
|
285
|
+
backgroundColor: lightTheme.colors.white,
|
|
286
|
+
marginBottom: moderateScale(8),
|
|
287
|
+
paddingLeft: moderateScale(16),
|
|
288
|
+
paddingTop: moderateScale(18),
|
|
289
|
+
},
|
|
290
|
+
});
|