@os-team/profile 1.0.34 → 1.0.37
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/ProfileConfigContext.js +1 -1
- package/dist/cjs/components/profile/ProfileContext.js +1 -1
- package/dist/cjs/components/profile/ProfileDrawer.js +19 -232
- package/dist/cjs/components/profile/ProfileDrawer.js.map +1 -1
- package/dist/cjs/components/profile/ProfileDrawerContent.js +259 -0
- package/dist/cjs/components/profile/ProfileDrawerContent.js.map +1 -0
- package/dist/cjs/components/profile/ProfileUpdateNameModal.js +1 -1
- package/dist/cjs/components/profile/ProfileUpdatePasswordModal.js +1 -1
- package/dist/cjs/components/profile/ProtectedWrapper.js +1 -1
- package/dist/cjs/components/profile/UserAvatar.js +1 -1
- package/dist/cjs/components/profile/__generated__/ProfileDrawerContentSignOutMutation.graphql.js +70 -0
- package/dist/cjs/components/profile/__generated__/ProfileDrawerContentSignOutMutation.graphql.js.map +1 -0
- package/dist/cjs/components/profile/__generated__/ProfileDrawerContentUpdateAvatarMutation.graphql.js +89 -0
- package/dist/cjs/components/profile/__generated__/ProfileDrawerContentUpdateAvatarMutation.graphql.js.map +1 -0
- package/dist/cjs/components/profile/__generated__/ProfileDrawerSignOutMutation.graphql.js +7 -9
- package/dist/cjs/components/profile/__generated__/ProfileDrawerSignOutMutation.graphql.js.map +1 -1
- package/dist/cjs/components/profile/__generated__/ProfileDrawerUpdateAvatarMutation.graphql.js +7 -12
- package/dist/cjs/components/profile/__generated__/ProfileDrawerUpdateAvatarMutation.graphql.js.map +1 -1
- package/dist/cjs/components/profile/__generated__/ProfileUpdateNameModalMutation.graphql.js +7 -13
- package/dist/cjs/components/profile/__generated__/ProfileUpdateNameModalMutation.graphql.js.map +1 -1
- package/dist/cjs/components/profile/__generated__/ProfileUpdatePasswordModalMutation.graphql.js +7 -11
- package/dist/cjs/components/profile/__generated__/ProfileUpdatePasswordModalMutation.graphql.js.map +1 -1
- package/dist/cjs/components/profile/__generated__/ProtectedWrapperQuery.graphql.js +7 -13
- package/dist/cjs/components/profile/__generated__/ProtectedWrapperQuery.graphql.js.map +1 -1
- package/dist/cjs/components/session/SessionDrawer.js +17 -10
- package/dist/cjs/components/session/SessionDrawer.js.map +1 -1
- package/dist/cjs/components/session/SessionDrawerContent.js +2 -5
- package/dist/cjs/components/session/SessionDrawerContent.js.map +1 -1
- package/dist/cjs/components/session/SessionList.js +1 -1
- package/dist/cjs/components/session/SessionListItem.js +1 -1
- package/dist/cjs/components/session/__generated__/SessionDrawerContentQuery.graphql.js +7 -34
- package/dist/cjs/components/session/__generated__/SessionDrawerContentQuery.graphql.js.map +1 -1
- package/dist/cjs/components/session/__generated__/SessionListDestroyAllOtherSessionsMutation.graphql.js +7 -9
- package/dist/cjs/components/session/__generated__/SessionListDestroyAllOtherSessionsMutation.graphql.js.map +1 -1
- package/dist/cjs/components/session/__generated__/SessionListItemDestroySessionMutation.graphql.js +7 -11
- package/dist/cjs/components/session/__generated__/SessionListItemDestroySessionMutation.graphql.js.map +1 -1
- package/dist/cjs/components/session/__generated__/SessionListItem_session.graphql.js +7 -1
- package/dist/cjs/components/session/__generated__/SessionListItem_session.graphql.js.map +1 -1
- package/dist/cjs/components/session/__generated__/SessionListRefetchQuery.graphql.js +7 -34
- package/dist/cjs/components/session/__generated__/SessionListRefetchQuery.graphql.js.map +1 -1
- package/dist/cjs/components/session/__generated__/SessionList_sessions.graphql.js +7 -5
- package/dist/cjs/components/session/__generated__/SessionList_sessions.graphql.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/esm/components/profile/ProfileDrawer.js +12 -196
- package/dist/esm/components/profile/ProfileDrawer.js.map +1 -1
- package/dist/esm/components/profile/ProfileDrawerContent.js +201 -0
- package/dist/esm/components/profile/ProfileDrawerContent.js.map +1 -0
- package/dist/esm/components/profile/__generated__/ProfileDrawerContentSignOutMutation.graphql.js +62 -0
- package/dist/esm/components/profile/__generated__/ProfileDrawerContentSignOutMutation.graphql.js.map +1 -0
- package/dist/esm/components/profile/__generated__/ProfileDrawerContentUpdateAvatarMutation.graphql.js +81 -0
- package/dist/esm/components/profile/__generated__/ProfileDrawerContentUpdateAvatarMutation.graphql.js.map +1 -0
- package/dist/esm/components/profile/__generated__/ProfileDrawerSignOutMutation.graphql.js +7 -9
- package/dist/esm/components/profile/__generated__/ProfileDrawerSignOutMutation.graphql.js.map +1 -1
- package/dist/esm/components/profile/__generated__/ProfileDrawerUpdateAvatarMutation.graphql.js +7 -12
- package/dist/esm/components/profile/__generated__/ProfileDrawerUpdateAvatarMutation.graphql.js.map +1 -1
- package/dist/esm/components/profile/__generated__/ProfileUpdateNameModalMutation.graphql.js +7 -13
- package/dist/esm/components/profile/__generated__/ProfileUpdateNameModalMutation.graphql.js.map +1 -1
- package/dist/esm/components/profile/__generated__/ProfileUpdatePasswordModalMutation.graphql.js +7 -11
- package/dist/esm/components/profile/__generated__/ProfileUpdatePasswordModalMutation.graphql.js.map +1 -1
- package/dist/esm/components/profile/__generated__/ProtectedWrapperQuery.graphql.js +7 -13
- package/dist/esm/components/profile/__generated__/ProtectedWrapperQuery.graphql.js.map +1 -1
- package/dist/esm/components/session/SessionDrawer.js +7 -4
- package/dist/esm/components/session/SessionDrawer.js.map +1 -1
- package/dist/esm/components/session/SessionDrawerContent.js +0 -1
- package/dist/esm/components/session/SessionDrawerContent.js.map +1 -1
- package/dist/esm/components/session/__generated__/SessionDrawerContentQuery.graphql.js +7 -34
- package/dist/esm/components/session/__generated__/SessionDrawerContentQuery.graphql.js.map +1 -1
- package/dist/esm/components/session/__generated__/SessionListDestroyAllOtherSessionsMutation.graphql.js +7 -9
- package/dist/esm/components/session/__generated__/SessionListDestroyAllOtherSessionsMutation.graphql.js.map +1 -1
- package/dist/esm/components/session/__generated__/SessionListItemDestroySessionMutation.graphql.js +7 -11
- package/dist/esm/components/session/__generated__/SessionListItemDestroySessionMutation.graphql.js.map +1 -1
- package/dist/esm/components/session/__generated__/SessionListItem_session.graphql.js +7 -1
- package/dist/esm/components/session/__generated__/SessionListItem_session.graphql.js.map +1 -1
- package/dist/esm/components/session/__generated__/SessionListRefetchQuery.graphql.js +7 -34
- package/dist/esm/components/session/__generated__/SessionListRefetchQuery.graphql.js.map +1 -1
- package/dist/esm/components/session/__generated__/SessionList_sessions.graphql.js +8 -3
- package/dist/esm/components/session/__generated__/SessionList_sessions.graphql.js.map +1 -1
- package/dist/types/components/profile/ProfileDrawer.d.ts +2 -3
- package/dist/types/components/profile/ProfileDrawer.d.ts.map +1 -1
- package/dist/types/components/profile/ProfileDrawerContent.d.ts +7 -0
- package/dist/types/components/profile/ProfileDrawerContent.d.ts.map +1 -0
- package/dist/types/components/profile/__generated__/ProfileDrawerContentSignOutMutation.graphql.d.ts +14 -0
- package/dist/types/components/profile/__generated__/ProfileDrawerContentSignOutMutation.graphql.d.ts.map +1 -0
- package/dist/types/components/profile/__generated__/ProfileDrawerContentUpdateAvatarMutation.graphql.d.ts +20 -0
- package/dist/types/components/profile/__generated__/ProfileDrawerContentUpdateAvatarMutation.graphql.d.ts.map +1 -0
- package/dist/types/components/profile/__generated__/ProfileDrawerSignOutMutation.graphql.d.ts +5 -5
- package/dist/types/components/profile/__generated__/ProfileDrawerSignOutMutation.graphql.d.ts.map +1 -1
- package/dist/types/components/profile/__generated__/ProfileDrawerUpdateAvatarMutation.graphql.d.ts +6 -6
- package/dist/types/components/profile/__generated__/ProfileDrawerUpdateAvatarMutation.graphql.d.ts.map +1 -1
- package/dist/types/components/profile/__generated__/ProfileUpdateNameModalMutation.graphql.d.ts +7 -7
- package/dist/types/components/profile/__generated__/ProfileUpdateNameModalMutation.graphql.d.ts.map +1 -1
- package/dist/types/components/profile/__generated__/ProfileUpdatePasswordModalMutation.graphql.d.ts +5 -5
- package/dist/types/components/profile/__generated__/ProfileUpdatePasswordModalMutation.graphql.d.ts.map +1 -1
- package/dist/types/components/profile/__generated__/ProtectedWrapperQuery.graphql.d.ts +5 -5
- package/dist/types/components/profile/__generated__/ProtectedWrapperQuery.graphql.d.ts.map +1 -1
- package/dist/types/components/session/SessionDrawer.d.ts.map +1 -1
- package/dist/types/components/session/SessionDrawerContent.d.ts +0 -1
- package/dist/types/components/session/SessionDrawerContent.d.ts.map +1 -1
- package/dist/types/components/session/__generated__/SessionDrawerContentQuery.graphql.d.ts +6 -6
- package/dist/types/components/session/__generated__/SessionDrawerContentQuery.graphql.d.ts.map +1 -1
- package/dist/types/components/session/__generated__/SessionListDestroyAllOtherSessionsMutation.graphql.d.ts +5 -5
- package/dist/types/components/session/__generated__/SessionListDestroyAllOtherSessionsMutation.graphql.d.ts.map +1 -1
- package/dist/types/components/session/__generated__/SessionListItemDestroySessionMutation.graphql.d.ts +5 -5
- package/dist/types/components/session/__generated__/SessionListItemDestroySessionMutation.graphql.d.ts.map +1 -1
- package/dist/types/components/session/__generated__/SessionListItem_session.graphql.d.ts +5 -6
- package/dist/types/components/session/__generated__/SessionListItem_session.graphql.d.ts.map +1 -1
- package/dist/types/components/session/__generated__/SessionListRefetchQuery.graphql.d.ts +6 -6
- package/dist/types/components/session/__generated__/SessionListRefetchQuery.graphql.d.ts.map +1 -1
- package/dist/types/components/session/__generated__/SessionList_sessions.graphql.d.ts +6 -7
- package/dist/types/components/session/__generated__/SessionList_sessions.graphql.d.ts.map +1 -1
- package/package.json +45 -47
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
@@ -13,31 +11,15 @@ var _core = require("@os-design/core");
|
|
|
13
11
|
|
|
14
12
|
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
15
13
|
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
var _reactI18next = require("react-i18next");
|
|
19
|
-
|
|
20
|
-
var _hooks = require("react-relay/hooks");
|
|
21
|
-
|
|
22
|
-
var _ProfileContext = require("./ProfileContext");
|
|
23
|
-
|
|
24
|
-
var _UserAvatar = _interopRequireDefault(require("./UserAvatar"));
|
|
25
|
-
|
|
26
|
-
var _ProfileButton = _interopRequireDefault(require("./ProfileButton"));
|
|
27
|
-
|
|
28
|
-
var _ProfileUpdateNameModal = _interopRequireDefault(require("./ProfileUpdateNameModal"));
|
|
29
|
-
|
|
30
|
-
var _ProfileUpdatePasswordModal = _interopRequireDefault(require("./ProfileUpdatePasswordModal"));
|
|
14
|
+
var _MainLoader = _interopRequireDefault(require("../shared/MainLoader"));
|
|
31
15
|
|
|
32
16
|
var _excluded = ["actions", "children"];
|
|
33
17
|
|
|
34
|
-
var
|
|
18
|
+
var _templateObject;
|
|
35
19
|
|
|
36
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
37
21
|
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
41
23
|
|
|
42
24
|
function _extends() { _extends = Object.assign || 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); }
|
|
43
25
|
|
|
@@ -45,227 +27,32 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
45
27
|
|
|
46
28
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
47
29
|
|
|
48
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
49
|
-
|
|
50
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
51
|
-
|
|
52
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
53
|
-
|
|
54
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
55
|
-
|
|
56
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
57
|
-
|
|
58
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
59
|
-
|
|
60
30
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
61
31
|
|
|
62
|
-
var
|
|
63
|
-
|
|
64
|
-
var AvatarContainer = _styled.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n"])));
|
|
65
|
-
|
|
66
|
-
var UserContent = _styled.default.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n margin-top: 1em;\n"])));
|
|
32
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
67
33
|
|
|
68
|
-
var
|
|
69
|
-
return p.theme.sizes.large;
|
|
70
|
-
});
|
|
34
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
71
35
|
|
|
72
|
-
var
|
|
73
|
-
return (
|
|
36
|
+
var LazyProfileDrawerContent = /*#__PURE__*/(0, _react.lazy)(function () {
|
|
37
|
+
return Promise.resolve().then(function () {
|
|
38
|
+
return _interopRequireWildcard(require('./ProfileDrawerContent'));
|
|
39
|
+
});
|
|
74
40
|
});
|
|
41
|
+
var StyledDrawer = (0, _styled.default)(_core.Drawer)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n padding: 2em 1em;\n"])));
|
|
75
42
|
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
var HiddenInput = _styled.default.input(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n display: none;\n"])));
|
|
81
|
-
|
|
82
|
-
var profileDrawerUpdateAvatarMutation = _ProfileDrawerUpdateAvatarMutation !== void 0 ? _ProfileDrawerUpdateAvatarMutation : (_ProfileDrawerUpdateAvatarMutation = require("./__generated__/ProfileDrawerUpdateAvatarMutation.graphql"), _ProfileDrawerUpdateAvatarMutation.hash && _ProfileDrawerUpdateAvatarMutation.hash !== "c129cb1974b7cb9090d6c5df4e0f790d" && console.error("The definition of 'ProfileDrawerUpdateAvatarMutation' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _ProfileDrawerUpdateAvatarMutation);
|
|
83
|
-
|
|
84
|
-
var DeleteAvatarButton = function DeleteAvatarButton() {
|
|
85
|
-
var _useTranslation = (0, _reactI18next.useTranslation)('profile'),
|
|
86
|
-
t = _useTranslation.t;
|
|
87
|
-
|
|
88
|
-
var _useMutation = (0, _hooks.useMutation)(profileDrawerUpdateAvatarMutation),
|
|
89
|
-
_useMutation2 = _slicedToArray(_useMutation, 2),
|
|
90
|
-
commit = _useMutation2[0],
|
|
91
|
-
loading = _useMutation2[1];
|
|
92
|
-
|
|
93
|
-
var handler = (0, _react.useCallback)(function () {
|
|
94
|
-
commit({
|
|
95
|
-
variables: {
|
|
96
|
-
input: {
|
|
97
|
-
avatar: null
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
onError: function onError(error) {
|
|
101
|
-
var _source, _source$errors, _source$errors$;
|
|
102
|
-
|
|
103
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
104
|
-
_core.message.error((_source = error.source) === null || _source === void 0 ? void 0 : (_source$errors = _source.errors) === null || _source$errors === void 0 ? void 0 : (_source$errors$ = _source$errors[0]) === null || _source$errors$ === void 0 ? void 0 : _source$errors$.message);
|
|
105
|
-
},
|
|
106
|
-
onCompleted: function onCompleted() {
|
|
107
|
-
_core.message.success(t('profile:updated'));
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}, [commit, t]);
|
|
111
|
-
return /*#__PURE__*/_react.default.createElement(_ProfileButton.default, {
|
|
112
|
-
loading: loading,
|
|
113
|
-
onClick: handler
|
|
114
|
-
}, t('profile:deleteAvatar'));
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
var UpdateAvatarButton = function UpdateAvatarButton(_ref) {
|
|
118
|
-
var hasAvatar = _ref.hasAvatar;
|
|
119
|
-
|
|
120
|
-
var _useTranslation2 = (0, _reactI18next.useTranslation)('profile'),
|
|
121
|
-
t = _useTranslation2.t;
|
|
122
|
-
|
|
123
|
-
var fileInputRef = (0, _react.useRef)(null);
|
|
124
|
-
|
|
125
|
-
var _useMutation3 = (0, _hooks.useMutation)(profileDrawerUpdateAvatarMutation),
|
|
126
|
-
_useMutation4 = _slicedToArray(_useMutation3, 2),
|
|
127
|
-
commit = _useMutation4[0],
|
|
128
|
-
loading = _useMutation4[1];
|
|
129
|
-
|
|
130
|
-
var handler = (0, _react.useCallback)(function (e) {
|
|
131
|
-
var target = e.target;
|
|
132
|
-
if (!target) return;
|
|
133
|
-
var files = target.files;
|
|
134
|
-
if (!files) return;
|
|
135
|
-
var file = files[0];
|
|
136
|
-
commit({
|
|
137
|
-
variables: {
|
|
138
|
-
input: {}
|
|
139
|
-
},
|
|
140
|
-
uploadables: {
|
|
141
|
-
avatar: file
|
|
142
|
-
},
|
|
143
|
-
onError: function onError(error) {
|
|
144
|
-
var _source2, _source2$errors, _source2$errors$;
|
|
145
|
-
|
|
146
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
147
|
-
_core.message.error((_source2 = error.source) === null || _source2 === void 0 ? void 0 : (_source2$errors = _source2.errors) === null || _source2$errors === void 0 ? void 0 : (_source2$errors$ = _source2$errors[0]) === null || _source2$errors$ === void 0 ? void 0 : _source2$errors$.message);
|
|
148
|
-
},
|
|
149
|
-
onCompleted: function onCompleted() {
|
|
150
|
-
_core.message.success(t('profile:updated'));
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}, [commit, t]);
|
|
154
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ProfileButton.default, {
|
|
155
|
-
loading: loading,
|
|
156
|
-
onClick: function onClick() {
|
|
157
|
-
if (!fileInputRef.current) return;
|
|
158
|
-
fileInputRef.current.value = '';
|
|
159
|
-
fileInputRef.current.click();
|
|
160
|
-
}
|
|
161
|
-
}, t("profile:".concat(hasAvatar ? 'changeAvatar' : 'setAvatar'))), /*#__PURE__*/_react.default.createElement(HiddenInput, {
|
|
162
|
-
type: "file",
|
|
163
|
-
accept: "image/jpeg,image/png,image/webp",
|
|
164
|
-
onChange: handler,
|
|
165
|
-
ref: fileInputRef
|
|
166
|
-
}));
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
var UpdateNameButton = function UpdateNameButton(_ref2) {
|
|
170
|
-
var hasName = _ref2.hasName;
|
|
171
|
-
|
|
172
|
-
var _useTranslation3 = (0, _reactI18next.useTranslation)('profile'),
|
|
173
|
-
t = _useTranslation3.t;
|
|
174
|
-
|
|
175
|
-
var _useState = (0, _react.useState)(false),
|
|
176
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
177
|
-
modalVisibility = _useState2[0],
|
|
178
|
-
setModalVisibility = _useState2[1];
|
|
179
|
-
|
|
180
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ProfileButton.default, {
|
|
181
|
-
onClick: function onClick() {
|
|
182
|
-
return setModalVisibility(true);
|
|
183
|
-
}
|
|
184
|
-
}, t("profile:".concat(hasName ? 'changeName' : 'setName'))), /*#__PURE__*/_react.default.createElement(_ProfileUpdateNameModal.default, {
|
|
185
|
-
visibility: modalVisibility,
|
|
186
|
-
onClose: function onClose() {
|
|
187
|
-
return setModalVisibility(false);
|
|
188
|
-
}
|
|
189
|
-
}));
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
var ChangePasswordButton = function ChangePasswordButton() {
|
|
193
|
-
var _useTranslation4 = (0, _reactI18next.useTranslation)('profile'),
|
|
194
|
-
t = _useTranslation4.t;
|
|
195
|
-
|
|
196
|
-
var _useState3 = (0, _react.useState)(false),
|
|
197
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
198
|
-
modalVisibility = _useState4[0],
|
|
199
|
-
setModalVisibility = _useState4[1];
|
|
200
|
-
|
|
201
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ProfileButton.default, {
|
|
202
|
-
onClick: function onClick() {
|
|
203
|
-
return setModalVisibility(true);
|
|
204
|
-
}
|
|
205
|
-
}, t('profile:changePassword')), /*#__PURE__*/_react.default.createElement(_ProfileUpdatePasswordModal.default, {
|
|
206
|
-
visibility: modalVisibility,
|
|
207
|
-
onClose: function onClose() {
|
|
208
|
-
return setModalVisibility(false);
|
|
209
|
-
}
|
|
210
|
-
}));
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
var SignOutButton = function SignOutButton() {
|
|
214
|
-
var _useTranslation5 = (0, _reactI18next.useTranslation)('profile'),
|
|
215
|
-
t = _useTranslation5.t;
|
|
216
|
-
|
|
217
|
-
var _useMutation5 = (0, _hooks.useMutation)(_ProfileDrawerSignOutMutation !== void 0 ? _ProfileDrawerSignOutMutation : (_ProfileDrawerSignOutMutation = require("./__generated__/ProfileDrawerSignOutMutation.graphql"), _ProfileDrawerSignOutMutation.hash && _ProfileDrawerSignOutMutation.hash !== "8510e6462e8f7839ce100254080ba293" && console.error("The definition of 'ProfileDrawerSignOutMutation' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _ProfileDrawerSignOutMutation)),
|
|
218
|
-
_useMutation6 = _slicedToArray(_useMutation5, 2),
|
|
219
|
-
commit = _useMutation6[0],
|
|
220
|
-
loading = _useMutation6[1];
|
|
221
|
-
|
|
222
|
-
var handler = (0, _react.useCallback)(function () {
|
|
223
|
-
commit({
|
|
224
|
-
variables: {},
|
|
225
|
-
onError: function onError(error) {
|
|
226
|
-
var _source3, _source3$errors, _source3$errors$;
|
|
227
|
-
|
|
228
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
229
|
-
_core.message.error((_source3 = error.source) === null || _source3 === void 0 ? void 0 : (_source3$errors = _source3.errors) === null || _source3$errors === void 0 ? void 0 : (_source3$errors$ = _source3$errors[0]) === null || _source3$errors$ === void 0 ? void 0 : _source3$errors$.message);
|
|
230
|
-
},
|
|
231
|
-
onCompleted: function onCompleted() {
|
|
232
|
-
window.location.href = '/auth/';
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
}, [commit]);
|
|
236
|
-
return /*#__PURE__*/_react.default.createElement(_ProfileButton.default, {
|
|
237
|
-
danger: true,
|
|
238
|
-
loading: loading,
|
|
239
|
-
onClick: handler
|
|
240
|
-
}, t('profile:signOut'));
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
var ProfileDrawer = function ProfileDrawer(_ref3) {
|
|
244
|
-
var actions = _ref3.actions,
|
|
245
|
-
children = _ref3.children,
|
|
246
|
-
rest = _objectWithoutProperties(_ref3, _excluded);
|
|
247
|
-
|
|
248
|
-
var _useProfile = (0, _ProfileContext.useProfile)(),
|
|
249
|
-
email = _useProfile.email,
|
|
250
|
-
firstName = _useProfile.firstName,
|
|
251
|
-
lastName = _useProfile.lastName,
|
|
252
|
-
avatar = _useProfile.avatar;
|
|
43
|
+
var ProfileDrawer = function ProfileDrawer(_ref) {
|
|
44
|
+
var actions = _ref.actions,
|
|
45
|
+
children = _ref.children,
|
|
46
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
253
47
|
|
|
254
|
-
var fullName = (0, _react.useMemo)(function () {
|
|
255
|
-
return [firstName, lastName].filter(function (i) {
|
|
256
|
-
return i;
|
|
257
|
-
}).join(' ');
|
|
258
|
-
}, [firstName, lastName]);
|
|
259
48
|
return /*#__PURE__*/_react.default.createElement(StyledDrawer, _extends({
|
|
260
49
|
placement: "right",
|
|
261
50
|
width: "15em"
|
|
262
|
-
}, rest), /*#__PURE__*/_react.default.createElement(
|
|
263
|
-
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
hasName: !!fullName
|
|
268
|
-
}), /*#__PURE__*/_react.default.createElement(ChangePasswordButton, null), actions, /*#__PURE__*/_react.default.createElement(SignOutButton, null), children), /*#__PURE__*/_react.default.createElement(Footer, null, /*#__PURE__*/_react.default.createElement(_core.ThemeSwitcher, null)));
|
|
51
|
+
}, rest), /*#__PURE__*/_react.default.createElement(_react.Suspense, {
|
|
52
|
+
fallback: /*#__PURE__*/_react.default.createElement(_MainLoader.default, null)
|
|
53
|
+
}, /*#__PURE__*/_react.default.createElement(LazyProfileDrawerContent, {
|
|
54
|
+
actions: actions
|
|
55
|
+
}, children)));
|
|
269
56
|
};
|
|
270
57
|
|
|
271
58
|
var _default = ProfileDrawer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/components/profile/ProfileDrawer.tsx"],"names":["StyledDrawer","Drawer","AvatarContainer","styled","div","UserContent","FullName","p","theme","sizes","large","Email","inputColorPlaceholder","ActionsContainer","Footer","HiddenInput","input","profileDrawerUpdateAvatarMutation","DeleteAvatarButton","t","commit","loading","handler","variables","avatar","onError","error","message","source","errors","onCompleted","success","UpdateAvatarButton","hasAvatar","fileInputRef","e","target","files","file","uploadables","current","value","click","UpdateNameButton","hasName","modalVisibility","setModalVisibility","ChangePasswordButton","SignOutButton","window","location","href","ProfileDrawer","actions","children","rest","email","firstName","lastName","fullName","filter","i","join"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,IAAMA,YAAY,GAAG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C,OAGI,SAHJA,OAGI;AAAA,MAFJC,QAEI,SAFJA,QAEI;AAAA,MADDC,IACC;;AACJ,oBAA+C,iCAA/C;AAAA,MAAQC,KAAR,eAAQA,KAAR;AAAA,MAAeC,SAAf,eAAeA,SAAf;AAAA,MAA0BC,QAA1B,eAA0BA,QAA1B;AAAA,MAAoClC,MAApC,eAAoCA,MAApC;;AAEA,MAAMmC,QAAQ,GAAG,oBACf;AAAA,WAAM,CAACF,SAAD,EAAYC,QAAZ,EAAsBE,MAAtB,CAA6B,UAACC,CAAD;AAAA,aAAOA,CAAP;AAAA,KAA7B,EAAuCC,IAAvC,CAA4C,GAA5C,CAAN;AAAA,GADe,EAEf,CAACL,SAAD,EAAYC,QAAZ,CAFe,CAAjB;AAKA,sBACE,6BAAC,YAAD;AAAc,IAAA,SAAS,EAAC,OAAxB;AAAgC,IAAA,KAAK,EAAC;AAAtC,KAAiDH,IAAjD,gBACE,6BAAC,eAAD,qBACE,6BAAC,mBAAD;AAAY,IAAA,IAAI,EAAC;AAAjB,IADF,eAEE,6BAAC,WAAD,QACGI,QAAQ,iBAAI,6BAAC,QAAD,QAAWA,QAAX,CADf,eAEE,6BAAC,KAAD,QAAQH,KAAR,CAFF,CAFF,CADF,eASE,6BAAC,gBAAD,QACGhC,MAAM,iBAAI,6BAAC,kBAAD,OADb,eAGE,6BAAC,kBAAD;AAAoB,IAAA,SAAS,EAAE,CAAC,CAACA;AAAjC,IAHF,eAIE,6BAAC,gBAAD;AAAkB,IAAA,OAAO,EAAE,CAAC,CAACmC;AAA7B,IAJF,eAKE,6BAAC,oBAAD,OALF,EAOGN,OAPH,eASE,6BAAC,aAAD,OATF,EAWGC,QAXH,CATF,eAuBE,6BAAC,MAAD,qBACE,6BAAC,mBAAD,OADF,CAvBF,CADF;AA6BD,CAzCD;;eA2CeF,a","sourcesContent":["import React, { useCallback, useMemo, useRef, useState } from 'react';\nimport { Drawer, DrawerProps, message, ThemeSwitcher } from '@os-design/core';\nimport styled from '@emotion/styled';\nimport { clr } from '@os-design/theming';\nimport { useTranslation } from 'react-i18next';\nimport { graphql } from 'babel-plugin-relay/macro';\nimport { useMutation } from 'react-relay/hooks';\nimport { useProfile } from './ProfileContext';\nimport UserAvatar from './UserAvatar';\nimport ProfileButton from './ProfileButton';\nimport ProfileUpdateNameModal from './ProfileUpdateNameModal';\nimport ProfileUpdatePasswordModal from './ProfileUpdatePasswordModal';\nimport { ProfileDrawerSignOutMutation } from './__generated__/ProfileDrawerSignOutMutation.graphql';\nimport { ProfileDrawerUpdateAvatarMutation } from './__generated__/ProfileDrawerUpdateAvatarMutation.graphql';\n\nexport interface ProfileDrawerProps extends DrawerProps {\n /**\n * Additional actions placed under the avatar.\n * @default undefined\n */\n actions?: React.ReactNode;\n}\n\nconst StyledDrawer = styled(Drawer)`\n display: flex;\n flex-direction: column;\n padding: 2em 1em;\n`;\n\nconst AvatarContainer = styled.div`\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n`;\n\nconst UserContent = styled.div`\n margin-top: 1em;\n`;\n\nconst FullName = styled.div`\n font-size: ${(p) => p.theme.sizes.large}em;\n font-weight: 500;\n text-align: center;\n line-height: 1.2;\n`;\n\nconst Email = styled.div`\n color: ${(p) => clr(p.theme.inputColorPlaceholder)};\n margin-top: 0.2em;\n text-align: center;\n`;\n\nconst ActionsContainer = styled.div`\n margin-top: 1.5em;\n`;\n\nconst Footer = styled.div`\n display: flex;\n justify-content: center;\n margin-top: auto;\n padding-top: 1.5em;\n`;\n\nconst HiddenInput = styled.input`\n display: none;\n`;\n\nconst profileDrawerUpdateAvatarMutation = graphql`\n mutation ProfileDrawerUpdateAvatarMutation($input: UpdateAvatarInput!) {\n updateAvatar(input: $input) {\n id\n avatar\n }\n }\n`;\n\nconst DeleteAvatarButton: React.FC = () => {\n const { t } = useTranslation('profile');\n\n const [commit, loading] = useMutation<ProfileDrawerUpdateAvatarMutation>(\n profileDrawerUpdateAvatarMutation\n );\n\n const handler = useCallback(() => {\n commit({\n variables: {\n input: { avatar: null },\n },\n onError: (error) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n message.error((error as any).source?.errors?.[0]?.message);\n },\n onCompleted: () => {\n message.success(t('profile:updated'));\n },\n });\n }, [commit, t]);\n\n return (\n <ProfileButton loading={loading} onClick={handler}>\n {t('profile:deleteAvatar')}\n </ProfileButton>\n );\n};\n\ninterface UpdateAvatarButtonProps {\n hasAvatar: boolean;\n}\n\nconst UpdateAvatarButton: React.FC<UpdateAvatarButtonProps> = ({\n hasAvatar,\n}) => {\n const { t } = useTranslation('profile');\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n const [commit, loading] = useMutation<ProfileDrawerUpdateAvatarMutation>(\n profileDrawerUpdateAvatarMutation\n );\n\n const handler = useCallback(\n (e) => {\n const target = e.target as HTMLInputElement | null;\n if (!target) return;\n\n const { files } = target;\n if (!files) return;\n\n const file = files[0];\n\n commit({\n variables: {\n input: {},\n },\n uploadables: { avatar: file },\n onError: (error) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n message.error((error as any).source?.errors?.[0]?.message);\n },\n onCompleted: () => {\n message.success(t('profile:updated'));\n },\n });\n },\n [commit, t]\n );\n\n return (\n <>\n <ProfileButton\n loading={loading}\n onClick={() => {\n if (!fileInputRef.current) return;\n fileInputRef.current.value = '';\n fileInputRef.current.click();\n }}\n >\n {t(`profile:${hasAvatar ? 'changeAvatar' : 'setAvatar'}`)}\n </ProfileButton>\n\n <HiddenInput\n type='file'\n accept='image/jpeg,image/png,image/webp'\n onChange={handler}\n ref={fileInputRef}\n />\n </>\n );\n};\n\ninterface UpdateNameButtonProps {\n hasName: boolean;\n}\n\nconst UpdateNameButton: React.FC<UpdateNameButtonProps> = ({ hasName }) => {\n const { t } = useTranslation('profile');\n const [modalVisibility, setModalVisibility] = useState(false);\n\n return (\n <>\n <ProfileButton onClick={() => setModalVisibility(true)}>\n {t(`profile:${hasName ? 'changeName' : 'setName'}`)}\n </ProfileButton>\n\n <ProfileUpdateNameModal\n visibility={modalVisibility}\n onClose={() => setModalVisibility(false)}\n />\n </>\n );\n};\n\nconst ChangePasswordButton: React.FC = () => {\n const { t } = useTranslation('profile');\n const [modalVisibility, setModalVisibility] = useState(false);\n\n return (\n <>\n <ProfileButton onClick={() => setModalVisibility(true)}>\n {t('profile:changePassword')}\n </ProfileButton>\n\n <ProfileUpdatePasswordModal\n visibility={modalVisibility}\n onClose={() => setModalVisibility(false)}\n />\n </>\n );\n};\n\nconst SignOutButton: React.FC = () => {\n const { t } = useTranslation('profile');\n\n const [commit, loading] = useMutation<ProfileDrawerSignOutMutation>(graphql`\n mutation ProfileDrawerSignOutMutation {\n signOut {\n ok\n }\n }\n `);\n\n const handler = useCallback(() => {\n commit({\n variables: {},\n onError: (error) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n message.error((error as any).source?.errors?.[0]?.message);\n },\n onCompleted: () => {\n window.location.href = '/auth/';\n },\n });\n }, [commit]);\n\n return (\n <ProfileButton danger loading={loading} onClick={handler}>\n {t('profile:signOut')}\n </ProfileButton>\n );\n};\n\nconst ProfileDrawer: React.FC<ProfileDrawerProps> = ({\n actions,\n children,\n ...rest\n}) => {\n const { email, firstName, lastName, avatar } = useProfile();\n\n const fullName = useMemo(\n () => [firstName, lastName].filter((i) => i).join(' '),\n [firstName, lastName]\n );\n\n return (\n <StyledDrawer placement='right' width='15em' {...rest}>\n <AvatarContainer>\n <UserAvatar size='10em' />\n <UserContent>\n {fullName && <FullName>{fullName}</FullName>}\n <Email>{email}</Email>\n </UserContent>\n </AvatarContainer>\n\n <ActionsContainer>\n {avatar && <DeleteAvatarButton />}\n\n <UpdateAvatarButton hasAvatar={!!avatar} />\n <UpdateNameButton hasName={!!fullName} />\n <ChangePasswordButton />\n\n {actions}\n\n <SignOutButton />\n\n {children}\n </ActionsContainer>\n\n <Footer>\n <ThemeSwitcher />\n </Footer>\n </StyledDrawer>\n );\n};\n\nexport default ProfileDrawer;\n"],"file":"ProfileDrawer.js"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/components/profile/ProfileDrawer.tsx"],"names":["LazyProfileDrawerContent","StyledDrawer","Drawer","ProfileDrawer","actions","children","rest"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,wBAAwB,gBAAG,iBAAK;AAAA;AAAA,2CAAa,wBAAb;AAAA;AAAA,CAAL,CAAjC;AAIA,IAAMC,YAAY,GAAG,qBAAOC,YAAP,CAAH,yIAAlB;;AAMA,IAAMC,aAA2C,GAAG,SAA9CA,aAA8C;AAAA,MAClDC,OADkD,QAClDA,OADkD;AAAA,MAElDC,QAFkD,QAElDA,QAFkD;AAAA,MAG/CC,IAH+C;;AAAA,sBAKlD,6BAAC,YAAD;AAAc,IAAA,SAAS,EAAC,OAAxB;AAAgC,IAAA,KAAK,EAAC;AAAtC,KAAiDA,IAAjD,gBACE,6BAAC,eAAD;AAAU,IAAA,QAAQ,eAAE,6BAAC,mBAAD;AAApB,kBACE,6BAAC,wBAAD;AAA0B,IAAA,OAAO,EAAEF;AAAnC,KACGC,QADH,CADF,CADF,CALkD;AAAA,CAApD;;eAceF,a","sourcesContent":["import React, { lazy, Suspense } from 'react';\nimport { Drawer, DrawerProps } from '@os-design/core';\nimport styled from '@emotion/styled';\nimport { ProfileDrawerContentProps } from './ProfileDrawerContent';\nimport MainLoader from '../shared/MainLoader';\n\nconst LazyProfileDrawerContent = lazy(() => import('./ProfileDrawerContent'));\n\nexport type ProfileDrawerProps = ProfileDrawerContentProps & DrawerProps;\n\nconst StyledDrawer = styled(Drawer)`\n display: flex;\n flex-direction: column;\n padding: 2em 1em;\n`;\n\nconst ProfileDrawer: React.FC<ProfileDrawerProps> = ({\n actions,\n children,\n ...rest\n}) => (\n <StyledDrawer placement='right' width='15em' {...rest}>\n <Suspense fallback={<MainLoader />}>\n <LazyProfileDrawerContent actions={actions}>\n {children}\n </LazyProfileDrawerContent>\n </Suspense>\n </StyledDrawer>\n);\n\nexport default ProfileDrawer;\n"],"file":"ProfileDrawer.js"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _core = require("@os-design/core");
|
|
13
|
+
|
|
14
|
+
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
15
|
+
|
|
16
|
+
var _theming = require("@os-design/theming");
|
|
17
|
+
|
|
18
|
+
var _reactI18next = require("react-i18next");
|
|
19
|
+
|
|
20
|
+
var _hooks = require("react-relay/hooks");
|
|
21
|
+
|
|
22
|
+
var _UserAvatar = _interopRequireDefault(require("./UserAvatar"));
|
|
23
|
+
|
|
24
|
+
var _ProfileContext = require("./ProfileContext");
|
|
25
|
+
|
|
26
|
+
var _ProfileButton = _interopRequireDefault(require("./ProfileButton"));
|
|
27
|
+
|
|
28
|
+
var _ProfileUpdateNameModal = _interopRequireDefault(require("./ProfileUpdateNameModal"));
|
|
29
|
+
|
|
30
|
+
var _ProfileUpdatePasswordModal = _interopRequireDefault(require("./ProfileUpdatePasswordModal"));
|
|
31
|
+
|
|
32
|
+
var _ProfileDrawerContentUpdateAvatarMutation, _ProfileDrawerContentSignOutMutation, _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
33
|
+
|
|
34
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
35
|
+
|
|
36
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
37
|
+
|
|
38
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
39
|
+
|
|
40
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
41
|
+
|
|
42
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
43
|
+
|
|
44
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
45
|
+
|
|
46
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
47
|
+
|
|
48
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
49
|
+
|
|
50
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
51
|
+
|
|
52
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
53
|
+
|
|
54
|
+
var AvatarContainer = _styled.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n"])));
|
|
55
|
+
|
|
56
|
+
var UserContent = _styled.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n margin-top: 1em;\n"])));
|
|
57
|
+
|
|
58
|
+
var FullName = _styled.default.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n font-size: ", "em;\n font-weight: 500;\n text-align: center;\n line-height: 1.2;\n"])), function (p) {
|
|
59
|
+
return p.theme.sizes.large;
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
var Email = _styled.default.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n color: ", ";\n margin-top: 0.2em;\n text-align: center;\n"])), function (p) {
|
|
63
|
+
return (0, _theming.clr)(p.theme.inputColorPlaceholder);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
var ActionsContainer = _styled.default.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n margin-top: 1.5em;\n"])));
|
|
67
|
+
|
|
68
|
+
var Footer = _styled.default.div(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n display: flex;\n justify-content: center;\n margin-top: auto;\n padding-top: 1.5em;\n"])));
|
|
69
|
+
|
|
70
|
+
var HiddenInput = _styled.default.input(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n display: none;\n"])));
|
|
71
|
+
|
|
72
|
+
var profileDrawerContentUpdateAvatarMutation = _ProfileDrawerContentUpdateAvatarMutation !== void 0 ? _ProfileDrawerContentUpdateAvatarMutation : (_ProfileDrawerContentUpdateAvatarMutation = require("./__generated__/ProfileDrawerContentUpdateAvatarMutation.graphql"), _ProfileDrawerContentUpdateAvatarMutation.hash && _ProfileDrawerContentUpdateAvatarMutation.hash !== "cf72a6314772ed0d1f182b197c858505" && console.error("The definition of 'ProfileDrawerContentUpdateAvatarMutation' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _ProfileDrawerContentUpdateAvatarMutation);
|
|
73
|
+
|
|
74
|
+
var DeleteAvatarButton = function DeleteAvatarButton() {
|
|
75
|
+
var _useTranslation = (0, _reactI18next.useTranslation)('profile'),
|
|
76
|
+
t = _useTranslation.t;
|
|
77
|
+
|
|
78
|
+
var _useMutation = (0, _hooks.useMutation)(profileDrawerContentUpdateAvatarMutation),
|
|
79
|
+
_useMutation2 = _slicedToArray(_useMutation, 2),
|
|
80
|
+
commit = _useMutation2[0],
|
|
81
|
+
loading = _useMutation2[1];
|
|
82
|
+
|
|
83
|
+
var handler = (0, _react.useCallback)(function () {
|
|
84
|
+
commit({
|
|
85
|
+
variables: {
|
|
86
|
+
input: {
|
|
87
|
+
avatar: null
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
onError: function onError(error) {
|
|
91
|
+
var _source, _source$errors, _source$errors$;
|
|
92
|
+
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
|
+
_core.message.error((_source = error.source) === null || _source === void 0 ? void 0 : (_source$errors = _source.errors) === null || _source$errors === void 0 ? void 0 : (_source$errors$ = _source$errors[0]) === null || _source$errors$ === void 0 ? void 0 : _source$errors$.message);
|
|
95
|
+
},
|
|
96
|
+
onCompleted: function onCompleted() {
|
|
97
|
+
_core.message.success(t('profile:updated'));
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}, [commit, t]);
|
|
101
|
+
return /*#__PURE__*/_react.default.createElement(_ProfileButton.default, {
|
|
102
|
+
loading: loading,
|
|
103
|
+
onClick: handler
|
|
104
|
+
}, t('profile:deleteAvatar'));
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
var UpdateAvatarButton = function UpdateAvatarButton(_ref) {
|
|
108
|
+
var hasAvatar = _ref.hasAvatar;
|
|
109
|
+
|
|
110
|
+
var _useTranslation2 = (0, _reactI18next.useTranslation)('profile'),
|
|
111
|
+
t = _useTranslation2.t;
|
|
112
|
+
|
|
113
|
+
var fileInputRef = (0, _react.useRef)(null);
|
|
114
|
+
|
|
115
|
+
var _useMutation3 = (0, _hooks.useMutation)(profileDrawerContentUpdateAvatarMutation),
|
|
116
|
+
_useMutation4 = _slicedToArray(_useMutation3, 2),
|
|
117
|
+
commit = _useMutation4[0],
|
|
118
|
+
loading = _useMutation4[1];
|
|
119
|
+
|
|
120
|
+
var handler = (0, _react.useCallback)(function (e) {
|
|
121
|
+
var target = e.target;
|
|
122
|
+
if (!target) return;
|
|
123
|
+
var files = target.files;
|
|
124
|
+
if (!files) return;
|
|
125
|
+
var file = files[0];
|
|
126
|
+
commit({
|
|
127
|
+
variables: {
|
|
128
|
+
input: {}
|
|
129
|
+
},
|
|
130
|
+
uploadables: {
|
|
131
|
+
avatar: file
|
|
132
|
+
},
|
|
133
|
+
onError: function onError(error) {
|
|
134
|
+
var _source2, _source2$errors, _source2$errors$;
|
|
135
|
+
|
|
136
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
137
|
+
_core.message.error((_source2 = error.source) === null || _source2 === void 0 ? void 0 : (_source2$errors = _source2.errors) === null || _source2$errors === void 0 ? void 0 : (_source2$errors$ = _source2$errors[0]) === null || _source2$errors$ === void 0 ? void 0 : _source2$errors$.message);
|
|
138
|
+
},
|
|
139
|
+
onCompleted: function onCompleted() {
|
|
140
|
+
_core.message.success(t('profile:updated'));
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}, [commit, t]);
|
|
144
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ProfileButton.default, {
|
|
145
|
+
loading: loading,
|
|
146
|
+
onClick: function onClick() {
|
|
147
|
+
if (!fileInputRef.current) return;
|
|
148
|
+
fileInputRef.current.value = '';
|
|
149
|
+
fileInputRef.current.click();
|
|
150
|
+
}
|
|
151
|
+
}, t("profile:".concat(hasAvatar ? 'changeAvatar' : 'setAvatar'))), /*#__PURE__*/_react.default.createElement(HiddenInput, {
|
|
152
|
+
type: "file",
|
|
153
|
+
accept: "image/jpeg,image/png,image/webp",
|
|
154
|
+
onChange: handler,
|
|
155
|
+
ref: fileInputRef
|
|
156
|
+
}));
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
var UpdateNameButton = function UpdateNameButton(_ref2) {
|
|
160
|
+
var hasName = _ref2.hasName;
|
|
161
|
+
|
|
162
|
+
var _useTranslation3 = (0, _reactI18next.useTranslation)('profile'),
|
|
163
|
+
t = _useTranslation3.t;
|
|
164
|
+
|
|
165
|
+
var _useState = (0, _react.useState)(false),
|
|
166
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
167
|
+
modalVisibility = _useState2[0],
|
|
168
|
+
setModalVisibility = _useState2[1];
|
|
169
|
+
|
|
170
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ProfileButton.default, {
|
|
171
|
+
onClick: function onClick() {
|
|
172
|
+
return setModalVisibility(true);
|
|
173
|
+
}
|
|
174
|
+
}, t("profile:".concat(hasName ? 'changeName' : 'setName'))), /*#__PURE__*/_react.default.createElement(_ProfileUpdateNameModal.default, {
|
|
175
|
+
visibility: modalVisibility,
|
|
176
|
+
onClose: function onClose() {
|
|
177
|
+
return setModalVisibility(false);
|
|
178
|
+
}
|
|
179
|
+
}));
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
var ChangePasswordButton = function ChangePasswordButton() {
|
|
183
|
+
var _useTranslation4 = (0, _reactI18next.useTranslation)('profile'),
|
|
184
|
+
t = _useTranslation4.t;
|
|
185
|
+
|
|
186
|
+
var _useState3 = (0, _react.useState)(false),
|
|
187
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
188
|
+
modalVisibility = _useState4[0],
|
|
189
|
+
setModalVisibility = _useState4[1];
|
|
190
|
+
|
|
191
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ProfileButton.default, {
|
|
192
|
+
onClick: function onClick() {
|
|
193
|
+
return setModalVisibility(true);
|
|
194
|
+
}
|
|
195
|
+
}, t('profile:changePassword')), /*#__PURE__*/_react.default.createElement(_ProfileUpdatePasswordModal.default, {
|
|
196
|
+
visibility: modalVisibility,
|
|
197
|
+
onClose: function onClose() {
|
|
198
|
+
return setModalVisibility(false);
|
|
199
|
+
}
|
|
200
|
+
}));
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
var SignOutButton = function SignOutButton() {
|
|
204
|
+
var _useTranslation5 = (0, _reactI18next.useTranslation)('profile'),
|
|
205
|
+
t = _useTranslation5.t;
|
|
206
|
+
|
|
207
|
+
var _useMutation5 = (0, _hooks.useMutation)(_ProfileDrawerContentSignOutMutation !== void 0 ? _ProfileDrawerContentSignOutMutation : (_ProfileDrawerContentSignOutMutation = require("./__generated__/ProfileDrawerContentSignOutMutation.graphql"), _ProfileDrawerContentSignOutMutation.hash && _ProfileDrawerContentSignOutMutation.hash !== "c7ca96e9e713315606b0c22d196b6f7b" && console.error("The definition of 'ProfileDrawerContentSignOutMutation' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _ProfileDrawerContentSignOutMutation)),
|
|
208
|
+
_useMutation6 = _slicedToArray(_useMutation5, 2),
|
|
209
|
+
commit = _useMutation6[0],
|
|
210
|
+
loading = _useMutation6[1];
|
|
211
|
+
|
|
212
|
+
var handler = (0, _react.useCallback)(function () {
|
|
213
|
+
commit({
|
|
214
|
+
variables: {},
|
|
215
|
+
onError: function onError(error) {
|
|
216
|
+
var _source3, _source3$errors, _source3$errors$;
|
|
217
|
+
|
|
218
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
219
|
+
_core.message.error((_source3 = error.source) === null || _source3 === void 0 ? void 0 : (_source3$errors = _source3.errors) === null || _source3$errors === void 0 ? void 0 : (_source3$errors$ = _source3$errors[0]) === null || _source3$errors$ === void 0 ? void 0 : _source3$errors$.message);
|
|
220
|
+
},
|
|
221
|
+
onCompleted: function onCompleted() {
|
|
222
|
+
window.location.href = '/auth/';
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}, [commit]);
|
|
226
|
+
return /*#__PURE__*/_react.default.createElement(_ProfileButton.default, {
|
|
227
|
+
danger: true,
|
|
228
|
+
loading: loading,
|
|
229
|
+
onClick: handler
|
|
230
|
+
}, t('profile:signOut'));
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
var ProfileDrawerContent = function ProfileDrawerContent(_ref3) {
|
|
234
|
+
var actions = _ref3.actions,
|
|
235
|
+
children = _ref3.children;
|
|
236
|
+
|
|
237
|
+
var _useProfile = (0, _ProfileContext.useProfile)(),
|
|
238
|
+
email = _useProfile.email,
|
|
239
|
+
firstName = _useProfile.firstName,
|
|
240
|
+
lastName = _useProfile.lastName,
|
|
241
|
+
avatar = _useProfile.avatar;
|
|
242
|
+
|
|
243
|
+
var fullName = (0, _react.useMemo)(function () {
|
|
244
|
+
return [firstName, lastName].filter(function (i) {
|
|
245
|
+
return i;
|
|
246
|
+
}).join(' ');
|
|
247
|
+
}, [firstName, lastName]);
|
|
248
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(AvatarContainer, null, /*#__PURE__*/_react.default.createElement(_UserAvatar.default, {
|
|
249
|
+
size: "10em"
|
|
250
|
+
}), /*#__PURE__*/_react.default.createElement(UserContent, null, fullName && /*#__PURE__*/_react.default.createElement(FullName, null, fullName), /*#__PURE__*/_react.default.createElement(Email, null, email))), /*#__PURE__*/_react.default.createElement(ActionsContainer, null, avatar && /*#__PURE__*/_react.default.createElement(DeleteAvatarButton, null), /*#__PURE__*/_react.default.createElement(UpdateAvatarButton, {
|
|
251
|
+
hasAvatar: !!avatar
|
|
252
|
+
}), /*#__PURE__*/_react.default.createElement(UpdateNameButton, {
|
|
253
|
+
hasName: !!fullName
|
|
254
|
+
}), /*#__PURE__*/_react.default.createElement(ChangePasswordButton, null), actions, /*#__PURE__*/_react.default.createElement(SignOutButton, null), children), /*#__PURE__*/_react.default.createElement(Footer, null, /*#__PURE__*/_react.default.createElement(_core.ThemeSwitcher, null)));
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
var _default = ProfileDrawerContent;
|
|
258
|
+
exports.default = _default;
|
|
259
|
+
//# sourceMappingURL=ProfileDrawerContent.js.map
|