@adminide-stack/yantra-mobile 12.0.162-alpha.1 → 12.0.162
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/components/CustomDrawer.js +70 -3
- package/lib/components/CustomDrawer.js.map +1 -1
- package/lib/compute.js +3 -1
- package/lib/config/env-config.js +4 -0
- package/lib/config/env-config.js.map +1 -1
- package/lib/features/credits/credits.js +151 -0
- package/lib/features/credits/credits.js.map +1 -0
- package/lib/features/credits/useLlmCredits.js +87 -0
- package/lib/features/credits/useLlmCredits.js.map +1 -0
- package/lib/features/design/surface/agentWriter.js +39 -0
- package/lib/features/design/surface/agentWriter.js.map +1 -0
- package/lib/features/design/surface/brandKit.js +9 -3
- package/lib/features/design/surface/brandKit.js.map +1 -1
- package/lib/features/design/surface/useBrandKitInUse.js.map +1 -1
- package/lib/features/design/surface/useDesignSurface.js +5 -39
- package/lib/features/design/surface/useDesignSurface.js.map +1 -1
- package/lib/features/webbuilder/WebBuilderExperience.js +64 -23
- package/lib/features/webbuilder/WebBuilderExperience.js.map +1 -1
- package/lib/features/webbuilder/brandKitMove.js +52 -0
- package/lib/features/webbuilder/brandKitMove.js.map +1 -0
- package/lib/features/webbuilder/codeToolbox.js +129 -0
- package/lib/features/webbuilder/codeToolbox.js.map +1 -0
- package/lib/features/webbuilder/components/CloudSheet.js +1451 -0
- package/lib/features/webbuilder/components/CloudSheet.js.map +1 -0
- package/lib/features/webbuilder/components/CodeActionsSheet.js +125 -0
- package/lib/features/webbuilder/components/CodeActionsSheet.js.map +1 -0
- package/lib/features/webbuilder/components/CodeView.js +10 -3
- package/lib/features/webbuilder/components/CodeView.js.map +1 -1
- package/lib/features/webbuilder/components/Composer.js.map +1 -1
- package/lib/features/webbuilder/components/IntegrationsPanel.js +643 -0
- package/lib/features/webbuilder/components/IntegrationsPanel.js.map +1 -0
- package/lib/features/webbuilder/components/ProjectChat.js +57 -44
- package/lib/features/webbuilder/components/ProjectChat.js.map +1 -1
- package/lib/features/webbuilder/components/SecretsSheet.js +235 -0
- package/lib/features/webbuilder/components/SecretsSheet.js.map +1 -0
- package/lib/features/webbuilder/components/StudioHome.js +38 -1
- package/lib/features/webbuilder/components/StudioHome.js.map +1 -1
- package/lib/features/webbuilder/studioCatalog.js +4 -19
- package/lib/features/webbuilder/studioCatalog.js.map +1 -1
- package/lib/features/webbuilder/web/data/cloud.js +387 -0
- package/lib/features/webbuilder/web/data/cloud.js.map +1 -0
- package/lib/features/webbuilder/web/data/dataApi.js +227 -0
- package/lib/features/webbuilder/web/data/dataApi.js.map +1 -0
- package/lib/features/webbuilder/web/data/database.js +190 -0
- package/lib/features/webbuilder/web/data/database.js.map +1 -0
- package/lib/features/webbuilder/web/data/graphql.js +95 -0
- package/lib/features/webbuilder/web/data/graphql.js.map +1 -0
- package/lib/features/webbuilder/web/design/directions.js +343 -0
- package/lib/features/webbuilder/web/design/directions.js.map +1 -0
- package/lib/features/webbuilder/web/integrations/appToken.js +165 -0
- package/lib/features/webbuilder/web/integrations/appToken.js.map +1 -0
- package/lib/features/webbuilder/web/integrations/catalog.js +238 -0
- package/lib/features/webbuilder/web/integrations/catalog.js.map +1 -0
- package/lib/features/webbuilder/web/integrations/siteBilling.js +67 -0
- package/lib/features/webbuilder/web/integrations/siteBilling.js.map +1 -0
- package/lib/features/webbuilder/web/integrations/siteMail.js +190 -0
- package/lib/features/webbuilder/web/integrations/siteMail.js.map +1 -0
- package/lib/features/webbuilder/web/project/projectSettings.js +11 -0
- package/lib/features/webbuilder/web/project/projectSettings.js.map +1 -0
- package/lib/features/webbuilder/web/project/restorePoint.js +16 -0
- package/lib/features/webbuilder/web/project/restorePoint.js.map +1 -0
- package/lib/features/webbuilder/web/project/serverSettings.js +157 -0
- package/lib/features/webbuilder/web/project/serverSettings.js.map +1 -0
- package/lib/features/webbuilder/web/secrets/secrets.js +162 -0
- package/lib/features/webbuilder/web/secrets/secrets.js.map +1 -0
- package/lib/features/webbuilder/web/secrets/secretsApi.js +302 -0
- package/lib/features/webbuilder/web/secrets/secretsApi.js.map +1 -0
- package/lib/features/webbuilder/web/secrets/secretsStore.js +39 -0
- package/lib/features/webbuilder/web/secrets/secretsStore.js.map +1 -0
- package/lib/features/webbuilder/web/sharing/okResult.js +40 -0
- package/lib/features/webbuilder/web/sharing/okResult.js.map +1 -0
- package/lib/features/webbuilder/web/sharing/roles.js +3 -0
- package/lib/features/webbuilder/web/sharing/roles.js.map +1 -0
- package/lib/features/webbuilder/web/state/storageKeys.js +59 -0
- package/lib/features/webbuilder/web/state/storageKeys.js.map +1 -0
- package/lib/features/webbuilder/web/webServices.js +282 -0
- package/lib/features/webbuilder/web/webServices.js.map +1 -0
- package/lib/features/webbuilder/workflow.js +1 -1
- package/lib/features/webbuilder/workflow.js.map +1 -1
- package/lib/routes.json +3 -1
- package/lib/screens/Account/AccountSheets.js +1049 -0
- package/lib/screens/Account/AccountSheets.js.map +1 -0
- package/lib/screens/Account/WorkspaceSection.js +271 -0
- package/lib/screens/Account/WorkspaceSection.js.map +1 -0
- package/lib/screens/Account/accountRules.js +103 -0
- package/lib/screens/Account/accountRules.js.map +1 -0
- package/lib/screens/Account/index.js +563 -259
- package/lib/screens/Account/index.js.map +1 -1
- package/lib/screens/Account/useAccountPreferences.js +87 -0
- package/lib/screens/Account/useAccountPreferences.js.map +1 -0
- package/lib/screens/WebBuilderNative/index.js +1 -1
- package/lib/screens/WebBuilderNative/index.js.map +1 -1
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js +122 -12
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js.map +1 -1
- package/lib/utils/authUserDisplay.js +1 -9
- package/lib/utils/authUserDisplay.js.map +1 -1
- package/package.json +4 -4
- package/lib/features/webbuilder/brandKitStorage.js +0 -69
- package/lib/features/webbuilder/brandKitStorage.js.map +0 -1
- package/lib/features/webbuilder/components/BrandKitSheet.js +0 -197
- package/lib/features/webbuilder/components/BrandKitSheet.js.map +0 -1
- package/lib/screens/Account/splitDisplayName.js +0 -15
- package/lib/screens/Account/splitDisplayName.js.map +0 -1
|
@@ -0,0 +1,1049 @@
|
|
|
1
|
+
import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useState,useRef,useEffect,useMemo,useCallback}from'react';import {View,StyleSheet,Image,ActivityIndicator,Pressable,TextInput,ScrollView,Modal,KeyboardAvoidingView,Platform}from'react-native';import {Ionicons}from'@expo/vector-icons';import {Text}from'@admin-layout/gluestack-ui-mobile';import {useLazyQuery,gql}from'@apollo/client/index.js';import {useDispatch}from'react-redux';import {updateUserProfile}from'@adminide-stack/user-auth0-client';import {useAccountProfileQuery,useCreateFileUploadLinksMutation,useUploadAccountProfilePhotoMutation,useDeleteAccountProfilePhotoMutation,useSetNameMutation,useUpdateUserProfileMutation,useIsUsernameAvailableLazyQuery,useSetGenderMutation,useSetDobMutation,useSetEmailAddressMutation,useSendEmailOtpMutation,useAddPhoneNumberMutation,useRemovePhoneNumberMutation,useSendPhoneOtpMutation}from'common/graphql';import {mobileTokens}from'../../theme/mobileTokens.js';import {USERNAME_HINT,GENDER_OPTIONS,savedDay,MONTHS,daysInMonth,isNewEmail,VERIFICATION_CODE_LENGTH,formatPhoneCode,looksLikePhoneNumber,USERNAME_SHAPE,USERNAME_INVALID,USERNAME_TAKEN,USERNAME_SAVE_FAILED,dobValue,RESEND_AFTER_SECONDS,contactCodeError,retryAfterSeconds,CODE_TTL_MINUTES}from'./accountRules.js';var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
const REFETCH = ["GetExtendedUserAccount"];
|
|
33
|
+
const OWN_ACCOUNT_ID = gql`
|
|
34
|
+
query OwnAccountId {
|
|
35
|
+
getExtendedUserAccount {
|
|
36
|
+
id
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
function useResendCountdown() {
|
|
41
|
+
const [secondsLeft, setSecondsLeft] = useState(0);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (secondsLeft <= 0) return void 0;
|
|
44
|
+
const timer = setTimeout(() => setSecondsLeft((s) => s - 1), 1e3);
|
|
45
|
+
return () => clearTimeout(timer);
|
|
46
|
+
}, [secondsLeft]);
|
|
47
|
+
const start = useCallback((seconds = RESEND_AFTER_SECONDS) => setSecondsLeft(seconds), []);
|
|
48
|
+
const reset = useCallback(() => setSecondsLeft(0), []);
|
|
49
|
+
return {
|
|
50
|
+
secondsLeft,
|
|
51
|
+
start,
|
|
52
|
+
reset
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function Sheet({
|
|
56
|
+
visible,
|
|
57
|
+
title,
|
|
58
|
+
subtitle,
|
|
59
|
+
colors,
|
|
60
|
+
onClose,
|
|
61
|
+
onSave,
|
|
62
|
+
saveLabel = "Save",
|
|
63
|
+
saveDisabled,
|
|
64
|
+
busy,
|
|
65
|
+
children
|
|
66
|
+
}) {
|
|
67
|
+
return /* @__PURE__ */ jsx(Modal, { visible, animationType: "fade", transparent: true, onRequestClose: onClose, children: /* @__PURE__ */ jsxs(KeyboardAvoidingView, { behavior: Platform.OS === "ios" ? "padding" : void 0, style: styles.backdrop, children: [
|
|
68
|
+
/* @__PURE__ */ jsx(Pressable, { style: styles.dismiss, onPress: onClose, accessibilityLabel: "Close" }),
|
|
69
|
+
/* @__PURE__ */ jsxs(View, { accessibilityViewIsModal: true, style: [styles.card, {
|
|
70
|
+
backgroundColor: colors.surface
|
|
71
|
+
}], children: [
|
|
72
|
+
/* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: [styles.title, {
|
|
73
|
+
color: colors.text
|
|
74
|
+
}], children: title }),
|
|
75
|
+
subtitle ? /* @__PURE__ */ jsx(Text, { style: [styles.subtitle, {
|
|
76
|
+
color: colors.textMuted
|
|
77
|
+
}], children: subtitle }) : null,
|
|
78
|
+
/* @__PURE__ */ jsx(ScrollView, { style: styles.body, keyboardShouldPersistTaps: "handled", children }),
|
|
79
|
+
/* @__PURE__ */ jsxs(View, { style: styles.actions, children: [
|
|
80
|
+
/* @__PURE__ */ jsx(Pressable, { onPress: onClose, style: styles.ghost, accessibilityRole: "button", children: /* @__PURE__ */ jsx(Text, { style: [styles.ghostLabel, {
|
|
81
|
+
color: colors.textMuted
|
|
82
|
+
}], children: onSave ? "Cancel" : "Done" }) }),
|
|
83
|
+
onSave ? /* @__PURE__ */ jsx(Pressable, { onPress: onSave, disabled: saveDisabled || busy, accessibilityRole: "button", accessibilityLabel: saveLabel, style: [styles.primary, (saveDisabled || busy) && styles.dim], children: busy ? /* @__PURE__ */ jsx(ActivityIndicator, { color: "#fff" }) : /* @__PURE__ */ jsx(Text, { style: styles.primaryLabel, children: saveLabel }) }) : null
|
|
84
|
+
] })
|
|
85
|
+
] })
|
|
86
|
+
] }) });
|
|
87
|
+
}
|
|
88
|
+
function Field(_a) {
|
|
89
|
+
var _b = _a, {
|
|
90
|
+
label,
|
|
91
|
+
colors
|
|
92
|
+
} = _b, input = __objRest(_b, [
|
|
93
|
+
"label",
|
|
94
|
+
"colors"
|
|
95
|
+
]);
|
|
96
|
+
return /* @__PURE__ */ jsxs(View, { style: styles.field, children: [
|
|
97
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.fieldLabel, {
|
|
98
|
+
color: colors.textMuted
|
|
99
|
+
}], children: label }),
|
|
100
|
+
/* @__PURE__ */ jsx(TextInput, __spreadProps(__spreadValues({ placeholderTextColor: colors.textMuted }, input), { style: [styles.input, {
|
|
101
|
+
color: colors.text,
|
|
102
|
+
backgroundColor: colors.surfaceMuted,
|
|
103
|
+
borderColor: colors.border
|
|
104
|
+
}, input.style] }))
|
|
105
|
+
] });
|
|
106
|
+
}
|
|
107
|
+
const Problem = ({
|
|
108
|
+
text
|
|
109
|
+
}) => text ? /* @__PURE__ */ jsx(Text, { accessibilityRole: "alert", style: styles.error, children: text }) : null;
|
|
110
|
+
function OptionList({
|
|
111
|
+
options,
|
|
112
|
+
selected,
|
|
113
|
+
onSelect,
|
|
114
|
+
colors
|
|
115
|
+
}) {
|
|
116
|
+
return /* @__PURE__ */ jsx(View, { children: options.map((option) => {
|
|
117
|
+
const active = option.value === selected;
|
|
118
|
+
return /* @__PURE__ */ jsxs(Pressable, { onPress: () => onSelect(option.value), accessibilityRole: "button", accessibilityState: {
|
|
119
|
+
selected: active
|
|
120
|
+
}, style: ({
|
|
121
|
+
pressed
|
|
122
|
+
}) => [styles.option, active && {
|
|
123
|
+
backgroundColor: colors.primarySoft
|
|
124
|
+
}, pressed && styles.dim], children: [
|
|
125
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.optionLabel, {
|
|
126
|
+
color: active ? colors.primary : colors.text
|
|
127
|
+
}], children: option.label }),
|
|
128
|
+
active ? /* @__PURE__ */ jsx(Ionicons, { name: "checkmark", size: 18, color: colors.primary }) : null
|
|
129
|
+
] }, String(option.value));
|
|
130
|
+
}) });
|
|
131
|
+
}
|
|
132
|
+
function PickerSheet({
|
|
133
|
+
visible,
|
|
134
|
+
title,
|
|
135
|
+
options,
|
|
136
|
+
selected,
|
|
137
|
+
colors,
|
|
138
|
+
onSelect,
|
|
139
|
+
onClose
|
|
140
|
+
}) {
|
|
141
|
+
return /* @__PURE__ */ jsx(Sheet, { visible, title, colors, onClose, children: /* @__PURE__ */ jsx(OptionList, { options, selected, colors, onSelect: (value) => {
|
|
142
|
+
onSelect(value);
|
|
143
|
+
onClose();
|
|
144
|
+
} }) });
|
|
145
|
+
}
|
|
146
|
+
function NameSheet({
|
|
147
|
+
visible,
|
|
148
|
+
colors,
|
|
149
|
+
givenName,
|
|
150
|
+
familyName,
|
|
151
|
+
onClose
|
|
152
|
+
}) {
|
|
153
|
+
const [given, setGiven] = useState(givenName);
|
|
154
|
+
const [family, setFamily] = useState(familyName);
|
|
155
|
+
const [error, setError] = useState(null);
|
|
156
|
+
const [setName, {
|
|
157
|
+
loading
|
|
158
|
+
}] = useSetNameMutation();
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
if (!visible) return;
|
|
161
|
+
setGiven(givenName);
|
|
162
|
+
setFamily(familyName);
|
|
163
|
+
setError(null);
|
|
164
|
+
}, [visible, givenName, familyName]);
|
|
165
|
+
const save = async () => {
|
|
166
|
+
try {
|
|
167
|
+
await setName({
|
|
168
|
+
variables: {
|
|
169
|
+
givenName: given.trim(),
|
|
170
|
+
familyName: family.trim()
|
|
171
|
+
},
|
|
172
|
+
refetchQueries: REFETCH
|
|
173
|
+
});
|
|
174
|
+
onClose();
|
|
175
|
+
} catch (e) {
|
|
176
|
+
setError("We couldn't save your name. Try again.");
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
return /* @__PURE__ */ jsxs(Sheet, { visible, title: "Change full name", colors, onClose, onSave: save, busy: loading, children: [
|
|
180
|
+
/* @__PURE__ */ jsx(Field, { label: "First name", colors, value: given, onChangeText: setGiven, autoCapitalize: "words" }),
|
|
181
|
+
/* @__PURE__ */ jsx(Field, { label: "Last name", colors, value: family, onChangeText: setFamily, autoCapitalize: "words" }),
|
|
182
|
+
/* @__PURE__ */ jsx(Problem, { text: error })
|
|
183
|
+
] });
|
|
184
|
+
}
|
|
185
|
+
function UsernameSheet({
|
|
186
|
+
visible,
|
|
187
|
+
colors,
|
|
188
|
+
username,
|
|
189
|
+
givenName,
|
|
190
|
+
familyName,
|
|
191
|
+
onClose
|
|
192
|
+
}) {
|
|
193
|
+
const dispatch = useDispatch();
|
|
194
|
+
const [value, setValue] = useState(username);
|
|
195
|
+
const [error, setError] = useState(null);
|
|
196
|
+
const [busy, setBusy] = useState(false);
|
|
197
|
+
const [updateProfile] = useUpdateUserProfileMutation();
|
|
198
|
+
const [checkAvailable] = useIsUsernameAvailableLazyQuery({
|
|
199
|
+
fetchPolicy: "network-only"
|
|
200
|
+
});
|
|
201
|
+
const [findOwnAccount] = useLazyQuery(OWN_ACCOUNT_ID, {
|
|
202
|
+
fetchPolicy: "network-only"
|
|
203
|
+
});
|
|
204
|
+
useEffect(() => {
|
|
205
|
+
if (!visible) return;
|
|
206
|
+
setValue(username);
|
|
207
|
+
setError(null);
|
|
208
|
+
}, [visible, username]);
|
|
209
|
+
const next = value.trim().toLowerCase();
|
|
210
|
+
const save = async () => {
|
|
211
|
+
var _a;
|
|
212
|
+
if (next === username.toLowerCase()) {
|
|
213
|
+
onClose();
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (!USERNAME_SHAPE.test(next)) {
|
|
217
|
+
setError(USERNAME_INVALID);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
setBusy(true);
|
|
221
|
+
setError(null);
|
|
222
|
+
try {
|
|
223
|
+
const {
|
|
224
|
+
data: availability
|
|
225
|
+
} = await checkAvailable({
|
|
226
|
+
variables: {
|
|
227
|
+
username: next
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
if (!(availability == null ? void 0 : availability.isUsernameAvailable)) {
|
|
231
|
+
setError(USERNAME_TAKEN);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const {
|
|
235
|
+
data: own
|
|
236
|
+
} = await findOwnAccount();
|
|
237
|
+
const accountId = (_a = own == null ? void 0 : own.getExtendedUserAccount) == null ? void 0 : _a.id;
|
|
238
|
+
if (!accountId) throw new Error("The session has no account to update.");
|
|
239
|
+
await updateProfile({
|
|
240
|
+
variables: {
|
|
241
|
+
input: {
|
|
242
|
+
id: accountId,
|
|
243
|
+
username: next,
|
|
244
|
+
givenName,
|
|
245
|
+
familyName
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
refetchQueries: REFETCH
|
|
249
|
+
});
|
|
250
|
+
dispatch(updateUserProfile({
|
|
251
|
+
username: next,
|
|
252
|
+
nickname: next
|
|
253
|
+
}));
|
|
254
|
+
onClose();
|
|
255
|
+
} catch (e) {
|
|
256
|
+
setError(USERNAME_SAVE_FAILED);
|
|
257
|
+
} finally {
|
|
258
|
+
setBusy(false);
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
return /* @__PURE__ */ jsxs(Sheet, { visible, title: "Change username", colors, onClose, onSave: save, busy, saveDisabled: !next, children: [
|
|
262
|
+
/* @__PURE__ */ jsx(Field, { label: "Username", colors, value, onChangeText: (text) => {
|
|
263
|
+
setValue(text);
|
|
264
|
+
setError(null);
|
|
265
|
+
}, autoCapitalize: "none", autoCorrect: false, autoComplete: "username", maxLength: 30 }),
|
|
266
|
+
error ? /* @__PURE__ */ jsx(Problem, { text: error }) : /* @__PURE__ */ jsx(Text, { style: [styles.hint, {
|
|
267
|
+
color: colors.textMuted
|
|
268
|
+
}], children: USERNAME_HINT })
|
|
269
|
+
] });
|
|
270
|
+
}
|
|
271
|
+
function GenderSheet({
|
|
272
|
+
visible,
|
|
273
|
+
colors,
|
|
274
|
+
gender,
|
|
275
|
+
onClose
|
|
276
|
+
}) {
|
|
277
|
+
const [picked, setPicked] = useState(null);
|
|
278
|
+
const [error, setError] = useState(null);
|
|
279
|
+
const [setGender, {
|
|
280
|
+
loading
|
|
281
|
+
}] = useSetGenderMutation();
|
|
282
|
+
useEffect(() => {
|
|
283
|
+
var _a, _b;
|
|
284
|
+
if (!visible) return;
|
|
285
|
+
setPicked((_b = (_a = GENDER_OPTIONS.find((option) => option.value === (gender == null ? void 0 : gender.toUpperCase()))) == null ? void 0 : _a.value) != null ? _b : null);
|
|
286
|
+
setError(null);
|
|
287
|
+
}, [visible, gender]);
|
|
288
|
+
const save = async () => {
|
|
289
|
+
if (!picked) return;
|
|
290
|
+
try {
|
|
291
|
+
await setGender({
|
|
292
|
+
variables: {
|
|
293
|
+
gender: picked
|
|
294
|
+
},
|
|
295
|
+
refetchQueries: REFETCH
|
|
296
|
+
});
|
|
297
|
+
onClose();
|
|
298
|
+
} catch (e) {
|
|
299
|
+
setError("We couldn't save that. Try again.");
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
return /* @__PURE__ */ jsxs(Sheet, { visible, title: "Change Gender", colors, onClose, onSave: save, busy: loading, saveDisabled: !picked, children: [
|
|
303
|
+
/* @__PURE__ */ jsx(OptionList, { options: GENDER_OPTIONS, selected: picked, onSelect: (value) => setPicked(value), colors }),
|
|
304
|
+
/* @__PURE__ */ jsx(Problem, { text: error })
|
|
305
|
+
] });
|
|
306
|
+
}
|
|
307
|
+
function Column({
|
|
308
|
+
label,
|
|
309
|
+
options,
|
|
310
|
+
selected,
|
|
311
|
+
onSelect,
|
|
312
|
+
colors
|
|
313
|
+
}) {
|
|
314
|
+
return /* @__PURE__ */ jsxs(View, { style: styles.column, children: [
|
|
315
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.fieldLabel, {
|
|
316
|
+
color: colors.textMuted
|
|
317
|
+
}], children: label }),
|
|
318
|
+
/* @__PURE__ */ jsx(ScrollView, { style: [styles.columnList, {
|
|
319
|
+
borderColor: colors.border
|
|
320
|
+
}], nestedScrollEnabled: true, children: options.map((option) => {
|
|
321
|
+
const active = option.value === selected;
|
|
322
|
+
return /* @__PURE__ */ jsx(Pressable, { onPress: () => onSelect(option.value), accessibilityRole: "button", accessibilityLabel: `${label} ${option.label}`, accessibilityState: {
|
|
323
|
+
selected: active
|
|
324
|
+
}, style: [styles.columnRow, active && {
|
|
325
|
+
backgroundColor: colors.primarySoft
|
|
326
|
+
}], children: /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [styles.columnLabel, {
|
|
327
|
+
color: active ? colors.primary : colors.text
|
|
328
|
+
}], children: option.label }) }, option.value);
|
|
329
|
+
}) })
|
|
330
|
+
] });
|
|
331
|
+
}
|
|
332
|
+
function DobSheet({
|
|
333
|
+
visible,
|
|
334
|
+
colors,
|
|
335
|
+
dob,
|
|
336
|
+
onClose
|
|
337
|
+
}) {
|
|
338
|
+
const [year, setYear] = useState(1990);
|
|
339
|
+
const [month, setMonth] = useState(0);
|
|
340
|
+
const [day, setDay] = useState(1);
|
|
341
|
+
const [error, setError] = useState(null);
|
|
342
|
+
const [setDob, {
|
|
343
|
+
loading
|
|
344
|
+
}] = useSetDobMutation();
|
|
345
|
+
useEffect(() => {
|
|
346
|
+
if (!visible) return;
|
|
347
|
+
setError(null);
|
|
348
|
+
if (dob && !Number.isNaN(new Date(dob).getTime())) {
|
|
349
|
+
const saved = savedDay(dob);
|
|
350
|
+
setYear(saved.year);
|
|
351
|
+
setMonth(saved.month);
|
|
352
|
+
setDay(saved.day);
|
|
353
|
+
}
|
|
354
|
+
}, [visible, dob]);
|
|
355
|
+
const thisYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
356
|
+
const years = useMemo(() => Array.from({
|
|
357
|
+
length: thisYear - 1900
|
|
358
|
+
}, (_, i) => ({
|
|
359
|
+
value: thisYear - i,
|
|
360
|
+
label: String(thisYear - i)
|
|
361
|
+
})), [thisYear]);
|
|
362
|
+
const months = useMemo(() => MONTHS.map((label, value) => ({
|
|
363
|
+
value,
|
|
364
|
+
label: label.slice(0, 3)
|
|
365
|
+
})), []);
|
|
366
|
+
const lastDay = daysInMonth(year, month);
|
|
367
|
+
const days = useMemo(() => Array.from({
|
|
368
|
+
length: lastDay
|
|
369
|
+
}, (_, i) => ({
|
|
370
|
+
value: i + 1,
|
|
371
|
+
label: String(i + 1)
|
|
372
|
+
})), [lastDay]);
|
|
373
|
+
useEffect(() => {
|
|
374
|
+
if (day > lastDay) setDay(lastDay);
|
|
375
|
+
}, [day, lastDay]);
|
|
376
|
+
const save = async () => {
|
|
377
|
+
try {
|
|
378
|
+
await setDob({
|
|
379
|
+
variables: {
|
|
380
|
+
dob: dobValue(year, month, day)
|
|
381
|
+
},
|
|
382
|
+
refetchQueries: REFETCH
|
|
383
|
+
});
|
|
384
|
+
onClose();
|
|
385
|
+
} catch (e) {
|
|
386
|
+
setError("We couldn't save your date of birth. Try again.");
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
return /* @__PURE__ */ jsxs(Sheet, { visible, title: "Date Of Birth", colors, onClose, onSave: save, busy: loading, children: [
|
|
390
|
+
/* @__PURE__ */ jsxs(View, { style: styles.columns, children: [
|
|
391
|
+
/* @__PURE__ */ jsx(Column, { label: "Month", options: months, selected: month, onSelect: setMonth, colors }),
|
|
392
|
+
/* @__PURE__ */ jsx(Column, { label: "Day", options: days, selected: day, onSelect: setDay, colors }),
|
|
393
|
+
/* @__PURE__ */ jsx(Column, { label: "Year", options: years, selected: year, onSelect: setYear, colors })
|
|
394
|
+
] }),
|
|
395
|
+
/* @__PURE__ */ jsx(Problem, { text: error })
|
|
396
|
+
] });
|
|
397
|
+
}
|
|
398
|
+
function CodeStep({
|
|
399
|
+
sentTo,
|
|
400
|
+
code,
|
|
401
|
+
onChange,
|
|
402
|
+
invalid,
|
|
403
|
+
secondsLeft,
|
|
404
|
+
busy,
|
|
405
|
+
onResend,
|
|
406
|
+
onBack,
|
|
407
|
+
colors
|
|
408
|
+
}) {
|
|
409
|
+
return /* @__PURE__ */ jsxs(View, { children: [
|
|
410
|
+
/* @__PURE__ */ jsxs(Text, { style: [styles.hint, {
|
|
411
|
+
color: colors.textMuted
|
|
412
|
+
}], children: [
|
|
413
|
+
"Enter the 6-digit code we sent to ",
|
|
414
|
+
sentTo,
|
|
415
|
+
". It expires in ",
|
|
416
|
+
CODE_TTL_MINUTES,
|
|
417
|
+
" minutes."
|
|
418
|
+
] }),
|
|
419
|
+
/* @__PURE__ */ jsx(TextInput, { value: code, onChangeText: (text) => onChange(text.replace(/\D/g, "").slice(0, VERIFICATION_CODE_LENGTH)), keyboardType: "number-pad", textContentType: "oneTimeCode", autoComplete: "one-time-code", maxLength: VERIFICATION_CODE_LENGTH, autoFocus: true, accessibilityLabel: "Verification code", style: [styles.input, styles.code, {
|
|
420
|
+
color: colors.text,
|
|
421
|
+
backgroundColor: colors.surfaceMuted,
|
|
422
|
+
borderColor: invalid ? "#ef4444" : colors.border
|
|
423
|
+
}] }),
|
|
424
|
+
/* @__PURE__ */ jsxs(View, { style: styles.codeActions, children: [
|
|
425
|
+
/* @__PURE__ */ jsx(Pressable, { onPress: onResend, disabled: busy || secondsLeft > 0, accessibilityRole: "button", children: /* @__PURE__ */ jsx(Text, { style: [styles.link, {
|
|
426
|
+
color: secondsLeft > 0 ? colors.textMuted : colors.primary
|
|
427
|
+
}], children: secondsLeft > 0 ? `Resend code in ${secondsLeft}s` : "Resend code" }) }),
|
|
428
|
+
/* @__PURE__ */ jsx(Pressable, { onPress: onBack, disabled: busy, accessibilityRole: "button", children: /* @__PURE__ */ jsx(Text, { style: [styles.link, {
|
|
429
|
+
color: colors.primary
|
|
430
|
+
}], children: "Change" }) })
|
|
431
|
+
] })
|
|
432
|
+
] });
|
|
433
|
+
}
|
|
434
|
+
function EmailSheet({
|
|
435
|
+
visible,
|
|
436
|
+
colors,
|
|
437
|
+
email,
|
|
438
|
+
onClose
|
|
439
|
+
}) {
|
|
440
|
+
const [address, setAddress] = useState("");
|
|
441
|
+
const [step, setStep] = useState("enter");
|
|
442
|
+
const [code, setCode] = useState("");
|
|
443
|
+
const [refused, setRefused] = useState(false);
|
|
444
|
+
const [error, setError] = useState(null);
|
|
445
|
+
const [busy, setBusy] = useState(false);
|
|
446
|
+
const resend = useResendCountdown();
|
|
447
|
+
const [setEmailAddress] = useSetEmailAddressMutation();
|
|
448
|
+
const [sendEmailOtp] = useSendEmailOtpMutation();
|
|
449
|
+
const trimmed = address.trim();
|
|
450
|
+
const canSend = isNewEmail(trimmed, email);
|
|
451
|
+
useEffect(() => {
|
|
452
|
+
if (!visible) return;
|
|
453
|
+
setAddress("");
|
|
454
|
+
setStep("enter");
|
|
455
|
+
setCode("");
|
|
456
|
+
setRefused(false);
|
|
457
|
+
setError(null);
|
|
458
|
+
resend.reset();
|
|
459
|
+
}, [visible]);
|
|
460
|
+
const sendCode = async () => {
|
|
461
|
+
if (busy || !canSend) return;
|
|
462
|
+
setError(null);
|
|
463
|
+
setBusy(true);
|
|
464
|
+
try {
|
|
465
|
+
await sendEmailOtp({
|
|
466
|
+
variables: {
|
|
467
|
+
email: trimmed
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
setStep("verify");
|
|
471
|
+
setCode("");
|
|
472
|
+
setRefused(false);
|
|
473
|
+
resend.start();
|
|
474
|
+
} catch (err) {
|
|
475
|
+
setError(contactCodeError(err, "We couldn't send a code. Try again."));
|
|
476
|
+
const wait = retryAfterSeconds(err);
|
|
477
|
+
if (wait) resend.start(wait);
|
|
478
|
+
} finally {
|
|
479
|
+
setBusy(false);
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
const verify = async () => {
|
|
483
|
+
if (busy || code.length !== VERIFICATION_CODE_LENGTH) return;
|
|
484
|
+
setError(null);
|
|
485
|
+
setBusy(true);
|
|
486
|
+
try {
|
|
487
|
+
await setEmailAddress({
|
|
488
|
+
variables: {
|
|
489
|
+
email: trimmed,
|
|
490
|
+
otp: code
|
|
491
|
+
},
|
|
492
|
+
refetchQueries: REFETCH
|
|
493
|
+
});
|
|
494
|
+
onClose();
|
|
495
|
+
} catch (err) {
|
|
496
|
+
setRefused(true);
|
|
497
|
+
setError(contactCodeError(err, "We couldn't check that code. Try again."));
|
|
498
|
+
} finally {
|
|
499
|
+
setBusy(false);
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
return /* @__PURE__ */ jsxs(Sheet, { visible, title: step === "verify" ? "Verify email address" : "Change email address", colors, onClose, onSave: step === "enter" ? sendCode : verify, saveLabel: step === "enter" ? "Send code" : "Verify", saveDisabled: step === "enter" ? !canSend : code.length !== VERIFICATION_CODE_LENGTH, busy, children: [
|
|
503
|
+
/* @__PURE__ */ jsx(Problem, { text: error }),
|
|
504
|
+
step === "enter" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
505
|
+
/* @__PURE__ */ jsx(Field, { label: "New email address", colors, value: address, onChangeText: setAddress, placeholder: email || "name@example.com", keyboardType: "email-address", autoCapitalize: "none", autoCorrect: false, autoComplete: "email", autoFocus: true }),
|
|
506
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.hint, {
|
|
507
|
+
color: colors.textMuted
|
|
508
|
+
}], children: "We'll email a 6-digit code to the new address to confirm it's yours." })
|
|
509
|
+
] }) : /* @__PURE__ */ jsx(CodeStep, { sentTo: trimmed, code, onChange: (next) => {
|
|
510
|
+
setCode(next);
|
|
511
|
+
setRefused(false);
|
|
512
|
+
}, invalid: refused, secondsLeft: resend.secondsLeft, busy, onResend: () => void sendCode(), onBack: () => setStep("enter"), colors })
|
|
513
|
+
] });
|
|
514
|
+
}
|
|
515
|
+
function PhoneSheet({
|
|
516
|
+
visible,
|
|
517
|
+
colors,
|
|
518
|
+
numbers,
|
|
519
|
+
countries,
|
|
520
|
+
onClose
|
|
521
|
+
}) {
|
|
522
|
+
const [countryIndex, setCountryIndex] = useState(0);
|
|
523
|
+
const [pickingCountry, setPickingCountry] = useState(false);
|
|
524
|
+
const [countryQuery, setCountryQuery] = useState("");
|
|
525
|
+
const [number, setNumber] = useState("");
|
|
526
|
+
const [step, setStep] = useState("enter");
|
|
527
|
+
const [code, setCode] = useState("");
|
|
528
|
+
const [refused, setRefused] = useState(false);
|
|
529
|
+
const [error, setError] = useState(null);
|
|
530
|
+
const [busy, setBusy] = useState(false);
|
|
531
|
+
const resend = useResendCountdown();
|
|
532
|
+
const [addPhoneNumber] = useAddPhoneNumberMutation();
|
|
533
|
+
const [removePhoneNumber] = useRemovePhoneNumberMutation();
|
|
534
|
+
const [sendPhoneOtp] = useSendPhoneOtpMutation();
|
|
535
|
+
useEffect(() => {
|
|
536
|
+
if (!countries.length) return;
|
|
537
|
+
const preferred = countries.findIndex((country2) => country2.name === "United States");
|
|
538
|
+
setCountryIndex(preferred >= 0 ? preferred : 0);
|
|
539
|
+
}, [countries]);
|
|
540
|
+
useEffect(() => {
|
|
541
|
+
if (!visible) return;
|
|
542
|
+
setNumber("");
|
|
543
|
+
setStep("enter");
|
|
544
|
+
setCode("");
|
|
545
|
+
setRefused(false);
|
|
546
|
+
setError(null);
|
|
547
|
+
setPickingCountry(false);
|
|
548
|
+
setCountryQuery("");
|
|
549
|
+
resend.reset();
|
|
550
|
+
}, [visible]);
|
|
551
|
+
const country = countries[countryIndex];
|
|
552
|
+
const dialCode = formatPhoneCode(country == null ? void 0 : country.phoneCode);
|
|
553
|
+
const visibleCountries = useMemo(() => {
|
|
554
|
+
const query = countryQuery.trim().toLowerCase();
|
|
555
|
+
const all = countries.map((item, index) => ({
|
|
556
|
+
item,
|
|
557
|
+
index
|
|
558
|
+
}));
|
|
559
|
+
return query ? all.filter(({
|
|
560
|
+
item
|
|
561
|
+
}) => item.name.toLowerCase().includes(query) || formatPhoneCode(item.phoneCode).includes(query)) : all;
|
|
562
|
+
}, [countries, countryQuery]);
|
|
563
|
+
const codeFor = (countryCode) => {
|
|
564
|
+
var _a;
|
|
565
|
+
return formatPhoneCode((_a = countries.find((item) => item.id === countryCode)) == null ? void 0 : _a.phoneCode) || countryCode;
|
|
566
|
+
};
|
|
567
|
+
const phoneInput = () => ({
|
|
568
|
+
countryCode: country == null ? void 0 : country.id,
|
|
569
|
+
phoneNumber: number
|
|
570
|
+
});
|
|
571
|
+
const sendCode = async () => {
|
|
572
|
+
if (!country) {
|
|
573
|
+
setError("Select a country code first.");
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
setError(null);
|
|
577
|
+
setBusy(true);
|
|
578
|
+
try {
|
|
579
|
+
await sendPhoneOtp({
|
|
580
|
+
variables: {
|
|
581
|
+
phoneNumber: phoneInput()
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
setStep("verify");
|
|
585
|
+
setCode("");
|
|
586
|
+
setRefused(false);
|
|
587
|
+
resend.start();
|
|
588
|
+
} catch (err) {
|
|
589
|
+
setError(contactCodeError(err, "We couldn't send a code. Try again."));
|
|
590
|
+
const wait = retryAfterSeconds(err);
|
|
591
|
+
if (wait) resend.start(wait);
|
|
592
|
+
} finally {
|
|
593
|
+
setBusy(false);
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
const verify = async () => {
|
|
597
|
+
if (busy || code.length !== VERIFICATION_CODE_LENGTH) return;
|
|
598
|
+
setError(null);
|
|
599
|
+
setBusy(true);
|
|
600
|
+
try {
|
|
601
|
+
await addPhoneNumber({
|
|
602
|
+
variables: {
|
|
603
|
+
phoneNumber: phoneInput(),
|
|
604
|
+
otp: code
|
|
605
|
+
},
|
|
606
|
+
refetchQueries: REFETCH
|
|
607
|
+
});
|
|
608
|
+
onClose();
|
|
609
|
+
} catch (err) {
|
|
610
|
+
setRefused(true);
|
|
611
|
+
setError(contactCodeError(err, "We couldn't check that code. Try again."));
|
|
612
|
+
} finally {
|
|
613
|
+
setBusy(false);
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
const remove = async (saved) => {
|
|
617
|
+
setError(null);
|
|
618
|
+
try {
|
|
619
|
+
await removePhoneNumber({
|
|
620
|
+
variables: {
|
|
621
|
+
phoneNumber: {
|
|
622
|
+
countryCode: saved.countryCode,
|
|
623
|
+
phoneNumber: saved.phoneNumber
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
refetchQueries: REFETCH
|
|
627
|
+
});
|
|
628
|
+
} catch (e) {
|
|
629
|
+
setError("We couldn't remove that number. Try again.");
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
return /* @__PURE__ */ jsxs(Sheet, { visible, title: step === "verify" ? "Verify phone number" : "Phone Number", colors, onClose, onSave: step === "enter" ? sendCode : verify, saveLabel: step === "enter" ? "Next" : "Verify", saveDisabled: step === "enter" ? !country || !looksLikePhoneNumber(number) : code.length !== VERIFICATION_CODE_LENGTH, busy, children: [
|
|
633
|
+
/* @__PURE__ */ jsx(Problem, { text: error }),
|
|
634
|
+
step === "verify" ? /* @__PURE__ */ jsx(CodeStep, { sentTo: `${dialCode} ${number}`, code, onChange: (next) => {
|
|
635
|
+
setCode(next);
|
|
636
|
+
setRefused(false);
|
|
637
|
+
}, invalid: refused, secondsLeft: resend.secondsLeft, busy, onResend: () => void sendCode(), onBack: () => setStep("enter"), colors }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
638
|
+
numbers.length ? /* @__PURE__ */ jsxs(View, { style: styles.field, children: [
|
|
639
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.fieldLabel, {
|
|
640
|
+
color: colors.textMuted
|
|
641
|
+
}], children: "Registered numbers" }),
|
|
642
|
+
numbers.map((saved) => /* @__PURE__ */ jsxs(View, { style: [styles.saved, {
|
|
643
|
+
borderColor: colors.border
|
|
644
|
+
}], children: [
|
|
645
|
+
/* @__PURE__ */ jsxs(Text, { style: [styles.optionLabel, {
|
|
646
|
+
color: colors.text
|
|
647
|
+
}], children: [
|
|
648
|
+
codeFor(saved.countryCode),
|
|
649
|
+
" ",
|
|
650
|
+
saved.phoneNumber
|
|
651
|
+
] }),
|
|
652
|
+
/* @__PURE__ */ jsx(Pressable, { onPress: () => void remove(saved), hitSlop: 10, accessibilityRole: "button", accessibilityLabel: `Remove ${saved.phoneNumber}`, children: /* @__PURE__ */ jsx(Ionicons, { name: "trash-outline", size: 18, color: "#ef4444" }) })
|
|
653
|
+
] }, `${saved.countryCode}-${saved.phoneNumber}`))
|
|
654
|
+
] }) : null,
|
|
655
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.fieldLabel, {
|
|
656
|
+
color: colors.textMuted
|
|
657
|
+
}], children: "Country code" }),
|
|
658
|
+
/* @__PURE__ */ jsxs(Pressable, { onPress: () => setPickingCountry((open) => !open), accessibilityRole: "button", style: [styles.input, styles.select, {
|
|
659
|
+
backgroundColor: colors.surfaceMuted,
|
|
660
|
+
borderColor: colors.border
|
|
661
|
+
}], children: [
|
|
662
|
+
/* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [styles.optionLabel, {
|
|
663
|
+
color: colors.text
|
|
664
|
+
}], children: country ? `${country.name} (${dialCode})` : "Loading\u2026" }),
|
|
665
|
+
/* @__PURE__ */ jsx(Ionicons, { name: pickingCountry ? "chevron-up" : "chevron-down", size: 16, color: colors.textMuted })
|
|
666
|
+
] }),
|
|
667
|
+
pickingCountry ? /* @__PURE__ */ jsxs(View, { style: [styles.countryBox, {
|
|
668
|
+
borderColor: colors.border
|
|
669
|
+
}], children: [
|
|
670
|
+
/* @__PURE__ */ jsx(TextInput, { value: countryQuery, onChangeText: setCountryQuery, placeholder: "Search countries", placeholderTextColor: colors.textMuted, autoCorrect: false, style: [styles.countrySearch, {
|
|
671
|
+
color: colors.text,
|
|
672
|
+
borderColor: colors.border
|
|
673
|
+
}] }),
|
|
674
|
+
/* @__PURE__ */ jsx(ScrollView, { style: styles.countryList, nestedScrollEnabled: true, keyboardShouldPersistTaps: "handled", children: visibleCountries.map(({
|
|
675
|
+
item,
|
|
676
|
+
index
|
|
677
|
+
}) => /* @__PURE__ */ jsxs(Pressable, { onPress: () => {
|
|
678
|
+
setCountryIndex(index);
|
|
679
|
+
setPickingCountry(false);
|
|
680
|
+
setCountryQuery("");
|
|
681
|
+
}, style: [styles.option, index === countryIndex && {
|
|
682
|
+
backgroundColor: colors.primarySoft
|
|
683
|
+
}], children: [
|
|
684
|
+
/* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [styles.optionLabel, {
|
|
685
|
+
color: colors.text
|
|
686
|
+
}], children: item.name }),
|
|
687
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.hint, {
|
|
688
|
+
color: colors.textMuted
|
|
689
|
+
}], children: formatPhoneCode(item.phoneCode) })
|
|
690
|
+
] }, item.id)) })
|
|
691
|
+
] }) : null,
|
|
692
|
+
/* @__PURE__ */ jsx(Field, { label: "Phone number", colors, value: number, onChangeText: (text) => setNumber(text.replace(/\D/g, "")), keyboardType: "phone-pad", autoComplete: "tel", maxLength: 15 })
|
|
693
|
+
] })
|
|
694
|
+
] });
|
|
695
|
+
}
|
|
696
|
+
const ACCEPTED_TYPES = ["image/jpeg", "image/png", "image/webp"];
|
|
697
|
+
const stripQuery = (url) => url.split("?")[0];
|
|
698
|
+
function loadImagePicker() {
|
|
699
|
+
try {
|
|
700
|
+
return require("expo-image-picker");
|
|
701
|
+
} catch (e) {
|
|
702
|
+
return null;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
function AvatarSheet({
|
|
706
|
+
visible,
|
|
707
|
+
colors,
|
|
708
|
+
fallback,
|
|
709
|
+
onClose
|
|
710
|
+
}) {
|
|
711
|
+
var _a, _b;
|
|
712
|
+
const [busy, setBusy] = useState(null);
|
|
713
|
+
const [error, setError] = useState(null);
|
|
714
|
+
const [preview, setPreview] = useState(null);
|
|
715
|
+
const {
|
|
716
|
+
data,
|
|
717
|
+
refetch
|
|
718
|
+
} = useAccountProfileQuery({
|
|
719
|
+
skip: !visible,
|
|
720
|
+
fetchPolicy: "cache-and-network"
|
|
721
|
+
});
|
|
722
|
+
const [createFileUploadLinks] = useCreateFileUploadLinksMutation();
|
|
723
|
+
const [uploadProfilePhoto] = useUploadAccountProfilePhotoMutation();
|
|
724
|
+
const [deleteProfilePhoto] = useDeleteAccountProfilePhotoMutation();
|
|
725
|
+
const profile = data == null ? void 0 : data.accountProfile;
|
|
726
|
+
const photos = (_a = profile == null ? void 0 : profile.photos) != null ? _a : [];
|
|
727
|
+
const current = preview || ((_b = photos[0]) == null ? void 0 : _b.url);
|
|
728
|
+
const mounted = useRef(true);
|
|
729
|
+
useEffect(() => () => {
|
|
730
|
+
mounted.current = false;
|
|
731
|
+
}, []);
|
|
732
|
+
useEffect(() => {
|
|
733
|
+
if (visible) setError(null);
|
|
734
|
+
}, [visible]);
|
|
735
|
+
const deletePhotos = async (urls) => {
|
|
736
|
+
for (const url of urls) await deleteProfilePhoto({
|
|
737
|
+
variables: {
|
|
738
|
+
url
|
|
739
|
+
}
|
|
740
|
+
});
|
|
741
|
+
};
|
|
742
|
+
const pick = async () => {
|
|
743
|
+
var _a2, _b2, _c, _d, _e;
|
|
744
|
+
const picker = loadImagePicker();
|
|
745
|
+
if (!picker) {
|
|
746
|
+
setError("Photos are not available in this version of the app.");
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
const permission = await picker.requestMediaLibraryPermissionsAsync();
|
|
750
|
+
if (!permission.granted) {
|
|
751
|
+
setError("Allow access to your photos to choose a profile picture.");
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
const result = await picker.launchImageLibraryAsync({
|
|
755
|
+
mediaTypes: ["images"],
|
|
756
|
+
allowsEditing: true,
|
|
757
|
+
aspect: [1, 1],
|
|
758
|
+
quality: 0.85,
|
|
759
|
+
exif: false
|
|
760
|
+
});
|
|
761
|
+
if (result.canceled || !((_a2 = result.assets) == null ? void 0 : _a2[0])) return;
|
|
762
|
+
const asset = result.assets[0];
|
|
763
|
+
const mimeType = (_b2 = asset.mimeType) != null ? _b2 : "image/jpeg";
|
|
764
|
+
if (!ACCEPTED_TYPES.includes(mimeType)) {
|
|
765
|
+
setError("That file isn't a JPG, PNG or WebP image. Choose another file.");
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
if (!(profile == null ? void 0 : profile.id)) {
|
|
769
|
+
setError("We couldn't upload that photo. Check your connection and try again.");
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
const name = (_c = asset.fileName) != null ? _c : `avatar.${mimeType.split("/")[1]}`;
|
|
773
|
+
const previous = photos.map((photo) => photo.url);
|
|
774
|
+
setPreview(asset.uri);
|
|
775
|
+
setBusy("upload");
|
|
776
|
+
setError(null);
|
|
777
|
+
try {
|
|
778
|
+
const {
|
|
779
|
+
data: links
|
|
780
|
+
} = await createFileUploadLinks({
|
|
781
|
+
variables: {
|
|
782
|
+
filenames: [name]
|
|
783
|
+
}
|
|
784
|
+
});
|
|
785
|
+
const signedUrl = (_d = links == null ? void 0 : links.createFileUploadLinks) == null ? void 0 : _d[0];
|
|
786
|
+
if (!signedUrl) throw new Error("No upload link was returned.");
|
|
787
|
+
const body = await (await fetch(asset.uri)).blob();
|
|
788
|
+
const response = await fetch(signedUrl, {
|
|
789
|
+
method: "PUT",
|
|
790
|
+
headers: {
|
|
791
|
+
"Content-Type": mimeType
|
|
792
|
+
},
|
|
793
|
+
body
|
|
794
|
+
});
|
|
795
|
+
if (!response.ok) throw new Error(`Storage rejected the upload (${response.status}).`);
|
|
796
|
+
await uploadProfilePhoto({
|
|
797
|
+
variables: {
|
|
798
|
+
id: profile.id,
|
|
799
|
+
image: {
|
|
800
|
+
name,
|
|
801
|
+
mimeType,
|
|
802
|
+
size: (_e = asset.fileSize) != null ? _e : body.size,
|
|
803
|
+
url: stripQuery(signedUrl)
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
await deletePhotos(previous);
|
|
808
|
+
await refetch();
|
|
809
|
+
} catch (e) {
|
|
810
|
+
if (mounted.current) setError("We couldn't upload that photo. Check your connection and try again.");
|
|
811
|
+
} finally {
|
|
812
|
+
if (mounted.current) {
|
|
813
|
+
setBusy(null);
|
|
814
|
+
setPreview(null);
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
const remove = async () => {
|
|
819
|
+
setBusy("remove");
|
|
820
|
+
setError(null);
|
|
821
|
+
try {
|
|
822
|
+
await deletePhotos(photos.map((photo) => photo.url));
|
|
823
|
+
await refetch();
|
|
824
|
+
} catch (e) {
|
|
825
|
+
setError("We couldn't remove that photo. Try again.");
|
|
826
|
+
} finally {
|
|
827
|
+
setBusy(null);
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
return /* @__PURE__ */ jsx(Sheet, { visible, title: "Profile photo", subtitle: "Your avatar in the sidebar and on your account.", colors, onClose, children: /* @__PURE__ */ jsxs(View, { style: styles.avatarBlock, children: [
|
|
831
|
+
/* @__PURE__ */ jsxs(View, { style: styles.avatar, children: [
|
|
832
|
+
current ? /* @__PURE__ */ jsx(Image, { source: {
|
|
833
|
+
uri: current
|
|
834
|
+
}, style: styles.avatarImage }) : fallback,
|
|
835
|
+
busy === "upload" ? /* @__PURE__ */ jsx(View, { style: styles.avatarBusy, children: /* @__PURE__ */ jsx(ActivityIndicator, { color: "#fff" }) }) : null
|
|
836
|
+
] }),
|
|
837
|
+
/* @__PURE__ */ jsxs(View, { style: styles.avatarActions, children: [
|
|
838
|
+
/* @__PURE__ */ jsx(Pressable, { onPress: () => void pick(), disabled: !!busy || !profile, accessibilityRole: "button", style: [styles.primary, (!!busy || !profile) && styles.dim], children: /* @__PURE__ */ jsx(Text, { style: styles.primaryLabel, children: busy === "upload" ? "Uploading\u2026" : photos.length ? "Change photo" : "Upload photo" }) }),
|
|
839
|
+
photos.length ? /* @__PURE__ */ jsx(Pressable, { onPress: () => void remove(), disabled: !!busy, accessibilityRole: "button", style: styles.ghost, children: /* @__PURE__ */ jsx(Text, { style: styles.removeLabel, children: busy === "remove" ? "Removing\u2026" : "Remove" }) }) : null
|
|
840
|
+
] }),
|
|
841
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.hint, styles.centered, {
|
|
842
|
+
color: colors.textMuted
|
|
843
|
+
}], children: "JPG, PNG or WebP. A square photo of your face or a logo works best." }),
|
|
844
|
+
/* @__PURE__ */ jsx(Problem, { text: error })
|
|
845
|
+
] }) });
|
|
846
|
+
}
|
|
847
|
+
const styles = StyleSheet.create({
|
|
848
|
+
backdrop: {
|
|
849
|
+
flex: 1,
|
|
850
|
+
backgroundColor: "rgba(15, 23, 42, 0.45)",
|
|
851
|
+
justifyContent: "flex-end"
|
|
852
|
+
},
|
|
853
|
+
dismiss: {
|
|
854
|
+
flex: 1
|
|
855
|
+
},
|
|
856
|
+
card: {
|
|
857
|
+
maxHeight: "88%",
|
|
858
|
+
borderTopLeftRadius: 20,
|
|
859
|
+
borderTopRightRadius: 20,
|
|
860
|
+
padding: 20,
|
|
861
|
+
paddingBottom: 28
|
|
862
|
+
},
|
|
863
|
+
title: {
|
|
864
|
+
fontSize: 18,
|
|
865
|
+
fontWeight: "700"
|
|
866
|
+
},
|
|
867
|
+
subtitle: {
|
|
868
|
+
marginTop: 4,
|
|
869
|
+
fontSize: 13,
|
|
870
|
+
lineHeight: 18
|
|
871
|
+
},
|
|
872
|
+
body: {
|
|
873
|
+
marginTop: 12,
|
|
874
|
+
flexGrow: 0
|
|
875
|
+
},
|
|
876
|
+
actions: {
|
|
877
|
+
flexDirection: "row",
|
|
878
|
+
justifyContent: "flex-end",
|
|
879
|
+
alignItems: "center",
|
|
880
|
+
gap: 10,
|
|
881
|
+
marginTop: 16
|
|
882
|
+
},
|
|
883
|
+
ghost: {
|
|
884
|
+
paddingHorizontal: 14,
|
|
885
|
+
paddingVertical: 10
|
|
886
|
+
},
|
|
887
|
+
ghostLabel: {
|
|
888
|
+
fontSize: 16,
|
|
889
|
+
fontWeight: "600"
|
|
890
|
+
},
|
|
891
|
+
primary: {
|
|
892
|
+
backgroundColor: mobileTokens.color.primary,
|
|
893
|
+
borderRadius: 12,
|
|
894
|
+
paddingHorizontal: 18,
|
|
895
|
+
paddingVertical: 10,
|
|
896
|
+
minWidth: 88,
|
|
897
|
+
minHeight: 44,
|
|
898
|
+
alignItems: "center",
|
|
899
|
+
justifyContent: "center"
|
|
900
|
+
},
|
|
901
|
+
primaryLabel: {
|
|
902
|
+
color: "#fff",
|
|
903
|
+
fontSize: 16,
|
|
904
|
+
fontWeight: "600"
|
|
905
|
+
},
|
|
906
|
+
dim: {
|
|
907
|
+
opacity: 0.5
|
|
908
|
+
},
|
|
909
|
+
field: {
|
|
910
|
+
marginBottom: 12
|
|
911
|
+
},
|
|
912
|
+
fieldLabel: {
|
|
913
|
+
fontSize: 13,
|
|
914
|
+
fontWeight: "600",
|
|
915
|
+
marginBottom: 6
|
|
916
|
+
},
|
|
917
|
+
input: {
|
|
918
|
+
borderWidth: 1,
|
|
919
|
+
borderRadius: 12,
|
|
920
|
+
paddingHorizontal: 12,
|
|
921
|
+
paddingVertical: 12,
|
|
922
|
+
fontSize: 16
|
|
923
|
+
},
|
|
924
|
+
hint: {
|
|
925
|
+
fontSize: 13,
|
|
926
|
+
lineHeight: 18
|
|
927
|
+
},
|
|
928
|
+
error: {
|
|
929
|
+
color: "#ef4444",
|
|
930
|
+
fontSize: 13,
|
|
931
|
+
lineHeight: 18,
|
|
932
|
+
marginBottom: 8
|
|
933
|
+
},
|
|
934
|
+
option: {
|
|
935
|
+
flexDirection: "row",
|
|
936
|
+
alignItems: "center",
|
|
937
|
+
justifyContent: "space-between",
|
|
938
|
+
gap: 10,
|
|
939
|
+
minHeight: 48,
|
|
940
|
+
paddingHorizontal: 12,
|
|
941
|
+
borderRadius: 10
|
|
942
|
+
},
|
|
943
|
+
optionLabel: {
|
|
944
|
+
flexShrink: 1,
|
|
945
|
+
fontSize: 16
|
|
946
|
+
},
|
|
947
|
+
columns: {
|
|
948
|
+
flexDirection: "row",
|
|
949
|
+
gap: 10
|
|
950
|
+
},
|
|
951
|
+
column: {
|
|
952
|
+
flex: 1
|
|
953
|
+
},
|
|
954
|
+
columnList: {
|
|
955
|
+
maxHeight: 220,
|
|
956
|
+
borderWidth: 1,
|
|
957
|
+
borderRadius: 12
|
|
958
|
+
},
|
|
959
|
+
columnRow: {
|
|
960
|
+
minHeight: 44,
|
|
961
|
+
justifyContent: "center",
|
|
962
|
+
paddingHorizontal: 10
|
|
963
|
+
},
|
|
964
|
+
columnLabel: {
|
|
965
|
+
fontSize: 15,
|
|
966
|
+
textAlign: "center"
|
|
967
|
+
},
|
|
968
|
+
code: {
|
|
969
|
+
marginTop: 12,
|
|
970
|
+
fontSize: 22,
|
|
971
|
+
letterSpacing: 8,
|
|
972
|
+
textAlign: "center"
|
|
973
|
+
},
|
|
974
|
+
codeActions: {
|
|
975
|
+
flexDirection: "row",
|
|
976
|
+
justifyContent: "center",
|
|
977
|
+
gap: 24,
|
|
978
|
+
marginTop: 14
|
|
979
|
+
},
|
|
980
|
+
link: {
|
|
981
|
+
fontSize: 14,
|
|
982
|
+
fontWeight: "600"
|
|
983
|
+
},
|
|
984
|
+
saved: {
|
|
985
|
+
flexDirection: "row",
|
|
986
|
+
alignItems: "center",
|
|
987
|
+
justifyContent: "space-between",
|
|
988
|
+
minHeight: 48,
|
|
989
|
+
paddingHorizontal: 12,
|
|
990
|
+
marginBottom: 8,
|
|
991
|
+
borderWidth: 1,
|
|
992
|
+
borderRadius: 12
|
|
993
|
+
},
|
|
994
|
+
select: {
|
|
995
|
+
flexDirection: "row",
|
|
996
|
+
alignItems: "center",
|
|
997
|
+
justifyContent: "space-between",
|
|
998
|
+
marginBottom: 12
|
|
999
|
+
},
|
|
1000
|
+
countryBox: {
|
|
1001
|
+
borderWidth: 1,
|
|
1002
|
+
borderRadius: 12,
|
|
1003
|
+
marginBottom: 12,
|
|
1004
|
+
overflow: "hidden"
|
|
1005
|
+
},
|
|
1006
|
+
countrySearch: {
|
|
1007
|
+
minHeight: 44,
|
|
1008
|
+
paddingHorizontal: 12,
|
|
1009
|
+
fontSize: 15,
|
|
1010
|
+
borderBottomWidth: StyleSheet.hairlineWidth
|
|
1011
|
+
},
|
|
1012
|
+
countryList: {
|
|
1013
|
+
maxHeight: 220
|
|
1014
|
+
},
|
|
1015
|
+
avatarBlock: {
|
|
1016
|
+
alignItems: "center",
|
|
1017
|
+
gap: 14
|
|
1018
|
+
},
|
|
1019
|
+
avatar: {
|
|
1020
|
+
width: 112,
|
|
1021
|
+
height: 112,
|
|
1022
|
+
borderRadius: 56,
|
|
1023
|
+
overflow: "hidden",
|
|
1024
|
+
alignItems: "center",
|
|
1025
|
+
justifyContent: "center"
|
|
1026
|
+
},
|
|
1027
|
+
avatarImage: {
|
|
1028
|
+
width: "100%",
|
|
1029
|
+
height: "100%"
|
|
1030
|
+
},
|
|
1031
|
+
avatarBusy: __spreadProps(__spreadValues({}, StyleSheet.absoluteFillObject), {
|
|
1032
|
+
backgroundColor: "rgba(0,0,0,0.5)",
|
|
1033
|
+
alignItems: "center",
|
|
1034
|
+
justifyContent: "center"
|
|
1035
|
+
}),
|
|
1036
|
+
avatarActions: {
|
|
1037
|
+
flexDirection: "row",
|
|
1038
|
+
alignItems: "center",
|
|
1039
|
+
gap: 8
|
|
1040
|
+
},
|
|
1041
|
+
removeLabel: {
|
|
1042
|
+
color: "#ef4444",
|
|
1043
|
+
fontSize: 16,
|
|
1044
|
+
fontWeight: "600"
|
|
1045
|
+
},
|
|
1046
|
+
centered: {
|
|
1047
|
+
textAlign: "center"
|
|
1048
|
+
}
|
|
1049
|
+
});export{AvatarSheet,DobSheet,EmailSheet,GenderSheet,NameSheet,OptionList,PhoneSheet,PickerSheet,Sheet,UsernameSheet};//# sourceMappingURL=AccountSheets.js.map
|