@os-team/profile 1.2.0 → 1.2.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/dist/@types/emotion.d.js +1 -0
- package/dist/@types/i18next.d.js +1 -0
- package/dist/@types/relay.d.js +0 -0
- package/dist/{types/components → components}/profile/ProfileButton.d.ts +1 -1
- package/dist/components/profile/ProfileButton.d.ts.map +1 -0
- package/dist/components/profile/ProfileButton.js +9 -0
- package/dist/components/profile/ProfileConfigContext.d.ts.map +1 -0
- package/dist/{esm/components → components}/profile/ProfileConfigContext.js +1 -2
- package/dist/components/profile/ProfileContext.d.ts.map +1 -0
- package/dist/{esm/components → components}/profile/ProfileContext.js +1 -2
- package/dist/{types/components → components}/profile/ProfileDrawer.d.ts +2 -2
- package/dist/components/profile/ProfileDrawer.d.ts.map +1 -0
- package/dist/components/profile/ProfileDrawer.js +28 -0
- package/dist/{types/components → components}/profile/ProfileDrawerContent.d.ts +7 -0
- package/dist/components/profile/ProfileDrawerContent.d.ts.map +1 -0
- package/dist/{esm/components → components}/profile/ProfileDrawerContent.js +66 -41
- package/dist/{types/components → components}/profile/ProfileNavigationItem.d.ts +1 -1
- package/dist/components/profile/ProfileNavigationItem.d.ts.map +1 -0
- package/dist/components/profile/ProfileNavigationItem.js +28 -0
- package/dist/components/profile/ProfileUpdateNameModal.d.ts.map +1 -0
- package/dist/{esm/components → components}/profile/ProfileUpdateNameModal.js +38 -31
- package/dist/components/profile/ProfileUpdatePasswordModal.d.ts.map +1 -0
- package/dist/{esm/components → components}/profile/ProfileUpdatePasswordModal.js +40 -33
- package/dist/components/profile/ProtectedWrapper.d.ts.map +1 -0
- package/dist/{esm/components → components}/profile/ProtectedWrapper.js +19 -14
- package/dist/{types/components → components}/profile/UserAvatar.d.ts +1 -1
- package/dist/components/profile/UserAvatar.d.ts.map +1 -0
- package/dist/{esm/components → components}/profile/UserAvatar.js +7 -6
- package/dist/{types/components → components}/profile/UserAvatarAddon.d.ts +1 -1
- package/dist/components/profile/UserAvatarAddon.d.ts.map +1 -0
- package/dist/components/profile/UserAvatarAddon.js +50 -0
- package/dist/{types/components → components}/profile/__generated__/ProfileDrawerContentSignOutMutation.graphql.d.ts +5 -0
- package/dist/components/profile/__generated__/ProfileDrawerContentSignOutMutation.graphql.d.ts.map +1 -0
- package/dist/{esm/components → components}/profile/__generated__/ProfileDrawerContentSignOutMutation.graphql.js +2 -3
- package/dist/{types/components → components}/profile/__generated__/ProfileDrawerContentUpdateAvatarMutation.graphql.d.ts +5 -0
- package/dist/components/profile/__generated__/ProfileDrawerContentUpdateAvatarMutation.graphql.d.ts.map +1 -0
- package/dist/{esm/components → components}/profile/__generated__/ProfileDrawerContentUpdateAvatarMutation.graphql.js +2 -3
- package/dist/{types/components → components}/profile/__generated__/ProfileUpdateNameModalMutation.graphql.d.ts +5 -0
- package/dist/components/profile/__generated__/ProfileUpdateNameModalMutation.graphql.d.ts.map +1 -0
- package/dist/{esm/components → components}/profile/__generated__/ProfileUpdateNameModalMutation.graphql.js +2 -3
- package/dist/{types/components → components}/profile/__generated__/ProfileUpdatePasswordModalMutation.graphql.d.ts +5 -0
- package/dist/components/profile/__generated__/ProfileUpdatePasswordModalMutation.graphql.d.ts.map +1 -0
- package/dist/{esm/components → components}/profile/__generated__/ProfileUpdatePasswordModalMutation.graphql.js +2 -3
- package/dist/{types/components → components}/profile/__generated__/ProtectedWrapperQuery.graphql.d.ts +5 -0
- package/dist/components/profile/__generated__/ProtectedWrapperQuery.graphql.d.ts.map +1 -0
- package/dist/{esm/components → components}/profile/__generated__/ProtectedWrapperQuery.graphql.js +2 -3
- package/dist/{types/components → components}/session/SessionDrawer.d.ts +1 -1
- package/dist/components/session/SessionDrawer.d.ts.map +1 -0
- package/dist/components/session/SessionDrawer.js +45 -0
- package/dist/components/session/SessionDrawerContent.d.ts.map +1 -0
- package/dist/{esm/components → components}/session/SessionDrawerContent.js +12 -10
- package/dist/{types/components → components}/session/SessionList.d.ts +5 -5
- package/dist/components/session/SessionList.d.ts.map +1 -0
- package/dist/{esm/components → components}/session/SessionList.js +33 -17
- package/dist/{types/components → components}/session/SessionListItem.d.ts +9 -9
- package/dist/components/session/SessionListItem.d.ts.map +1 -0
- package/dist/{esm/components → components}/session/SessionListItem.js +37 -19
- package/dist/components/session/SessionListSkeleton.d.ts.map +1 -0
- package/dist/components/session/SessionListSkeleton.js +43 -0
- package/dist/{types/components → components}/session/__generated__/SessionDrawerContentQuery.graphql.d.ts +5 -0
- package/dist/components/session/__generated__/SessionDrawerContentQuery.graphql.d.ts.map +1 -0
- package/dist/{esm/components → components}/session/__generated__/SessionDrawerContentQuery.graphql.js +2 -3
- package/dist/{types/components → components}/session/__generated__/SessionListDestroyAllOtherSessionsMutation.graphql.d.ts +5 -0
- package/dist/components/session/__generated__/SessionListDestroyAllOtherSessionsMutation.graphql.d.ts.map +1 -0
- package/dist/{esm/components → components}/session/__generated__/SessionListDestroyAllOtherSessionsMutation.graphql.js +2 -3
- package/dist/{types/components → components}/session/__generated__/SessionListItemDestroySessionMutation.graphql.d.ts +5 -0
- package/dist/components/session/__generated__/SessionListItemDestroySessionMutation.graphql.d.ts.map +1 -0
- package/dist/{esm/components → components}/session/__generated__/SessionListItemDestroySessionMutation.graphql.js +2 -3
- package/dist/{types/components → components}/session/__generated__/SessionListItem_session.graphql.d.ts +5 -0
- package/dist/components/session/__generated__/SessionListItem_session.graphql.d.ts.map +1 -0
- package/dist/{esm/components → components}/session/__generated__/SessionListItem_session.graphql.js +2 -3
- package/dist/{types/components → components}/session/__generated__/SessionListRefetchQuery.graphql.d.ts +5 -0
- package/dist/components/session/__generated__/SessionListRefetchQuery.graphql.d.ts.map +1 -0
- package/dist/{esm/components → components}/session/__generated__/SessionListRefetchQuery.graphql.js +2 -3
- package/dist/{types/components → components}/session/__generated__/SessionList_sessions.graphql.d.ts +5 -0
- package/dist/components/session/__generated__/SessionList_sessions.graphql.d.ts.map +1 -0
- package/dist/{esm/components → components}/session/__generated__/SessionList_sessions.graphql.js +2 -3
- package/dist/{types/components → components}/session/formatDate.d.ts +1 -1
- package/dist/components/session/formatDate.d.ts.map +1 -0
- package/dist/{esm/components → components}/session/formatDate.js +1 -2
- package/dist/components/session/getLastSeen.d.ts +3 -0
- package/dist/components/session/getLastSeen.d.ts.map +1 -0
- package/dist/{esm/components → components}/session/getLastSeen.js +1 -2
- package/dist/{types/components → components}/shared/ButtonUpdate.d.ts +1 -1
- package/dist/components/shared/ButtonUpdate.d.ts.map +1 -0
- package/dist/{esm/components → components}/shared/ButtonUpdate.js +6 -3
- package/dist/components/shared/ErrorResult.d.ts.map +1 -0
- package/dist/{esm/components → components}/shared/ErrorResult.js +4 -4
- package/dist/components/shared/FormError.d.ts.map +1 -0
- package/dist/{esm/components → components}/shared/FormError.js +6 -5
- package/dist/components/shared/MainLoader.d.ts.map +1 -0
- package/dist/{esm/components → components}/shared/MainLoader.js +5 -3
- package/dist/{types/components → components}/shared/icons/AndroidIcon.d.ts +1 -1
- package/dist/components/shared/icons/AndroidIcon.d.ts.map +1 -0
- package/dist/components/shared/icons/AndroidIcon.js +12 -0
- package/dist/{types/components → components}/shared/icons/AppleIcon.d.ts +1 -1
- package/dist/components/shared/icons/AppleIcon.d.ts.map +1 -0
- package/dist/components/shared/icons/AppleIcon.js +12 -0
- package/dist/{types/components → components}/shared/icons/BrowserIcon.d.ts +1 -1
- package/dist/components/shared/icons/BrowserIcon.d.ts.map +1 -0
- package/dist/components/shared/icons/BrowserIcon.js +12 -0
- package/dist/{types/components → components}/shared/icons/ProfileIcon.d.ts +1 -1
- package/dist/components/shared/icons/ProfileIcon.d.ts.map +1 -0
- package/dist/components/shared/icons/ProfileIcon.js +12 -0
- package/dist/{types/components → components}/shared/icons/UnknownDeviceIcon.d.ts +1 -1
- package/dist/components/shared/icons/UnknownDeviceIcon.d.ts.map +1 -0
- package/dist/components/shared/icons/UnknownDeviceIcon.js +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/utils/getError.d.ts.map +1 -0
- package/dist/{esm/utils → utils}/getError.js +1 -2
- package/dist/utils/getUserFullName.d.ts.map +1 -0
- package/dist/{esm/utils → utils}/getUserFullName.js +1 -2
- package/dist/{types/utils → utils}/handleFormErrors.d.ts +1 -1
- package/dist/utils/handleFormErrors.d.ts.map +1 -0
- package/dist/{esm/utils → utils}/handleFormErrors.js +1 -2
- package/package.json +55 -61
- package/src/@types/react-app-env.d.ts +3 -0
- package/src/App.tsx +42 -0
- package/src/AppRouter.tsx +12 -0
- package/src/components/ErrorResult.tsx +23 -0
- package/src/components/Layout.tsx +70 -0
- package/src/components/MainLoader.tsx +22 -0
- package/src/components/icons/HomeIcon.tsx +12 -0
- package/src/i18next.ts +34 -0
- package/src/index.tsx +6 -0
- package/src/lib/@types/emotion.d.ts +7 -0
- package/src/lib/@types/i18next.d.ts +12 -0
- package/src/lib/@types/relay.d.ts +3 -0
- package/src/lib/components/profile/ProfileButton.tsx +8 -0
- package/src/lib/components/profile/ProfileConfigContext.ts +16 -0
- package/src/lib/components/profile/ProfileContext.ts +20 -0
- package/src/lib/components/profile/ProfileDrawer.tsx +31 -0
- package/src/lib/components/profile/ProfileDrawerContent.tsx +276 -0
- package/src/lib/components/profile/ProfileNavigationItem.tsx +36 -0
- package/src/lib/components/profile/ProfileUpdateNameModal.tsx +117 -0
- package/src/lib/components/profile/ProfileUpdatePasswordModal.tsx +129 -0
- package/src/lib/components/profile/ProtectedWrapper.tsx +81 -0
- package/src/lib/components/profile/UserAvatar.tsx +23 -0
- package/src/lib/components/profile/UserAvatarAddon.tsx +62 -0
- package/src/lib/components/profile/__generated__/ProfileDrawerContentSignOutMutation.graphql.ts +74 -0
- package/src/lib/components/profile/__generated__/ProfileDrawerContentUpdateAvatarMutation.graphql.ts +100 -0
- package/src/lib/components/profile/__generated__/ProfileUpdateNameModalMutation.graphql.ts +124 -0
- package/src/lib/components/profile/__generated__/ProfileUpdatePasswordModalMutation.graphql.ts +93 -0
- package/src/lib/components/profile/__generated__/ProtectedWrapperQuery.graphql.ts +106 -0
- package/src/lib/components/session/SessionDrawer.tsx +50 -0
- package/src/lib/components/session/SessionDrawerContent.tsx +34 -0
- package/src/lib/components/session/SessionList.tsx +138 -0
- package/src/lib/components/session/SessionListItem.tsx +318 -0
- package/src/lib/components/session/SessionListSkeleton.tsx +48 -0
- package/src/lib/components/session/__generated__/SessionDrawerContentQuery.graphql.ts +181 -0
- package/src/lib/components/session/__generated__/SessionListDestroyAllOtherSessionsMutation.graphql.ts +74 -0
- package/src/lib/components/session/__generated__/SessionListItemDestroySessionMutation.graphql.ts +92 -0
- package/src/lib/components/session/__generated__/SessionListItem_session.graphql.ts +154 -0
- package/src/lib/components/session/__generated__/SessionListRefetchQuery.graphql.ts +181 -0
- package/src/lib/components/session/__generated__/SessionList_sessions.graphql.ts +83 -0
- package/src/lib/components/session/formatDate.ts +21 -0
- package/{dist/cjs/components/session/getLastSeen.js → src/lib/components/session/getLastSeen.ts} +9 -9
- package/src/lib/components/shared/ButtonUpdate.tsx +10 -0
- package/src/lib/components/shared/ErrorResult.tsx +28 -0
- package/src/lib/components/shared/FormError.tsx +11 -0
- package/src/lib/components/shared/MainLoader.tsx +22 -0
- package/src/lib/components/shared/icons/AndroidIcon.tsx +12 -0
- package/src/lib/components/shared/icons/AppleIcon.tsx +12 -0
- package/src/lib/components/shared/icons/BrowserIcon.tsx +12 -0
- package/src/lib/components/shared/icons/ProfileIcon.tsx +12 -0
- package/src/lib/components/shared/icons/UnknownDeviceIcon.tsx +14 -0
- package/{dist/esm/index.js → src/lib/index.ts} +1 -1
- package/src/lib/utils/getError.ts +101 -0
- package/src/lib/utils/getUserFullName.ts +14 -0
- package/src/lib/utils/handleFormErrors.ts +16 -0
- package/src/pages/HomePage.tsx +11 -0
- package/src/schema.graphql +2494 -0
- package/src/utils/createRelayEnvironment.ts +22 -0
- package/src/utils/getError.ts +101 -0
- package/dist/cjs/@types/emotion.d.js +0 -4
- package/dist/cjs/@types/emotion.d.js.map +0 -1
- package/dist/cjs/@types/i18next.d.js +0 -4
- package/dist/cjs/@types/i18next.d.js.map +0 -1
- package/dist/cjs/components/profile/ProfileButton.js +0 -16
- package/dist/cjs/components/profile/ProfileButton.js.map +0 -1
- package/dist/cjs/components/profile/ProfileConfigContext.js +0 -17
- package/dist/cjs/components/profile/ProfileConfigContext.js.map +0 -1
- package/dist/cjs/components/profile/ProfileContext.js +0 -18
- package/dist/cjs/components/profile/ProfileContext.js.map +0 -1
- package/dist/cjs/components/profile/ProfileDrawer.js +0 -35
- package/dist/cjs/components/profile/ProfileDrawer.js.map +0 -1
- package/dist/cjs/components/profile/ProfileDrawerContent.js +0 -167
- package/dist/cjs/components/profile/ProfileDrawerContent.js.map +0 -1
- package/dist/cjs/components/profile/ProfileNavigationItem.js +0 -35
- package/dist/cjs/components/profile/ProfileNavigationItem.js.map +0 -1
- package/dist/cjs/components/profile/ProfileUpdateNameModal.js +0 -106
- package/dist/cjs/components/profile/ProfileUpdateNameModal.js.map +0 -1
- package/dist/cjs/components/profile/ProfileUpdatePasswordModal.js +0 -106
- package/dist/cjs/components/profile/ProfileUpdatePasswordModal.js.map +0 -1
- package/dist/cjs/components/profile/ProtectedWrapper.js +0 -54
- package/dist/cjs/components/profile/ProtectedWrapper.js.map +0 -1
- package/dist/cjs/components/profile/UserAvatar.js +0 -42
- package/dist/cjs/components/profile/UserAvatar.js.map +0 -1
- package/dist/cjs/components/profile/UserAvatarAddon.js +0 -41
- package/dist/cjs/components/profile/UserAvatarAddon.js.map +0 -1
- package/dist/cjs/components/profile/__generated__/ProfileDrawerContentSignOutMutation.graphql.js +0 -63
- package/dist/cjs/components/profile/__generated__/ProfileDrawerContentSignOutMutation.graphql.js.map +0 -1
- package/dist/cjs/components/profile/__generated__/ProfileDrawerContentUpdateAvatarMutation.graphql.js +0 -78
- package/dist/cjs/components/profile/__generated__/ProfileDrawerContentUpdateAvatarMutation.graphql.js.map +0 -1
- package/dist/cjs/components/profile/__generated__/ProfileUpdateNameModalMutation.graphql.js +0 -95
- package/dist/cjs/components/profile/__generated__/ProfileUpdateNameModalMutation.graphql.js.map +0 -1
- package/dist/cjs/components/profile/__generated__/ProfileUpdatePasswordModalMutation.graphql.js +0 -72
- package/dist/cjs/components/profile/__generated__/ProfileUpdatePasswordModalMutation.graphql.js.map +0 -1
- package/dist/cjs/components/profile/__generated__/ProtectedWrapperQuery.graphql.js +0 -87
- package/dist/cjs/components/profile/__generated__/ProtectedWrapperQuery.graphql.js.map +0 -1
- package/dist/cjs/components/session/SessionDrawer.js +0 -46
- package/dist/cjs/components/session/SessionDrawer.js.map +0 -1
- package/dist/cjs/components/session/SessionDrawerContent.js +0 -39
- package/dist/cjs/components/session/SessionDrawerContent.js.map +0 -1
- package/dist/cjs/components/session/SessionList.js +0 -73
- package/dist/cjs/components/session/SessionList.js.map +0 -1
- package/dist/cjs/components/session/SessionListItem.js +0 -150
- package/dist/cjs/components/session/SessionListItem.js.map +0 -1
- package/dist/cjs/components/session/SessionListSkeleton.js +0 -31
- package/dist/cjs/components/session/SessionListSkeleton.js.map +0 -1
- package/dist/cjs/components/session/__generated__/SessionDrawerContentQuery.graphql.js +0 -154
- package/dist/cjs/components/session/__generated__/SessionDrawerContentQuery.graphql.js.map +0 -1
- package/dist/cjs/components/session/__generated__/SessionListDestroyAllOtherSessionsMutation.graphql.js +0 -63
- package/dist/cjs/components/session/__generated__/SessionListDestroyAllOtherSessionsMutation.graphql.js.map +0 -1
- package/dist/cjs/components/session/__generated__/SessionListItemDestroySessionMutation.graphql.js +0 -72
- package/dist/cjs/components/session/__generated__/SessionListItemDestroySessionMutation.graphql.js.map +0 -1
- package/dist/cjs/components/session/__generated__/SessionListItem_session.graphql.js +0 -118
- package/dist/cjs/components/session/__generated__/SessionListItem_session.graphql.js.map +0 -1
- package/dist/cjs/components/session/__generated__/SessionListRefetchQuery.graphql.js +0 -154
- package/dist/cjs/components/session/__generated__/SessionListRefetchQuery.graphql.js.map +0 -1
- package/dist/cjs/components/session/__generated__/SessionList_sessions.graphql.js +0 -65
- package/dist/cjs/components/session/__generated__/SessionList_sessions.graphql.js.map +0 -1
- package/dist/cjs/components/session/formatDate.js +0 -19
- package/dist/cjs/components/session/formatDate.js.map +0 -1
- package/dist/cjs/components/session/getLastSeen.js.map +0 -1
- package/dist/cjs/components/shared/ButtonUpdate.js +0 -18
- package/dist/cjs/components/shared/ButtonUpdate.js.map +0 -1
- package/dist/cjs/components/shared/ErrorResult.js +0 -31
- package/dist/cjs/components/shared/ErrorResult.js.map +0 -1
- package/dist/cjs/components/shared/FormError.js +0 -21
- package/dist/cjs/components/shared/FormError.js.map +0 -1
- package/dist/cjs/components/shared/MainLoader.js +0 -17
- package/dist/cjs/components/shared/MainLoader.js.map +0 -1
- package/dist/cjs/components/shared/icons/AndroidIcon.js +0 -18
- package/dist/cjs/components/shared/icons/AndroidIcon.js.map +0 -1
- package/dist/cjs/components/shared/icons/AppleIcon.js +0 -18
- package/dist/cjs/components/shared/icons/AppleIcon.js.map +0 -1
- package/dist/cjs/components/shared/icons/BrowserIcon.js +0 -18
- package/dist/cjs/components/shared/icons/BrowserIcon.js.map +0 -1
- package/dist/cjs/components/shared/icons/ProfileIcon.js +0 -18
- package/dist/cjs/components/shared/icons/ProfileIcon.js.map +0 -1
- package/dist/cjs/components/shared/icons/UnknownDeviceIcon.js +0 -18
- package/dist/cjs/components/shared/icons/UnknownDeviceIcon.js.map +0 -1
- package/dist/cjs/index.js +0 -142
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/utils/getError.js +0 -59
- package/dist/cjs/utils/getError.js.map +0 -1
- package/dist/cjs/utils/getUserFullName.js +0 -19
- package/dist/cjs/utils/getUserFullName.js.map +0 -1
- package/dist/cjs/utils/handleFormErrors.js +0 -25
- package/dist/cjs/utils/handleFormErrors.js.map +0 -1
- package/dist/esm/@types/emotion.d.js +0 -2
- package/dist/esm/@types/emotion.d.js.map +0 -1
- package/dist/esm/@types/i18next.d.js +0 -2
- package/dist/esm/@types/i18next.d.js.map +0 -1
- package/dist/esm/components/profile/ProfileButton.js +0 -9
- package/dist/esm/components/profile/ProfileButton.js.map +0 -1
- package/dist/esm/components/profile/ProfileConfigContext.js.map +0 -1
- package/dist/esm/components/profile/ProfileContext.js.map +0 -1
- package/dist/esm/components/profile/ProfileDrawer.js +0 -25
- package/dist/esm/components/profile/ProfileDrawer.js.map +0 -1
- package/dist/esm/components/profile/ProfileDrawerContent.js.map +0 -1
- package/dist/esm/components/profile/ProfileNavigationItem.js +0 -27
- package/dist/esm/components/profile/ProfileNavigationItem.js.map +0 -1
- package/dist/esm/components/profile/ProfileUpdateNameModal.js.map +0 -1
- package/dist/esm/components/profile/ProfileUpdatePasswordModal.js.map +0 -1
- package/dist/esm/components/profile/ProtectedWrapper.js.map +0 -1
- package/dist/esm/components/profile/UserAvatar.js.map +0 -1
- package/dist/esm/components/profile/UserAvatarAddon.js +0 -47
- package/dist/esm/components/profile/UserAvatarAddon.js.map +0 -1
- package/dist/esm/components/profile/__generated__/ProfileDrawerContentSignOutMutation.graphql.js.map +0 -1
- package/dist/esm/components/profile/__generated__/ProfileDrawerContentUpdateAvatarMutation.graphql.js.map +0 -1
- package/dist/esm/components/profile/__generated__/ProfileUpdateNameModalMutation.graphql.js.map +0 -1
- package/dist/esm/components/profile/__generated__/ProfileUpdatePasswordModalMutation.graphql.js.map +0 -1
- package/dist/esm/components/profile/__generated__/ProtectedWrapperQuery.graphql.js.map +0 -1
- package/dist/esm/components/session/SessionDrawer.js +0 -39
- package/dist/esm/components/session/SessionDrawer.js.map +0 -1
- package/dist/esm/components/session/SessionDrawerContent.js.map +0 -1
- package/dist/esm/components/session/SessionList.js.map +0 -1
- package/dist/esm/components/session/SessionListItem.js.map +0 -1
- package/dist/esm/components/session/SessionListSkeleton.js +0 -31
- package/dist/esm/components/session/SessionListSkeleton.js.map +0 -1
- package/dist/esm/components/session/__generated__/SessionDrawerContentQuery.graphql.js.map +0 -1
- package/dist/esm/components/session/__generated__/SessionListDestroyAllOtherSessionsMutation.graphql.js.map +0 -1
- package/dist/esm/components/session/__generated__/SessionListItemDestroySessionMutation.graphql.js.map +0 -1
- package/dist/esm/components/session/__generated__/SessionListItem_session.graphql.js.map +0 -1
- package/dist/esm/components/session/__generated__/SessionListRefetchQuery.graphql.js.map +0 -1
- package/dist/esm/components/session/__generated__/SessionList_sessions.graphql.js.map +0 -1
- package/dist/esm/components/session/formatDate.js.map +0 -1
- package/dist/esm/components/session/getLastSeen.js.map +0 -1
- package/dist/esm/components/shared/ButtonUpdate.js.map +0 -1
- package/dist/esm/components/shared/ErrorResult.js.map +0 -1
- package/dist/esm/components/shared/FormError.js.map +0 -1
- package/dist/esm/components/shared/MainLoader.js.map +0 -1
- package/dist/esm/components/shared/icons/AndroidIcon.js +0 -11
- package/dist/esm/components/shared/icons/AndroidIcon.js.map +0 -1
- package/dist/esm/components/shared/icons/AppleIcon.js +0 -11
- package/dist/esm/components/shared/icons/AppleIcon.js.map +0 -1
- package/dist/esm/components/shared/icons/BrowserIcon.js +0 -11
- package/dist/esm/components/shared/icons/BrowserIcon.js.map +0 -1
- package/dist/esm/components/shared/icons/ProfileIcon.js +0 -11
- package/dist/esm/components/shared/icons/ProfileIcon.js.map +0 -1
- package/dist/esm/components/shared/icons/UnknownDeviceIcon.js +0 -11
- package/dist/esm/components/shared/icons/UnknownDeviceIcon.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/utils/getError.js.map +0 -1
- package/dist/esm/utils/getUserFullName.js.map +0 -1
- package/dist/esm/utils/handleFormErrors.js.map +0 -1
- package/dist/types/components/profile/ProfileButton.d.ts.map +0 -1
- package/dist/types/components/profile/ProfileConfigContext.d.ts.map +0 -1
- package/dist/types/components/profile/ProfileContext.d.ts.map +0 -1
- package/dist/types/components/profile/ProfileDrawer.d.ts.map +0 -1
- package/dist/types/components/profile/ProfileDrawerContent.d.ts.map +0 -1
- package/dist/types/components/profile/ProfileNavigationItem.d.ts.map +0 -1
- package/dist/types/components/profile/ProfileUpdateNameModal.d.ts.map +0 -1
- package/dist/types/components/profile/ProfileUpdatePasswordModal.d.ts.map +0 -1
- package/dist/types/components/profile/ProtectedWrapper.d.ts.map +0 -1
- package/dist/types/components/profile/UserAvatar.d.ts.map +0 -1
- package/dist/types/components/profile/UserAvatarAddon.d.ts.map +0 -1
- package/dist/types/components/profile/__generated__/ProfileDrawerContentSignOutMutation.graphql.d.ts.map +0 -1
- package/dist/types/components/profile/__generated__/ProfileDrawerContentUpdateAvatarMutation.graphql.d.ts.map +0 -1
- package/dist/types/components/profile/__generated__/ProfileUpdateNameModalMutation.graphql.d.ts.map +0 -1
- package/dist/types/components/profile/__generated__/ProfileUpdatePasswordModalMutation.graphql.d.ts.map +0 -1
- package/dist/types/components/profile/__generated__/ProtectedWrapperQuery.graphql.d.ts.map +0 -1
- package/dist/types/components/session/SessionDrawer.d.ts.map +0 -1
- package/dist/types/components/session/SessionDrawerContent.d.ts.map +0 -1
- package/dist/types/components/session/SessionList.d.ts.map +0 -1
- package/dist/types/components/session/SessionListItem.d.ts.map +0 -1
- package/dist/types/components/session/SessionListSkeleton.d.ts.map +0 -1
- package/dist/types/components/session/__generated__/SessionDrawerContentQuery.graphql.d.ts.map +0 -1
- package/dist/types/components/session/__generated__/SessionListDestroyAllOtherSessionsMutation.graphql.d.ts.map +0 -1
- package/dist/types/components/session/__generated__/SessionListItemDestroySessionMutation.graphql.d.ts.map +0 -1
- package/dist/types/components/session/__generated__/SessionListItem_session.graphql.d.ts.map +0 -1
- package/dist/types/components/session/__generated__/SessionListRefetchQuery.graphql.d.ts.map +0 -1
- package/dist/types/components/session/__generated__/SessionList_sessions.graphql.d.ts.map +0 -1
- package/dist/types/components/session/formatDate.d.ts.map +0 -1
- package/dist/types/components/session/getLastSeen.d.ts +0 -3
- package/dist/types/components/session/getLastSeen.d.ts.map +0 -1
- package/dist/types/components/shared/ButtonUpdate.d.ts.map +0 -1
- package/dist/types/components/shared/ErrorResult.d.ts.map +0 -1
- package/dist/types/components/shared/FormError.d.ts.map +0 -1
- package/dist/types/components/shared/MainLoader.d.ts.map +0 -1
- package/dist/types/components/shared/icons/AndroidIcon.d.ts.map +0 -1
- package/dist/types/components/shared/icons/AppleIcon.d.ts.map +0 -1
- package/dist/types/components/shared/icons/BrowserIcon.d.ts.map +0 -1
- package/dist/types/components/shared/icons/ProfileIcon.d.ts.map +0 -1
- package/dist/types/components/shared/icons/UnknownDeviceIcon.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/utils/getError.d.ts.map +0 -1
- package/dist/types/utils/getUserFullName.d.ts.map +0 -1
- package/dist/types/utils/handleFormErrors.d.ts.map +0 -1
- /package/dist/{types/components → components}/profile/ProfileConfigContext.d.ts +0 -0
- /package/dist/{types/components → components}/profile/ProfileContext.d.ts +0 -0
- /package/dist/{types/components → components}/profile/ProfileUpdateNameModal.d.ts +0 -0
- /package/dist/{types/components → components}/profile/ProfileUpdatePasswordModal.d.ts +0 -0
- /package/dist/{types/components → components}/profile/ProtectedWrapper.d.ts +0 -0
- /package/dist/{types/components → components}/session/SessionDrawerContent.d.ts +0 -0
- /package/dist/{types/components → components}/session/SessionListSkeleton.d.ts +0 -0
- /package/dist/{types/components → components}/shared/ErrorResult.d.ts +0 -0
- /package/dist/{types/components → components}/shared/FormError.d.ts +0 -0
- /package/dist/{types/components → components}/shared/MainLoader.d.ts +0 -0
- /package/dist/{types/index.d.ts → index.d.ts} +0 -0
- /package/dist/{types/utils → utils}/getError.d.ts +0 -0
- /package/dist/{types/utils → utils}/getUserFullName.d.ts +0 -0
package/src/App.tsx
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { Suspense } from 'react';
|
|
2
|
+
import { GlobalStyles } from '@os-design/core';
|
|
3
|
+
import { ThemeProvider } from '@os-design/theming';
|
|
4
|
+
import { BrowserRouter } from 'react-router-dom';
|
|
5
|
+
import { RelayEnvironmentProvider } from 'react-relay';
|
|
6
|
+
import { ErrorBoundary, type FallbackFn } from '@os-design/utils';
|
|
7
|
+
import AppRouter from './AppRouter';
|
|
8
|
+
import createRelayEnvironment from './utils/createRelayEnvironment';
|
|
9
|
+
import MainLoader from './components/MainLoader';
|
|
10
|
+
import Layout from './components/Layout';
|
|
11
|
+
import { ProtectedWrapper } from './lib';
|
|
12
|
+
import 'lazysizes';
|
|
13
|
+
import 'lazysizes/plugins/attrchange/ls.attrchange';
|
|
14
|
+
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
16
|
+
require('./i18next');
|
|
17
|
+
|
|
18
|
+
const relayEnvironment = createRelayEnvironment();
|
|
19
|
+
|
|
20
|
+
const errorFallback: FallbackFn = ({ error }) => <p>{error.message}</p>;
|
|
21
|
+
|
|
22
|
+
const App: React.FC = () => (
|
|
23
|
+
<ThemeProvider>
|
|
24
|
+
<GlobalStyles />
|
|
25
|
+
|
|
26
|
+
<RelayEnvironmentProvider environment={relayEnvironment}>
|
|
27
|
+
<BrowserRouter>
|
|
28
|
+
<Suspense fallback={<MainLoader />}>
|
|
29
|
+
<ProtectedWrapper bucketId='os-team-test'>
|
|
30
|
+
<ErrorBoundary fallback={errorFallback}>
|
|
31
|
+
<Layout>
|
|
32
|
+
<AppRouter />
|
|
33
|
+
</Layout>
|
|
34
|
+
</ErrorBoundary>
|
|
35
|
+
</ProtectedWrapper>
|
|
36
|
+
</Suspense>
|
|
37
|
+
</BrowserRouter>
|
|
38
|
+
</RelayEnvironmentProvider>
|
|
39
|
+
</ThemeProvider>
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
export default App;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Routes, Route, Navigate } from 'react-router-dom';
|
|
3
|
+
import HomePage from './pages/HomePage';
|
|
4
|
+
|
|
5
|
+
const AppRouter: React.FC = () => (
|
|
6
|
+
<Routes>
|
|
7
|
+
<Route path='home' element={<HomePage />} />
|
|
8
|
+
<Route path='*' element={<Navigate replace to='home' />} />
|
|
9
|
+
</Routes>
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export default AppRouter;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CloseCircle } from '@os-design/icons';
|
|
3
|
+
import { Result } from '@os-design/core';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import getError from '../utils/getError';
|
|
6
|
+
|
|
7
|
+
interface ErrorResultProps {
|
|
8
|
+
error: Error;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const ErrorResult: React.FC<ErrorResultProps> = ({ error }) => {
|
|
12
|
+
const { t } = useTranslation(['common']);
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<Result
|
|
16
|
+
title={t('common:errorTitle')}
|
|
17
|
+
description={getError(error).message}
|
|
18
|
+
icon={<CloseCircle />}
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default ErrorResult;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Layout as BaseLayout,
|
|
4
|
+
Navigation,
|
|
5
|
+
NavigationItem,
|
|
6
|
+
} from '@os-design/core';
|
|
7
|
+
import { useLocation, Link } from 'react-router-dom';
|
|
8
|
+
import { useTranslation } from 'react-i18next';
|
|
9
|
+
import HomeIcon from './icons/HomeIcon';
|
|
10
|
+
import {
|
|
11
|
+
UserAvatarAddon,
|
|
12
|
+
ProfileDrawer,
|
|
13
|
+
ProfileNavigationItem,
|
|
14
|
+
ProfileButton,
|
|
15
|
+
SessionDrawer,
|
|
16
|
+
} from '../lib';
|
|
17
|
+
|
|
18
|
+
interface LayoutProps {
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const Layout: React.FC<LayoutProps> = ({ children }) => {
|
|
23
|
+
const { pathname } = useLocation();
|
|
24
|
+
const { t } = useTranslation(['profile']);
|
|
25
|
+
const [profileDrawerVisible, setProfileDrawerVisible] = useState(false);
|
|
26
|
+
const [sessionDrawerVisible, setSessionDrawerVisible] = useState(false);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<>
|
|
30
|
+
<BaseLayout hasNavigation hasPageHeader>
|
|
31
|
+
<Navigation
|
|
32
|
+
sideBottom={
|
|
33
|
+
<UserAvatarAddon onClick={() => setProfileDrawerVisible(true)} />
|
|
34
|
+
}
|
|
35
|
+
>
|
|
36
|
+
<NavigationItem
|
|
37
|
+
icon={<HomeIcon />}
|
|
38
|
+
currentPage={pathname === '/home'}
|
|
39
|
+
as={Link}
|
|
40
|
+
to='/home'
|
|
41
|
+
>
|
|
42
|
+
Home
|
|
43
|
+
</NavigationItem>
|
|
44
|
+
<ProfileNavigationItem
|
|
45
|
+
onClick={() => setProfileDrawerVisible(true)}
|
|
46
|
+
/>
|
|
47
|
+
</Navigation>
|
|
48
|
+
|
|
49
|
+
{children}
|
|
50
|
+
</BaseLayout>
|
|
51
|
+
|
|
52
|
+
<ProfileDrawer
|
|
53
|
+
visible={profileDrawerVisible}
|
|
54
|
+
onClose={() => setProfileDrawerVisible(false)}
|
|
55
|
+
actions={
|
|
56
|
+
<ProfileButton onClick={() => setSessionDrawerVisible(true)}>
|
|
57
|
+
{t('profile:sessions.title')}
|
|
58
|
+
</ProfileButton>
|
|
59
|
+
}
|
|
60
|
+
/>
|
|
61
|
+
|
|
62
|
+
<SessionDrawer
|
|
63
|
+
visible={sessionDrawerVisible}
|
|
64
|
+
onClose={() => setSessionDrawerVisible(false)}
|
|
65
|
+
/>
|
|
66
|
+
</>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export default Layout;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
import { Loading } from '@os-design/icons';
|
|
4
|
+
import { clr } from '@os-design/theming';
|
|
5
|
+
|
|
6
|
+
const Container = styled.div`
|
|
7
|
+
display: flex;
|
|
8
|
+
justify-content: center;
|
|
9
|
+
align-items: center;
|
|
10
|
+
|
|
11
|
+
height: calc(var(--vh, 1vh) * 100);
|
|
12
|
+
font-size: 2em;
|
|
13
|
+
color: ${(p) => clr(p.theme.colorPrimary)};
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
const MainLoader: React.FC = () => (
|
|
17
|
+
<Container>
|
|
18
|
+
<Loading />
|
|
19
|
+
</Container>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export default MainLoader;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { Icon, type IconProps } from '@os-design/icons';
|
|
3
|
+
|
|
4
|
+
const HomeIcon = forwardRef<SVGSVGElement, IconProps>((props, ref) => (
|
|
5
|
+
<Icon {...props} ref={ref}>
|
|
6
|
+
<path d='M946.5 505L534.6 93.4a31.93 31.93 0 0 0-45.2 0L77.5 505c-12 12-18.8 28.3-18.8 45.3c0 35.3 28.7 64 64 64h43.4V908c0 17.7 14.3 32 32 32H448V716h112v224h265.9c17.7 0 32-14.3 32-32V614.3h43.4c17 0 33.3-6.7 45.3-18.8c24.9-25 24.9-65.5-.1-90.5z' />
|
|
7
|
+
</Icon>
|
|
8
|
+
));
|
|
9
|
+
|
|
10
|
+
HomeIcon.displayName = 'HomeIcon';
|
|
11
|
+
|
|
12
|
+
export default HomeIcon;
|
package/src/i18next.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import i18next from 'i18next';
|
|
2
|
+
import HttpBackend from 'i18next-http-backend';
|
|
3
|
+
import { initReactI18next } from 'react-i18next';
|
|
4
|
+
import LanguageDetector from 'i18next-browser-languagedetector';
|
|
5
|
+
|
|
6
|
+
i18next
|
|
7
|
+
.use(HttpBackend) // Load translation. See /public/locales
|
|
8
|
+
.use(LanguageDetector) // Detect user language
|
|
9
|
+
.use(initReactI18next) // Pass the i18n instance to react-i18next
|
|
10
|
+
.init({
|
|
11
|
+
fallbackLng: 'en',
|
|
12
|
+
supportedLngs: ['en', 'ru'],
|
|
13
|
+
ns: [], // Do not preload any namespaces
|
|
14
|
+
defaultNS: undefined, // No default namespace
|
|
15
|
+
|
|
16
|
+
backend: {
|
|
17
|
+
loadPath: '/locales/{{lng}}/{{ns}}.json',
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
interpolation: {
|
|
21
|
+
escapeValue: false, // Not needed for react as it escapes by default
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
detection: {
|
|
25
|
+
order: ['sessionStorage', 'navigator'],
|
|
26
|
+
caches: ['sessionStorage'],
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
i18next.on('languageChanged', (lang) => {
|
|
31
|
+
document.documentElement.lang = lang; // Update html lang
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export default i18next;
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import 'i18next';
|
|
2
|
+
import common from '../../../public/locales/en/common.json';
|
|
3
|
+
import profile from '../../../public/locales/en/profile.json';
|
|
4
|
+
|
|
5
|
+
declare module 'i18next' {
|
|
6
|
+
interface CustomTypeOptions {
|
|
7
|
+
resources: {
|
|
8
|
+
common: typeof common;
|
|
9
|
+
profile: typeof profile;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface ProfileConfigProps {
|
|
4
|
+
bucketId: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const ProfileConfig = React.createContext<ProfileConfigProps>({
|
|
8
|
+
bucketId: '',
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
ProfileConfig.displayName = 'ProfileConfig';
|
|
12
|
+
|
|
13
|
+
export const useProfileConfig = (): ProfileConfigProps =>
|
|
14
|
+
useContext(ProfileConfig);
|
|
15
|
+
|
|
16
|
+
export default ProfileConfig;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface ProfileContextProps {
|
|
4
|
+
id: string;
|
|
5
|
+
email: string;
|
|
6
|
+
firstName?: string;
|
|
7
|
+
lastName?: string;
|
|
8
|
+
avatar?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const ProfileContext = React.createContext<ProfileContextProps>({
|
|
12
|
+
id: '',
|
|
13
|
+
email: '',
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
ProfileContext.displayName = 'ProfileContext';
|
|
17
|
+
|
|
18
|
+
export const useProfile = (): ProfileContextProps => useContext(ProfileContext);
|
|
19
|
+
|
|
20
|
+
export default ProfileContext;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { lazy, Suspense } from 'react';
|
|
2
|
+
import { Drawer, type DrawerProps } from '@os-design/core';
|
|
3
|
+
import styled from '@emotion/styled';
|
|
4
|
+
import { type ProfileDrawerContentProps } from './ProfileDrawerContent';
|
|
5
|
+
import MainLoader from '../shared/MainLoader';
|
|
6
|
+
|
|
7
|
+
const LazyProfileDrawerContent = lazy(() => import('./ProfileDrawerContent'));
|
|
8
|
+
|
|
9
|
+
export type ProfileDrawerProps = ProfileDrawerContentProps & DrawerProps;
|
|
10
|
+
|
|
11
|
+
const StyledDrawer = styled(Drawer)`
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
padding: 2em 1em;
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
const ProfileDrawer: React.FC<ProfileDrawerProps> = ({
|
|
18
|
+
actions,
|
|
19
|
+
children,
|
|
20
|
+
...rest
|
|
21
|
+
}) => (
|
|
22
|
+
<StyledDrawer placement='right' width='15em' {...rest}>
|
|
23
|
+
<Suspense fallback={<MainLoader />}>
|
|
24
|
+
<LazyProfileDrawerContent actions={actions}>
|
|
25
|
+
{children}
|
|
26
|
+
</LazyProfileDrawerContent>
|
|
27
|
+
</Suspense>
|
|
28
|
+
</StyledDrawer>
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export default ProfileDrawer;
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import styled from '@emotion/styled';
|
|
2
|
+
import { ThemeSwitcher, message } from '@os-design/core';
|
|
3
|
+
import { clr } from '@os-design/theming';
|
|
4
|
+
import graphql from 'babel-plugin-relay/macro';
|
|
5
|
+
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
import { useMutation } from 'react-relay';
|
|
8
|
+
import getError from '../../utils/getError';
|
|
9
|
+
import ProfileButton from './ProfileButton';
|
|
10
|
+
import { useProfile } from './ProfileContext';
|
|
11
|
+
import ProfileUpdateNameModal from './ProfileUpdateNameModal';
|
|
12
|
+
import ProfileUpdatePasswordModal from './ProfileUpdatePasswordModal';
|
|
13
|
+
import UserAvatar from './UserAvatar';
|
|
14
|
+
import { type ProfileDrawerContentSignOutMutation } from './__generated__/ProfileDrawerContentSignOutMutation.graphql';
|
|
15
|
+
import { type ProfileDrawerContentUpdateAvatarMutation } from './__generated__/ProfileDrawerContentUpdateAvatarMutation.graphql';
|
|
16
|
+
|
|
17
|
+
export interface ProfileDrawerContentProps {
|
|
18
|
+
/**
|
|
19
|
+
* Additional actions placed under the avatar.
|
|
20
|
+
* @default undefined
|
|
21
|
+
*/
|
|
22
|
+
actions?: React.ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* The children.
|
|
25
|
+
*/
|
|
26
|
+
children?: React.ReactNode;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const AvatarContainer = styled.div`
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
justify-content: center;
|
|
33
|
+
align-items: center;
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
const UserContent = styled.div`
|
|
37
|
+
margin-top: 1em;
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
const FullName = styled.div`
|
|
41
|
+
font-size: ${(p) => p.theme.sizes.large}em;
|
|
42
|
+
font-weight: 500;
|
|
43
|
+
text-align: center;
|
|
44
|
+
line-height: 1.2;
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
const Email = styled.div`
|
|
48
|
+
color: ${(p) => clr(p.theme.inputColorPlaceholder)};
|
|
49
|
+
margin-top: 0.2em;
|
|
50
|
+
text-align: center;
|
|
51
|
+
`;
|
|
52
|
+
|
|
53
|
+
const ActionsContainer = styled.div`
|
|
54
|
+
margin-top: 1.5em;
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
const Footer = styled.div`
|
|
58
|
+
display: flex;
|
|
59
|
+
justify-content: center;
|
|
60
|
+
margin-top: auto;
|
|
61
|
+
padding-top: 1.5em;
|
|
62
|
+
`;
|
|
63
|
+
|
|
64
|
+
const HiddenInput = styled.input`
|
|
65
|
+
display: none;
|
|
66
|
+
`;
|
|
67
|
+
|
|
68
|
+
const query = graphql`
|
|
69
|
+
mutation ProfileDrawerContentUpdateAvatarMutation(
|
|
70
|
+
$input: UpdateAvatarInput!
|
|
71
|
+
) {
|
|
72
|
+
updateAvatar(input: $input) {
|
|
73
|
+
id
|
|
74
|
+
avatar
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
`;
|
|
78
|
+
|
|
79
|
+
const DeleteAvatarButton: React.FC = () => {
|
|
80
|
+
const { t } = useTranslation(['profile']);
|
|
81
|
+
|
|
82
|
+
const [commit, loading] =
|
|
83
|
+
useMutation<ProfileDrawerContentUpdateAvatarMutation>(query);
|
|
84
|
+
|
|
85
|
+
const handler = useCallback(() => {
|
|
86
|
+
commit({
|
|
87
|
+
variables: {
|
|
88
|
+
input: { avatar: null },
|
|
89
|
+
},
|
|
90
|
+
onError: (e) => message.error(getError(e).message),
|
|
91
|
+
onCompleted: () => {
|
|
92
|
+
message.success(t('profile:updated'));
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
}, [commit, t]);
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<ProfileButton loading={loading} onClick={handler}>
|
|
99
|
+
{t('profile:deleteAvatar')}
|
|
100
|
+
</ProfileButton>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
interface UpdateAvatarButtonProps {
|
|
105
|
+
hasAvatar: boolean;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const UpdateAvatarButton: React.FC<UpdateAvatarButtonProps> = ({
|
|
109
|
+
hasAvatar,
|
|
110
|
+
}) => {
|
|
111
|
+
const { t } = useTranslation(['profile']);
|
|
112
|
+
const fileInputRef = useRef<HTMLInputElement>(null);
|
|
113
|
+
|
|
114
|
+
const [commit, loading] =
|
|
115
|
+
useMutation<ProfileDrawerContentUpdateAvatarMutation>(query);
|
|
116
|
+
|
|
117
|
+
const handler = useCallback(
|
|
118
|
+
(e) => {
|
|
119
|
+
const target = e.target as HTMLInputElement | null;
|
|
120
|
+
if (!target) return;
|
|
121
|
+
|
|
122
|
+
const { files } = target;
|
|
123
|
+
if (!files) return;
|
|
124
|
+
|
|
125
|
+
const file = files[0];
|
|
126
|
+
|
|
127
|
+
commit({
|
|
128
|
+
variables: {
|
|
129
|
+
input: {},
|
|
130
|
+
},
|
|
131
|
+
uploadables: { avatar: file },
|
|
132
|
+
onError: (error) => message.error(getError(error).message),
|
|
133
|
+
onCompleted: () => {
|
|
134
|
+
message.success(t('profile:updated'));
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
},
|
|
138
|
+
[commit, t]
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<>
|
|
143
|
+
<ProfileButton
|
|
144
|
+
loading={loading}
|
|
145
|
+
onClick={() => {
|
|
146
|
+
if (!fileInputRef.current) return;
|
|
147
|
+
fileInputRef.current.value = '';
|
|
148
|
+
fileInputRef.current.click();
|
|
149
|
+
}}
|
|
150
|
+
>
|
|
151
|
+
{t(`profile:${hasAvatar ? 'changeAvatar' : 'setAvatar'}`)}
|
|
152
|
+
</ProfileButton>
|
|
153
|
+
|
|
154
|
+
<HiddenInput
|
|
155
|
+
type='file'
|
|
156
|
+
accept='image/jpeg,image/png,image/webp'
|
|
157
|
+
onChange={handler}
|
|
158
|
+
ref={fileInputRef}
|
|
159
|
+
/>
|
|
160
|
+
</>
|
|
161
|
+
);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
interface UpdateNameButtonProps {
|
|
165
|
+
hasName: boolean;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const UpdateNameButton: React.FC<UpdateNameButtonProps> = ({ hasName }) => {
|
|
169
|
+
const { t } = useTranslation(['profile']);
|
|
170
|
+
const [modalVisible, setModalVisible] = useState(false);
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<>
|
|
174
|
+
<ProfileButton onClick={() => setModalVisible(true)}>
|
|
175
|
+
{t(`profile:${hasName ? 'changeName' : 'setName'}`)}
|
|
176
|
+
</ProfileButton>
|
|
177
|
+
|
|
178
|
+
<ProfileUpdateNameModal
|
|
179
|
+
visible={modalVisible}
|
|
180
|
+
onClose={() => setModalVisible(false)}
|
|
181
|
+
/>
|
|
182
|
+
</>
|
|
183
|
+
);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const ChangePasswordButton: React.FC = () => {
|
|
187
|
+
const { t } = useTranslation(['profile']);
|
|
188
|
+
const [modalVisible, setModalVisible] = useState(false);
|
|
189
|
+
|
|
190
|
+
return (
|
|
191
|
+
<>
|
|
192
|
+
<ProfileButton onClick={() => setModalVisible(true)}>
|
|
193
|
+
{t('profile:changePassword')}
|
|
194
|
+
</ProfileButton>
|
|
195
|
+
|
|
196
|
+
<ProfileUpdatePasswordModal
|
|
197
|
+
visible={modalVisible}
|
|
198
|
+
onClose={() => setModalVisible(false)}
|
|
199
|
+
/>
|
|
200
|
+
</>
|
|
201
|
+
);
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
const SignOutButton: React.FC = () => {
|
|
205
|
+
const { t } = useTranslation(['profile']);
|
|
206
|
+
|
|
207
|
+
const [commit, loading] = useMutation<ProfileDrawerContentSignOutMutation>(
|
|
208
|
+
graphql`
|
|
209
|
+
mutation ProfileDrawerContentSignOutMutation {
|
|
210
|
+
signOut {
|
|
211
|
+
ok
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
`
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
const handler = useCallback(() => {
|
|
218
|
+
commit({
|
|
219
|
+
variables: {},
|
|
220
|
+
onError: (e) => message.error(getError(e).message),
|
|
221
|
+
onCompleted: () => {
|
|
222
|
+
window.location.href = '/auth/';
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
}, [commit]);
|
|
226
|
+
|
|
227
|
+
return (
|
|
228
|
+
<ProfileButton danger loading={loading} onClick={handler}>
|
|
229
|
+
{t('profile:signOut')}
|
|
230
|
+
</ProfileButton>
|
|
231
|
+
);
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
const ProfileDrawerContent: React.FC<ProfileDrawerContentProps> = ({
|
|
235
|
+
actions,
|
|
236
|
+
children,
|
|
237
|
+
}) => {
|
|
238
|
+
const { email, firstName, lastName, avatar } = useProfile();
|
|
239
|
+
|
|
240
|
+
const fullName = useMemo(
|
|
241
|
+
() => [firstName, lastName].filter((i) => i).join(' '),
|
|
242
|
+
[firstName, lastName]
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
return (
|
|
246
|
+
<>
|
|
247
|
+
<AvatarContainer>
|
|
248
|
+
<UserAvatar size='10em' />
|
|
249
|
+
<UserContent>
|
|
250
|
+
{fullName && <FullName>{fullName}</FullName>}
|
|
251
|
+
<Email>{email}</Email>
|
|
252
|
+
</UserContent>
|
|
253
|
+
</AvatarContainer>
|
|
254
|
+
|
|
255
|
+
<ActionsContainer>
|
|
256
|
+
{avatar && <DeleteAvatarButton />}
|
|
257
|
+
|
|
258
|
+
<UpdateAvatarButton hasAvatar={!!avatar} />
|
|
259
|
+
<UpdateNameButton hasName={!!fullName} />
|
|
260
|
+
<ChangePasswordButton />
|
|
261
|
+
|
|
262
|
+
{actions}
|
|
263
|
+
|
|
264
|
+
<SignOutButton />
|
|
265
|
+
|
|
266
|
+
{children}
|
|
267
|
+
</ActionsContainer>
|
|
268
|
+
|
|
269
|
+
<Footer>
|
|
270
|
+
<ThemeSwitcher />
|
|
271
|
+
</Footer>
|
|
272
|
+
</>
|
|
273
|
+
);
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
export default ProfileDrawerContent;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIsMinWidth } from '@os-design/media';
|
|
3
|
+
import { NavigationItem, type NavigationItemProps } from '@os-design/core';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import ProfileIcon from '../shared/icons/ProfileIcon';
|
|
6
|
+
|
|
7
|
+
export interface ProfileNavigationItemProps
|
|
8
|
+
extends Partial<NavigationItemProps> {
|
|
9
|
+
onClick?: () => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const ProfileNavigationItem: React.FC<ProfileNavigationItemProps> = ({
|
|
13
|
+
onClick = () => {},
|
|
14
|
+
...rest
|
|
15
|
+
}) => {
|
|
16
|
+
const { t } = useTranslation(['profile']);
|
|
17
|
+
const isMinMd = useIsMinWidth('md');
|
|
18
|
+
|
|
19
|
+
if (isMinMd) return null;
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<NavigationItem
|
|
23
|
+
href='#' // To make focusable
|
|
24
|
+
icon={<ProfileIcon />}
|
|
25
|
+
onClick={onClick}
|
|
26
|
+
onKeyDown={(e) => {
|
|
27
|
+
if (e.key === 'Enter') onClick();
|
|
28
|
+
}}
|
|
29
|
+
{...rest}
|
|
30
|
+
>
|
|
31
|
+
{t('profile:menu')}
|
|
32
|
+
</NavigationItem>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default ProfileNavigationItem;
|