@oxy.so/services 11.3.0 → 11.4.0
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/lib/commonjs/index.js +28 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/components/AccountInvitationAcceptance.js +97 -0
- package/lib/commonjs/ui/components/AccountInvitationAcceptance.js.map +1 -0
- package/lib/commonjs/ui/components/DisplayCurrencySelector.js +49 -0
- package/lib/commonjs/ui/components/DisplayCurrencySelector.js.map +1 -0
- package/lib/commonjs/ui/hooks/useDisplayCurrency.js +77 -0
- package/lib/commonjs/ui/hooks/useDisplayCurrency.js.map +1 -0
- package/lib/commonjs/ui/hooks/useDisplayPrice.js +59 -0
- package/lib/commonjs/ui/hooks/useDisplayPrice.js.map +1 -0
- package/lib/commonjs/ui/screens/AccountMembersScreen.js +63 -20
- package/lib/commonjs/ui/screens/AccountMembersScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/PreferencesScreen.js +4 -3
- package/lib/commonjs/ui/screens/PreferencesScreen.js.map +1 -1
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/components/AccountInvitationAcceptance.js +94 -0
- package/lib/module/ui/components/AccountInvitationAcceptance.js.map +1 -0
- package/lib/module/ui/components/DisplayCurrencySelector.js +44 -0
- package/lib/module/ui/components/DisplayCurrencySelector.js.map +1 -0
- package/lib/module/ui/hooks/useDisplayCurrency.js +72 -0
- package/lib/module/ui/hooks/useDisplayCurrency.js.map +1 -0
- package/lib/module/ui/hooks/useDisplayPrice.js +56 -0
- package/lib/module/ui/hooks/useDisplayPrice.js.map +1 -0
- package/lib/module/ui/screens/AccountMembersScreen.js +63 -20
- package/lib/module/ui/screens/AccountMembersScreen.js.map +1 -1
- package/lib/module/ui/screens/PreferencesScreen.js +4 -3
- package/lib/module/ui/screens/PreferencesScreen.js.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +4 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/AccountInvitationAcceptance.d.ts +5 -0
- package/lib/typescript/commonjs/ui/components/AccountInvitationAcceptance.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/DisplayCurrencySelector.d.ts +3 -0
- package/lib/typescript/commonjs/ui/components/DisplayCurrencySelector.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts +7 -1
- package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/queries/usePersonalPlans.d.ts +2 -1
- package/lib/typescript/commonjs/ui/hooks/queries/usePersonalPlans.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useDisplayCurrency.d.ts +11 -0
- package/lib/typescript/commonjs/ui/hooks/useDisplayCurrency.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/hooks/useDisplayPrice.d.ts +6 -0
- package/lib/typescript/commonjs/ui/hooks/useDisplayPrice.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/AccountMembersScreen.d.ts +1 -1
- package/lib/typescript/commonjs/ui/screens/AccountMembersScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/PreferencesScreen.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +4 -0
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/AccountInvitationAcceptance.d.ts +5 -0
- package/lib/typescript/module/ui/components/AccountInvitationAcceptance.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/DisplayCurrencySelector.d.ts +3 -0
- package/lib/typescript/module/ui/components/DisplayCurrencySelector.d.ts.map +1 -0
- package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts +7 -1
- package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/queries/usePersonalPlans.d.ts +2 -1
- package/lib/typescript/module/ui/hooks/queries/usePersonalPlans.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useDisplayCurrency.d.ts +11 -0
- package/lib/typescript/module/ui/hooks/useDisplayCurrency.d.ts.map +1 -0
- package/lib/typescript/module/ui/hooks/useDisplayPrice.d.ts +6 -0
- package/lib/typescript/module/ui/hooks/useDisplayPrice.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/AccountMembersScreen.d.ts +1 -1
- package/lib/typescript/module/ui/screens/AccountMembersScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/PreferencesScreen.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/index.ts +5 -0
- package/src/ui/components/AccountInvitationAcceptance.tsx +90 -0
- package/src/ui/components/DisplayCurrencySelector.tsx +38 -0
- package/src/ui/components/__tests__/AccountInvitationAcceptance.test.tsx +61 -0
- package/src/ui/hooks/useDisplayCurrency.ts +64 -0
- package/src/ui/hooks/useDisplayPrice.ts +40 -0
- package/src/ui/screens/AccountMembersScreen.tsx +71 -27
- package/src/ui/screens/PreferencesScreen.tsx +2 -0
package/lib/commonjs/index.js
CHANGED
|
@@ -3,12 +3,24 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "AccountInvitationAcceptance", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _AccountInvitationAcceptance.AccountInvitationAcceptance;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "CLEARABLE_USER_FIELDS", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function () {
|
|
9
15
|
return _userCache.CLEARABLE_USER_FIELDS;
|
|
10
16
|
}
|
|
11
17
|
});
|
|
18
|
+
Object.defineProperty(exports, "DisplayCurrencySelector", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _DisplayCurrencySelector.DisplayCurrencySelector;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
12
24
|
Object.defineProperty(exports, "FOLLOW_ACTION_LEAVES_ACTIVE", {
|
|
13
25
|
enumerable: true,
|
|
14
26
|
get: function () {
|
|
@@ -537,6 +549,18 @@ Object.defineProperty(exports, "useDeviceSwitcher", {
|
|
|
537
549
|
return _useDeviceSwitcher.useDeviceSwitcher;
|
|
538
550
|
}
|
|
539
551
|
});
|
|
552
|
+
Object.defineProperty(exports, "useDisplayCurrency", {
|
|
553
|
+
enumerable: true,
|
|
554
|
+
get: function () {
|
|
555
|
+
return _useDisplayCurrency.useDisplayCurrency;
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
Object.defineProperty(exports, "useDisplayPrice", {
|
|
559
|
+
enumerable: true,
|
|
560
|
+
get: function () {
|
|
561
|
+
return _useDisplayPrice.useDisplayPrice;
|
|
562
|
+
}
|
|
563
|
+
});
|
|
540
564
|
Object.defineProperty(exports, "useFileDownloadUrl", {
|
|
541
565
|
enumerable: true,
|
|
542
566
|
get: function () {
|
|
@@ -910,6 +934,10 @@ var _useSurfaceHeader = require("./ui/hooks/useSurfaceHeader.js");
|
|
|
910
934
|
var _SurfaceHeaderAction = require("./ui/components/SurfaceHeaderAction.js");
|
|
911
935
|
var _accountDialogManager = require("./ui/navigation/accountDialogManager.js");
|
|
912
936
|
var _usePersonalPlans = require("./ui/hooks/queries/usePersonalPlans.js");
|
|
937
|
+
var _AccountInvitationAcceptance = require("./ui/components/AccountInvitationAcceptance.js");
|
|
938
|
+
var _DisplayCurrencySelector = require("./ui/components/DisplayCurrencySelector.js");
|
|
939
|
+
var _useDisplayCurrency = require("./ui/hooks/useDisplayCurrency.js");
|
|
940
|
+
var _useDisplayPrice = require("./ui/hooks/useDisplayPrice.js");
|
|
913
941
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
914
942
|
/**
|
|
915
943
|
* @oxy.so/services — OxyHQ Expo/React Native SDK
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_core","require","_reactNative","_OxyProvider","_interopRequireDefault","_OxyContext","_index","_useAuth","_productAnalytics","_identityBinding","_authStore","_assetStore","_useAssets","_useFileDownloadUrl","_useFollow","_useStorage","_useAccountQueries","_useServicesQueries","_useSecurityQueries","_useAuthMethods","_usePaymentQueries","_useAccountMutations","_useServicesMutations","_mutationFactory","_mutationKeys","_queryKeys","_userCache","_useMutationStatus","_useOnlineStatus","_useOxyEvent","_errorHandlers","_useFileFiltering","_OxySignInButton","_oauthPopup","_OxyAuthPrompt","_OxyOAuthCallback","_OxyConsentScreen","_RequireOxyAuth","_FollowButton","_FollowTargetButton","_followRules","_useFollowTarget","_followTargetStore","_PeableButton","_OxyPayButton","_LogoIcon","_LogoText","_ProfileButton","_OxySignInPanel","_OxySignUpPanel","_OxyAccountPicker","_OxyDeleteAccountPanel","_OxyLinkCommonsPanel","_OxyPasswordPanel","_OxyAuthenticatorPanel","_OxyAuthScreen","_OxySignInRequestSurface","_useDeviceSwitcher","_bottomSheetManager","_useSurfaceHeader","_SurfaceHeaderAction","_accountDialogManager","_usePersonalPlans","e","__esModule","default","setPlatformOS","Platform","OS"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_core","require","_reactNative","_OxyProvider","_interopRequireDefault","_OxyContext","_index","_useAuth","_productAnalytics","_identityBinding","_authStore","_assetStore","_useAssets","_useFileDownloadUrl","_useFollow","_useStorage","_useAccountQueries","_useServicesQueries","_useSecurityQueries","_useAuthMethods","_usePaymentQueries","_useAccountMutations","_useServicesMutations","_mutationFactory","_mutationKeys","_queryKeys","_userCache","_useMutationStatus","_useOnlineStatus","_useOxyEvent","_errorHandlers","_useFileFiltering","_OxySignInButton","_oauthPopup","_OxyAuthPrompt","_OxyOAuthCallback","_OxyConsentScreen","_RequireOxyAuth","_FollowButton","_FollowTargetButton","_followRules","_useFollowTarget","_followTargetStore","_PeableButton","_OxyPayButton","_LogoIcon","_LogoText","_ProfileButton","_OxySignInPanel","_OxySignUpPanel","_OxyAccountPicker","_OxyDeleteAccountPanel","_OxyLinkCommonsPanel","_OxyPasswordPanel","_OxyAuthenticatorPanel","_OxyAuthScreen","_OxySignInRequestSurface","_useDeviceSwitcher","_bottomSheetManager","_useSurfaceHeader","_SurfaceHeaderAction","_accountDialogManager","_usePersonalPlans","_AccountInvitationAcceptance","_DisplayCurrencySelector","_useDisplayCurrency","_useDisplayPrice","e","__esModule","default","setPlatformOS","Platform","OS"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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E,OAAA;AACA,IAAAiE,gBAAA,GAAAjE,OAAA;AAA6D,SAAAG,uBAAA+D,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AA3c7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAIA,IAAAG,mBAAa,EAACC,qBAAQ,CAACC,EAAgB,CAAC;;AAExC;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAqBA;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;;AAOA;AACA;AACA;;AAgCA;;AAeA;AACA;AACA;;AA2BA;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA;;AAMA;AACA;AACA;;AASA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAQA;AACA;AACA;AACA;;AA6BA;AACA;AACA;AACA;AACA;;AAGA;;AASA;;AAoCA;;AAEA;;AAKA;AACA;AACA;;AAKA;AACA;AACA;;AAOA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AccountInvitationAcceptance = AccountInvitationAcceptance;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _typography = require("@oxy.so/bloom/typography");
|
|
10
|
+
var _button = require("@oxy.so/bloom/button");
|
|
11
|
+
var _core = require("@oxy.so/core");
|
|
12
|
+
var _OxyContext = require("../context/OxyContext.js");
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
/** The link never grants access on navigation, preview, sign-in or account switching. */
|
|
15
|
+
function AccountInvitationAcceptance({
|
|
16
|
+
token
|
|
17
|
+
}) {
|
|
18
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(InvitationContent, {
|
|
19
|
+
token: token
|
|
20
|
+
}, token);
|
|
21
|
+
}
|
|
22
|
+
function InvitationContent({
|
|
23
|
+
token
|
|
24
|
+
}) {
|
|
25
|
+
const {
|
|
26
|
+
oxyServices,
|
|
27
|
+
user,
|
|
28
|
+
canUsePrivateApi,
|
|
29
|
+
openAccountDialog
|
|
30
|
+
} = (0, _OxyContext.useOxy)();
|
|
31
|
+
const [preview, setPreview] = (0, _react.useState)(null);
|
|
32
|
+
const [error, setError] = (0, _react.useState)('');
|
|
33
|
+
const [busy, setBusy] = (0, _react.useState)(false);
|
|
34
|
+
const [accepted, setAccepted] = (0, _react.useState)(false);
|
|
35
|
+
(0, _react.useEffect)(() => {
|
|
36
|
+
let alive = true;
|
|
37
|
+
setPreview(null);
|
|
38
|
+
setError('');
|
|
39
|
+
if (canUsePrivateApi && token) {
|
|
40
|
+
oxyServices.accounts.invitations.preview(token).then(value => {
|
|
41
|
+
if (alive) setPreview(value);
|
|
42
|
+
}).catch(reason => {
|
|
43
|
+
if (alive) setError(reason instanceof Error ? reason.message : 'Invitation unavailable');
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return () => {
|
|
47
|
+
alive = false;
|
|
48
|
+
};
|
|
49
|
+
}, [oxyServices, canUsePrivateApi, token]);
|
|
50
|
+
const accept = async () => {
|
|
51
|
+
if (!user || !preview) return;
|
|
52
|
+
setBusy(true);
|
|
53
|
+
setError('');
|
|
54
|
+
try {
|
|
55
|
+
await oxyServices.accounts.invitations.accept(token, user.id);
|
|
56
|
+
setAccepted(true);
|
|
57
|
+
} catch (reason) {
|
|
58
|
+
setError(reason instanceof Error ? reason.message : 'Could not accept invitation');
|
|
59
|
+
} finally {
|
|
60
|
+
setBusy(false);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
64
|
+
className: "gap-space-16 p-space-24",
|
|
65
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
|
|
66
|
+
className: "text-title font-semibold text-text",
|
|
67
|
+
children: "Account invitation"
|
|
68
|
+
}), canUsePrivateApi && token && !preview && !error ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
|
|
69
|
+
accessibilityRole: "progressbar",
|
|
70
|
+
children: "Loading invitation\u2026"
|
|
71
|
+
}) : null, accepted ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
|
|
72
|
+
children: "Invitation accepted. You can now access this account."
|
|
73
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
74
|
+
children: [preview ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_typography.Text, {
|
|
75
|
+
children: ["Join ", preview.account.displayName ?? preview.account.username, " as", ' ', preview.invitation.role, "."]
|
|
76
|
+
}) : null, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_typography.Text, {
|
|
77
|
+
children: ["Selected account:", ' ', user ? `${user.name?.displayName ?? (0, _core.getNormalizedUserHandle)(user) ?? user.id} (${user.email ?? user.id})` : 'Not signed in']
|
|
78
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
|
|
79
|
+
children: "The selected account receives access. Its email can differ from the invitation address. No access is granted until you confirm."
|
|
80
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
|
|
81
|
+
disabled: busy,
|
|
82
|
+
onPress: () => openAccountDialog(),
|
|
83
|
+
children: user ? 'Change account' : 'Sign in or create account'
|
|
84
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
|
|
85
|
+
disabled: busy || !user || !preview || user.kind !== 'personal',
|
|
86
|
+
onPress: accept,
|
|
87
|
+
children: "Confirm and accept"
|
|
88
|
+
})]
|
|
89
|
+
}), error ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
|
|
90
|
+
accessibilityRole: "alert",
|
|
91
|
+
children: error
|
|
92
|
+
}) : null, !token ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
|
|
93
|
+
children: "This invitation link is incomplete."
|
|
94
|
+
}) : null]
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=AccountInvitationAcceptance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_typography","_button","_core","_OxyContext","_jsxRuntime","AccountInvitationAcceptance","token","jsx","InvitationContent","oxyServices","user","canUsePrivateApi","openAccountDialog","useOxy","preview","setPreview","useState","error","setError","busy","setBusy","accepted","setAccepted","useEffect","alive","accounts","invitations","then","value","catch","reason","Error","message","accept","id","jsxs","View","className","children","Text","accessibilityRole","Fragment","account","displayName","username","invitation","role","name","getNormalizedUserHandle","email","Button","disabled","onPress","kind"],"sourceRoot":"../../../../src","sources":["ui/components/AccountInvitationAcceptance.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AAA+C,IAAAM,WAAA,GAAAN,OAAA;AAE/C;AACO,SAASO,2BAA2BA,CAAC;EAAEC;AAAyB,CAAC,EAAE;EACxE,oBAAO,IAAAF,WAAA,CAAAG,GA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AuC,IAAI;MAAAD,QAAA,EAAC;IAAmC,CAAM,CAAC,GAAG,IAAI;EAAA,CAC7D,CAAC;AAEX","ignoreList":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DisplayCurrencySelector = DisplayCurrencySelector;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _segmentedControl = require("@oxy.so/bloom/segmented-control");
|
|
10
|
+
var _typography = require("@oxy.so/bloom/typography");
|
|
11
|
+
var _useDisplayCurrency = require("../hooks/useDisplayCurrency.js");
|
|
12
|
+
var _useI18n = require("../hooks/useI18n.js");
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
function DisplayCurrencySelector() {
|
|
16
|
+
const {
|
|
17
|
+
currency,
|
|
18
|
+
selectCurrency,
|
|
19
|
+
isSaving,
|
|
20
|
+
error
|
|
21
|
+
} = (0, _useDisplayCurrency.useDisplayCurrency)();
|
|
22
|
+
const {
|
|
23
|
+
t
|
|
24
|
+
} = (0, _useI18n.useI18n)();
|
|
25
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
26
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
|
|
27
|
+
children: t('preferences.displayCurrency.label')
|
|
28
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_segmentedControl.SegmentedControl, {
|
|
29
|
+
type: "radio",
|
|
30
|
+
label: t('preferences.displayCurrency.label'),
|
|
31
|
+
value: currency,
|
|
32
|
+
onValueChange: value => {
|
|
33
|
+
const selected = _useDisplayCurrency.DISPLAY_CURRENCIES.find(item => item === value);
|
|
34
|
+
if (selected && !isSaving) selectCurrency(selected);
|
|
35
|
+
},
|
|
36
|
+
children: _useDisplayCurrency.DISPLAY_CURRENCIES.map(value => /*#__PURE__*/(0, _jsxRuntime.jsx)(_segmentedControl.SegmentedControlItem, {
|
|
37
|
+
value: value,
|
|
38
|
+
disabled: isSaving,
|
|
39
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_segmentedControl.SegmentedControlItemText, {
|
|
40
|
+
children: value
|
|
41
|
+
})
|
|
42
|
+
}, value))
|
|
43
|
+
}), error && /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
|
|
44
|
+
accessibilityLiveRegion: "polite",
|
|
45
|
+
children: t('preferences.displayCurrency.saveFailed')
|
|
46
|
+
})]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=DisplayCurrencySelector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_segmentedControl","_typography","_useDisplayCurrency","_useI18n","_jsxRuntime","e","__esModule","default","DisplayCurrencySelector","currency","selectCurrency","isSaving","error","useDisplayCurrency","t","useI18n","jsxs","View","children","jsx","Text","SegmentedControl","type","label","value","onValueChange","selected","DISPLAY_CURRENCIES","find","item","map","SegmentedControlItem","disabled","SegmentedControlItemText","accessibilityLiveRegion"],"sourceRoot":"../../../../src","sources":["ui/components/DisplayCurrencySelector.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAKA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAA2C,IAAAM,WAAA,GAAAN,OAAA;AAAA,SAAAD,uBAAAQ,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CA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,CAAC,CAAC,wCAAwC;IAAC,CAAO,CAC3F;EAAA,CACG,CAAC;AAEX","ignoreList":[]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DISPLAY_CURRENCIES = void 0;
|
|
7
|
+
exports.useDisplayCurrency = useDisplayCurrency;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _reactQuery = require("@tanstack/react-query");
|
|
10
|
+
var _core = require("@oxy.so/core");
|
|
11
|
+
var _OxyContext = require("../context/OxyContext.js");
|
|
12
|
+
var _useAccountQueries = require("./queries/useAccountQueries.js");
|
|
13
|
+
var _queryKeys = require("./queries/queryKeys.js");
|
|
14
|
+
var _authStore = require("../stores/authStore.js");
|
|
15
|
+
var _mutationKeys = require("./mutations/mutationKeys.js");
|
|
16
|
+
const DISPLAY_CURRENCIES = exports.DISPLAY_CURRENCIES = ['USD', 'EUR', 'FAIR'];
|
|
17
|
+
let anonymousCurrency = 'USD';
|
|
18
|
+
const anonymousListeners = new Set();
|
|
19
|
+
const subscribeAnonymous = listener => {
|
|
20
|
+
anonymousListeners.add(listener);
|
|
21
|
+
return () => {
|
|
22
|
+
anonymousListeners.delete(listener);
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
const anonymousSnapshot = () => anonymousCurrency;
|
|
26
|
+
|
|
27
|
+
/** Account-scoped server preference. A late save can never replace another account. */
|
|
28
|
+
function useDisplayCurrency() {
|
|
29
|
+
const {
|
|
30
|
+
oxyServices,
|
|
31
|
+
activeSessionId,
|
|
32
|
+
isAuthenticated,
|
|
33
|
+
user
|
|
34
|
+
} = (0, _OxyContext.useOxy)();
|
|
35
|
+
const current = (0, _useAccountQueries.useCurrentUser)({
|
|
36
|
+
enabled: isAuthenticated
|
|
37
|
+
});
|
|
38
|
+
const client = (0, _reactQuery.useQueryClient)();
|
|
39
|
+
const anonymous = (0, _react.useSyncExternalStore)(subscribeAnonymous, anonymousSnapshot, () => 'USD');
|
|
40
|
+
const currency = isAuthenticated ? current.data?.userPreferences?.displayCurrency ?? user?.userPreferences?.displayCurrency ?? 'USD' : anonymous;
|
|
41
|
+
const mutation = (0, _reactQuery.useMutation)({
|
|
42
|
+
mutationKey: [..._mutationKeys.mutationKeys.account.updateSettings],
|
|
43
|
+
mutationFn: async input => {
|
|
44
|
+
const updated = await (0, _core.authenticatedApiCall)(oxyServices, input.sessionId, () => oxyServices.users.updateMe({
|
|
45
|
+
userPreferences: {
|
|
46
|
+
displayCurrency: input.currency
|
|
47
|
+
}
|
|
48
|
+
}));
|
|
49
|
+
if (updated.id !== input.userId) throw new Error('Account changed. Please try again.');
|
|
50
|
+
return updated;
|
|
51
|
+
},
|
|
52
|
+
onSuccess: (updated, input) => {
|
|
53
|
+
client.setQueryData(_queryKeys.queryKeys.accounts.current(input.sessionId), updated);
|
|
54
|
+
if (_authStore.useAuthStore.getState().user?.id === input.userId) _authStore.useAuthStore.getState().setUser(updated);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
function selectCurrency(next) {
|
|
58
|
+
if (!DISPLAY_CURRENCIES.includes(next)) return;
|
|
59
|
+
if (!isAuthenticated) {
|
|
60
|
+
anonymousCurrency = next;
|
|
61
|
+
for (const listener of anonymousListeners) listener();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (activeSessionId && user?.id) mutation.mutate({
|
|
65
|
+
currency: next,
|
|
66
|
+
sessionId: activeSessionId,
|
|
67
|
+
userId: user.id
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
currency,
|
|
72
|
+
selectCurrency,
|
|
73
|
+
isSaving: mutation.isPending,
|
|
74
|
+
error: mutation.error
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=useDisplayCurrency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactQuery","_core","_OxyContext","_useAccountQueries","_queryKeys","_authStore","_mutationKeys","DISPLAY_CURRENCIES","exports","anonymousCurrency","anonymousListeners","Set","subscribeAnonymous","listener","add","delete","anonymousSnapshot","useDisplayCurrency","oxyServices","activeSessionId","isAuthenticated","user","useOxy","current","useCurrentUser","enabled","client","useQueryClient","anonymous","useSyncExternalStore","currency","data","userPreferences","displayCurrency","mutation","useMutation","mutationKey","mutationKeys","account","updateSettings","mutationFn","input","updated","authenticatedApiCall","sessionId","users","updateMe","id","userId","Error","onSuccess","setQueryData","queryKeys","accounts","useAuthStore","getState","setUser","selectCurrency","next","includes","mutate","isSaving","isPending","error"],"sourceRoot":"../../../../src","sources":["ui/hooks/useDisplayCurrency.ts"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AAGO,MAAMQ,kBAA8C,GAAAC,OAAA,CAAAD,kBAAA,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC;AAEpF,IAAIE,iBAAkC,GAAG,KAAK;AAC9C,MAAMC,kBAAkB,GAAG,IAAIC,GAAG,CAAa,CAAC;AAChD,MAAMC,kBAAkB,GAAIC,QAAoB,IAAK;EACnDH,kBAAkB,CAACI,GAAG,CAACD,QAAQ,CAAC;EAChC,OAAO,MAAM;IACXH,kBAAkB,CAACK,MAAM,CAACF,QAAQ,CAAC;EACrC,CAAC;AACH,CAAC;AACD,MAAMG,iBAAiB,GAAGA,CAAA,KAAMP,iBAAiB;;AAEjD;AACO,SAASQ,kBAAkBA,CAAA,EAAG;EACnC,MAAM;IAAEC,WAAW;IAAEC,eAAe;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AAM,EACnDM,uBAAY,CAACC,QAAQ,CAAC,CAAC,CAACC,OAAO,CAACd,OAAO,CAAC;IAC5C;EACF,CAAC,CAAC;EACF,SAASe,cAAcA,CAACC,IAAqB,EAAE;IAC7C,IAAI,CAACnD,kBAAkB,CAACoD,QAAQ,CAACD,IAAI,CAAC,EAAE;IACxC,IAAI,CAACtC,eAAe,EAAE;MACpBX,iBAAiB,GAAGiD,IAAI;MACxB,KAAK,MAAM7C,QAAQ,IAAIH,kBAAkB,EAAEG,QAAQ,CAAC,CAAC;MACrD;IACF;IACA,IAAIM,eAAe,IAAIE,IAAI,EAAE0B,EAAE,EAC7Bb,QAAQ,CAAC0B,MAAM,CAAC;MAAE9B,QAAQ,EAAE4B,IAAI;MAAEd,SAAS,EAAEzB,eAAe;MAAE6B,MAAM,EAAE3B,IAAI,CAAC0B;IAAG,CAAC,CAAC;EACpF;EACA,OAAO;IAAEjB,QAAQ;IAAE2B,cAAc;IAAEI,QAAQ,EAAE3B,QAAQ,CAAC4B,SAAS;IAAEC,KAAK,EAAE7B,QAAQ,CAAC6B;EAAM,CAAC;AAC1F","ignoreList":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useDisplayPrice = useDisplayPrice;
|
|
7
|
+
var _reactQuery = require("@tanstack/react-query");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _display = require("@peable.to/sdk/display");
|
|
10
|
+
var _useDisplayCurrency = require("./useDisplayCurrency.js");
|
|
11
|
+
var _useI18n = require("./useI18n.js");
|
|
12
|
+
/** Display conversion only. Pricing and checkout request bodies retain their source units. */
|
|
13
|
+
function useDisplayPrice() {
|
|
14
|
+
const {
|
|
15
|
+
currency
|
|
16
|
+
} = (0, _useDisplayCurrency.useDisplayCurrency)();
|
|
17
|
+
const {
|
|
18
|
+
t
|
|
19
|
+
} = (0, _useI18n.useI18n)();
|
|
20
|
+
const [now, setNow] = (0, _react.useState)(Date.now);
|
|
21
|
+
const rates = (0, _reactQuery.useQuery)({
|
|
22
|
+
queryKey: ['display-currency', 'faircoin-indexed-price'],
|
|
23
|
+
queryFn: ({
|
|
24
|
+
signal
|
|
25
|
+
}) => (0, _display.readDisplayRates)({
|
|
26
|
+
signal
|
|
27
|
+
}),
|
|
28
|
+
enabled: currency !== 'USD',
|
|
29
|
+
staleTime: 30_000,
|
|
30
|
+
gcTime: 0,
|
|
31
|
+
retry: false,
|
|
32
|
+
refetchInterval: 60_000,
|
|
33
|
+
refetchOnWindowFocus: 'always'
|
|
34
|
+
});
|
|
35
|
+
(0, _react.useEffect)(() => {
|
|
36
|
+
const timer = setInterval(() => setNow(Date.now()), 1000);
|
|
37
|
+
return () => clearInterval(timer);
|
|
38
|
+
}, []);
|
|
39
|
+
function formatUsd(minorUnits) {
|
|
40
|
+
const display = (0, _display.convertDisplayAmount)({
|
|
41
|
+
units: String(minorUnits),
|
|
42
|
+
currency: 'USD',
|
|
43
|
+
displayCurrency: currency,
|
|
44
|
+
rates: rates.isError ? null : rates.data,
|
|
45
|
+
now
|
|
46
|
+
});
|
|
47
|
+
if (!display) return t('preferences.displayCurrency.unavailable', {
|
|
48
|
+
currency
|
|
49
|
+
});
|
|
50
|
+
return currency === 'USD' ? display : t('preferences.displayCurrency.approximate', {
|
|
51
|
+
amount: display
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
currency,
|
|
56
|
+
formatUsd
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=useDisplayPrice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactQuery","require","_react","_display","_useDisplayCurrency","_useI18n","useDisplayPrice","currency","useDisplayCurrency","t","useI18n","now","setNow","useState","Date","rates","useQuery","queryKey","queryFn","signal","readDisplayRates","enabled","staleTime","gcTime","retry","refetchInterval","refetchOnWindowFocus","useEffect","timer","setInterval","clearInterval","formatUsd","minorUnits","display","convertDisplayAmount","units","String","displayCurrency","isError","data","amount"],"sourceRoot":"../../../../src","sources":["ui/hooks/useDisplayPrice.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAEA;AACO,SAASK,eAAeA,CAAA,EAAG;EAChC,MAAM;IAAEC;EAAS,CAAC,GAAG,IAAAC,sCAAkB,EAAC,CAAC;EACzC,MAAM;IAAEC;EAAE,CAAC,GAAG,IAAAC,gBAAO,EAAC,CAAC;EACvB,MAAM,CAACC,GAAG,EAAEC,MAAM,CAAC,GAAG,IAAAC,eAAQ,EAACC,IAAI,CAACH,GAAG,CAAC;EACxC,MAAMI,KAAK,GAAG,IAAAC,oBAAQ,EAAC;IACrBC,QAAQ,EAAE,CAAC,kBAAkB,EAAE,wBAAwB,CAAC;IACxDC,OAAO,EAAEA,CAAC;MAAEC;IAAO,CAAC,KAAK,IAAAC,yBAAgB,EAAC;MAAED;IAAO,CAAC,CAAC;IACrDE,OAAO,EAAEd,QAAQ,KAAK,KAAK;IAC3Be,SAAS,EAAE,MAAM;IACjBC,MAAM,EAAE,CAAC;IACTC,KAAK,EAAE,KAAK;IACZC,eAAe,EAAE,MAAM;IACvBC,oBAAoB,EAAE;EACxB,CAAC,CAAC;EACF,IAAAC,gBAAS,EAAC,MAAM;IACd,MAAMC,KAAK,GAAGC,WAAW,CAAC,MAAMjB,MAAM,CAACE,IAAI,CAACH,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;IACzD,OAAO,MAAMmB,aAAa,CAACF,KAAK,CAAC;EACnC,CAAC,EAAE,EAAE,CAAC;EACN,SAASG,SAASA,CAACC,UAAkB,EAAE;IACrC,MAAMC,OAAO,GAAG,IAAAC,6BAAoB,EAAC;MACnCC,KAAK,EAAEC,MAAM,CAACJ,UAAU,CAAC;MACzBzB,QAAQ,EAAE,KAAK;MACf8B,eAAe,EAAE9B,QAAQ;MACzBQ,KAAK,EAAEA,KAAK,CAACuB,OAAO,GAAG,IAAI,GAAGvB,KAAK,CAACwB,IAAI;MACxC5B;IACF,CAAC,CAAC;IACF,IAAI,CAACsB,OAAO,EAAE,OAAOxB,CAAC,CAAC,yCAAyC,EAAE;MAAEF;IAAS,CAAC,CAAC;IAC/E,OAAOA,QAAQ,KAAK,KAAK,GACrB0B,OAAO,GACPxB,CAAC,CAAC,yCAAyC,EAAE;MAAE+B,MAAM,EAAEP;IAAQ,CAAC,CAAC;EACvE;EACA,OAAO;IAAE1B,QAAQ;IAAEwB;EAAU,CAAC;AAChC","ignoreList":[]}
|
|
@@ -26,13 +26,9 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
26
26
|
|
|
27
27
|
const ASSIGNABLE_ROLES = ['admin', 'editor', 'developer', 'billing', 'viewer'];
|
|
28
28
|
const errorMessage = (error, fallback) => error instanceof Error && error.message ? error.message : fallback;
|
|
29
|
-
const isUserNotFound = error => {
|
|
30
|
-
const message = error instanceof Error ? error.message.toLowerCase() : '';
|
|
31
|
-
return message.includes('user not found') || message.includes('not found');
|
|
32
|
-
};
|
|
33
29
|
|
|
34
30
|
/**
|
|
35
|
-
* Manage the members of an account (invite by
|
|
31
|
+
* Manage the members of an account (invite by email, change roles,
|
|
36
32
|
* remove, transfer ownership). Gated on the caller's `callerMembership`
|
|
37
33
|
* permissions. Receives the target `accountId` via navigation props.
|
|
38
34
|
*/
|
|
@@ -79,6 +75,23 @@ const AccountMembersScreen = ({
|
|
|
79
75
|
queryFn: () => oxyServices.accounts.members.list(id),
|
|
80
76
|
enabled: canUsePrivateApi && id.length > 0 && canRead
|
|
81
77
|
});
|
|
78
|
+
const invitationsQuery = (0, _reactQuery.useQuery)({
|
|
79
|
+
queryKey: ['account-invitations', id],
|
|
80
|
+
queryFn: () => oxyServices.accounts.invitations.list(id),
|
|
81
|
+
enabled: canUsePrivateApi && !!id && canRead
|
|
82
|
+
});
|
|
83
|
+
const invitationAction = (0, _reactQuery.useMutation)({
|
|
84
|
+
mutationFn: async ({
|
|
85
|
+
invitationId,
|
|
86
|
+
action
|
|
87
|
+
}) => {
|
|
88
|
+
if (action === 'resend') await oxyServices.accounts.invitations.resend(id, invitationId);else await oxyServices.accounts.invitations.cancel(id, invitationId);
|
|
89
|
+
},
|
|
90
|
+
onSuccess: () => {
|
|
91
|
+
void invitationsQuery.refetch();
|
|
92
|
+
},
|
|
93
|
+
onError: error => _toast.toast.error(errorMessage(error, 'Could not update invitation'))
|
|
94
|
+
});
|
|
82
95
|
const members = (0, _react.useMemo)(() => membersQuery.data ?? [], [membersQuery.data]);
|
|
83
96
|
const memberUserIds = (0, _react.useMemo)(() => [...new Set(members.map(member => member.memberUserId).filter(id => id.length > 0))], [members]);
|
|
84
97
|
const memberProfilesQuery = (0, _reactQuery.useQuery)({
|
|
@@ -111,6 +124,9 @@ const AccountMembersScreen = ({
|
|
|
111
124
|
queryClient.invalidateQueries({
|
|
112
125
|
queryKey: ['accounts', 'members']
|
|
113
126
|
});
|
|
127
|
+
queryClient.invalidateQueries({
|
|
128
|
+
queryKey: ['account-invitations', id]
|
|
129
|
+
});
|
|
114
130
|
queryClient.invalidateQueries({
|
|
115
131
|
queryKey: ['accounts', 'detail', id]
|
|
116
132
|
});
|
|
@@ -122,22 +138,20 @@ const AccountMembersScreen = ({
|
|
|
122
138
|
const [inviteError, setInviteError] = (0, _react.useState)(null);
|
|
123
139
|
const inviteMutation = (0, _reactQuery.useMutation)({
|
|
124
140
|
mutationKey: ['accounts', 'members', 'invite', id],
|
|
125
|
-
mutationFn: input => oxyServices.accounts.
|
|
141
|
+
mutationFn: input => oxyServices.accounts.invitations.create(id, {
|
|
142
|
+
email: input.usernameOrEmail,
|
|
143
|
+
role: input.role
|
|
144
|
+
}),
|
|
126
145
|
onSuccess: () => {
|
|
127
146
|
setInviteIdentifier('');
|
|
128
147
|
setInviteRole('editor');
|
|
129
148
|
setInviteError(null);
|
|
130
149
|
invalidateMembers();
|
|
131
|
-
_toast.toast.success(
|
|
150
|
+
_toast.toast.success('Invitation sent');
|
|
132
151
|
},
|
|
133
152
|
onError: error => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
setInviteError(message);
|
|
137
|
-
_toast.toast.error(message);
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
_toast.toast.error(errorMessage(error, t('accounts.members.toasts.addFailed') || 'Failed to add member'));
|
|
153
|
+
invalidateMembers();
|
|
154
|
+
_toast.toast.error(errorMessage(error, 'Could not send invitation'));
|
|
141
155
|
}
|
|
142
156
|
});
|
|
143
157
|
const updateMutation = (0, _reactQuery.useMutation)({
|
|
@@ -180,7 +194,7 @@ const AccountMembersScreen = ({
|
|
|
180
194
|
const handleInvite = (0, _react.useCallback)(() => {
|
|
181
195
|
const usernameOrEmail = inviteIdentifier.trim();
|
|
182
196
|
if (!usernameOrEmail) {
|
|
183
|
-
setInviteError(
|
|
197
|
+
setInviteError('Enter an email to invite');
|
|
184
198
|
return;
|
|
185
199
|
}
|
|
186
200
|
setInviteError(null);
|
|
@@ -188,7 +202,7 @@ const AccountMembersScreen = ({
|
|
|
188
202
|
usernameOrEmail,
|
|
189
203
|
role: inviteRole
|
|
190
204
|
});
|
|
191
|
-
}, [inviteIdentifier, inviteRole, inviteMutation
|
|
205
|
+
}, [inviteIdentifier, inviteRole, inviteMutation]);
|
|
192
206
|
const handleChangeRole = (0, _react.useCallback)((member, role) => {
|
|
193
207
|
if (role === member.role || role === 'owner') {
|
|
194
208
|
return;
|
|
@@ -238,12 +252,12 @@ const AccountMembersScreen = ({
|
|
|
238
252
|
className: "gap-space-12 p-space-16 rounded-radius-20 bg-fill",
|
|
239
253
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
|
|
240
254
|
className: "text-body font-semibold text-text",
|
|
241
|
-
children:
|
|
255
|
+
children: 'Invite a member'
|
|
242
256
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_textField.TextField, {
|
|
243
257
|
isInvalid: !!inviteError,
|
|
244
258
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_textField.TextFieldInput, {
|
|
245
259
|
floatingLabel: true,
|
|
246
|
-
label:
|
|
260
|
+
label: 'Email',
|
|
247
261
|
value: inviteIdentifier,
|
|
248
262
|
onChangeText: value => {
|
|
249
263
|
setInviteIdentifier(value);
|
|
@@ -281,10 +295,39 @@ const AccountMembersScreen = ({
|
|
|
281
295
|
onPress: handleInvite,
|
|
282
296
|
disabled: inviteMutation.isPending || !inviteIdentifier.trim(),
|
|
283
297
|
loading: inviteMutation.isPending,
|
|
284
|
-
accessibilityLabel:
|
|
298
|
+
accessibilityLabel: 'Send invitation',
|
|
285
299
|
className: "w-full",
|
|
286
|
-
children:
|
|
300
|
+
children: 'Send invitation'
|
|
287
301
|
})]
|
|
302
|
+
}) : null, canRead ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
303
|
+
className: "gap-space-12",
|
|
304
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
|
|
305
|
+
className: "text-body font-semibold text-text",
|
|
306
|
+
children: "Pending invitations"
|
|
307
|
+
}), invitationsQuery.isError ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Text, {
|
|
308
|
+
children: "Could not load invitations."
|
|
309
|
+
}) : null, (invitationsQuery.data ?? []).map(invitation => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
310
|
+
className: "gap-space-8 p-space-16 rounded-radius-20 bg-fill",
|
|
311
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_typography.Text, {
|
|
312
|
+
children: [invitation.email, " \xB7 ", roleLabel(invitation.role), " \xB7 ", invitation.status]
|
|
313
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_typography.Text, {
|
|
314
|
+
children: ["Expires ", new Date(invitation.expiresAt).toLocaleDateString()]
|
|
315
|
+
}), canInvite ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
|
|
316
|
+
disabled: invitationAction.isPending,
|
|
317
|
+
onPress: () => invitationAction.mutate({
|
|
318
|
+
invitationId: invitation.id,
|
|
319
|
+
action: 'resend'
|
|
320
|
+
}),
|
|
321
|
+
children: "Resend"
|
|
322
|
+
}) : null, canRemove ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
|
|
323
|
+
disabled: invitationAction.isPending,
|
|
324
|
+
onPress: () => invitationAction.mutate({
|
|
325
|
+
invitationId: invitation.id,
|
|
326
|
+
action: 'cancel'
|
|
327
|
+
}),
|
|
328
|
+
children: "Cancel invitation"
|
|
329
|
+
}) : null]
|
|
330
|
+
}, invitation.id))]
|
|
288
331
|
}) : null, canRead ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
289
332
|
className: "gap-space-8",
|
|
290
333
|
children: membersQuery.isLoading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|