@oxy.so/services 11.2.0 → 11.3.1
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/ui/boot/runProviderColdBoot.js +47 -3
- package/lib/commonjs/ui/boot/runProviderColdBoot.js.map +1 -1
- package/lib/commonjs/ui/components/organizations/OrganizationClaimReview.js +208 -0
- package/lib/commonjs/ui/components/organizations/OrganizationClaimReview.js.map +1 -0
- package/lib/commonjs/ui/components/organizations/OrganizationClaims.js +77 -0
- package/lib/commonjs/ui/components/organizations/OrganizationClaims.js.map +1 -0
- package/lib/commonjs/ui/components/organizations/OrganizationDirectorySearch.js +218 -0
- package/lib/commonjs/ui/components/organizations/OrganizationDirectorySearch.js.map +1 -0
- package/lib/commonjs/ui/components/organizations/OrganizationSettings.js +147 -0
- package/lib/commonjs/ui/components/organizations/OrganizationSettings.js.map +1 -0
- package/lib/commonjs/ui/components/organizations/OrganizationTypePicker.js +34 -0
- package/lib/commonjs/ui/components/organizations/OrganizationTypePicker.js.map +1 -0
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js +14 -5
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/CreateAccountScreen.js +148 -115
- package/lib/commonjs/ui/screens/CreateAccountScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/ManageAccountScreen.js +13 -1
- package/lib/commonjs/ui/screens/ManageAccountScreen.js.map +1 -1
- package/lib/module/ui/boot/runProviderColdBoot.js +47 -3
- package/lib/module/ui/boot/runProviderColdBoot.js.map +1 -1
- package/lib/module/ui/components/organizations/OrganizationClaimReview.js +205 -0
- package/lib/module/ui/components/organizations/OrganizationClaimReview.js.map +1 -0
- package/lib/module/ui/components/organizations/OrganizationClaims.js +73 -0
- package/lib/module/ui/components/organizations/OrganizationClaims.js.map +1 -0
- package/lib/module/ui/components/organizations/OrganizationDirectorySearch.js +215 -0
- package/lib/module/ui/components/organizations/OrganizationDirectorySearch.js.map +1 -0
- package/lib/module/ui/components/organizations/OrganizationSettings.js +143 -0
- package/lib/module/ui/components/organizations/OrganizationSettings.js.map +1 -0
- package/lib/module/ui/components/organizations/OrganizationTypePicker.js +30 -0
- package/lib/module/ui/components/organizations/OrganizationTypePicker.js.map +1 -0
- package/lib/module/ui/screens/AccountSettingsScreen.js +14 -5
- package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/module/ui/screens/CreateAccountScreen.js +149 -115
- package/lib/module/ui/screens/CreateAccountScreen.js.map +1 -1
- package/lib/module/ui/screens/ManageAccountScreen.js +13 -1
- package/lib/module/ui/screens/ManageAccountScreen.js.map +1 -1
- package/lib/typescript/commonjs/ui/boot/runProviderColdBoot.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/organizations/OrganizationClaimReview.d.ts +3 -0
- package/lib/typescript/commonjs/ui/components/organizations/OrganizationClaimReview.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/organizations/OrganizationClaims.d.ts +2 -0
- package/lib/typescript/commonjs/ui/components/organizations/OrganizationClaims.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/organizations/OrganizationDirectorySearch.d.ts +6 -0
- package/lib/typescript/commonjs/ui/components/organizations/OrganizationDirectorySearch.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/organizations/OrganizationSettings.d.ts +5 -0
- package/lib/typescript/commonjs/ui/components/organizations/OrganizationSettings.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/organizations/OrganizationTypePicker.d.ts +7 -0
- package/lib/typescript/commonjs/ui/components/organizations/OrganizationTypePicker.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts +3 -2
- package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/queries/usePersonalPlans.d.ts +2 -2
- package/lib/typescript/commonjs/ui/icons/Ionicons.d.ts +1 -1
- package/lib/typescript/commonjs/ui/icons/MaterialCommunityIcons.d.ts +1 -1
- package/lib/typescript/commonjs/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/CreateAccountScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/ManageAccountScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/boot/runProviderColdBoot.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/organizations/OrganizationClaimReview.d.ts +3 -0
- package/lib/typescript/module/ui/components/organizations/OrganizationClaimReview.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/organizations/OrganizationClaims.d.ts +2 -0
- package/lib/typescript/module/ui/components/organizations/OrganizationClaims.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/organizations/OrganizationDirectorySearch.d.ts +6 -0
- package/lib/typescript/module/ui/components/organizations/OrganizationDirectorySearch.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/organizations/OrganizationSettings.d.ts +5 -0
- package/lib/typescript/module/ui/components/organizations/OrganizationSettings.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/organizations/OrganizationTypePicker.d.ts +7 -0
- package/lib/typescript/module/ui/components/organizations/OrganizationTypePicker.d.ts.map +1 -0
- package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts +3 -2
- package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/queries/usePersonalPlans.d.ts +2 -2
- package/lib/typescript/module/ui/icons/Ionicons.d.ts +1 -1
- package/lib/typescript/module/ui/icons/MaterialCommunityIcons.d.ts +1 -1
- package/lib/typescript/module/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/CreateAccountScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/ManageAccountScreen.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/ui/boot/__tests__/coldBootNoIdpRedirect.test.ts +166 -3
- package/src/ui/boot/runProviderColdBoot.ts +49 -4
- package/src/ui/components/organizations/OrganizationClaimReview.tsx +218 -0
- package/src/ui/components/organizations/OrganizationClaims.tsx +67 -0
- package/src/ui/components/organizations/OrganizationDirectorySearch.tsx +228 -0
- package/src/ui/components/organizations/OrganizationSettings.tsx +131 -0
- package/src/ui/components/organizations/OrganizationTypePicker.tsx +31 -0
- package/src/ui/screens/AccountSettingsScreen.tsx +22 -4
- package/src/ui/screens/CreateAccountScreen.tsx +177 -124
- package/src/ui/screens/ManageAccountScreen.tsx +18 -0
|
@@ -8,6 +8,28 @@ import { createPlatformSharedDeviceCredentialStore } from "../session/sharedDevi
|
|
|
8
8
|
import { tryCompleteOAuthReturn } from "../utils/oauthReturn.js";
|
|
9
9
|
import { isWebBrowser } from "../utils/isWebBrowser.js";
|
|
10
10
|
import { isNetConnectivityExplicitlyOffline } from "../utils/netConnectivity.js";
|
|
11
|
+
/**
|
|
12
|
+
* Whether the URL carries an OAuth return (`?code=` or `?error=`) for
|
|
13
|
+
* `tryCompleteOAuthReturn` to consume. Reads the address bar only.
|
|
14
|
+
*/
|
|
15
|
+
function hasOAuthReturnOnUrl() {
|
|
16
|
+
const search = globalThis.location?.search;
|
|
17
|
+
if (!search) return false;
|
|
18
|
+
const params = new URLSearchParams(search);
|
|
19
|
+
return params.has('code') || params.has('error');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Whether this origin's own store holds anything a web boot could restore from:
|
|
24
|
+
* a warm access token to plant or a device secret to mint with. A presence
|
|
25
|
+
* check only — nothing read here is used, sent or synced before the
|
|
26
|
+
* classification allows it.
|
|
27
|
+
*/
|
|
28
|
+
async function hasRestorableState(store) {
|
|
29
|
+
const persisted = await store.load();
|
|
30
|
+
return Boolean(persisted?.accessToken || persisted?.deviceSecret);
|
|
31
|
+
}
|
|
32
|
+
|
|
11
33
|
/** How long the cold boot waits for the post-boot SessionClient handoff (ms). */
|
|
12
34
|
export const SESSION_HANDOFF_DEADLINE_MS = 6000;
|
|
13
35
|
|
|
@@ -95,9 +117,31 @@ export async function runProviderColdBoot(opts) {
|
|
|
95
117
|
const identityBound = sessionMode === 'identity';
|
|
96
118
|
setTokenReady(false);
|
|
97
119
|
try {
|
|
98
|
-
// Classification precedes every local
|
|
99
|
-
//
|
|
100
|
-
|
|
120
|
+
// Classification precedes every USE of a local secret, the shared credential
|
|
121
|
+
// and the identity key. Unavailable registry metadata fails closed, including
|
|
122
|
+
// offline boot. It starts now, before anything else, so its round trip
|
|
123
|
+
// overlaps the local work below.
|
|
124
|
+
const classification = (async () => opts.resolveSessionLane?.() ?? resolveApplicationSessionLane(oxyServices, clientId))();
|
|
125
|
+
// Observed so a rejection that lands before it is awaited is not reported as
|
|
126
|
+
// unhandled; every path below still awaits it and sees the rejection.
|
|
127
|
+
classification.catch(() => undefined);
|
|
128
|
+
|
|
129
|
+
// The verdict decides HOW a session is restored, never WHETHER there is one.
|
|
130
|
+
// A web origin with nothing to restore and no OAuth return on the URL ends
|
|
131
|
+
// signed out on either lane, so routing need not wait a network round trip
|
|
132
|
+
// for an answer that cannot change the outcome. The classification still
|
|
133
|
+
// completes below and still gates every later sign-in
|
|
134
|
+
// (`ensureDeviceSessionLane` shares this same in-flight lookup).
|
|
135
|
+
if (!identityBound && isWebBrowser() && !hasOAuthReturnOnUrl()) {
|
|
136
|
+
if (!(await hasRestorableState(authStore))) {
|
|
137
|
+
markAuthResolved();
|
|
138
|
+
const lane = await classification;
|
|
139
|
+
await opts.onClassified?.(lane);
|
|
140
|
+
if (lane === 'oauth') setTokenReady(true);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const lane = await classification;
|
|
101
145
|
await opts.onClassified?.(lane);
|
|
102
146
|
if (identityBound && lane !== 'device') return;
|
|
103
147
|
// The redirect transport's RETURN leg. An app reaches it whenever the browser
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["resolveApplicationSessionLane","logger","loggerUtil","runSessionColdBoot","loadPersistedDeviceCredential","createPlatformSharedDeviceCredentialStore","tryCompleteOAuthReturn","isWebBrowser","isNetConnectivityExplicitlyOffline","SESSION_HANDOFF_DEADLINE_MS","COLD_BOOT_OVERALL_DEADLINE_MS","OFFLINE_PROBE_TIMEOUT_MS","detectOfflineHint","online","
|
|
1
|
+
{"version":3,"names":["resolveApplicationSessionLane","logger","loggerUtil","runSessionColdBoot","loadPersistedDeviceCredential","createPlatformSharedDeviceCredentialStore","tryCompleteOAuthReturn","isWebBrowser","isNetConnectivityExplicitlyOffline","hasOAuthReturnOnUrl","search","globalThis","location","params","URLSearchParams","has","hasRestorableState","store","persisted","load","Boolean","accessToken","deviceSecret","SESSION_HANDOFF_DEADLINE_MS","COLD_BOOT_OVERALL_DEADLINE_MS","OFFLINE_PROBE_TIMEOUT_MS","detectOfflineHint","online","navigator","onLine","NetInfo","state","Promise","race","default","fetch","resolve","setTimeout","runProviderColdBoot","opts","oxyServices","authStore","clientId","authRedirectUri","sessionMode","identity","sessionClient","syncDeviceCredentialToHost","commitSession","markAuthResolved","setTokenReady","identityBound","classification","resolveSessionLane","catch","undefined","lane","onClassified","oauthCompleted","input","activate","oauth","beforeDeviceBoot","offline","oxy","platform","isWeb","isNative","sharedDeviceCredential","overallDeadlineMs","isOffline","onStepDeadline","stepId","warn","component","method","onSession","session","handoff","sessionId","userId","deviceState","handoffDeadlineId","finally","clearTimeout","onSignedOut","cred","start","socketError","__DEV__","debug","onStepError","id","error","afterDeviceBoot","Error","String"],"sourceRoot":"../../../../src","sources":["ui/boot/runProviderColdBoot.ts"],"mappings":";;AAAA,SAASA,6BAA6B,QAAQ,oCAAiC;AAC/E,SAASC,MAAM,IAAIC,UAAU,QAA0B,cAAc;AACrE,SACEC,kBAAkB,QAIb,sBAAsB;AAE7B,SAASC,6BAA6B,QAAQ,8BAA2B;AACzE,SAASC,yCAAyC,QAAQ,2CAAwC;AAClG,SAASC,sBAAsB,QAAQ,yBAAsB;AAC7D,SAASC,YAAY,QAAQ,0B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K,KAAK;QAC1B,IAAIJ,OAAO,EAAE;UACXvF,UAAU,CAACwF,KAAK,CACd,mBAAmBE,EAAE,wCAAwC,EAC7D;YAAElB,SAAS,EAAE;UAAsB,CAAC,EACpCmB,KACF,CAAC;QACH;MACF;IACF,CAAC,CAAC;IACF,MAAMtD,IAAI,CAACuD,eAAe,GAAG,CAAC;EAChC,CAAC,CAAC,OAAOD,KAAK,EAAE;IACd,IAAIJ,OAAO,EAAE;MACXvF,UAAU,CAAC2F,KAAK,CACd,iBAAiB,EACjBA,KAAK,YAAYE,KAAK,GAAGF,KAAK,GAAG,IAAIE,KAAK,CAACC,MAAM,CAACH,KAAK,CAAC,CAAC,EACzD;QAAEnB,SAAS,EAAE;MAAsB,CACrC,CAAC;IACH;EACF,CAAC,SAAS;IACRzB,gBAAgB,CAAC,CAAC;EACpB;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { ActivityIndicator, View } from 'react-native';
|
|
5
|
+
import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
6
|
+
import { isHttpRequestError } from '@oxy.so/core';
|
|
7
|
+
import { organizationClaimReviewSchema } from '@oxy.so/contracts';
|
|
8
|
+
import { Button } from '@oxy.so/bloom/button';
|
|
9
|
+
import { SettingsListGroup, SettingsListItem } from '@oxy.so/bloom/settings-list';
|
|
10
|
+
import { TextField, TextFieldInput } from '@oxy.so/bloom/text-field';
|
|
11
|
+
import { Text } from '@oxy.so/bloom/typography';
|
|
12
|
+
import { useOxy } from "../../context/OxyContext.js";
|
|
13
|
+
import { useI18n } from "../../hooks/useI18n.js";
|
|
14
|
+
|
|
15
|
+
/** The queue is requested only after an explicit action; the server rechecks staff authority. */
|
|
16
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
17
|
+
export function OrganizationClaimReview() {
|
|
18
|
+
const {
|
|
19
|
+
t
|
|
20
|
+
} = useI18n();
|
|
21
|
+
const {
|
|
22
|
+
user,
|
|
23
|
+
canUsePrivateApi
|
|
24
|
+
} = useOxy();
|
|
25
|
+
const [open, setOpen] = useState(false);
|
|
26
|
+
return /*#__PURE__*/_jsxs(SettingsListGroup, {
|
|
27
|
+
children: [/*#__PURE__*/_jsx(SettingsListItem, {
|
|
28
|
+
title: t('organizationDirectory.review.title'),
|
|
29
|
+
disabled: !canUsePrivateApi,
|
|
30
|
+
onPress: () => setOpen(value => !value)
|
|
31
|
+
}), open && user?.kind === 'personal' && canUsePrivateApi ? /*#__PURE__*/_jsx(ReviewQueue, {}, user.id) : null]
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function ReviewQueue() {
|
|
35
|
+
const {
|
|
36
|
+
t
|
|
37
|
+
} = useI18n();
|
|
38
|
+
const {
|
|
39
|
+
oxyServices,
|
|
40
|
+
user,
|
|
41
|
+
canUsePrivateApi
|
|
42
|
+
} = useOxy();
|
|
43
|
+
const [selected, setSelected] = useState(null);
|
|
44
|
+
const requests = useInfiniteQuery({
|
|
45
|
+
queryKey: ['oxy', 'organizations', 'review', user?.id, canUsePrivateApi],
|
|
46
|
+
queryFn: ({
|
|
47
|
+
pageParam
|
|
48
|
+
}) => oxyServices.organizations.reviewClaims({
|
|
49
|
+
status: 'pending',
|
|
50
|
+
limit: 20,
|
|
51
|
+
...(pageParam ? {
|
|
52
|
+
cursor: pageParam
|
|
53
|
+
} : {})
|
|
54
|
+
}),
|
|
55
|
+
initialPageParam: undefined,
|
|
56
|
+
getNextPageParam: page => page.nextCursor ?? undefined,
|
|
57
|
+
enabled: canUsePrivateApi,
|
|
58
|
+
retry: false,
|
|
59
|
+
gcTime: 0
|
|
60
|
+
});
|
|
61
|
+
const claims = requests.data?.pages.flatMap(page => page.items) ?? [];
|
|
62
|
+
const ids = [...new Set(claims.map(claim => claim.accountId))].sort();
|
|
63
|
+
const organizations = useQuery({
|
|
64
|
+
queryKey: ['oxy', 'organizations', 'review-organizations', ids],
|
|
65
|
+
queryFn: async () => {
|
|
66
|
+
const batches = [];
|
|
67
|
+
for (let offset = 0; offset < ids.length; offset += 100) batches.push(oxyServices.organizations.batch({
|
|
68
|
+
ids: ids.slice(offset, offset + 100)
|
|
69
|
+
}));
|
|
70
|
+
return (await Promise.all(batches)).flatMap(batch => batch.items);
|
|
71
|
+
},
|
|
72
|
+
enabled: canUsePrivateApi && requests.isSuccess && ids.length > 0,
|
|
73
|
+
retry: false
|
|
74
|
+
});
|
|
75
|
+
if (requests.isPending) return /*#__PURE__*/_jsx(ActivityIndicator, {});
|
|
76
|
+
if (requests.isError) return /*#__PURE__*/_jsxs(View, {
|
|
77
|
+
className: "gap-space-16 p-space-16",
|
|
78
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
79
|
+
accessibilityRole: "alert",
|
|
80
|
+
children: t(isHttpRequestError(requests.error) && requests.error.status === 403 ? 'organizationDirectory.review.forbidden' : 'organizationDirectory.requestError')
|
|
81
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
82
|
+
onPress: () => requests.refetch(),
|
|
83
|
+
children: t('organizationDirectory.retry')
|
|
84
|
+
})]
|
|
85
|
+
});
|
|
86
|
+
if (selected) return /*#__PURE__*/_jsx(ReviewDetail, {
|
|
87
|
+
claimId: selected,
|
|
88
|
+
onClose: () => setSelected(null)
|
|
89
|
+
}, selected);
|
|
90
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
91
|
+
className: "gap-space-16 p-space-16",
|
|
92
|
+
children: [claims.length === 0 ? /*#__PURE__*/_jsx(Text, {
|
|
93
|
+
children: t('organizationDirectory.review.empty')
|
|
94
|
+
}) : null, claims.map(claim => /*#__PURE__*/_jsx(SettingsListItem, {
|
|
95
|
+
title: organizations.data?.find(item => item.requestedAccountId === claim.accountId)?.organization.name ?? t('organizationDirectory.view'),
|
|
96
|
+
description: t('organizationDirectory.pending'),
|
|
97
|
+
onPress: () => setSelected(claim.id)
|
|
98
|
+
}, claim.id)), requests.hasNextPage ? /*#__PURE__*/_jsx(Button, {
|
|
99
|
+
onPress: () => requests.fetchNextPage(),
|
|
100
|
+
disabled: requests.isFetchingNextPage,
|
|
101
|
+
children: t('organizationDirectory.loadMore')
|
|
102
|
+
}) : null]
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function ReviewDetail({
|
|
106
|
+
claimId,
|
|
107
|
+
onClose
|
|
108
|
+
}) {
|
|
109
|
+
const {
|
|
110
|
+
t
|
|
111
|
+
} = useI18n();
|
|
112
|
+
const {
|
|
113
|
+
oxyServices,
|
|
114
|
+
user,
|
|
115
|
+
canUsePrivateApi
|
|
116
|
+
} = useOxy();
|
|
117
|
+
const queryClient = useQueryClient();
|
|
118
|
+
const [evidence, setEvidence] = useState('');
|
|
119
|
+
const [authorizationRevoked, setAuthorizationRevoked] = useState(false);
|
|
120
|
+
const detail = useQuery({
|
|
121
|
+
queryKey: ['oxy', 'organizations', 'review-detail', user?.id, canUsePrivateApi, claimId],
|
|
122
|
+
queryFn: () => oxyServices.organizations.reviewClaimDetail(claimId),
|
|
123
|
+
enabled: canUsePrivateApi,
|
|
124
|
+
retry: false,
|
|
125
|
+
gcTime: 0
|
|
126
|
+
});
|
|
127
|
+
const review = useMutation({
|
|
128
|
+
mutationFn: decision => {
|
|
129
|
+
if (!canUsePrivateApi || authorizationRevoked || !detail.isSuccess || !detail.data || detail.data.claimantUserId === user?.id) throw new Error('Independent staff review is required');
|
|
130
|
+
return oxyServices.organizations.reviewClaim(claimId, organizationClaimReviewSchema.parse({
|
|
131
|
+
decision,
|
|
132
|
+
evidenceReference: evidence
|
|
133
|
+
}));
|
|
134
|
+
},
|
|
135
|
+
onError: error => {
|
|
136
|
+
if (isHttpRequestError(error) && error.status === 403) setAuthorizationRevoked(true);
|
|
137
|
+
},
|
|
138
|
+
onSuccess: async () => {
|
|
139
|
+
await queryClient.invalidateQueries({
|
|
140
|
+
queryKey: ['oxy', 'organizations']
|
|
141
|
+
});
|
|
142
|
+
await queryClient.invalidateQueries({
|
|
143
|
+
queryKey: ['accounts']
|
|
144
|
+
});
|
|
145
|
+
onClose();
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
const conflict = isHttpRequestError(review.error) && review.error.status === 409;
|
|
149
|
+
const forbidden = isHttpRequestError(review.error) && review.error.status === 403;
|
|
150
|
+
const selfReview = detail.data?.claimantUserId === user?.id;
|
|
151
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
152
|
+
className: "gap-space-16 p-space-16",
|
|
153
|
+
children: [detail.isPending ? /*#__PURE__*/_jsx(ActivityIndicator, {}) : null, detail.isError ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
154
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
155
|
+
accessibilityRole: "alert",
|
|
156
|
+
children: t(isHttpRequestError(detail.error) && detail.error.status === 403 ? 'organizationDirectory.review.forbidden' : 'organizationDirectory.requestError')
|
|
157
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
158
|
+
onPress: () => detail.refetch(),
|
|
159
|
+
children: t('organizationDirectory.retry')
|
|
160
|
+
})]
|
|
161
|
+
}) : null, authorizationRevoked ? /*#__PURE__*/_jsx(Text, {
|
|
162
|
+
accessibilityRole: "alert",
|
|
163
|
+
children: t('organizationDirectory.review.forbidden')
|
|
164
|
+
}) : null, detail.isSuccess && canUsePrivateApi && !authorizationRevoked ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
165
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
166
|
+
children: t('organizationDirectory.evidence')
|
|
167
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
168
|
+
selectable: true,
|
|
169
|
+
children: detail.data.evidenceReference
|
|
170
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
171
|
+
children: t('organizationDirectory.review.hint')
|
|
172
|
+
}), selfReview ? /*#__PURE__*/_jsx(Text, {
|
|
173
|
+
children: t('organizationDirectory.review.independent')
|
|
174
|
+
}) : null, /*#__PURE__*/_jsx(TextField, {
|
|
175
|
+
children: /*#__PURE__*/_jsx(TextFieldInput, {
|
|
176
|
+
label: t('organizationDirectory.review.evidence'),
|
|
177
|
+
value: evidence,
|
|
178
|
+
onChangeText: setEvidence,
|
|
179
|
+
maxLength: 1000
|
|
180
|
+
})
|
|
181
|
+
}), review.isError ? /*#__PURE__*/_jsx(Text, {
|
|
182
|
+
accessibilityRole: "alert",
|
|
183
|
+
children: t(conflict ? 'organizationDirectory.review.conflict' : forbidden ? 'organizationDirectory.review.forbidden' : 'organizationDirectory.review.failed')
|
|
184
|
+
}) : null, ['approved', 'rejected'].map(decision => /*#__PURE__*/_jsx(Button, {
|
|
185
|
+
disabled: !canUsePrivateApi || selfReview || detail.data.status !== 'pending' || !evidence.trim() || review.isPending || conflict || forbidden,
|
|
186
|
+
onPress: () => review.mutate(decision),
|
|
187
|
+
children: t(`organizationDirectory.review.${decision}`)
|
|
188
|
+
}, decision)), conflict ? /*#__PURE__*/_jsx(Button, {
|
|
189
|
+
onPress: async () => {
|
|
190
|
+
await queryClient.invalidateQueries({
|
|
191
|
+
queryKey: ['oxy', 'organizations']
|
|
192
|
+
});
|
|
193
|
+
onClose();
|
|
194
|
+
},
|
|
195
|
+
children: t('organizationDirectory.retry')
|
|
196
|
+
}) : null]
|
|
197
|
+
}) : null, /*#__PURE__*/_jsx(Button, {
|
|
198
|
+
appearance: "outline",
|
|
199
|
+
onPress: onClose,
|
|
200
|
+
disabled: review.isPending,
|
|
201
|
+
children: t('organizationDirectory.back')
|
|
202
|
+
})]
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=OrganizationClaimReview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useState","ActivityIndicator","View","useInfiniteQuery","useMutation","useQuery","useQueryClient","isHttpRequestError","organizationClaimReviewSchema","Button","SettingsListGroup","SettingsListItem","TextField","TextFieldInput","Text","useOxy","useI18n","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","OrganizationClaimReview","t","user","canUsePrivateApi","open","setOpen","children","title","disabled","onPress","value","kind","ReviewQueue","id","oxyServices","selected","setSelected","requests","queryKey","queryFn","pageParam","organizations","reviewClaims","status","limit","cursor","initialPageParam","undefined","getNextPageParam","page","nextCursor","enabled","retry","gcTime","claims","data","pages","flatMap","items","ids","Set","map","claim","accountId","sort","batches","offset","length","push","batch","slice","Promise","all","isSuccess","isPending","isError","className","accessibilityRole","error","refetch","ReviewDetail","claimId","onClose","find","item","requestedAccountId","organization","name","description","hasNextPage","fetchNextPage","isFetchingNextPage","queryClient","evidence","setEvidence","authorizationRevoked","setAuthorizationRevoked","detail","reviewClaimDetail","review","mutationFn","decision","claimantUserId","Error","reviewClaim","parse","evidenceReference","onError","onSuccess","invalidateQueries","conflict","forbidden","selfReview","selectable","label","onChangeText","maxLength","trim","mutate","appearance"],"sourceRoot":"../../../../../src","sources":["ui/components/organizations/OrganizationClaimReview.tsx"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,OAAO;AAChC,SAASC,iBAAiB,EAAEC,IAAI,QAAQ,cAAc;AACtD,SAASC,gBAAgB,EAAEC,WAAW,EAAEC,QAAQ,EAAEC,cAAc,QAAQ,uBAAuB;AAC/F,SAASC,kBAAkB,QAAQ,cAAc;AACjD,SACEC,6BAA6B,QAExB,mBAAmB;AAC1B,SAASC,MAAM,QAAQ,sBAAsB;AAC7C,SAASC,iBAAiB,EAAEC,gBAAgB,QAAQ,6BAA6B;AACjF,SAASC,SAAS,EAAEC,cAAc,QAAQ,0BAA0B;AACpE,SAASC,IAAI,QAAQ,0BAA0B;AAC/C,SAASC,MAAM,QAAQ,6BAA0B;AACjD,SAASC,OAAO,QAAQ,wBAAqB;;AAE7C;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA,EAAAC,QAAA,IAAAC,SAAA;AACA,OAAO,SAASC,uBAAuBA,CAAA,EAAG;EACxC,MAAM;IAAEC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eACRN,IAAA,CAACT,MAAM;MAACiH,UAAU,EAAC,SAAS;MAAC1F,OAAO,EAAEqD,OAAQ;MAACtD,QAAQ,EAAEuE,MAAM,CAACzB,SAAU;MAAAhD,QAAA,EACvEL,CAAC,CAAC,4BAA4B;IAAC,CAC1B,CAAC;EAAA,CACL,CAAC;AAEX","ignoreList":[]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import { useInfiniteQuery, useQuery } from '@tanstack/react-query';
|
|
5
|
+
import { Button } from '@oxy.so/bloom/button';
|
|
6
|
+
import { SettingsListGroup, SettingsListItem } from '@oxy.so/bloom/settings-list';
|
|
7
|
+
import { Text } from '@oxy.so/bloom/typography';
|
|
8
|
+
import { useOxy } from "../../context/OxyContext.js";
|
|
9
|
+
import { useI18n } from "../../hooks/useI18n.js";
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
export function OrganizationClaims() {
|
|
12
|
+
const {
|
|
13
|
+
oxyServices,
|
|
14
|
+
user,
|
|
15
|
+
canUsePrivateApi
|
|
16
|
+
} = useOxy();
|
|
17
|
+
const {
|
|
18
|
+
t
|
|
19
|
+
} = useI18n();
|
|
20
|
+
const enabled = canUsePrivateApi && user?.kind === 'personal';
|
|
21
|
+
const requests = useInfiniteQuery({
|
|
22
|
+
queryKey: ['oxy', 'organizations', 'claims', user?.id, canUsePrivateApi],
|
|
23
|
+
queryFn: ({
|
|
24
|
+
pageParam
|
|
25
|
+
}) => oxyServices.organizations.myClaims({
|
|
26
|
+
limit: 20,
|
|
27
|
+
...(pageParam ? {
|
|
28
|
+
cursor: pageParam
|
|
29
|
+
} : {})
|
|
30
|
+
}),
|
|
31
|
+
initialPageParam: undefined,
|
|
32
|
+
getNextPageParam: page => page.nextCursor ?? undefined,
|
|
33
|
+
enabled,
|
|
34
|
+
retry: false,
|
|
35
|
+
gcTime: 0
|
|
36
|
+
});
|
|
37
|
+
const claims = requests.data?.pages.flatMap(page => page.items) ?? [];
|
|
38
|
+
const ids = [...new Set(claims.map(claim => claim.accountId))].sort();
|
|
39
|
+
const organizations = useQuery({
|
|
40
|
+
queryKey: ['oxy', 'organizations', 'claims-employers', ids],
|
|
41
|
+
queryFn: async () => {
|
|
42
|
+
const batches = [];
|
|
43
|
+
for (let offset = 0; offset < ids.length; offset += 100) batches.push(oxyServices.organizations.batch({
|
|
44
|
+
ids: ids.slice(offset, offset + 100)
|
|
45
|
+
}));
|
|
46
|
+
return (await Promise.all(batches)).flatMap(batch => batch.items);
|
|
47
|
+
},
|
|
48
|
+
enabled: enabled && ids.length > 0,
|
|
49
|
+
retry: false
|
|
50
|
+
});
|
|
51
|
+
if (!enabled || !requests.isError && claims.length === 0) return null;
|
|
52
|
+
return /*#__PURE__*/_jsxs(SettingsListGroup, {
|
|
53
|
+
title: t('organizationDirectory.requests'),
|
|
54
|
+
children: [requests.isError ? /*#__PURE__*/_jsxs(View, {
|
|
55
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
56
|
+
accessibilityRole: "alert",
|
|
57
|
+
children: t('organizationDirectory.requestError')
|
|
58
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
59
|
+
onPress: () => requests.refetch(),
|
|
60
|
+
children: t('organizationDirectory.retry')
|
|
61
|
+
})]
|
|
62
|
+
}) : null, !requests.isError && claims.map(claim => /*#__PURE__*/_jsx(SettingsListItem, {
|
|
63
|
+
title: organizations.data?.find(item => item.requestedAccountId === claim.accountId)?.organization.name ?? t('organizationDirectory.view'),
|
|
64
|
+
description: t(`organizationDirectory.${claim.status}`),
|
|
65
|
+
showChevron: false
|
|
66
|
+
}, claim.id)), !requests.isError && requests.hasNextPage ? /*#__PURE__*/_jsx(Button, {
|
|
67
|
+
onPress: () => requests.fetchNextPage(),
|
|
68
|
+
disabled: requests.isFetchingNextPage,
|
|
69
|
+
children: t('organizationDirectory.loadMore')
|
|
70
|
+
}) : null]
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=OrganizationClaims.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["View","useInfiniteQuery","useQuery","Button","SettingsListGroup","SettingsListItem","Text","useOxy","useI18n","jsx","_jsx","jsxs","_jsxs","OrganizationClaims","oxyServices","user","canUsePrivateApi","t","enabled","kind","requests","queryKey","id","queryFn","pageParam","organizations","myClaims","limit","cursor","initialPageParam","undefined","getNextPageParam","page","nextCursor","retry","gcTime","claims","data","pages","flatMap","items","ids","Set","map","claim","accountId","sort","batches","offset","length","push","batch","slice","Promise","all","isError","title","children","accessibilityRole","onPress","refetch","find","item","requestedAccountId","organization","name","description","status","showChevron","hasNextPage","fetchNextPage","disabled","isFetchingNextPage"],"sourceRoot":"../../../../../src","sources":["ui/components/organizations/OrganizationClaims.tsx"],"mappings":";;AAAA,SAASA,IAAI,QAAQ,cAAc;AACnC,SAASC,gBAAgB,EAAEC,QAAQ,QAAQ,uBAAuB;AAClE,SAASC,MAAM,QAAQ,sBAAsB;AAC7C,SAASC,iBAAiB,EAAEC,gBAAgB,QAAQ,6BAA6B;AACjF,SAASC,IAAI,QAAQ,0BAA0B;AAC/C,SAASC,MAAM,QAAQ,6BAA0B;AACjD,SAASC,OAAO,QAAQ,wBAAqB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE9C,OAAO,SAASC,kBAAkBA,CAAA,EAAG;EACnC,MAAM;IAAEC,WAAW;IAAEC,IAAI;IAAEC;EAAiB,CAAC,GAAGT,MAAM,CAAC,CAAC;EACxD,MAAM;IAAEU;EAAE,CAAC,GAAGT,OAAO,CAAC,CAAC;EACvB,MAAMU,OAAO,GAAGF,gBAAgB,IAAID,IAAI,EAAEI,IAAI,KAAK,UAAU;EAC7D,MAAMC,QAAQ,GAAGnB,gBAAgB,CAAC;IAChCoB,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,EA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AAInC,QAAQ,CAACiD,WAAW,gBACxC3D,IAAA,CAACP,MAAM;MAACwD,OAAO,EAAEA,CAAA,KAAMvC,QAAQ,CAACkD,aAAa,CAAC,CAAE;MAACC,QAAQ,EAAEnD,QAAQ,CAACoD,kBAAmB;MAAAf,QAAA,EACpFxC,CAAC,CAAC,gCAAgC;IAAC,CAC9B,CAAC,GACP,IAAI;EAAA,CACS,CAAC;AAExB","ignoreList":[]}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { ActivityIndicator, View } from 'react-native';
|
|
5
|
+
import { useInfiniteQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
|
6
|
+
import { createOrganizationSchema, organizationClaimInputSchema } from '@oxy.so/contracts';
|
|
7
|
+
import { Avatar } from '@oxy.so/bloom/avatar';
|
|
8
|
+
import { Button } from '@oxy.so/bloom/button';
|
|
9
|
+
import { SettingsListGroup, SettingsListItem } from '@oxy.so/bloom/settings-list';
|
|
10
|
+
import { TextField, TextFieldInput } from '@oxy.so/bloom/text-field';
|
|
11
|
+
import { Text } from '@oxy.so/bloom/typography';
|
|
12
|
+
import { useOxy } from "../../context/OxyContext.js";
|
|
13
|
+
import { useI18n } from "../../hooks/useI18n.js";
|
|
14
|
+
import { OrganizationTypePicker } from "./OrganizationTypePicker.js";
|
|
15
|
+
|
|
16
|
+
/** Finding an existing identity never grants ownership or silently creates an account. */
|
|
17
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
+
export function OrganizationDirectorySearch({
|
|
19
|
+
onCreateAccount
|
|
20
|
+
}) {
|
|
21
|
+
const {
|
|
22
|
+
oxyServices,
|
|
23
|
+
user,
|
|
24
|
+
canUsePrivateApi
|
|
25
|
+
} = useOxy();
|
|
26
|
+
const {
|
|
27
|
+
t
|
|
28
|
+
} = useI18n();
|
|
29
|
+
const queryClient = useQueryClient();
|
|
30
|
+
const [search, setSearch] = useState('');
|
|
31
|
+
const [query, setQuery] = useState('');
|
|
32
|
+
const [selected, setSelected] = useState(null);
|
|
33
|
+
const [adding, setAdding] = useState(false);
|
|
34
|
+
const [type, setType] = useState('business');
|
|
35
|
+
const [evidence, setEvidence] = useState('');
|
|
36
|
+
const [validationError, setValidationError] = useState(false);
|
|
37
|
+
const personalReady = canUsePrivateApi && user?.kind === 'personal';
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
const timer = setTimeout(() => setQuery(search.trim()), 300);
|
|
40
|
+
return () => clearTimeout(timer);
|
|
41
|
+
}, [search]);
|
|
42
|
+
const results = useInfiniteQuery({
|
|
43
|
+
queryKey: ['oxy', 'organizations', 'search', query],
|
|
44
|
+
queryFn: ({
|
|
45
|
+
pageParam
|
|
46
|
+
}) => oxyServices.organizations.search({
|
|
47
|
+
query,
|
|
48
|
+
limit: 20,
|
|
49
|
+
...(pageParam ? {
|
|
50
|
+
cursor: pageParam
|
|
51
|
+
} : {})
|
|
52
|
+
}),
|
|
53
|
+
initialPageParam: undefined,
|
|
54
|
+
getNextPageParam: page => page.nextCursor ?? undefined,
|
|
55
|
+
enabled: query.length > 0,
|
|
56
|
+
retry: false
|
|
57
|
+
});
|
|
58
|
+
const claim = useMutation({
|
|
59
|
+
mutationFn: () => {
|
|
60
|
+
if (!personalReady || !selected || selected.status !== 'active') throw new Error('An active organization and personal session are required');
|
|
61
|
+
return oxyServices.organizations.claim(selected.accountId, organizationClaimInputSchema.parse({
|
|
62
|
+
evidenceReference: evidence
|
|
63
|
+
}));
|
|
64
|
+
},
|
|
65
|
+
onSuccess: () => queryClient.invalidateQueries({
|
|
66
|
+
queryKey: ['oxy', 'organizations']
|
|
67
|
+
})
|
|
68
|
+
});
|
|
69
|
+
const create = useMutation({
|
|
70
|
+
mutationFn: () => {
|
|
71
|
+
if (!personalReady) throw new Error('A personal session is required');
|
|
72
|
+
return oxyServices.organizations.create(createOrganizationSchema.parse({
|
|
73
|
+
name: search.trim(),
|
|
74
|
+
organizationType: type
|
|
75
|
+
}));
|
|
76
|
+
},
|
|
77
|
+
onSuccess: organization => {
|
|
78
|
+
setSelected(organization);
|
|
79
|
+
setAdding(false);
|
|
80
|
+
void queryClient.invalidateQueries({
|
|
81
|
+
queryKey: ['oxy', 'organizations']
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
const reset = () => {
|
|
86
|
+
setSelected(null);
|
|
87
|
+
setAdding(false);
|
|
88
|
+
setEvidence('');
|
|
89
|
+
claim.reset();
|
|
90
|
+
create.reset();
|
|
91
|
+
setValidationError(false);
|
|
92
|
+
};
|
|
93
|
+
if (selected) return /*#__PURE__*/_jsx(SettingsListGroup, {
|
|
94
|
+
title: selected.name,
|
|
95
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
96
|
+
className: "gap-space-16 p-space-16",
|
|
97
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
98
|
+
children: t(`organizationDirectory.${selected.claimStatus}`)
|
|
99
|
+
}), selected.status === 'inactive' ? /*#__PURE__*/_jsx(Text, {
|
|
100
|
+
children: t('organizationDirectory.inactive')
|
|
101
|
+
}) : null, selected.claimStatus === 'unclaimed' ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
102
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
103
|
+
children: t('organizationDirectory.claimHint')
|
|
104
|
+
}), /*#__PURE__*/_jsx(TextField, {
|
|
105
|
+
children: /*#__PURE__*/_jsx(TextFieldInput, {
|
|
106
|
+
label: t('organizationDirectory.evidence'),
|
|
107
|
+
value: evidence,
|
|
108
|
+
onChangeText: setEvidence,
|
|
109
|
+
maxLength: 1000
|
|
110
|
+
})
|
|
111
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
112
|
+
children: t('organizationDirectory.evidenceHint')
|
|
113
|
+
}), claim.isSuccess ? /*#__PURE__*/_jsx(Text, {
|
|
114
|
+
accessibilityRole: "alert",
|
|
115
|
+
children: t('organizationDirectory.claimSent')
|
|
116
|
+
}) : /*#__PURE__*/_jsx(Button, {
|
|
117
|
+
onPress: () => claim.mutate(),
|
|
118
|
+
disabled: !personalReady || selected.status !== 'active' || !evidence.trim() || claim.isPending,
|
|
119
|
+
loading: claim.isPending,
|
|
120
|
+
children: t('organizationDirectory.claim')
|
|
121
|
+
}), claim.isError ? /*#__PURE__*/_jsx(Text, {
|
|
122
|
+
accessibilityRole: "alert",
|
|
123
|
+
children: t('organizationDirectory.claimFailed')
|
|
124
|
+
}) : null]
|
|
125
|
+
}) : /*#__PURE__*/_jsx(Text, {
|
|
126
|
+
children: t('organizationDirectory.claimedHint')
|
|
127
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
128
|
+
appearance: "outline",
|
|
129
|
+
onPress: reset,
|
|
130
|
+
disabled: claim.isPending,
|
|
131
|
+
children: t('organizationDirectory.back')
|
|
132
|
+
})]
|
|
133
|
+
})
|
|
134
|
+
});
|
|
135
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
136
|
+
className: "gap-space-16",
|
|
137
|
+
children: [/*#__PURE__*/_jsx(TextField, {
|
|
138
|
+
children: /*#__PURE__*/_jsx(TextFieldInput, {
|
|
139
|
+
label: t('organizationDirectory.search'),
|
|
140
|
+
value: search,
|
|
141
|
+
onChangeText: value => {
|
|
142
|
+
setSearch(value);
|
|
143
|
+
setValidationError(false);
|
|
144
|
+
},
|
|
145
|
+
maxLength: 200
|
|
146
|
+
})
|
|
147
|
+
}), query && results.isPending ? /*#__PURE__*/_jsx(ActivityIndicator, {}) : null, results.isError ? /*#__PURE__*/_jsxs(View, {
|
|
148
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
149
|
+
accessibilityRole: "alert",
|
|
150
|
+
children: t('organizationDirectory.failed')
|
|
151
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
152
|
+
onPress: () => results.refetch(),
|
|
153
|
+
children: t('organizationDirectory.retry')
|
|
154
|
+
})]
|
|
155
|
+
}) : null, results.data ? /*#__PURE__*/_jsxs(SettingsListGroup, {
|
|
156
|
+
title: t('organizationDirectory.title'),
|
|
157
|
+
children: [results.data.pages.flatMap(page => page.items).map(organization => /*#__PURE__*/_jsx(SettingsListItem, {
|
|
158
|
+
title: organization.name,
|
|
159
|
+
description: [organization.websiteUrl, organization.countryCode, t(`organizationDirectory.${organization.claimStatus}`)].filter(Boolean).join(' · '),
|
|
160
|
+
icon: /*#__PURE__*/_jsx(Avatar, {
|
|
161
|
+
source: organization.avatar,
|
|
162
|
+
name: organization.name,
|
|
163
|
+
size: 40
|
|
164
|
+
}),
|
|
165
|
+
onPress: () => setSelected(organization)
|
|
166
|
+
}, organization.accountId)), results.data.pages[0].items.length === 0 ? /*#__PURE__*/_jsx(Text, {
|
|
167
|
+
children: t('organizationDirectory.empty')
|
|
168
|
+
}) : null, results.hasNextPage ? /*#__PURE__*/_jsx(Button, {
|
|
169
|
+
onPress: () => results.fetchNextPage(),
|
|
170
|
+
disabled: results.isFetchingNextPage,
|
|
171
|
+
children: t('organizationDirectory.loadMore')
|
|
172
|
+
}) : null]
|
|
173
|
+
}) : null, results.isSuccess && query === search.trim() ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
174
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
175
|
+
children: t('organizationDirectory.newAccountHint')
|
|
176
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
177
|
+
onPress: () => onCreateAccount(search.trim(), type),
|
|
178
|
+
children: t('organizationDirectory.newAccount')
|
|
179
|
+
}), personalReady && !adding ? /*#__PURE__*/_jsx(Button, {
|
|
180
|
+
appearance: "outline",
|
|
181
|
+
onPress: () => setAdding(true),
|
|
182
|
+
children: t('organizationDirectory.addDirectory')
|
|
183
|
+
}) : null]
|
|
184
|
+
}) : null, adding ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
185
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
186
|
+
children: t('organizationDirectory.directoryHint')
|
|
187
|
+
}), /*#__PURE__*/_jsx(OrganizationTypePicker, {
|
|
188
|
+
value: type,
|
|
189
|
+
onChange: setType,
|
|
190
|
+
disabled: create.isPending
|
|
191
|
+
}), validationError ? /*#__PURE__*/_jsx(Text, {
|
|
192
|
+
accessibilityRole: "alert",
|
|
193
|
+
children: t('organizationDirectory.invalid')
|
|
194
|
+
}) : null, create.isError ? /*#__PURE__*/_jsx(Text, {
|
|
195
|
+
accessibilityRole: "alert",
|
|
196
|
+
children: t('organizationDirectory.saveFailed')
|
|
197
|
+
}) : null, /*#__PURE__*/_jsx(Button, {
|
|
198
|
+
disabled: !personalReady || create.isPending || !results.isSuccess || query !== search.trim(),
|
|
199
|
+
loading: create.isPending,
|
|
200
|
+
onPress: () => {
|
|
201
|
+
if (!createOrganizationSchema.safeParse({
|
|
202
|
+
name: search.trim(),
|
|
203
|
+
organizationType: type
|
|
204
|
+
}).success) {
|
|
205
|
+
setValidationError(true);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
create.mutate();
|
|
209
|
+
},
|
|
210
|
+
children: t('organizationDirectory.addDirectory')
|
|
211
|
+
})]
|
|
212
|
+
}) : null]
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
//# sourceMappingURL=OrganizationDirectorySearch.js.map
|