@os-team/profile 1.1.13 → 1.1.15
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/cjs/components/profile/ProfileButton.js +4 -6
- package/dist/cjs/components/profile/ProfileButton.js.map +1 -1
- package/dist/cjs/components/profile/ProfileConfigContext.js +5 -7
- package/dist/cjs/components/profile/ProfileConfigContext.js.map +1 -1
- package/dist/cjs/components/profile/ProfileContext.js +5 -7
- package/dist/cjs/components/profile/ProfileContext.js.map +1 -1
- package/dist/cjs/components/profile/ProfileDrawer.js +10 -16
- package/dist/cjs/components/profile/ProfileDrawer.js.map +1 -1
- package/dist/cjs/components/profile/ProfileDrawerContent.js +73 -103
- package/dist/cjs/components/profile/ProfileDrawerContent.js.map +1 -1
- package/dist/cjs/components/profile/ProfileNavigationItem.js +10 -11
- package/dist/cjs/components/profile/ProfileNavigationItem.js.map +1 -1
- package/dist/cjs/components/profile/ProfileUpdateNameModal.js +43 -54
- package/dist/cjs/components/profile/ProfileUpdateNameModal.js.map +1 -1
- package/dist/cjs/components/profile/ProfileUpdatePasswordModal.js +42 -52
- package/dist/cjs/components/profile/ProfileUpdatePasswordModal.js.map +1 -1
- package/dist/cjs/components/profile/ProtectedWrapper.js +27 -27
- package/dist/cjs/components/profile/ProtectedWrapper.js.map +1 -1
- package/dist/cjs/components/profile/UserAvatar.js +16 -15
- package/dist/cjs/components/profile/UserAvatar.js.map +1 -1
- package/dist/cjs/components/profile/UserAvatarAddon.js +13 -23
- package/dist/cjs/components/profile/UserAvatarAddon.js.map +1 -1
- package/dist/cjs/components/profile/__generated__/ProfileDrawerContentSignOutMutation.graphql.js +1 -2
- package/dist/cjs/components/profile/__generated__/ProfileDrawerContentSignOutMutation.graphql.js.map +1 -1
- package/dist/cjs/components/profile/__generated__/ProfileDrawerContentUpdateAvatarMutation.graphql.js +1 -2
- package/dist/cjs/components/profile/__generated__/ProfileDrawerContentUpdateAvatarMutation.graphql.js.map +1 -1
- package/dist/cjs/components/profile/__generated__/ProfileUpdateNameModalMutation.graphql.js +1 -2
- package/dist/cjs/components/profile/__generated__/ProfileUpdateNameModalMutation.graphql.js.map +1 -1
- package/dist/cjs/components/profile/__generated__/ProfileUpdatePasswordModalMutation.graphql.js +1 -2
- package/dist/cjs/components/profile/__generated__/ProfileUpdatePasswordModalMutation.graphql.js.map +1 -1
- package/dist/cjs/components/profile/__generated__/ProtectedWrapperQuery.graphql.js +1 -2
- package/dist/cjs/components/profile/__generated__/ProtectedWrapperQuery.graphql.js.map +1 -1
- package/dist/cjs/components/session/SessionDrawer.js +11 -15
- package/dist/cjs/components/session/SessionDrawer.js.map +1 -1
- package/dist/cjs/components/session/SessionDrawerContent.js +13 -14
- package/dist/cjs/components/session/SessionDrawerContent.js.map +1 -1
- package/dist/cjs/components/session/SessionList.js +31 -55
- package/dist/cjs/components/session/SessionList.js.map +1 -1
- package/dist/cjs/components/session/SessionListItem.js +59 -106
- package/dist/cjs/components/session/SessionListItem.js.map +1 -1
- package/dist/cjs/components/session/SessionListSkeleton.js +8 -9
- package/dist/cjs/components/session/SessionListSkeleton.js.map +1 -1
- package/dist/cjs/components/session/__generated__/SessionDrawerContentQuery.graphql.js +1 -1
- package/dist/cjs/components/session/__generated__/SessionDrawerContentQuery.graphql.js.map +1 -1
- package/dist/cjs/components/session/__generated__/SessionListDestroyAllOtherSessionsMutation.graphql.js +1 -2
- package/dist/cjs/components/session/__generated__/SessionListDestroyAllOtherSessionsMutation.graphql.js.map +1 -1
- package/dist/cjs/components/session/__generated__/SessionListItemDestroySessionMutation.graphql.js +1 -2
- package/dist/cjs/components/session/__generated__/SessionListItemDestroySessionMutation.graphql.js.map +1 -1
- package/dist/cjs/components/session/__generated__/SessionListItem_session.graphql.js +1 -1
- package/dist/cjs/components/session/__generated__/SessionListItem_session.graphql.js.map +1 -1
- package/dist/cjs/components/session/__generated__/SessionListRefetchQuery.graphql.js +1 -1
- package/dist/cjs/components/session/__generated__/SessionListRefetchQuery.graphql.js.map +1 -1
- package/dist/cjs/components/session/__generated__/SessionList_sessions.graphql.js +1 -1
- package/dist/cjs/components/session/__generated__/SessionList_sessions.graphql.js.map +1 -1
- package/dist/cjs/components/session/formatDate.js +6 -6
- package/dist/cjs/components/session/formatDate.js.map +1 -1
- package/dist/cjs/components/session/getLastSeen.js +6 -6
- package/dist/cjs/components/session/getLastSeen.js.map +1 -1
- package/dist/cjs/components/shared/ButtonUpdate.js +4 -3
- package/dist/cjs/components/shared/ButtonUpdate.js.map +1 -1
- package/dist/cjs/components/shared/ErrorResult.js +8 -5
- package/dist/cjs/components/shared/ErrorResult.js.map +1 -1
- package/dist/cjs/components/shared/FormError.js +5 -4
- package/dist/cjs/components/shared/FormError.js.map +1 -1
- package/dist/cjs/components/shared/MainLoader.js +2 -6
- package/dist/cjs/components/shared/MainLoader.js.map +1 -1
- package/dist/cjs/components/shared/icons/AndroidIcon.js +5 -7
- package/dist/cjs/components/shared/icons/AndroidIcon.js.map +1 -1
- package/dist/cjs/components/shared/icons/AppleIcon.js +5 -7
- package/dist/cjs/components/shared/icons/AppleIcon.js.map +1 -1
- package/dist/cjs/components/shared/icons/BrowserIcon.js +5 -7
- package/dist/cjs/components/shared/icons/BrowserIcon.js.map +1 -1
- package/dist/cjs/components/shared/icons/ProfileIcon.js +5 -7
- package/dist/cjs/components/shared/icons/ProfileIcon.js.map +1 -1
- package/dist/cjs/components/shared/icons/UnknownDeviceIcon.js +5 -7
- package/dist/cjs/components/shared/icons/UnknownDeviceIcon.js.map +1 -1
- package/dist/cjs/index.js +16 -17
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/getErrorMessage.js +13 -13
- package/dist/cjs/utils/getErrorMessage.js.map +1 -1
- package/dist/cjs/utils/getUserFullName.js +7 -5
- package/dist/cjs/utils/getUserFullName.js.map +1 -1
- package/dist/cjs/utils/handleFormErrors.js +11 -16
- package/dist/cjs/utils/handleFormErrors.js.map +1 -1
- package/dist/esm/components/profile/__generated__/ProfileDrawerContentSignOutMutation.graphql.js +0 -1
- package/dist/esm/components/profile/__generated__/ProfileDrawerContentSignOutMutation.graphql.js.map +1 -1
- package/dist/esm/components/profile/__generated__/ProfileDrawerContentUpdateAvatarMutation.graphql.js +0 -1
- package/dist/esm/components/profile/__generated__/ProfileDrawerContentUpdateAvatarMutation.graphql.js.map +1 -1
- package/dist/esm/components/profile/__generated__/ProfileUpdateNameModalMutation.graphql.js +0 -1
- package/dist/esm/components/profile/__generated__/ProfileUpdateNameModalMutation.graphql.js.map +1 -1
- package/dist/esm/components/profile/__generated__/ProfileUpdatePasswordModalMutation.graphql.js +0 -1
- package/dist/esm/components/profile/__generated__/ProfileUpdatePasswordModalMutation.graphql.js.map +1 -1
- package/dist/esm/components/profile/__generated__/ProtectedWrapperQuery.graphql.js +0 -1
- package/dist/esm/components/profile/__generated__/ProtectedWrapperQuery.graphql.js.map +1 -1
- package/dist/esm/components/session/__generated__/SessionListDestroyAllOtherSessionsMutation.graphql.js +0 -1
- package/dist/esm/components/session/__generated__/SessionListDestroyAllOtherSessionsMutation.graphql.js.map +1 -1
- package/dist/esm/components/session/__generated__/SessionListItemDestroySessionMutation.graphql.js +0 -1
- package/dist/esm/components/session/__generated__/SessionListItemDestroySessionMutation.graphql.js.map +1 -1
- package/dist/esm/utils/getUserFullName.js.map +1 -1
- package/dist/types/components/profile/ProfileButton.d.ts.map +1 -0
- package/dist/types/components/profile/ProfileConfigContext.d.ts.map +1 -0
- package/dist/types/components/profile/ProfileContext.d.ts.map +1 -0
- package/dist/types/components/profile/ProfileDrawer.d.ts.map +1 -0
- package/dist/types/components/profile/ProfileDrawerContent.d.ts.map +1 -0
- package/dist/types/components/profile/ProfileNavigationItem.d.ts.map +1 -0
- package/dist/types/components/profile/ProfileUpdateNameModal.d.ts.map +1 -0
- package/dist/types/components/profile/ProfileUpdatePasswordModal.d.ts.map +1 -0
- package/dist/types/components/profile/ProtectedWrapper.d.ts.map +1 -0
- package/dist/types/components/profile/UserAvatar.d.ts.map +1 -0
- package/dist/types/components/profile/UserAvatarAddon.d.ts.map +1 -0
- package/dist/types/components/profile/__generated__/ProfileDrawerContentSignOutMutation.graphql.d.ts.map +1 -0
- package/dist/types/components/profile/__generated__/ProfileDrawerContentUpdateAvatarMutation.graphql.d.ts.map +1 -0
- package/dist/types/components/profile/__generated__/ProfileUpdateNameModalMutation.graphql.d.ts.map +1 -0
- package/dist/types/components/profile/__generated__/ProfileUpdatePasswordModalMutation.graphql.d.ts.map +1 -0
- package/dist/types/components/profile/__generated__/ProtectedWrapperQuery.graphql.d.ts.map +1 -0
- package/dist/types/components/session/SessionDrawer.d.ts.map +1 -0
- package/dist/types/components/session/SessionDrawerContent.d.ts.map +1 -0
- package/dist/types/{src/lib/components → components}/session/SessionList.d.ts +2 -2
- package/dist/types/components/session/SessionList.d.ts.map +1 -0
- package/dist/types/{src/lib/components → components}/session/SessionListItem.d.ts +4 -4
- package/dist/types/components/session/SessionListItem.d.ts.map +1 -0
- package/dist/types/components/session/SessionListSkeleton.d.ts.map +1 -0
- package/dist/types/components/session/__generated__/SessionDrawerContentQuery.graphql.d.ts.map +1 -0
- package/dist/types/components/session/__generated__/SessionListDestroyAllOtherSessionsMutation.graphql.d.ts.map +1 -0
- package/dist/types/components/session/__generated__/SessionListItemDestroySessionMutation.graphql.d.ts.map +1 -0
- package/dist/types/components/session/__generated__/SessionListItem_session.graphql.d.ts.map +1 -0
- package/dist/types/components/session/__generated__/SessionListRefetchQuery.graphql.d.ts.map +1 -0
- package/dist/types/components/session/__generated__/SessionList_sessions.graphql.d.ts.map +1 -0
- package/dist/types/components/session/formatDate.d.ts.map +1 -0
- package/dist/types/components/session/getLastSeen.d.ts.map +1 -0
- package/dist/types/components/shared/ButtonUpdate.d.ts.map +1 -0
- package/dist/types/components/shared/ErrorResult.d.ts.map +1 -0
- package/dist/types/components/shared/FormError.d.ts.map +1 -0
- package/dist/types/components/shared/MainLoader.d.ts.map +1 -0
- package/dist/types/components/shared/icons/AndroidIcon.d.ts.map +1 -0
- package/dist/types/components/shared/icons/AppleIcon.d.ts.map +1 -0
- package/dist/types/components/shared/icons/BrowserIcon.d.ts.map +1 -0
- package/dist/types/components/shared/icons/ProfileIcon.d.ts.map +1 -0
- package/dist/types/components/shared/icons/UnknownDeviceIcon.d.ts.map +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/utils/getErrorMessage.d.ts.map +1 -0
- package/dist/types/{src/lib/utils → utils}/getUserFullName.d.ts +2 -2
- package/dist/types/utils/getUserFullName.d.ts.map +1 -0
- package/dist/types/utils/handleFormErrors.d.ts.map +1 -0
- package/package.json +41 -41
- package/dist/types/src/lib/components/profile/ProfileButton.d.ts.map +0 -1
- package/dist/types/src/lib/components/profile/ProfileConfigContext.d.ts.map +0 -1
- package/dist/types/src/lib/components/profile/ProfileContext.d.ts.map +0 -1
- package/dist/types/src/lib/components/profile/ProfileDrawer.d.ts.map +0 -1
- package/dist/types/src/lib/components/profile/ProfileDrawerContent.d.ts.map +0 -1
- package/dist/types/src/lib/components/profile/ProfileNavigationItem.d.ts.map +0 -1
- package/dist/types/src/lib/components/profile/ProfileUpdateNameModal.d.ts.map +0 -1
- package/dist/types/src/lib/components/profile/ProfileUpdatePasswordModal.d.ts.map +0 -1
- package/dist/types/src/lib/components/profile/ProtectedWrapper.d.ts.map +0 -1
- package/dist/types/src/lib/components/profile/UserAvatar.d.ts.map +0 -1
- package/dist/types/src/lib/components/profile/UserAvatarAddon.d.ts.map +0 -1
- package/dist/types/src/lib/components/profile/__generated__/ProfileDrawerContentSignOutMutation.graphql.d.ts.map +0 -1
- package/dist/types/src/lib/components/profile/__generated__/ProfileDrawerContentUpdateAvatarMutation.graphql.d.ts.map +0 -1
- package/dist/types/src/lib/components/profile/__generated__/ProfileUpdateNameModalMutation.graphql.d.ts.map +0 -1
- package/dist/types/src/lib/components/profile/__generated__/ProfileUpdatePasswordModalMutation.graphql.d.ts.map +0 -1
- package/dist/types/src/lib/components/profile/__generated__/ProtectedWrapperQuery.graphql.d.ts.map +0 -1
- package/dist/types/src/lib/components/session/SessionDrawer.d.ts.map +0 -1
- package/dist/types/src/lib/components/session/SessionDrawerContent.d.ts.map +0 -1
- package/dist/types/src/lib/components/session/SessionList.d.ts.map +0 -1
- package/dist/types/src/lib/components/session/SessionListItem.d.ts.map +0 -1
- package/dist/types/src/lib/components/session/SessionListSkeleton.d.ts.map +0 -1
- package/dist/types/src/lib/components/session/__generated__/SessionDrawerContentQuery.graphql.d.ts.map +0 -1
- package/dist/types/src/lib/components/session/__generated__/SessionListDestroyAllOtherSessionsMutation.graphql.d.ts.map +0 -1
- package/dist/types/src/lib/components/session/__generated__/SessionListItemDestroySessionMutation.graphql.d.ts.map +0 -1
- package/dist/types/src/lib/components/session/__generated__/SessionListItem_session.graphql.d.ts.map +0 -1
- package/dist/types/src/lib/components/session/__generated__/SessionListRefetchQuery.graphql.d.ts.map +0 -1
- package/dist/types/src/lib/components/session/__generated__/SessionList_sessions.graphql.d.ts.map +0 -1
- package/dist/types/src/lib/components/session/formatDate.d.ts.map +0 -1
- package/dist/types/src/lib/components/session/getLastSeen.d.ts.map +0 -1
- package/dist/types/src/lib/components/shared/ButtonUpdate.d.ts.map +0 -1
- package/dist/types/src/lib/components/shared/ErrorResult.d.ts.map +0 -1
- package/dist/types/src/lib/components/shared/FormError.d.ts.map +0 -1
- package/dist/types/src/lib/components/shared/MainLoader.d.ts.map +0 -1
- package/dist/types/src/lib/components/shared/icons/AndroidIcon.d.ts.map +0 -1
- package/dist/types/src/lib/components/shared/icons/AppleIcon.d.ts.map +0 -1
- package/dist/types/src/lib/components/shared/icons/BrowserIcon.d.ts.map +0 -1
- package/dist/types/src/lib/components/shared/icons/ProfileIcon.d.ts.map +0 -1
- package/dist/types/src/lib/components/shared/icons/UnknownDeviceIcon.d.ts.map +0 -1
- package/dist/types/src/lib/index.d.ts.map +0 -1
- package/dist/types/src/lib/utils/getErrorMessage.d.ts.map +0 -1
- package/dist/types/src/lib/utils/getUserFullName.d.ts.map +0 -1
- package/dist/types/src/lib/utils/handleFormErrors.d.ts.map +0 -1
- /package/dist/types/{src/lib/components → components}/profile/ProfileButton.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/profile/ProfileConfigContext.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/profile/ProfileContext.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/profile/ProfileDrawer.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/profile/ProfileDrawerContent.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/profile/ProfileNavigationItem.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/profile/ProfileUpdateNameModal.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/profile/ProfileUpdatePasswordModal.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/profile/ProtectedWrapper.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/profile/UserAvatar.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/profile/UserAvatarAddon.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/profile/__generated__/ProfileDrawerContentSignOutMutation.graphql.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/profile/__generated__/ProfileDrawerContentUpdateAvatarMutation.graphql.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/profile/__generated__/ProfileUpdateNameModalMutation.graphql.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/profile/__generated__/ProfileUpdatePasswordModalMutation.graphql.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/profile/__generated__/ProtectedWrapperQuery.graphql.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/session/SessionDrawer.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/session/SessionDrawerContent.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/session/SessionListSkeleton.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/session/__generated__/SessionDrawerContentQuery.graphql.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/session/__generated__/SessionListDestroyAllOtherSessionsMutation.graphql.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/session/__generated__/SessionListItemDestroySessionMutation.graphql.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/session/__generated__/SessionListItem_session.graphql.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/session/__generated__/SessionListRefetchQuery.graphql.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/session/__generated__/SessionList_sessions.graphql.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/session/formatDate.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/session/getLastSeen.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/shared/ButtonUpdate.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/shared/ErrorResult.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/shared/FormError.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/shared/MainLoader.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/shared/icons/AndroidIcon.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/shared/icons/AppleIcon.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/shared/icons/BrowserIcon.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/shared/icons/ProfileIcon.d.ts +0 -0
- /package/dist/types/{src/lib/components → components}/shared/icons/UnknownDeviceIcon.d.ts +0 -0
- /package/dist/types/{src/lib/index.d.ts → index.d.ts} +0 -0
- /package/dist/types/{src/lib/utils → utils}/getErrorMessage.d.ts +0 -0
- /package/dist/types/{src/lib/utils → utils}/handleFormErrors.d.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProfileNavigationItem.js","names":["_react","_interopRequireDefault","require","_media","_core","_reactI18next","_ProfileIcon","
|
|
1
|
+
{"version":3,"file":"ProfileNavigationItem.js","names":["_react","_interopRequireDefault","require","_media","_core","_reactI18next","_ProfileIcon","obj","__esModule","default","_extends","Object","assign","bind","target","i","arguments","length","source","key","prototype","hasOwnProperty","call","apply","ProfileNavigationItem","_ref","onClick","rest","t","useTranslation","isMinMd","useIsMinWidth","createElement","NavigationItem","href","icon","onKeyDown","e","_default","exports"],"sources":["../../../../src/lib/components/profile/ProfileNavigationItem.tsx"],"sourcesContent":["import React from 'react';\nimport { useIsMinWidth } from '@os-design/media';\nimport { NavigationItem, NavigationItemProps } from '@os-design/core';\nimport { useTranslation } from 'react-i18next';\nimport ProfileIcon from '../shared/icons/ProfileIcon';\n\nexport interface ProfileNavigationItemProps\n extends Partial<NavigationItemProps> {\n onClick?: () => void;\n}\n\nconst ProfileNavigationItem: React.FC<ProfileNavigationItemProps> = ({\n onClick = () => {},\n ...rest\n}) => {\n const { t } = useTranslation(['profile']);\n const isMinMd = useIsMinWidth('md');\n\n if (isMinMd) return null;\n\n return (\n <NavigationItem\n href='#' // To make focusable\n icon={<ProfileIcon />}\n onClick={onClick}\n onKeyDown={(e) => {\n if (e.key === 'Enter') onClick();\n }}\n {...rest}\n >\n {t('profile:menu')}\n </NavigationItem>\n );\n};\n\nexport default ProfileNavigationItem;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAL,sBAAA,CAAAC,OAAA;AAAsD,SAAAD,uBAAAM,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,SAAA,IAAAA,QAAA,GAAAC,MAAA,CAAAC,MAAA,GAAAD,MAAA,CAAAC,MAAA,CAAAC,IAAA,eAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,GAAAF,SAAA,CAAAD,CAAA,YAAAI,GAAA,IAAAD,MAAA,QAAAP,MAAA,CAAAS,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAJ,MAAA,EAAAC,GAAA,KAAAL,MAAA,CAAAK,GAAA,IAAAD,MAAA,CAAAC,GAAA,gBAAAL,MAAA,YAAAJ,QAAA,CAAAa,KAAA,OAAAP,SAAA;AAOtD,MAAMQ,qBAA2D,GAAGC,IAAA,IAG9D;EAAA,IAH+D;IACnEC,OAAO,GAAGA,CAAA,KAAM,CAAC,CAAC;IAClB,GAAGC;EACL,CAAC,GAAAF,IAAA;EACC,MAAM;IAAEG;EAAE,CAAC,GAAG,IAAAC,4BAAc,EAAC,CAAC,SAAS,CAAC,CAAC;EACzC,MAAMC,OAAO,GAAG,IAAAC,oBAAa,EAAC,IAAI,CAAC;EAEnC,IAAID,OAAO,EAAE,OAAO,IAAI;EAExB,oBACE9B,MAAA,CAAAS,OAAA,CAAAuB,aAAA,CAAC5B,KAAA,CAAA6B,cAAc,EAAAvB,QAAA;IACbwB,IAAI,EAAC,GAAG,CAAC;IAAA;IACTC,IAAI,eAAEnC,MAAA,CAAAS,OAAA,CAAAuB,aAAA,CAAC1B,YAAA,CAAAG,OAAW,MAAE,CAAE;IACtBiB,OAAO,EAAEA,OAAQ;IACjBU,SAAS,EAAGC,CAAC,IAAK;MAChB,IAAIA,CAAC,CAAClB,GAAG,KAAK,OAAO,EAAEO,OAAO,CAAC,CAAC;IAClC;EAAE,GACEC,IAAI,GAEPC,CAAC,CAAC,cAAc,CACH,CAAC;AAErB,CAAC;AAAC,IAAAU,QAAA,GAAAC,OAAA,CAAA9B,OAAA,GAEae,qBAAqB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -15,69 +14,55 @@ var _FormError = _interopRequireDefault(require("../shared/FormError"));
|
|
|
15
14
|
var _ProfileContext = require("./ProfileContext");
|
|
16
15
|
var _ProfileUpdateNameModalMutation;
|
|
17
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function
|
|
19
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
17
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
20
19
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
firstName
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}, [firstName, lastName]);
|
|
43
|
-
var _useForm = (0, _form.useForm)(initValues),
|
|
44
|
-
form = _useForm.form,
|
|
45
|
-
Field = _useForm.Field;
|
|
46
|
-
var _useMutation = (0, _hooks.useMutation)(_ProfileUpdateNameModalMutation !== void 0 ? _ProfileUpdateNameModalMutation : (_ProfileUpdateNameModalMutation = require("./__generated__/ProfileUpdateNameModalMutation.graphql"), _ProfileUpdateNameModalMutation.hash && _ProfileUpdateNameModalMutation.hash !== "7264a05b6738d5417df9f1dc462486aa" && console.error("The definition of 'ProfileUpdateNameModalMutation' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _ProfileUpdateNameModalMutation)),
|
|
47
|
-
_useMutation2 = _slicedToArray(_useMutation, 2),
|
|
48
|
-
commit = _useMutation2[0],
|
|
49
|
-
loading = _useMutation2[1];
|
|
20
|
+
const ProfileUpdateNameModal = _ref => {
|
|
21
|
+
let {
|
|
22
|
+
visible,
|
|
23
|
+
onClose
|
|
24
|
+
} = _ref;
|
|
25
|
+
const {
|
|
26
|
+
t
|
|
27
|
+
} = (0, _reactI18next.useTranslation)(['profile']);
|
|
28
|
+
const {
|
|
29
|
+
firstName = '',
|
|
30
|
+
lastName = ''
|
|
31
|
+
} = (0, _ProfileContext.useProfile)();
|
|
32
|
+
const initValues = (0, _react.useMemo)(() => ({
|
|
33
|
+
firstName,
|
|
34
|
+
lastName
|
|
35
|
+
}), [firstName, lastName]);
|
|
36
|
+
const {
|
|
37
|
+
form,
|
|
38
|
+
Field
|
|
39
|
+
} = (0, _form.useForm)(initValues);
|
|
40
|
+
const [commit, loading] = (0, _hooks.useMutation)(_ProfileUpdateNameModalMutation !== void 0 ? _ProfileUpdateNameModalMutation : (_ProfileUpdateNameModalMutation = require("./__generated__/ProfileUpdateNameModalMutation.graphql"), _ProfileUpdateNameModalMutation.hash && _ProfileUpdateNameModalMutation.hash !== "7264a05b6738d5417df9f1dc462486aa" && console.error("The definition of 'ProfileUpdateNameModalMutation' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _ProfileUpdateNameModalMutation));
|
|
50
41
|
|
|
51
42
|
// Reset the form when the modal is opened
|
|
52
|
-
(0, _react.useEffect)(
|
|
43
|
+
(0, _react.useEffect)(() => {
|
|
53
44
|
if (visible) form.reset();
|
|
54
45
|
}, [form, visible]);
|
|
55
|
-
|
|
46
|
+
const onSubmit = (0, _react.useCallback)(() => {
|
|
56
47
|
commit({
|
|
57
48
|
variables: {
|
|
58
49
|
input: form.values.getAll()
|
|
59
50
|
},
|
|
60
|
-
onError:
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
onCompleted: function onCompleted() {
|
|
51
|
+
onError: error => (0, _handleFormErrors.default)(form, error),
|
|
52
|
+
onCompleted: () => {
|
|
64
53
|
_core.message.success(t('profile:updated'));
|
|
65
54
|
onClose();
|
|
66
55
|
}
|
|
67
56
|
});
|
|
68
57
|
}, [commit, form, onClose, t]);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
label: t('profile:updateNameModal.lastName.label'),
|
|
78
|
-
placeholder: t('profile:updateNameModal.lastName.placeholder')
|
|
79
|
-
};
|
|
80
|
-
}, [t]);
|
|
58
|
+
const firstNameData = (0, _react.useMemo)(() => ({
|
|
59
|
+
label: t('profile:updateNameModal.firstName.label'),
|
|
60
|
+
placeholder: t('profile:updateNameModal.firstName.placeholder')
|
|
61
|
+
}), [t]);
|
|
62
|
+
const lastNameData = (0, _react.useMemo)(() => ({
|
|
63
|
+
label: t('profile:updateNameModal.lastName.label'),
|
|
64
|
+
placeholder: t('profile:updateNameModal.lastName.placeholder')
|
|
65
|
+
}), [t]);
|
|
81
66
|
return /*#__PURE__*/_react.default.createElement(_core.Modal, {
|
|
82
67
|
title: t('profile:updateNameModal.title'),
|
|
83
68
|
visible: visible,
|
|
@@ -90,8 +75,10 @@ var ProfileUpdateNameModal = function ProfileUpdateNameModal(_ref) {
|
|
|
90
75
|
}, /*#__PURE__*/_react.default.createElement(_core.Form, null, /*#__PURE__*/_react.default.createElement(Field, {
|
|
91
76
|
name: "firstName",
|
|
92
77
|
data: firstNameData,
|
|
93
|
-
render:
|
|
94
|
-
|
|
78
|
+
render: (props, _ref2, data) => {
|
|
79
|
+
let {
|
|
80
|
+
error
|
|
81
|
+
} = _ref2;
|
|
95
82
|
return /*#__PURE__*/_react.default.createElement(_core.FormItem, {
|
|
96
83
|
label: data.label,
|
|
97
84
|
error: error
|
|
@@ -102,8 +89,10 @@ var ProfileUpdateNameModal = function ProfileUpdateNameModal(_ref) {
|
|
|
102
89
|
}), /*#__PURE__*/_react.default.createElement(Field, {
|
|
103
90
|
name: "lastName",
|
|
104
91
|
data: lastNameData,
|
|
105
|
-
render:
|
|
106
|
-
|
|
92
|
+
render: (props, _ref3, data) => {
|
|
93
|
+
let {
|
|
94
|
+
error
|
|
95
|
+
} = _ref3;
|
|
107
96
|
return /*#__PURE__*/_react.default.createElement(_core.FormItem, {
|
|
108
97
|
label: data.label,
|
|
109
98
|
error: error
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProfileUpdateNameModal.js","names":["_core","require","_form","_react","_interopRequireWildcard","_reactI18next","_hooks","_handleFormErrors","_interopRequireDefault","_FormError","_ProfileContext","_ProfileUpdateNameModalMutation","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","_extends","assign","bind","target","arguments","length","source","key","apply","_slicedToArray","arr","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","o","minLen","_arrayLikeToArray","toString","slice","constructor","name","Array","from","test","len","arr2","l","Symbol","iterator","f","next","done","push","value","return","isArray","ProfileUpdateNameModal","_ref","visible","onClose","_useTranslation","useTranslation","_useProfile","useProfile","_useProfile$firstName","firstName","_useProfile$lastName","lastName","initValues","useMemo","_useForm","useForm","form","Field","_useMutation","useMutation","hash","console","error","_useMutation2","commit","loading","useEffect","reset","onSubmit","useCallback","variables","input","values","getAll","onError","handleFormErrors","onCompleted","message","success","firstNameData","label","placeholder","lastNameData","createElement","Modal","title","okText","okLoading","onOk","FormProvider","Form","data","render","props","_ref2","FormItem","Input","_ref3","_default","exports"],"sources":["../../../../src/lib/components/profile/ProfileUpdateNameModal.tsx"],"sourcesContent":["import { Form, FormItem, Input, message, Modal } from '@os-design/core';\nimport { FormProvider, useForm } from '@os-design/form';\nimport { graphql } from 'babel-plugin-relay/macro';\nimport React, { useCallback, useEffect, useMemo } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useMutation } from 'react-relay/hooks';\nimport handleFormErrors from '../../utils/handleFormErrors';\nimport FormError from '../shared/FormError';\nimport { ProfileUpdateNameModalMutation } from './__generated__/ProfileUpdateNameModalMutation.graphql';\nimport { useProfile } from './ProfileContext';\n\ninterface ProfileUpdateNameFormData {\n firstName: string;\n lastName: string;\n}\n\ninterface ProfileUpdateNameModalProps {\n visible: boolean;\n onClose: () => void;\n}\n\nconst ProfileUpdateNameModal: React.FC<ProfileUpdateNameModalProps> = ({\n visible,\n onClose,\n}) => {\n const { t } = useTranslation(['profile']);\n const { firstName = '', lastName = '' } = useProfile();\n\n const initValues = useMemo<ProfileUpdateNameFormData>(\n () => ({ firstName, lastName }),\n [firstName, lastName]\n );\n\n const { form, Field } = useForm(initValues);\n\n const [commit, loading] = useMutation<ProfileUpdateNameModalMutation>(graphql`\n mutation ProfileUpdateNameModalMutation($input: UpdateProfileInput!) {\n updateProfile(input: $input) {\n firstName\n lastName\n }\n }\n `);\n\n // Reset the form when the modal is opened\n useEffect(() => {\n if (visible) form.reset();\n }, [form, visible]);\n\n const onSubmit = useCallback(() => {\n commit({\n variables: {\n input: form.values.getAll(),\n },\n onError: (error) => handleFormErrors(form, error),\n onCompleted: () => {\n message.success(t('profile:updated'));\n onClose();\n },\n });\n }, [commit, form, onClose, t]);\n\n const firstNameData = useMemo(\n () => ({\n label: t('profile:updateNameModal.firstName.label'),\n placeholder: t('profile:updateNameModal.firstName.placeholder'),\n }),\n [t]\n );\n\n const lastNameData = useMemo(\n () => ({\n label: t('profile:updateNameModal.lastName.label'),\n placeholder: t('profile:updateNameModal.lastName.placeholder'),\n }),\n [t]\n );\n\n return (\n <Modal\n title={t('profile:updateNameModal.title')}\n visible={visible}\n okText={t('profile:update')}\n okLoading={loading}\n onOk={onSubmit}\n onClose={onClose}\n >\n <FormProvider form={form}>\n <Form>\n <Field\n name='firstName'\n data={firstNameData}\n render={(props, { error }, data) => (\n <FormItem label={data.label} error={error}>\n <Input placeholder={data.placeholder} {...props} />\n </FormItem>\n )}\n />\n\n <Field\n name='lastName'\n data={lastNameData}\n render={(props, { error }, data) => (\n <FormItem label={data.label} error={error}>\n <Input placeholder={data.placeholder} {...props} />\n </FormItem>\n )}\n />\n\n <FormError />\n </Form>\n </FormProvider>\n </Modal>\n );\n};\n\nexport default ProfileUpdateNameModal;\n"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAD,sBAAA,CAAAP,OAAA;AAEA,IAAAS,eAAA,GAAAT,OAAA;AAA8C,IAAAU,+BAAA;AAAA,SAAAH,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,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AACC,KAAK,EAAAC,KAAA,EAAaH,IAAI;MAAA,IAAb7B,KAAK,GAAAgC,KAAA,CAALhC,KAAK;MAAA,oBACrB5F,MAAA,CAAAW,OAAA,CAAAsG,aAAA,CAACpH,KAAA,CAAAgI,QAAQ;QAACf,KAAK,EAAEW,IAAI,CAACX,KAAM;QAAClB,KAAK,EAAEA;MAAM,gBACxC5F,MAAA,CAAAW,OAAA,CAAAsG,aAAA,CAACpH,KAAA,CAAAiI,KAAK,EAAA9F,QAAA;QAAC+E,WAAW,EAAEU,IAAI,CAACV;MAAY,GAAKY,KAAK,CAAG,CAC1C,CAAC;IAAA;EACX,CACH,CAAC,eAEF3H,MAAA,CAAAW,OAAA,CAAAsG,aAAA,CAAC1B,KAAK;IACJjC,IAAI,EAAC,UAAU;IACfmE,IAAI,EAAET,YAAa;IACnBU,MAAM,EAAE,SAAAA,OAACC,KAAK,EAAAI,KAAA,EAAaN,IAAI;MAAA,IAAb7B,KAAK,GAAAmC,KAAA,CAALnC,KAAK;MAAA,oBACrB5F,MAAA,CAAAW,OAAA,CAAAsG,aAAA,CAACpH,KAAA,CAAAgI,QAAQ;QAACf,KAAK,EAAEW,IAAI,CAACX,KAAM;QAAClB,KAAK,EAAEA;MAAM,gBACxC5F,MAAA,CAAAW,OAAA,CAAAsG,aAAA,CAACpH,KAAA,CAAAiI,KAAK,EAAA9F,QAAA;QAAC+E,WAAW,EAAEU,IAAI,CAACV;MAAY,GAAKY,KAAK,CAAG,CAC1C,CAAC;IAAA;EACX,CACH,CAAC,eAEF3H,MAAA,CAAAW,OAAA,CAAAsG,aAAA,CAAC3G,UAAA,CAAAK,OAAS,MAAE,CACR,CACM,CACT,CAAC;AAEZ,CAAC;AAAC,IAAAqH,QAAA,GAAAC,OAAA,CAAAtH,OAAA,GAEa2D,sBAAsB"}
|
|
1
|
+
{"version":3,"file":"ProfileUpdateNameModal.js","names":["_core","require","_form","_react","_interopRequireWildcard","_reactI18next","_hooks","_handleFormErrors","_interopRequireDefault","_FormError","_ProfileContext","_ProfileUpdateNameModalMutation","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","_extends","assign","bind","target","arguments","length","source","key","apply","ProfileUpdateNameModal","_ref","visible","onClose","useTranslation","firstName","lastName","useProfile","initValues","useMemo","form","Field","useForm","commit","loading","useMutation","hash","console","error","useEffect","reset","onSubmit","useCallback","variables","input","values","getAll","onError","handleFormErrors","onCompleted","message","success","firstNameData","label","placeholder","lastNameData","createElement","Modal","title","okText","okLoading","onOk","FormProvider","Form","name","data","render","props","_ref2","FormItem","Input","_ref3","_default","exports"],"sources":["../../../../src/lib/components/profile/ProfileUpdateNameModal.tsx"],"sourcesContent":["import { Form, FormItem, Input, message, Modal } from '@os-design/core';\nimport { FormProvider, useForm } from '@os-design/form';\nimport { graphql } from 'babel-plugin-relay/macro';\nimport React, { useCallback, useEffect, useMemo } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useMutation } from 'react-relay/hooks';\nimport handleFormErrors from '../../utils/handleFormErrors';\nimport FormError from '../shared/FormError';\nimport { ProfileUpdateNameModalMutation } from './__generated__/ProfileUpdateNameModalMutation.graphql';\nimport { useProfile } from './ProfileContext';\n\ninterface ProfileUpdateNameFormData {\n firstName: string;\n lastName: string;\n}\n\ninterface ProfileUpdateNameModalProps {\n visible: boolean;\n onClose: () => void;\n}\n\nconst ProfileUpdateNameModal: React.FC<ProfileUpdateNameModalProps> = ({\n visible,\n onClose,\n}) => {\n const { t } = useTranslation(['profile']);\n const { firstName = '', lastName = '' } = useProfile();\n\n const initValues = useMemo<ProfileUpdateNameFormData>(\n () => ({ firstName, lastName }),\n [firstName, lastName]\n );\n\n const { form, Field } = useForm(initValues);\n\n const [commit, loading] = useMutation<ProfileUpdateNameModalMutation>(graphql`\n mutation ProfileUpdateNameModalMutation($input: UpdateProfileInput!) {\n updateProfile(input: $input) {\n firstName\n lastName\n }\n }\n `);\n\n // Reset the form when the modal is opened\n useEffect(() => {\n if (visible) form.reset();\n }, [form, visible]);\n\n const onSubmit = useCallback(() => {\n commit({\n variables: {\n input: form.values.getAll(),\n },\n onError: (error) => handleFormErrors(form, error),\n onCompleted: () => {\n message.success(t('profile:updated'));\n onClose();\n },\n });\n }, [commit, form, onClose, t]);\n\n const firstNameData = useMemo(\n () => ({\n label: t('profile:updateNameModal.firstName.label'),\n placeholder: t('profile:updateNameModal.firstName.placeholder'),\n }),\n [t]\n );\n\n const lastNameData = useMemo(\n () => ({\n label: t('profile:updateNameModal.lastName.label'),\n placeholder: t('profile:updateNameModal.lastName.placeholder'),\n }),\n [t]\n );\n\n return (\n <Modal\n title={t('profile:updateNameModal.title')}\n visible={visible}\n okText={t('profile:update')}\n okLoading={loading}\n onOk={onSubmit}\n onClose={onClose}\n >\n <FormProvider form={form}>\n <Form>\n <Field\n name='firstName'\n data={firstNameData}\n render={(props, { error }, data) => (\n <FormItem label={data.label} error={error}>\n <Input placeholder={data.placeholder} {...props} />\n </FormItem>\n )}\n />\n\n <Field\n name='lastName'\n data={lastNameData}\n render={(props, { error }, data) => (\n <FormItem label={data.label} error={error}>\n <Input placeholder={data.placeholder} {...props} />\n </FormItem>\n )}\n />\n\n <FormError />\n </Form>\n </FormProvider>\n </Modal>\n );\n};\n\nexport default ProfileUpdateNameModal;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAD,sBAAA,CAAAP,OAAA;AAEA,IAAAS,eAAA,GAAAT,OAAA;AAA8C,IAAAU,+BAAA;AAAA,SAAAH,uBAAAI,GAAA,WAAAA,GAAA,IA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AAA,CAACtE,UAAA,CAAAK,OAAS,MAAE,CACR,CACM,CACT,CAAC;AAEZ,CAAC;AAAC,IAAAiF,QAAA,GAAAC,OAAA,CAAAlF,OAAA,GAEa6B,sBAAsB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -14,67 +13,54 @@ var _handleFormErrors = _interopRequireDefault(require("../../utils/handleFormEr
|
|
|
14
13
|
var _FormError = _interopRequireDefault(require("../shared/FormError"));
|
|
15
14
|
var _ProfileUpdatePasswordModalMutation;
|
|
16
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function
|
|
18
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
16
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
17
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
18
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
var _useForm = (0, _form.useForm)(initValues),
|
|
38
|
-
form = _useForm.form,
|
|
39
|
-
Field = _useForm.Field;
|
|
40
|
-
var _useMutation = (0, _hooks.useMutation)(_ProfileUpdatePasswordModalMutation !== void 0 ? _ProfileUpdatePasswordModalMutation : (_ProfileUpdatePasswordModalMutation = require("./__generated__/ProfileUpdatePasswordModalMutation.graphql"), _ProfileUpdatePasswordModalMutation.hash && _ProfileUpdatePasswordModalMutation.hash !== "efa37ccbe82fbace709f7e3992643c05" && console.error("The definition of 'ProfileUpdatePasswordModalMutation' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _ProfileUpdatePasswordModalMutation)),
|
|
41
|
-
_useMutation2 = _slicedToArray(_useMutation, 2),
|
|
42
|
-
commit = _useMutation2[0],
|
|
43
|
-
loading = _useMutation2[1];
|
|
19
|
+
const ProfileUpdatePasswordModal = _ref => {
|
|
20
|
+
let {
|
|
21
|
+
visible,
|
|
22
|
+
onClose
|
|
23
|
+
} = _ref;
|
|
24
|
+
const {
|
|
25
|
+
t
|
|
26
|
+
} = (0, _reactI18next.useTranslation)(['profile']);
|
|
27
|
+
const initValues = (0, _react.useMemo)(() => ({
|
|
28
|
+
currentPassword: '',
|
|
29
|
+
password: ''
|
|
30
|
+
}), []);
|
|
31
|
+
const {
|
|
32
|
+
form,
|
|
33
|
+
Field
|
|
34
|
+
} = (0, _form.useForm)(initValues);
|
|
35
|
+
const [commit, loading] = (0, _hooks.useMutation)(_ProfileUpdatePasswordModalMutation !== void 0 ? _ProfileUpdatePasswordModalMutation : (_ProfileUpdatePasswordModalMutation = require("./__generated__/ProfileUpdatePasswordModalMutation.graphql"), _ProfileUpdatePasswordModalMutation.hash && _ProfileUpdatePasswordModalMutation.hash !== "efa37ccbe82fbace709f7e3992643c05" && console.error("The definition of 'ProfileUpdatePasswordModalMutation' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _ProfileUpdatePasswordModalMutation));
|
|
44
36
|
|
|
45
37
|
// Reset the form when the modal is opened
|
|
46
|
-
(0, _react.useEffect)(
|
|
38
|
+
(0, _react.useEffect)(() => {
|
|
47
39
|
if (visible) form.reset();
|
|
48
40
|
}, [form, visible]);
|
|
49
|
-
|
|
41
|
+
const onSubmit = (0, _react.useCallback)(() => {
|
|
50
42
|
commit({
|
|
51
43
|
variables: {
|
|
52
44
|
input: form.values.getAll()
|
|
53
45
|
},
|
|
54
|
-
onError:
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
onCompleted: function onCompleted() {
|
|
46
|
+
onError: error => (0, _handleFormErrors.default)(form, error),
|
|
47
|
+
onCompleted: () => {
|
|
58
48
|
_core.message.success(t('profile:updatePasswordModal.success'));
|
|
59
49
|
onClose();
|
|
60
50
|
}
|
|
61
51
|
});
|
|
62
52
|
}, [commit, form, onClose, t]);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
returnObjects: true
|
|
75
|
-
})
|
|
76
|
-
};
|
|
77
|
-
}, [t]);
|
|
53
|
+
const currentPasswordData = (0, _react.useMemo)(() => ({
|
|
54
|
+
label: t('profile:updatePasswordModal.currentPassword.label'),
|
|
55
|
+
placeholder: t('profile:updatePasswordModal.currentPassword.placeholder')
|
|
56
|
+
}), [t]);
|
|
57
|
+
const passwordData = (0, _react.useMemo)(() => ({
|
|
58
|
+
label: t('profile:updatePasswordModal.newPassword.label'),
|
|
59
|
+
placeholder: t('profile:updatePasswordModal.newPassword.placeholder'),
|
|
60
|
+
strengthNames: t('profile:updatePasswordModal.passwordStrengthNames', {
|
|
61
|
+
returnObjects: true
|
|
62
|
+
})
|
|
63
|
+
}), [t]);
|
|
78
64
|
return /*#__PURE__*/_react.default.createElement(_core.Modal, {
|
|
79
65
|
title: t('profile:updatePasswordModal.title'),
|
|
80
66
|
visible: visible,
|
|
@@ -87,8 +73,10 @@ var ProfileUpdatePasswordModal = function ProfileUpdatePasswordModal(_ref) {
|
|
|
87
73
|
}, /*#__PURE__*/_react.default.createElement(_core.Form, null, /*#__PURE__*/_react.default.createElement(Field, {
|
|
88
74
|
name: "currentPassword",
|
|
89
75
|
data: currentPasswordData,
|
|
90
|
-
render:
|
|
91
|
-
|
|
76
|
+
render: (props, _ref2, data) => {
|
|
77
|
+
let {
|
|
78
|
+
error
|
|
79
|
+
} = _ref2;
|
|
92
80
|
return /*#__PURE__*/_react.default.createElement(_core.FormItem, {
|
|
93
81
|
label: data.label,
|
|
94
82
|
error: error
|
|
@@ -99,8 +87,10 @@ var ProfileUpdatePasswordModal = function ProfileUpdatePasswordModal(_ref) {
|
|
|
99
87
|
}), /*#__PURE__*/_react.default.createElement(Field, {
|
|
100
88
|
name: "password",
|
|
101
89
|
data: passwordData,
|
|
102
|
-
render:
|
|
103
|
-
|
|
90
|
+
render: (props, _ref3, data) => {
|
|
91
|
+
let {
|
|
92
|
+
error
|
|
93
|
+
} = _ref3;
|
|
104
94
|
return /*#__PURE__*/_react.default.createElement(_core.FormItem, {
|
|
105
95
|
label: data.label,
|
|
106
96
|
error: error
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProfileUpdatePasswordModal.js","names":["_core","require","_form","_react","_interopRequireWildcard","_reactI18next","_hooks","_handleFormErrors","_interopRequireDefault","_FormError","_ProfileUpdatePasswordModalMutation","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","_extends","assign","bind","target","arguments","length","source","key","apply","_slicedToArray","arr","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","o","minLen","_arrayLikeToArray","toString","slice","constructor","name","Array","from","test","len","arr2","l","Symbol","iterator","f","next","done","push","value","return","isArray","ProfileUpdatePasswordModal","_ref","visible","onClose","_useTranslation","useTranslation","initValues","useMemo","currentPassword","password","_useForm","useForm","form","Field","_useMutation","useMutation","hash","console","error","_useMutation2","commit","loading","useEffect","reset","onSubmit","useCallback","variables","input","values","getAll","onError","handleFormErrors","onCompleted","message","success","currentPasswordData","label","placeholder","passwordData","strengthNames","returnObjects","createElement","Modal","title","okText","okLoading","onOk","FormProvider","Form","data","render","props","_ref2","FormItem","InputPassword","_ref3","showStrengthMeter","_default","exports"],"sources":["../../../../src/lib/components/profile/ProfileUpdatePasswordModal.tsx"],"sourcesContent":["import { Form, FormItem, InputPassword, message, Modal } from '@os-design/core';\nimport { FormProvider, useForm } from '@os-design/form';\nimport { graphql } from 'babel-plugin-relay/macro';\nimport React, { useCallback, useEffect, useMemo } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useMutation } from 'react-relay/hooks';\nimport handleFormErrors from '../../utils/handleFormErrors';\nimport FormError from '../shared/FormError';\nimport { ProfileUpdatePasswordModalMutation } from './__generated__/ProfileUpdatePasswordModalMutation.graphql';\n\ninterface ProfileUpdatePasswordFormData {\n currentPassword: string;\n password: string;\n}\n\ninterface ProfileUpdatePasswordModalProps {\n visible: boolean;\n onClose: () => void;\n}\n\nconst ProfileUpdatePasswordModal: React.FC<ProfileUpdatePasswordModalProps> = ({\n visible,\n onClose,\n}) => {\n const { t } = useTranslation(['profile']);\n\n const initValues = useMemo<ProfileUpdatePasswordFormData>(\n () => ({\n currentPassword: '',\n password: '',\n }),\n []\n );\n\n const { form, Field } = useForm(initValues);\n\n const [commit, loading] = useMutation<ProfileUpdatePasswordModalMutation>(\n graphql`\n mutation ProfileUpdatePasswordModalMutation(\n $input: UpdatePasswordInput!\n ) {\n updatePassword(input: $input) {\n id\n }\n }\n `\n );\n\n // Reset the form when the modal is opened\n useEffect(() => {\n if (visible) form.reset();\n }, [form, visible]);\n\n const onSubmit = useCallback(() => {\n commit({\n variables: {\n input: form.values.getAll(),\n },\n onError: (error) => handleFormErrors(form, error),\n onCompleted: () => {\n message.success(t('profile:updatePasswordModal.success'));\n onClose();\n },\n });\n }, [commit, form, onClose, t]);\n\n const currentPasswordData = useMemo(\n () => ({\n label: t('profile:updatePasswordModal.currentPassword.label'),\n placeholder: t('profile:updatePasswordModal.currentPassword.placeholder'),\n }),\n [t]\n );\n\n const passwordData = useMemo(\n () => ({\n label: t('profile:updatePasswordModal.newPassword.label'),\n placeholder: t('profile:updatePasswordModal.newPassword.placeholder'),\n strengthNames: t('profile:updatePasswordModal.passwordStrengthNames', {\n returnObjects: true,\n }),\n }),\n [t]\n );\n\n return (\n <Modal\n title={t('profile:updatePasswordModal.title')}\n visible={visible}\n okText={t('profile:updatePasswordModal.button')}\n okLoading={loading}\n onOk={onSubmit}\n onClose={onClose}\n >\n <FormProvider form={form}>\n <Form>\n <Field\n name='currentPassword'\n data={currentPasswordData}\n render={(props, { error }, data) => (\n <FormItem label={data.label} error={error}>\n <InputPassword placeholder={data.placeholder} {...props} />\n </FormItem>\n )}\n />\n\n <Field\n name='password'\n data={passwordData}\n render={(props, { error }, data) => (\n <FormItem label={data.label} error={error}>\n <InputPassword\n placeholder={data.placeholder}\n showStrengthMeter\n strengthNames={data.strengthNames}\n {...props}\n />\n </FormItem>\n )}\n />\n\n <FormError />\n </Form>\n </FormProvider>\n </Modal>\n );\n};\n\nexport default ProfileUpdatePasswordModal;\n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EAAEU,IAAI,CAACV;MAAc,GAC9BY,KAAK,CACV,CACO,CAAC;IAAA;EACX,CACH,CAAC,eAEFxH,MAAA,CAAAU,OAAA,CAAAoG,aAAA,CAACxG,UAAA,CAAAI,OAAS,MAAE,CACR,CACM,CACT,CAAC;AAEZ,CAAC;AAAC,IAAAoH,QAAA,GAAAC,OAAA,CAAArH,OAAA,GAEa2D,0BAA0B"}
|
|
1
|
+
{"version":3,"file":"ProfileUpdatePasswordModal.js","names":["_core","require","_form","_react","_interopRequireWildcard","_reactI18next","_hooks","_handleFormErrors","_interopRequireDefault","_FormError","_ProfileUpdatePasswordModalMutation","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","_extends","assign","bind","target","arguments","length","source","key","apply","ProfileUpdatePasswordModal","_ref","visible","onClose","useTranslation","initValues","useMemo","currentPassword","password","form","Field","useForm","commit","loading","useMutation","hash","console","error","useEffect","reset","onSubmit","useCallback","variables","input","values","getAll","onError","handleFormErrors","onCompleted","message","success","currentPasswordData","label","placeholder","passwordData","strengthNames","returnObjects","createElement","Modal","title","okText","okLoading","onOk","FormProvider","Form","name","data","render","props","_ref2","FormItem","InputPassword","_ref3","showStrengthMeter","_default","exports"],"sources":["../../../../src/lib/components/profile/ProfileUpdatePasswordModal.tsx"],"sourcesContent":["import { Form, FormItem, InputPassword, message, Modal } from '@os-design/core';\nimport { FormProvider, useForm } from '@os-design/form';\nimport { graphql } from 'babel-plugin-relay/macro';\nimport React, { useCallback, useEffect, useMemo } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useMutation } from 'react-relay/hooks';\nimport handleFormErrors from '../../utils/handleFormErrors';\nimport FormError from '../shared/FormError';\nimport { ProfileUpdatePasswordModalMutation } from './__generated__/ProfileUpdatePasswordModalMutation.graphql';\n\ninterface ProfileUpdatePasswordFormData {\n currentPassword: string;\n password: string;\n}\n\ninterface ProfileUpdatePasswordModalProps {\n visible: boolean;\n onClose: () => void;\n}\n\nconst ProfileUpdatePasswordModal: React.FC<ProfileUpdatePasswordModalProps> = ({\n visible,\n onClose,\n}) => {\n const { t } = useTranslation(['profile']);\n\n const initValues = useMemo<ProfileUpdatePasswordFormData>(\n () => ({\n currentPassword: '',\n password: '',\n }),\n []\n );\n\n const { form, Field } = useForm(initValues);\n\n const [commit, loading] = useMutation<ProfileUpdatePasswordModalMutation>(\n graphql`\n mutation ProfileUpdatePasswordModalMutation(\n $input: UpdatePasswordInput!\n ) {\n updatePassword(input: $input) {\n id\n }\n }\n `\n );\n\n // Reset the form when the modal is opened\n useEffect(() => {\n if (visible) form.reset();\n }, [form, visible]);\n\n const onSubmit = useCallback(() => {\n commit({\n variables: {\n input: form.values.getAll(),\n },\n onError: (error) => handleFormErrors(form, error),\n onCompleted: () => {\n message.success(t('profile:updatePasswordModal.success'));\n onClose();\n },\n });\n }, [commit, form, onClose, t]);\n\n const currentPasswordData = useMemo(\n () => ({\n label: t('profile:updatePasswordModal.currentPassword.label'),\n placeholder: t('profile:updatePasswordModal.currentPassword.placeholder'),\n }),\n [t]\n );\n\n const passwordData = useMemo(\n () => ({\n label: t('profile:updatePasswordModal.newPassword.label'),\n placeholder: t('profile:updatePasswordModal.newPassword.placeholder'),\n strengthNames: t('profile:updatePasswordModal.passwordStrengthNames', {\n returnObjects: true,\n }),\n }),\n [t]\n );\n\n return (\n <Modal\n title={t('profile:updatePasswordModal.title')}\n visible={visible}\n okText={t('profile:updatePasswordModal.button')}\n okLoading={loading}\n onOk={onSubmit}\n onClose={onClose}\n >\n <FormProvider form={form}>\n <Form>\n <Field\n name='currentPassword'\n data={currentPasswordData}\n render={(props, { error }, data) => (\n <FormItem label={data.label} error={error}>\n <InputPassword placeholder={data.placeholder} {...props} />\n </FormItem>\n )}\n />\n\n <Field\n name='password'\n data={passwordData}\n render={(props, { error }, data) => (\n <FormItem label={data.label} error={error}>\n <InputPassword\n placeholder={data.placeholder}\n showStrengthMeter\n strengthNames={data.strengthNames}\n {...props}\n />\n </FormItem>\n )}\n />\n\n <FormError />\n </Form>\n </FormProvider>\n </Modal>\n );\n};\n\nexport default ProfileUpdatePasswordModal;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAD,sBAAA,CAAAP,OAAA;AAA4C,IAAAS,mCAAA;AAAA,SAAAF,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAX,wBAAAW,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAH,UAAA,SAAAG,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAF,OAAA,EAAAE,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAJ,CAAA,UAAAG,CAAA,CAAAE,GAAA,CAAAL,CAAA,OAAAM,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAZ,CAAA,oBAAAY,CAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAA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a,MAAM,EAAEA,CAACC,KAAK,EAAAI,KAAA,EAAaN,IAAI;MAAA,IAAf;QAAE7B;MAAM,CAAC,GAAAmC,KAAA;MAAA,oBACvB3F,MAAA,CAAAU,OAAA,CAAAkE,aAAA,CAAC/E,KAAA,CAAA4F,QAAQ;QAAClB,KAAK,EAAEc,IAAI,CAACd,KAAM;QAACf,KAAK,EAAEA;MAAM,gBACxCxD,MAAA,CAAAU,OAAA,CAAAkE,aAAA,CAAC/E,KAAA,CAAA6F,aAAa,EAAA5D,QAAA;QACZ0C,WAAW,EAAEa,IAAI,CAACb,WAAY;QAC9BoB,iBAAiB;QACjBlB,aAAa,EAAEW,IAAI,CAACX;MAAc,GAC9Ba,KAAK,CACV,CACO,CAAC;IAAA;EACX,CACH,CAAC,eAEFvF,MAAA,CAAAU,OAAA,CAAAkE,aAAA,CAACtE,UAAA,CAAAI,OAAS,MAAE,CACR,CACM,CACT,CAAC;AAEZ,CAAC;AAAC,IAAAmF,QAAA,GAAAC,OAAA,CAAApF,OAAA,GAEa6B,0BAA0B"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -12,39 +11,40 @@ var _ProfileConfigContext = _interopRequireDefault(require("./ProfileConfigConte
|
|
|
12
11
|
var _ProfileContext = _interopRequireDefault(require("./ProfileContext"));
|
|
13
12
|
var _ProtectedWrapperQuery;
|
|
14
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function
|
|
16
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
profile
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
const ProtectedWrapperLoader = _ref => {
|
|
17
|
+
let {
|
|
18
|
+
children
|
|
19
|
+
} = _ref;
|
|
20
|
+
const {
|
|
21
|
+
profile
|
|
22
|
+
} = (0, _hooks.useLazyLoadQuery)(_ProtectedWrapperQuery !== void 0 ? _ProtectedWrapperQuery : (_ProtectedWrapperQuery = require("./__generated__/ProtectedWrapperQuery.graphql"), _ProtectedWrapperQuery.hash && _ProtectedWrapperQuery.hash !== "903b234e48f53b4a44dc0b4974ebc521" && console.error("The definition of 'ProtectedWrapperQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _ProtectedWrapperQuery), {}, {
|
|
23
|
+
fetchPolicy: 'store-or-network'
|
|
24
|
+
});
|
|
25
|
+
const profileContext = (0, _react.useMemo)(() => ({
|
|
26
|
+
id: profile.id,
|
|
27
|
+
email: profile.email,
|
|
28
|
+
firstName: profile.firstName || undefined,
|
|
29
|
+
lastName: profile.lastName || undefined,
|
|
30
|
+
avatar: profile.avatar || undefined
|
|
31
|
+
}), [profile.avatar, profile.email, profile.firstName, profile.id, profile.lastName]);
|
|
32
32
|
return /*#__PURE__*/_react.default.createElement(_ProfileContext.default.Provider, {
|
|
33
33
|
value: profileContext
|
|
34
34
|
}, children);
|
|
35
35
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}, [bucketId]);
|
|
36
|
+
const ProtectedWrapper = _ref2 => {
|
|
37
|
+
let {
|
|
38
|
+
bucketId,
|
|
39
|
+
children
|
|
40
|
+
} = _ref2;
|
|
41
|
+
const profileConfigContext = (0, _react.useMemo)(() => ({
|
|
42
|
+
bucketId
|
|
43
|
+
}), [bucketId]);
|
|
44
44
|
return /*#__PURE__*/_react.default.createElement(_ProfileConfigContext.default.Provider, {
|
|
45
45
|
value: profileConfigContext
|
|
46
46
|
}, /*#__PURE__*/_react.default.createElement(_utils.ErrorBoundary, {
|
|
47
|
-
fallback:
|
|
47
|
+
fallback: () => {
|
|
48
48
|
window.location.href = '/auth/';
|
|
49
49
|
return null;
|
|
50
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProtectedWrapper.js","names":["_react","_interopRequireWildcard","require","_hooks","_utils","_ProfileConfigContext","_interopRequireDefault","_ProfileContext","_ProtectedWrapperQuery","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","
|
|
1
|
+
{"version":3,"file":"ProtectedWrapper.js","names":["_react","_interopRequireWildcard","require","_hooks","_utils","_ProfileConfigContext","_interopRequireDefault","_ProfileContext","_ProtectedWrapperQuery","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","ProtectedWrapperLoader","_ref","children","profile","useLazyLoadQuery","hash","console","error","fetchPolicy","profileContext","useMemo","id","email","firstName","undefined","lastName","avatar","createElement","Provider","value","ProtectedWrapper","_ref2","bucketId","profileConfigContext","ErrorBoundary","fallback","window","location","href","_default","exports"],"sources":["../../../../src/lib/components/profile/ProtectedWrapper.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport graphql from 'babel-plugin-relay/macro';\nimport { useLazyLoadQuery } from 'react-relay/hooks';\nimport { ErrorBoundary } from '@os-design/utils';\nimport ProfileConfigContext from './ProfileConfigContext';\nimport ProfileContext from './ProfileContext';\nimport { ProtectedWrapperQuery } from './__generated__/ProtectedWrapperQuery.graphql';\n\ninterface ProtectedWrapperLoaderProps {\n children?: React.ReactNode;\n}\n\nconst ProtectedWrapperLoader: React.FC<ProtectedWrapperLoaderProps> = ({\n children,\n}) => {\n const { profile } = useLazyLoadQuery<ProtectedWrapperQuery>(\n graphql`\n query ProtectedWrapperQuery {\n profile {\n id\n email\n firstName\n lastName\n avatar\n }\n }\n `,\n {},\n { fetchPolicy: 'store-or-network' }\n );\n\n const profileContext = useMemo(\n () => ({\n id: profile.id,\n email: profile.email,\n firstName: profile.firstName || undefined,\n lastName: profile.lastName || undefined,\n avatar: profile.avatar || undefined,\n }),\n [\n profile.avatar,\n profile.email,\n profile.firstName,\n profile.id,\n profile.lastName,\n ]\n );\n\n return (\n <ProfileContext.Provider value={profileContext}>\n {children}\n </ProfileContext.Provider>\n );\n};\n\nexport interface ProtectedWrapperProps {\n bucketId: string;\n children?: React.ReactNode;\n}\n\nconst ProtectedWrapper: React.FC<ProtectedWrapperProps> = ({\n bucketId,\n children,\n}) => {\n const profileConfigContext = useMemo(() => ({ bucketId }), [bucketId]);\n\n return (\n <ProfileConfigContext.Provider value={profileConfigContext}>\n <ErrorBoundary\n fallback={() => {\n window.location.href = '/auth/';\n return null;\n }}\n >\n <ProtectedWrapperLoader>{children}</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AC;AAE9B,CAAC;AAOD,MAAMkB,gBAAiD,GAAGC,KAAA,IAGpD;EAAA,IAHqD;IACzDC,QAAQ;IACRpB;EACF,CAAC,GAAAmB,KAAA;EACC,MAAME,oBAAoB,GAAG,IAAAb,cAAO,EAAC,OAAO;IAAEY;EAAS,CAAC,CAAC,EAAE,CAACA,QAAQ,CAAC,CAAC;EAEtE,oBACErD,MAAA,CAAAW,OAAA,CAAAqC,aAAA,CAAC3C,qBAAA,CAAAM,OAAoB,CAACsC,QAAQ;IAACC,KAAK,EAAEI;EAAqB,gBACzDtD,MAAA,CAAAW,OAAA,CAAAqC,aAAA,CAAC5C,MAAA,CAAAmD,aAAa;IACZC,QAAQ,EAAEA,CAAA,KAAM;MACdC,MAAM,CAACC,QAAQ,CAACC,IAAI,GAAG,QAAQ;MAC/B,OAAO,IAAI;IACb;EAAE,gBAEF3D,MAAA,CAAAW,OAAA,CAAAqC,aAAA,CAACjB,sBAAsB,QAAEE,QAAiC,CAC7C,CACc,CAAC;AAEpC,CAAC;AAAC,IAAA2B,QAAA,GAAAC,OAAA,CAAAlD,OAAA,GAEawC,gBAAgB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -9,27 +8,29 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
8
|
var _core = require("@os-design/core");
|
|
10
9
|
var _ProfileContext = require("./ProfileContext");
|
|
11
10
|
var _ProfileConfigContext = require("./ProfileConfigContext");
|
|
12
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function
|
|
13
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
13
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
email
|
|
18
|
-
firstName
|
|
19
|
-
lastName
|
|
20
|
-
avatar
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
const UserAvatar = props => {
|
|
15
|
+
const {
|
|
16
|
+
email,
|
|
17
|
+
firstName,
|
|
18
|
+
lastName,
|
|
19
|
+
avatar
|
|
20
|
+
} = (0, _ProfileContext.useProfile)();
|
|
21
|
+
const {
|
|
22
|
+
bucketId
|
|
23
|
+
} = (0, _ProfileConfigContext.useProfileConfig)();
|
|
24
|
+
const avatarProps = (0, _react.useMemo)(() => {
|
|
24
25
|
if (firstName || lastName) return {
|
|
25
|
-
firstName
|
|
26
|
-
lastName
|
|
26
|
+
firstName,
|
|
27
|
+
lastName
|
|
27
28
|
};
|
|
28
29
|
return {
|
|
29
30
|
firstName: email
|
|
30
31
|
};
|
|
31
32
|
}, [email, firstName, lastName]);
|
|
32
|
-
|
|
33
|
+
const image = (0, _react.useMemo)(() => {
|
|
33
34
|
if (!avatar) return undefined;
|
|
34
35
|
return "https://storage.yandexcloud.net/".concat(bucketId, "/users/").concat(avatar);
|
|
35
36
|
}, [avatar, bucketId]);
|