@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,135 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Pressable, StyleSheet, View } from "react-native";
|
|
3
|
+
|
|
4
|
+
import { Container, Typography, lightTheme } from "@bigbinary/neetoui-rn";
|
|
5
|
+
|
|
6
|
+
import { type OrganizationRole } from "../../api/organization_roles";
|
|
7
|
+
import { moderateScale } from "../../helpers/scale";
|
|
8
|
+
|
|
9
|
+
/** The organization-roles endpoint also sends a human-readable description. */
|
|
10
|
+
export type RoleOption = OrganizationRole & { description?: string };
|
|
11
|
+
|
|
12
|
+
interface RadioCircleProps {
|
|
13
|
+
selected?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const RadioCircle = ({ selected }: RadioCircleProps) => (
|
|
17
|
+
<View style={[styles.radioOuter, selected && styles.radioOuterSelected]}>
|
|
18
|
+
{selected && <View style={styles.radioInner} />}
|
|
19
|
+
</View>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
interface RoleRowProps {
|
|
23
|
+
role: RoleOption;
|
|
24
|
+
isSelected: boolean;
|
|
25
|
+
isLast: boolean;
|
|
26
|
+
onSelect: () => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const RoleRow = ({ role, isSelected, isLast, onSelect }: RoleRowProps) => (
|
|
30
|
+
<Pressable
|
|
31
|
+
style={[
|
|
32
|
+
styles.roleRow,
|
|
33
|
+
isSelected && styles.roleRowSelected,
|
|
34
|
+
!isLast && styles.roleRowBorder,
|
|
35
|
+
]}
|
|
36
|
+
onPress={onSelect}
|
|
37
|
+
>
|
|
38
|
+
<View style={styles.roleInfo}>
|
|
39
|
+
<Typography size="m" weight={isSelected ? "semibold" : "medium"}>
|
|
40
|
+
{role.name}
|
|
41
|
+
</Typography>
|
|
42
|
+
{!!role.description && (
|
|
43
|
+
<Typography
|
|
44
|
+
color={lightTheme.colors.palette.grey500}
|
|
45
|
+
size="xs"
|
|
46
|
+
weight="regular"
|
|
47
|
+
>
|
|
48
|
+
{role.description}
|
|
49
|
+
</Typography>
|
|
50
|
+
)}
|
|
51
|
+
</View>
|
|
52
|
+
<RadioCircle selected={isSelected} />
|
|
53
|
+
</Pressable>
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
interface RolesRadioGroupProps {
|
|
57
|
+
roles: RoleOption[];
|
|
58
|
+
selectedRole?: string;
|
|
59
|
+
updateRole: (role: string) => void;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const RolesRadioGroup = ({
|
|
63
|
+
roles,
|
|
64
|
+
selectedRole,
|
|
65
|
+
updateRole,
|
|
66
|
+
}: RolesRadioGroupProps) => (
|
|
67
|
+
<Container style={styles.container}>
|
|
68
|
+
<Typography size="l" weight="medium">
|
|
69
|
+
Role<Typography color={lightTheme.colors.danger}>*</Typography>
|
|
70
|
+
</Typography>
|
|
71
|
+
<View style={styles.cardContainer}>
|
|
72
|
+
{roles.map((role, index) => (
|
|
73
|
+
<RoleRow
|
|
74
|
+
isLast={index === roles.length - 1}
|
|
75
|
+
isSelected={selectedRole === role.name}
|
|
76
|
+
key={role.id}
|
|
77
|
+
role={role}
|
|
78
|
+
onSelect={() => updateRole(role.name)}
|
|
79
|
+
/>
|
|
80
|
+
))}
|
|
81
|
+
</View>
|
|
82
|
+
</Container>
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const styles = StyleSheet.create({
|
|
86
|
+
container: {
|
|
87
|
+
paddingTop: moderateScale(8),
|
|
88
|
+
rowGap: moderateScale(8),
|
|
89
|
+
},
|
|
90
|
+
cardContainer: {
|
|
91
|
+
borderRadius: moderateScale(8),
|
|
92
|
+
borderWidth: 1,
|
|
93
|
+
borderColor: lightTheme.colors.palette.grey300,
|
|
94
|
+
overflow: "hidden",
|
|
95
|
+
},
|
|
96
|
+
roleRow: {
|
|
97
|
+
flexDirection: "row",
|
|
98
|
+
alignItems: "center",
|
|
99
|
+
justifyContent: "space-between",
|
|
100
|
+
paddingVertical: moderateScale(14),
|
|
101
|
+
paddingHorizontal: moderateScale(16),
|
|
102
|
+
},
|
|
103
|
+
roleRowSelected: {
|
|
104
|
+
backgroundColor: "#E8F5E9",
|
|
105
|
+
},
|
|
106
|
+
roleRowBorder: {
|
|
107
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
108
|
+
borderBottomColor: lightTheme.colors.palette.grey300,
|
|
109
|
+
},
|
|
110
|
+
roleInfo: {
|
|
111
|
+
flex: 1,
|
|
112
|
+
rowGap: moderateScale(2),
|
|
113
|
+
marginRight: moderateScale(12),
|
|
114
|
+
},
|
|
115
|
+
radioOuter: {
|
|
116
|
+
width: moderateScale(22),
|
|
117
|
+
height: moderateScale(22),
|
|
118
|
+
borderRadius: moderateScale(11),
|
|
119
|
+
borderWidth: 2,
|
|
120
|
+
borderColor: lightTheme.colors.palette.grey400,
|
|
121
|
+
alignItems: "center",
|
|
122
|
+
justifyContent: "center",
|
|
123
|
+
},
|
|
124
|
+
radioOuterSelected: {
|
|
125
|
+
borderColor: lightTheme.colors.primary,
|
|
126
|
+
},
|
|
127
|
+
radioInner: {
|
|
128
|
+
width: moderateScale(12),
|
|
129
|
+
height: moderateScale(12),
|
|
130
|
+
borderRadius: moderateScale(6),
|
|
131
|
+
backgroundColor: lightTheme.colors.primary,
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
export default RolesRadioGroup;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyleSheet } from "react-native";
|
|
3
|
+
|
|
4
|
+
import { Button, Container, lightTheme } from "@bigbinary/neetoui-rn";
|
|
5
|
+
|
|
6
|
+
import { moderateScale } from "../../helpers/scale";
|
|
7
|
+
|
|
8
|
+
interface SaveButtonsProps {
|
|
9
|
+
onSave: () => void;
|
|
10
|
+
onCancel: () => void;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
isLoading?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const SaveButtons = ({
|
|
16
|
+
onSave,
|
|
17
|
+
onCancel,
|
|
18
|
+
disabled,
|
|
19
|
+
isLoading = false,
|
|
20
|
+
}: SaveButtonsProps) => (
|
|
21
|
+
<Container style={styles.container}>
|
|
22
|
+
<Button
|
|
23
|
+
disabled={disabled}
|
|
24
|
+
isLoading={isLoading}
|
|
25
|
+
label="Save changes"
|
|
26
|
+
labelStyle={styles.buttonLabel}
|
|
27
|
+
style={styles.button}
|
|
28
|
+
onPress={() => onSave()}
|
|
29
|
+
/>
|
|
30
|
+
<Button
|
|
31
|
+
label="Cancel"
|
|
32
|
+
labelStyle={styles.buttonLabel}
|
|
33
|
+
style={styles.button}
|
|
34
|
+
variant="secondary"
|
|
35
|
+
onPress={() => onCancel()}
|
|
36
|
+
/>
|
|
37
|
+
</Container>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const styles = StyleSheet.create({
|
|
41
|
+
container: {
|
|
42
|
+
backgroundColor: lightTheme.colors.white,
|
|
43
|
+
bottom: 10,
|
|
44
|
+
columnGap: moderateScale(16),
|
|
45
|
+
flex: 1,
|
|
46
|
+
flexDirection: "row",
|
|
47
|
+
left: 0,
|
|
48
|
+
padding: moderateScale(16),
|
|
49
|
+
position: "absolute",
|
|
50
|
+
right: 0,
|
|
51
|
+
width: "100%",
|
|
52
|
+
},
|
|
53
|
+
button: {
|
|
54
|
+
flex: 1,
|
|
55
|
+
height: moderateScale(48),
|
|
56
|
+
},
|
|
57
|
+
buttonLabel: {
|
|
58
|
+
fontSize: lightTheme.fontSizes.m,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export default SaveButtons;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import Config from "react-native-config";
|
|
2
|
+
|
|
3
|
+
export const LOADING_CARD = {
|
|
4
|
+
CARD_HEIGHT: 70,
|
|
5
|
+
TITLE_HEIGHT: 14,
|
|
6
|
+
SUBTITLE_HEIGHT: 10,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const ADMIN_ROLE_NAME = "Admin";
|
|
10
|
+
export const OWNER_ROLE_NAME = "Owner";
|
|
11
|
+
export const ADMIN_ROLES = [ADMIN_ROLE_NAME, OWNER_ROLE_NAME];
|
|
12
|
+
|
|
13
|
+
export interface RoleColor {
|
|
14
|
+
bg: string;
|
|
15
|
+
text: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Keyed by role name, which the server owns — hence the open record rather
|
|
19
|
+
// than a union of the four names spelled out here.
|
|
20
|
+
export const ROLE_COLORS: Record<string, RoleColor> = {
|
|
21
|
+
Admin: { bg: "#E8F5E9", text: "#2E7D32" },
|
|
22
|
+
Standard: { bg: "#E8F5E9", text: "#388E3C" },
|
|
23
|
+
Manager: { bg: "#FFF3E0", text: "#E65100" },
|
|
24
|
+
Owner: { bg: "#E3F2FD", text: "#1565C0" },
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const DEFAULT_ROLE_COLOR: RoleColor = { bg: "#F5F5F5", text: "#616161" };
|
|
28
|
+
|
|
29
|
+
// Read at module load, so an unset APP_DISPLAY_NAME would crash the import
|
|
30
|
+
// graph rather than the screen that needs it.
|
|
31
|
+
export const APP_NAME = (Config.APP_DISPLAY_NAME ?? "")
|
|
32
|
+
.split(" ")[0]
|
|
33
|
+
.substring(5);
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import React, { useCallback, useState } from "react";
|
|
2
|
+
import { StyleSheet } from "react-native";
|
|
3
|
+
|
|
4
|
+
import { Edit, Delete } from "@bigbinary/neeto-icons-rn";
|
|
5
|
+
import {
|
|
6
|
+
Container,
|
|
7
|
+
Divider,
|
|
8
|
+
Loader,
|
|
9
|
+
ParentView,
|
|
10
|
+
SearchBar,
|
|
11
|
+
FlashList,
|
|
12
|
+
Touchable,
|
|
13
|
+
Typography,
|
|
14
|
+
lightTheme,
|
|
15
|
+
} from "@bigbinary/neetoui-rn";
|
|
16
|
+
|
|
17
|
+
import Card from "./Card";
|
|
18
|
+
import { LoadingCard } from "./LoadingCard";
|
|
19
|
+
|
|
20
|
+
import { type TeamMember } from "../../api/team_members";
|
|
21
|
+
import { BottomSheetMenu, EmptyView, Header } from "../../components";
|
|
22
|
+
import ConfirmSheet from "../../components/ConfirmSheet";
|
|
23
|
+
import { moderateScale } from "../../helpers/scale";
|
|
24
|
+
import {
|
|
25
|
+
useFetchTeamMembers,
|
|
26
|
+
useRemoveTeamMember,
|
|
27
|
+
} from "../../hooks/query/useTeamMembersApi";
|
|
28
|
+
import { navigate } from "../../navigation/navigationService";
|
|
29
|
+
import { SCREEN_NAMES } from "../../navigation/screenNames";
|
|
30
|
+
|
|
31
|
+
type TeamMemberRenderItem = (info: {
|
|
32
|
+
item: TeamMember;
|
|
33
|
+
}) => React.ReactElement | null;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Host apps register this screen in their own navigator, so its route is not
|
|
37
|
+
* part of CommonsParamList.
|
|
38
|
+
*/
|
|
39
|
+
interface TeamMembersScreenProps {
|
|
40
|
+
route?: {
|
|
41
|
+
params?: {
|
|
42
|
+
canGoBack?: boolean;
|
|
43
|
+
bottomInset?: boolean;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const TeamMembersScreen = ({ route }: TeamMembersScreenProps) => {
|
|
49
|
+
const { canGoBack = false, bottomInset = false } = route?.params || {};
|
|
50
|
+
const [searchTerm, setSearchTerm] = useState("");
|
|
51
|
+
const [selectedTeamMember, setSelectedTeamMember] =
|
|
52
|
+
useState<TeamMember | null>(null);
|
|
53
|
+
const [isActionsVisible, setIsActionsVisible] = useState(false);
|
|
54
|
+
|
|
55
|
+
const {
|
|
56
|
+
data: members = [],
|
|
57
|
+
isPending: isLoading,
|
|
58
|
+
isRefetching,
|
|
59
|
+
refetch,
|
|
60
|
+
isFetchingNextPage,
|
|
61
|
+
hasNextPage,
|
|
62
|
+
fetchNextPage,
|
|
63
|
+
} = useFetchTeamMembers(searchTerm);
|
|
64
|
+
|
|
65
|
+
const { mutate: removeTeamMember } = useRemoveTeamMember();
|
|
66
|
+
|
|
67
|
+
const handleAddMember = () => navigate(SCREEN_NAMES.AddTeamMemberScreen);
|
|
68
|
+
|
|
69
|
+
const handleDelete = () => {
|
|
70
|
+
if (!selectedTeamMember) return;
|
|
71
|
+
|
|
72
|
+
ConfirmSheet.show({
|
|
73
|
+
title: "Remove member?",
|
|
74
|
+
description: `${selectedTeamMember?.display_name} will lose access to the workspace. This can't be undone.`,
|
|
75
|
+
buttons: [
|
|
76
|
+
{
|
|
77
|
+
label: "Remove",
|
|
78
|
+
onPress: () => {
|
|
79
|
+
removeTeamMember({ id: selectedTeamMember.id });
|
|
80
|
+
setSelectedTeamMember(null);
|
|
81
|
+
},
|
|
82
|
+
variant: "danger",
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
label: "Cancel",
|
|
86
|
+
onPress: () => setSelectedTeamMember(null),
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const handleEdit = () => {
|
|
93
|
+
if (!selectedTeamMember) return;
|
|
94
|
+
|
|
95
|
+
navigate(SCREEN_NAMES.EditTeamMemberScreen, {
|
|
96
|
+
member: selectedTeamMember,
|
|
97
|
+
});
|
|
98
|
+
setSelectedTeamMember(null);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const renderItem = useCallback<TeamMemberRenderItem>(
|
|
102
|
+
({ item }) => (
|
|
103
|
+
<Card
|
|
104
|
+
member={item}
|
|
105
|
+
onPress={member => {
|
|
106
|
+
setSelectedTeamMember(member);
|
|
107
|
+
setIsActionsVisible(true);
|
|
108
|
+
}}
|
|
109
|
+
/>
|
|
110
|
+
),
|
|
111
|
+
[]
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
const renderFooter = useCallback(
|
|
115
|
+
() =>
|
|
116
|
+
isFetchingNextPage ? (
|
|
117
|
+
<Container style={styles.footerLoader}>
|
|
118
|
+
<Loader />
|
|
119
|
+
</Container>
|
|
120
|
+
) : null,
|
|
121
|
+
[isFetchingNextPage]
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
const keyExtractor = useCallback(({ id }: TeamMember) => id, []);
|
|
125
|
+
|
|
126
|
+
const renderItemSeparator = () => <Container style={styles.itemSeparator} />;
|
|
127
|
+
|
|
128
|
+
const renderEmptyComponent = () => (
|
|
129
|
+
<EmptyView title="No team members found" />
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
// v2's `bg`/`flex` are dropped: v3's ParentView already fills its parent
|
|
134
|
+
// and paints the active theme's primary background by default.
|
|
135
|
+
<ParentView barStyle="dark-content" bottomInset={bottomInset}>
|
|
136
|
+
<Header
|
|
137
|
+
canGoBack={canGoBack}
|
|
138
|
+
title="Team members"
|
|
139
|
+
RightComponent={() => (
|
|
140
|
+
<Touchable onPress={handleAddMember}>
|
|
141
|
+
<Typography
|
|
142
|
+
color={lightTheme.colors.palette.base}
|
|
143
|
+
size="m"
|
|
144
|
+
weight="medium"
|
|
145
|
+
>
|
|
146
|
+
+ Add
|
|
147
|
+
</Typography>
|
|
148
|
+
</Touchable>
|
|
149
|
+
)}
|
|
150
|
+
/>
|
|
151
|
+
<Divider style={styles.divider} />
|
|
152
|
+
<Container style={styles.searchContainer}>
|
|
153
|
+
<SearchBar
|
|
154
|
+
containerStyle={styles.searchBar}
|
|
155
|
+
placeholder="Search members..."
|
|
156
|
+
onCancel={() => setSearchTerm("")}
|
|
157
|
+
onChangeText={setSearchTerm}
|
|
158
|
+
/>
|
|
159
|
+
</Container>
|
|
160
|
+
<FlashList
|
|
161
|
+
ItemSeparatorComponent={renderItemSeparator}
|
|
162
|
+
ListEmptyComponent={renderEmptyComponent}
|
|
163
|
+
ListFooterComponent={renderFooter}
|
|
164
|
+
SkeletonComponent={<LoadingCard />}
|
|
165
|
+
contentContainerStyle={styles.listContent}
|
|
166
|
+
data={members || []}
|
|
167
|
+
isLoading={isLoading}
|
|
168
|
+
keyExtractor={keyExtractor}
|
|
169
|
+
refreshing={isRefetching}
|
|
170
|
+
renderItem={renderItem}
|
|
171
|
+
showsVerticalScrollIndicator={false}
|
|
172
|
+
onEndReached={() => hasNextPage && fetchNextPage()}
|
|
173
|
+
onEndReachedThreshold={0.7}
|
|
174
|
+
onRefresh={refetch}
|
|
175
|
+
/>
|
|
176
|
+
<BottomSheetMenu
|
|
177
|
+
isVisible={isActionsVisible}
|
|
178
|
+
title={selectedTeamMember?.display_name}
|
|
179
|
+
items={[
|
|
180
|
+
{
|
|
181
|
+
key: "edit",
|
|
182
|
+
label: "Edit member",
|
|
183
|
+
icon: Edit,
|
|
184
|
+
onPress: handleEdit,
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
key: "delete",
|
|
188
|
+
label: "Remove member",
|
|
189
|
+
icon: Delete,
|
|
190
|
+
color: lightTheme.colors.danger,
|
|
191
|
+
onPress: handleDelete,
|
|
192
|
+
},
|
|
193
|
+
]}
|
|
194
|
+
onClose={() => setIsActionsVisible(false)}
|
|
195
|
+
/>
|
|
196
|
+
</ParentView>
|
|
197
|
+
);
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const styles = StyleSheet.create({
|
|
201
|
+
divider: {
|
|
202
|
+
backgroundColor: lightTheme.colors.palette.grey200,
|
|
203
|
+
},
|
|
204
|
+
searchContainer: {
|
|
205
|
+
paddingHorizontal: moderateScale(14),
|
|
206
|
+
paddingTop: moderateScale(10),
|
|
207
|
+
},
|
|
208
|
+
searchBar: {
|
|
209
|
+
borderColor: lightTheme.colors.palette.grey300,
|
|
210
|
+
height: moderateScale(36),
|
|
211
|
+
},
|
|
212
|
+
listContent: {
|
|
213
|
+
padding: moderateScale(16),
|
|
214
|
+
},
|
|
215
|
+
footerLoader: {
|
|
216
|
+
paddingVertical: moderateScale(8),
|
|
217
|
+
},
|
|
218
|
+
itemSeparator: {
|
|
219
|
+
height: moderateScale(12),
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
export default TeamMembersScreen;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { _findBy, notEquals } from "@bigbinary/neeto-cist";
|
|
2
|
+
import { equals, includes, move } from "ramda";
|
|
3
|
+
|
|
4
|
+
import { ADMIN_ROLE_NAME, ADMIN_ROLES, APP_NAME } from "./constants";
|
|
5
|
+
|
|
6
|
+
import { type GlobalRole } from "../../api/global_roles";
|
|
7
|
+
|
|
8
|
+
/** `useFetchGlobalRoles` groups the global roles by their `app_name`. */
|
|
9
|
+
export type GlobalRolesByApp = Partial<Record<string, GlobalRole[]>>;
|
|
10
|
+
|
|
11
|
+
/** One row of the "add member" product matrix. */
|
|
12
|
+
export interface ProductRole {
|
|
13
|
+
app_name: string;
|
|
14
|
+
active_role: string;
|
|
15
|
+
is_enabled: boolean;
|
|
16
|
+
is_primary: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// A type alias rather than an interface so the object keeps an implicit index
|
|
20
|
+
// signature and stays assignable to the create-member payload.
|
|
21
|
+
export type AddTeamMemberFormValues = {
|
|
22
|
+
email: string;
|
|
23
|
+
role: string;
|
|
24
|
+
products: ProductRole[];
|
|
25
|
+
otherProducts: boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const isAdminRole = (role: string) =>
|
|
29
|
+
includes(role, ADMIN_ROLES)
|
|
30
|
+
? equals(ADMIN_ROLE_NAME)
|
|
31
|
+
: notEquals(ADMIN_ROLE_NAME);
|
|
32
|
+
|
|
33
|
+
const getDefaultRole = (
|
|
34
|
+
roles: GlobalRole[],
|
|
35
|
+
currentAppRole: string,
|
|
36
|
+
appName: string
|
|
37
|
+
) => {
|
|
38
|
+
if (appName === APP_NAME) {
|
|
39
|
+
return currentAppRole;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const condition = isAdminRole(currentAppRole);
|
|
43
|
+
|
|
44
|
+
const role = _findBy({ name: condition }, roles);
|
|
45
|
+
|
|
46
|
+
return role ? role.name : roles[0].name;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const generateAppsRolesInitialValue = (
|
|
50
|
+
globalRoles: GlobalRolesByApp | undefined,
|
|
51
|
+
currentAppRole: string
|
|
52
|
+
): ProductRole[] => {
|
|
53
|
+
if (!globalRoles) return [];
|
|
54
|
+
|
|
55
|
+
const appNames = Object.keys(globalRoles).filter(
|
|
56
|
+
name => (globalRoles[name]?.length ?? 0) > 0
|
|
57
|
+
);
|
|
58
|
+
const currentAppNameIndex = appNames.indexOf(APP_NAME);
|
|
59
|
+
const appNamesSorted =
|
|
60
|
+
currentAppNameIndex >= 0
|
|
61
|
+
? move(currentAppNameIndex, 0, appNames)
|
|
62
|
+
: appNames;
|
|
63
|
+
|
|
64
|
+
return appNamesSorted.map(appName => ({
|
|
65
|
+
app_name: appName,
|
|
66
|
+
active_role: getDefaultRole(
|
|
67
|
+
globalRoles[appName] ?? [],
|
|
68
|
+
currentAppRole,
|
|
69
|
+
appName
|
|
70
|
+
),
|
|
71
|
+
is_enabled: true,
|
|
72
|
+
is_primary: APP_NAME === appName,
|
|
73
|
+
}));
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const getInitialValues = (
|
|
77
|
+
role = "",
|
|
78
|
+
globalRoles?: GlobalRolesByApp
|
|
79
|
+
): AddTeamMemberFormValues => ({
|
|
80
|
+
email: "",
|
|
81
|
+
role,
|
|
82
|
+
products: generateAppsRolesInitialValue(globalRoles, role),
|
|
83
|
+
otherProducts: true,
|
|
84
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { createSlice, type PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
+
import notifee from "react-native-notify-kit";
|
|
3
|
+
|
|
4
|
+
// A workspace the signed-in email belongs to. The snake_case keys are the
|
|
5
|
+
// server's and reach consumers unchanged.
|
|
6
|
+
export interface Organization {
|
|
7
|
+
id: string;
|
|
8
|
+
auth_token: string;
|
|
9
|
+
email: string;
|
|
10
|
+
name: string;
|
|
11
|
+
subdomain: string;
|
|
12
|
+
organization_name: string;
|
|
13
|
+
profile_image_url: string | null;
|
|
14
|
+
is_onboard?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface AuthState {
|
|
18
|
+
appName: string | null;
|
|
19
|
+
isLoggedIn: boolean;
|
|
20
|
+
email: string;
|
|
21
|
+
subdomain: string;
|
|
22
|
+
name: string;
|
|
23
|
+
userId: string;
|
|
24
|
+
organization_name: string;
|
|
25
|
+
profile_image_url: string | null;
|
|
26
|
+
organizations: Organization[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type LoginPayload = Pick<
|
|
30
|
+
Organization,
|
|
31
|
+
"email" | "name" | "subdomain" | "organization_name" | "profile_image_url"
|
|
32
|
+
> & { id: string };
|
|
33
|
+
|
|
34
|
+
const initialState: AuthState = {
|
|
35
|
+
appName: null,
|
|
36
|
+
isLoggedIn: false,
|
|
37
|
+
email: "",
|
|
38
|
+
subdomain: "",
|
|
39
|
+
name: "",
|
|
40
|
+
userId: "",
|
|
41
|
+
organization_name: "",
|
|
42
|
+
profile_image_url: null,
|
|
43
|
+
organizations: [],
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const auth = createSlice({
|
|
47
|
+
name: "auth",
|
|
48
|
+
initialState,
|
|
49
|
+
reducers: {
|
|
50
|
+
setAppName: (state, { payload }: PayloadAction<{ appName: string }>) => {
|
|
51
|
+
state.appName = payload.appName;
|
|
52
|
+
},
|
|
53
|
+
setOrganizations: (
|
|
54
|
+
state,
|
|
55
|
+
{ payload }: PayloadAction<{ organizations: Organization[] }>
|
|
56
|
+
) => {
|
|
57
|
+
state.organizations = payload.organizations;
|
|
58
|
+
},
|
|
59
|
+
loginUserAction: (state, { payload }: PayloadAction<LoginPayload>) => {
|
|
60
|
+
state.isLoggedIn = true;
|
|
61
|
+
state.email = payload.email;
|
|
62
|
+
state.name = payload.name;
|
|
63
|
+
state.userId = payload.id;
|
|
64
|
+
state.subdomain = payload.subdomain;
|
|
65
|
+
state.organization_name = payload.organization_name;
|
|
66
|
+
state.profile_image_url = payload.profile_image_url;
|
|
67
|
+
},
|
|
68
|
+
logoutUserAction: state => {
|
|
69
|
+
state.isLoggedIn = initialState.isLoggedIn;
|
|
70
|
+
state.email = initialState.email;
|
|
71
|
+
state.name = initialState.name;
|
|
72
|
+
state.userId = initialState.userId;
|
|
73
|
+
state.subdomain = initialState.subdomain;
|
|
74
|
+
state.organization_name = initialState.organization_name;
|
|
75
|
+
state.profile_image_url = initialState.profile_image_url;
|
|
76
|
+
state.organizations = initialState.organizations;
|
|
77
|
+
// eslint-disable-next-line promise/prefer-await-to-then
|
|
78
|
+
notifee.setBadgeCount(0).catch(() => {});
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
export const {
|
|
84
|
+
actions: { setAppName, setOrganizations, loginUserAction, logoutUserAction },
|
|
85
|
+
reducer: authReducer,
|
|
86
|
+
} = auth;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useDispatch, useSelector } from "react-redux";
|
|
2
|
+
|
|
3
|
+
import { type AppDispatch, type RootState } from ".";
|
|
4
|
+
|
|
5
|
+
// Internal typed wrappers so commons' own selectors know the shape of the
|
|
6
|
+
// slices it owns. Not part of the published API — apps type their own.
|
|
7
|
+
export const useAppSelector = useSelector.withTypes<RootState>();
|
|
8
|
+
export const useAppDispatch = useDispatch.withTypes<AppDispatch>();
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
2
|
+
import { configureStore } from "@reduxjs/toolkit";
|
|
3
|
+
import {
|
|
4
|
+
persistStore,
|
|
5
|
+
persistReducer,
|
|
6
|
+
FLUSH,
|
|
7
|
+
REHYDRATE,
|
|
8
|
+
PAUSE,
|
|
9
|
+
PERSIST,
|
|
10
|
+
PURGE,
|
|
11
|
+
REGISTER,
|
|
12
|
+
type PersistConfig,
|
|
13
|
+
} from "redux-persist";
|
|
14
|
+
|
|
15
|
+
import { rootReducer } from "../slices";
|
|
16
|
+
|
|
17
|
+
// Host apps merge their own reducers in through `updateRootReducer`, so the
|
|
18
|
+
// state is commons' slices plus keys only the app knows about.
|
|
19
|
+
export type CommonsState = ReturnType<typeof rootReducer>;
|
|
20
|
+
export type RootState = CommonsState & Record<string, unknown>;
|
|
21
|
+
|
|
22
|
+
const persistConfig: PersistConfig<CommonsState> = {
|
|
23
|
+
key: "root",
|
|
24
|
+
storage: AsyncStorage,
|
|
25
|
+
blacklist: [],
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const persistedReducer = persistReducer(persistConfig, rootReducer);
|
|
29
|
+
|
|
30
|
+
const baseStore = configureStore({
|
|
31
|
+
reducer: persistedReducer,
|
|
32
|
+
middleware: getDefaultMiddleware =>
|
|
33
|
+
getDefaultMiddleware({
|
|
34
|
+
serializableCheck: {
|
|
35
|
+
ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER],
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
38
|
+
});
|
|
39
|
+
const Persistor = persistStore(baseStore);
|
|
40
|
+
|
|
41
|
+
// `Store.Persistor` is part of the published contract — apps and
|
|
42
|
+
// `updateRootReducer` reach the persistor through the store.
|
|
43
|
+
const Store = Object.assign(baseStore, { Persistor });
|
|
44
|
+
|
|
45
|
+
export type AppDispatch = typeof Store.dispatch;
|
|
46
|
+
|
|
47
|
+
export { Store, Persistor, persistConfig };
|