@ollaid/native-sso 2.7.6 → 2.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/LoginModal.d.ts +1 -1
- package/dist/components/NativeSSOPage.d.ts +1 -1
- package/dist/components/OnboardingModal.d.ts +7 -2
- package/dist/components/SignupModal.d.ts +1 -1
- package/dist/index.cjs +199 -70
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +199 -70
- package/dist/index.js.map +1 -1
- package/dist/services/profile.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -12144,26 +12144,41 @@ const C = {
|
|
|
12144
12144
|
gray700: "#374151",
|
|
12145
12145
|
white: "#ffffff"
|
|
12146
12146
|
};
|
|
12147
|
-
function OnboardingModal({
|
|
12147
|
+
function OnboardingModal({
|
|
12148
|
+
open,
|
|
12149
|
+
onOpenChange,
|
|
12150
|
+
onDismiss,
|
|
12151
|
+
user,
|
|
12152
|
+
variant = "missing",
|
|
12153
|
+
profileHydrating = false,
|
|
12154
|
+
hydrateProfile = true,
|
|
12155
|
+
onUserInfosSync,
|
|
12156
|
+
onComplete,
|
|
12157
|
+
onSkip
|
|
12158
|
+
}) {
|
|
12148
12159
|
var _a;
|
|
12149
12160
|
const isEditMode = variant === "edit";
|
|
12150
|
-
const
|
|
12151
|
-
const
|
|
12161
|
+
const [hydratedUser, setHydratedUser] = useState(null);
|
|
12162
|
+
const [internalHydrating, setInternalHydrating] = useState(false);
|
|
12163
|
+
const hydrationKeyRef = useRef(null);
|
|
12164
|
+
const profileUser = hydratedUser ?? user;
|
|
12165
|
+
const hasCurrentPhone = Boolean(profileUser.phone);
|
|
12166
|
+
const hasCurrentEmail = Boolean(profileUser.email);
|
|
12152
12167
|
const directPhoneEdit = !isEditMode || !hasCurrentPhone;
|
|
12153
12168
|
const directEmailEdit = !isEditMode || !hasCurrentEmail;
|
|
12154
|
-
!isEditMode ? !((_a =
|
|
12155
|
-
const [name, setName] = useState(
|
|
12169
|
+
!isEditMode ? !((_a = profileUser.name) == null ? void 0 : _a.trim()) : true;
|
|
12170
|
+
const [name, setName] = useState(profileUser.name || "");
|
|
12156
12171
|
const [photoPreview, setPhotoPreview] = useState("");
|
|
12157
12172
|
const [avatarPickerOpen, setAvatarPickerOpen] = useState(false);
|
|
12158
12173
|
const [pendingAvatarSrc, setPendingAvatarSrc] = useState(null);
|
|
12159
12174
|
const [avatarUploading, setAvatarUploading] = useState(false);
|
|
12160
12175
|
const avatarFileInputRef = useRef(null);
|
|
12161
|
-
const [ccphone, setCcphone] = useState(
|
|
12162
|
-
const [phone, setPhone] = useState(
|
|
12163
|
-
const [email, setEmail] = useState(
|
|
12164
|
-
const [address, setAddress] = useState(
|
|
12165
|
-
const [town, setTown] = useState(
|
|
12166
|
-
const [country, setCountry] = useState(
|
|
12176
|
+
const [ccphone, setCcphone] = useState(profileUser.ccphone || "+221");
|
|
12177
|
+
const [phone, setPhone] = useState(profileUser.phone || "");
|
|
12178
|
+
const [email, setEmail] = useState(profileUser.email || "");
|
|
12179
|
+
const [address, setAddress] = useState(profileUser.address || "");
|
|
12180
|
+
const [town, setTown] = useState(profileUser.town || "");
|
|
12181
|
+
const [country, setCountry] = useState(profileUser.country || DEFAULT_COUNTRY_CODE);
|
|
12167
12182
|
const [submitting, setSubmitting] = useState(false);
|
|
12168
12183
|
const [fileError, setFileError] = useState("");
|
|
12169
12184
|
const [contactFlow, setContactFlow] = useState(null);
|
|
@@ -12173,34 +12188,54 @@ function OnboardingModal({ open, onOpenChange, onDismiss, user, variant = "missi
|
|
|
12173
12188
|
const [confirmAction, setConfirmAction] = useState(null);
|
|
12174
12189
|
const [nowTick, setNowTick] = useState(Date.now());
|
|
12175
12190
|
const userHydrationKey = [
|
|
12176
|
-
|
|
12177
|
-
|
|
12178
|
-
|
|
12179
|
-
|
|
12180
|
-
|
|
12181
|
-
|
|
12182
|
-
|
|
12183
|
-
|
|
12184
|
-
|
|
12185
|
-
|
|
12191
|
+
profileUser.reference || "",
|
|
12192
|
+
profileUser.name || "",
|
|
12193
|
+
profileUser.email || "",
|
|
12194
|
+
profileUser.ccphone || "",
|
|
12195
|
+
profileUser.phone || "",
|
|
12196
|
+
profileUser.address || "",
|
|
12197
|
+
profileUser.town || "",
|
|
12198
|
+
profileUser.country || "",
|
|
12199
|
+
profileUser.image_url || "",
|
|
12200
|
+
profileUser.auth_2fa ? "1" : "0"
|
|
12186
12201
|
].join("|");
|
|
12187
|
-
const currentDialCode = (
|
|
12202
|
+
const currentDialCode = (profileUser.ccphone || ccphone || "+221").trim();
|
|
12188
12203
|
const baseSmsAllowed = currentDialCode === "+221";
|
|
12189
12204
|
const contactSmsAllowed = contactFlow ? contactFlow.kind === "phone" ? contactFlow.newCcphone.trim() === "+221" : baseSmsAllowed : baseSmsAllowed;
|
|
12190
12205
|
const lockModalClose = profileHydrating || submitting || submitState === "success" || avatarUploading || Boolean(contactFlow == null ? void 0 : contactFlow.loading);
|
|
12206
|
+
const syncFormFromUser = useCallback((nextUser) => {
|
|
12207
|
+
setName(nextUser.name || "");
|
|
12208
|
+
setPhotoPreview(isEditMode ? nextUser.image_url || "" : "");
|
|
12209
|
+
setCcphone(nextUser.ccphone || "+221");
|
|
12210
|
+
setPhone(nextUser.phone || "");
|
|
12211
|
+
setEmail(nextUser.email || "");
|
|
12212
|
+
setAddress(nextUser.address || "");
|
|
12213
|
+
setTown(nextUser.town || "");
|
|
12214
|
+
setCountry(nextUser.country || DEFAULT_COUNTRY_CODE);
|
|
12215
|
+
}, [isEditMode]);
|
|
12216
|
+
const toUserInfos = useCallback((nextUser) => ({
|
|
12217
|
+
reference: nextUser.reference,
|
|
12218
|
+
name: nextUser.name,
|
|
12219
|
+
email: nextUser.email || null,
|
|
12220
|
+
ccphone: nextUser.ccphone,
|
|
12221
|
+
phone: nextUser.phone,
|
|
12222
|
+
address: nextUser.address,
|
|
12223
|
+
town: nextUser.town,
|
|
12224
|
+
country: nextUser.country,
|
|
12225
|
+
image_url: nextUser.image_url,
|
|
12226
|
+
auth_2fa: nextUser.auth_2fa,
|
|
12227
|
+
alias_reference: nextUser.alias_reference,
|
|
12228
|
+
iam_reference: nextUser.iam_reference
|
|
12229
|
+
}), []);
|
|
12191
12230
|
useEffect(() => {
|
|
12192
|
-
if (!open)
|
|
12193
|
-
|
|
12194
|
-
|
|
12231
|
+
if (!open) {
|
|
12232
|
+
setHydratedUser(null);
|
|
12233
|
+
hydrationKeyRef.current = null;
|
|
12234
|
+
return;
|
|
12235
|
+
}
|
|
12195
12236
|
setPendingAvatarSrc(null);
|
|
12196
12237
|
setAvatarPickerOpen(false);
|
|
12197
12238
|
setAvatarUploading(false);
|
|
12198
|
-
setCcphone(user.ccphone || "+221");
|
|
12199
|
-
setPhone(user.phone || "");
|
|
12200
|
-
setEmail(user.email || "");
|
|
12201
|
-
setAddress(user.address || "");
|
|
12202
|
-
setTown(user.town || "");
|
|
12203
|
-
setCountry(user.country || DEFAULT_COUNTRY_CODE);
|
|
12204
12239
|
setSubmitting(false);
|
|
12205
12240
|
setFileError("");
|
|
12206
12241
|
setContactFlow(null);
|
|
@@ -12208,7 +12243,54 @@ function OnboardingModal({ open, onOpenChange, onDismiss, user, variant = "missi
|
|
|
12208
12243
|
setSubmitMessage("");
|
|
12209
12244
|
setSubmitError("");
|
|
12210
12245
|
setConfirmAction(null);
|
|
12211
|
-
|
|
12246
|
+
syncFormFromUser(profileUser);
|
|
12247
|
+
}, [open, userHydrationKey, profileUser, syncFormFromUser]);
|
|
12248
|
+
useEffect(() => {
|
|
12249
|
+
if (!open || !hydratedUser) return;
|
|
12250
|
+
if (contactFlow || submitting || submitState !== "idle") return;
|
|
12251
|
+
syncFormFromUser(hydratedUser);
|
|
12252
|
+
}, [open, hydratedUser, contactFlow, submitting, submitState, syncFormFromUser]);
|
|
12253
|
+
useEffect(() => {
|
|
12254
|
+
if (!open || !hydrateProfile || profileHydrating || internalHydrating || hydratedUser) return;
|
|
12255
|
+
const key = userHydrationKey;
|
|
12256
|
+
if (hydrationKeyRef.current === key) return;
|
|
12257
|
+
hydrationKeyRef.current = key;
|
|
12258
|
+
let cancelled = false;
|
|
12259
|
+
setInternalHydrating(true);
|
|
12260
|
+
(async () => {
|
|
12261
|
+
try {
|
|
12262
|
+
const response = await profileService.getProfile();
|
|
12263
|
+
const payload = response.user_infos || response.user || {};
|
|
12264
|
+
const nextUser = {
|
|
12265
|
+
...profileUser,
|
|
12266
|
+
name: payload.name || profileUser.name,
|
|
12267
|
+
email: payload.email ?? profileUser.email ?? null,
|
|
12268
|
+
ccphone: payload.ccphone || profileUser.ccphone,
|
|
12269
|
+
phone: payload.phone || profileUser.phone,
|
|
12270
|
+
address: payload.address || profileUser.address,
|
|
12271
|
+
town: payload.town || profileUser.town,
|
|
12272
|
+
country: payload.country || profileUser.country,
|
|
12273
|
+
image_url: payload.image_url || profileUser.image_url,
|
|
12274
|
+
auth_2fa: payload.auth_2fa ?? profileUser.auth_2fa,
|
|
12275
|
+
alias_reference: payload.alias_reference || profileUser.alias_reference,
|
|
12276
|
+
iam_reference: payload.iam_reference || profileUser.iam_reference
|
|
12277
|
+
};
|
|
12278
|
+
if (cancelled) return;
|
|
12279
|
+
setHydratedUser(nextUser);
|
|
12280
|
+
syncFormFromUser(nextUser);
|
|
12281
|
+
onUserInfosSync == null ? void 0 : onUserInfosSync({ source: "hydration", user_infos: toUserInfos(nextUser) });
|
|
12282
|
+
} catch {
|
|
12283
|
+
if (cancelled) return;
|
|
12284
|
+
} finally {
|
|
12285
|
+
if (!cancelled) {
|
|
12286
|
+
setInternalHydrating(false);
|
|
12287
|
+
}
|
|
12288
|
+
}
|
|
12289
|
+
})();
|
|
12290
|
+
return () => {
|
|
12291
|
+
cancelled = true;
|
|
12292
|
+
};
|
|
12293
|
+
}, [open, hydrateProfile, profileHydrating, internalHydrating, userHydrationKey, profileUser, onUserInfosSync, syncFormFromUser, toUserInfos]);
|
|
12212
12294
|
useEffect(() => {
|
|
12213
12295
|
if (!(contactFlow == null ? void 0 : contactFlow.resendAvailableAt)) return;
|
|
12214
12296
|
const timer = window.setInterval(() => {
|
|
@@ -12244,9 +12326,9 @@ function OnboardingModal({ open, onOpenChange, onDismiss, user, variant = "missi
|
|
|
12244
12326
|
setSubmitError("");
|
|
12245
12327
|
const data = {
|
|
12246
12328
|
name: name.trim(),
|
|
12247
|
-
ccphone: directPhoneEdit ? ccphone :
|
|
12248
|
-
phone: directPhoneEdit ? phone :
|
|
12249
|
-
email: directEmailEdit ? email.trim() :
|
|
12329
|
+
ccphone: directPhoneEdit ? ccphone : profileUser.ccphone || void 0,
|
|
12330
|
+
phone: directPhoneEdit ? phone : profileUser.phone || void 0,
|
|
12331
|
+
email: directEmailEdit ? email.trim() : profileUser.email || void 0,
|
|
12250
12332
|
...address.trim() ? { address: address.trim() } : {},
|
|
12251
12333
|
...town.trim() ? { town: town.trim() } : {},
|
|
12252
12334
|
...country ? { country } : {}
|
|
@@ -12255,19 +12337,21 @@ function OnboardingModal({ open, onOpenChange, onDismiss, user, variant = "missi
|
|
|
12255
12337
|
const response = await profileService.updateProfile(data);
|
|
12256
12338
|
const payload = response.user_infos || response.user || {};
|
|
12257
12339
|
const updatedUser = {
|
|
12258
|
-
...
|
|
12259
|
-
name: payload.name || data.name ||
|
|
12260
|
-
email: payload.email ?? data.email ??
|
|
12261
|
-
ccphone: payload.ccphone || data.ccphone ||
|
|
12262
|
-
phone: payload.phone || data.phone ||
|
|
12263
|
-
address: payload.address || data.address ||
|
|
12264
|
-
town: payload.town || data.town ||
|
|
12265
|
-
country: payload.country || data.country ||
|
|
12266
|
-
image_url: payload.image_url ||
|
|
12267
|
-
auth_2fa: payload.auth_2fa ??
|
|
12268
|
-
alias_reference: payload.alias_reference ||
|
|
12269
|
-
iam_reference: payload.iam_reference ||
|
|
12340
|
+
...profileUser,
|
|
12341
|
+
name: payload.name || data.name || profileUser.name,
|
|
12342
|
+
email: payload.email ?? data.email ?? profileUser.email,
|
|
12343
|
+
ccphone: payload.ccphone || data.ccphone || profileUser.ccphone,
|
|
12344
|
+
phone: payload.phone || data.phone || profileUser.phone,
|
|
12345
|
+
address: payload.address || data.address || profileUser.address,
|
|
12346
|
+
town: payload.town || data.town || profileUser.town,
|
|
12347
|
+
country: payload.country || data.country || profileUser.country,
|
|
12348
|
+
image_url: payload.image_url || profileUser.image_url,
|
|
12349
|
+
auth_2fa: payload.auth_2fa ?? profileUser.auth_2fa,
|
|
12350
|
+
alias_reference: payload.alias_reference || profileUser.alias_reference,
|
|
12351
|
+
iam_reference: payload.iam_reference || profileUser.iam_reference
|
|
12270
12352
|
};
|
|
12353
|
+
setHydratedUser(updatedUser);
|
|
12354
|
+
onUserInfosSync == null ? void 0 : onUserInfosSync({ source: "update", user_infos: toUserInfos(updatedUser) });
|
|
12271
12355
|
onComplete({
|
|
12272
12356
|
name: updatedUser.name,
|
|
12273
12357
|
image_url: updatedUser.image_url,
|
|
@@ -12298,7 +12382,7 @@ function OnboardingModal({ open, onOpenChange, onDismiss, user, variant = "missi
|
|
|
12298
12382
|
setSubmitState("error");
|
|
12299
12383
|
setSubmitError(error instanceof Error ? error.message : "Erreur lors de l’enregistrement");
|
|
12300
12384
|
}
|
|
12301
|
-
}, [canSubmit,
|
|
12385
|
+
}, [canSubmit, profileUser, name, directPhoneEdit, directEmailEdit, ccphone, phone, email, address, town, country, onComplete, onUserInfosSync, toUserInfos, markSuccess]);
|
|
12302
12386
|
const openAvatarPicker = useCallback(() => {
|
|
12303
12387
|
var _a2;
|
|
12304
12388
|
(_a2 = avatarFileInputRef.current) == null ? void 0 : _a2.click();
|
|
@@ -12328,6 +12412,23 @@ function OnboardingModal({ open, onOpenChange, onDismiss, user, variant = "missi
|
|
|
12328
12412
|
setPhotoPreview(URL.createObjectURL(blob));
|
|
12329
12413
|
}
|
|
12330
12414
|
if (Object.keys(payload).length > 0) {
|
|
12415
|
+
const updatedUser = {
|
|
12416
|
+
...profileUser,
|
|
12417
|
+
reference: payload.reference || profileUser.reference,
|
|
12418
|
+
name: payload.name || profileUser.name,
|
|
12419
|
+
email: payload.email ?? profileUser.email ?? null,
|
|
12420
|
+
ccphone: payload.ccphone || profileUser.ccphone,
|
|
12421
|
+
phone: payload.phone || profileUser.phone,
|
|
12422
|
+
address: payload.address || profileUser.address,
|
|
12423
|
+
town: payload.town || profileUser.town,
|
|
12424
|
+
country: payload.country || profileUser.country,
|
|
12425
|
+
image_url: nextImage || profileUser.image_url,
|
|
12426
|
+
auth_2fa: payload.auth_2fa ?? profileUser.auth_2fa,
|
|
12427
|
+
alias_reference: payload.alias_reference || profileUser.alias_reference,
|
|
12428
|
+
iam_reference: payload.iam_reference || profileUser.iam_reference
|
|
12429
|
+
};
|
|
12430
|
+
setHydratedUser(updatedUser);
|
|
12431
|
+
onUserInfosSync == null ? void 0 : onUserInfosSync({ source: "avatar", user_infos: toUserInfos(updatedUser) });
|
|
12331
12432
|
onComplete({
|
|
12332
12433
|
name: payload.name,
|
|
12333
12434
|
image_url: nextImage || void 0,
|
|
@@ -12338,18 +12439,18 @@ function OnboardingModal({ open, onOpenChange, onDismiss, user, variant = "missi
|
|
|
12338
12439
|
town: payload.town || void 0,
|
|
12339
12440
|
country: payload.country || void 0,
|
|
12340
12441
|
user_infos: {
|
|
12341
|
-
reference: payload.reference ||
|
|
12342
|
-
name: payload.name ||
|
|
12343
|
-
email: payload.email ??
|
|
12344
|
-
ccphone: payload.ccphone ||
|
|
12345
|
-
phone: payload.phone ||
|
|
12346
|
-
address: payload.address ||
|
|
12347
|
-
town: payload.town ||
|
|
12348
|
-
country: payload.country ||
|
|
12349
|
-
image_url: nextImage ||
|
|
12350
|
-
auth_2fa: payload.auth_2fa ??
|
|
12351
|
-
alias_reference: payload.alias_reference ||
|
|
12352
|
-
iam_reference: payload.iam_reference ||
|
|
12442
|
+
reference: payload.reference || profileUser.reference,
|
|
12443
|
+
name: payload.name || profileUser.name,
|
|
12444
|
+
email: payload.email ?? profileUser.email ?? null,
|
|
12445
|
+
ccphone: payload.ccphone || profileUser.ccphone,
|
|
12446
|
+
phone: payload.phone || profileUser.phone,
|
|
12447
|
+
address: payload.address || profileUser.address,
|
|
12448
|
+
town: payload.town || profileUser.town,
|
|
12449
|
+
country: payload.country || profileUser.country,
|
|
12450
|
+
image_url: nextImage || profileUser.image_url,
|
|
12451
|
+
auth_2fa: payload.auth_2fa ?? profileUser.auth_2fa,
|
|
12452
|
+
alias_reference: payload.alias_reference || profileUser.alias_reference,
|
|
12453
|
+
iam_reference: payload.iam_reference || profileUser.iam_reference
|
|
12353
12454
|
}
|
|
12354
12455
|
});
|
|
12355
12456
|
}
|
|
@@ -12359,7 +12460,7 @@ function OnboardingModal({ open, onOpenChange, onDismiss, user, variant = "missi
|
|
|
12359
12460
|
} finally {
|
|
12360
12461
|
setAvatarUploading(false);
|
|
12361
12462
|
}
|
|
12362
|
-
}, [onComplete, markSuccess,
|
|
12463
|
+
}, [onComplete, onUserInfosSync, toUserInfos, markSuccess, profileUser.reference, profileUser.name, profileUser.email, profileUser.ccphone, profileUser.phone, profileUser.address, profileUser.town, profileUser.country, profileUser.image_url, profileUser.auth_2fa, profileUser.alias_reference, profileUser.iam_reference]);
|
|
12363
12464
|
const openContactFlow = useCallback((kind) => {
|
|
12364
12465
|
setContactFlow({
|
|
12365
12466
|
kind,
|
|
@@ -12367,7 +12468,7 @@ function OnboardingModal({ open, onOpenChange, onDismiss, user, variant = "missi
|
|
|
12367
12468
|
requestId: null,
|
|
12368
12469
|
method: kind === "email" ? "email" : currentDialCode === "+221" ? "phone" : "email",
|
|
12369
12470
|
newEmail: "",
|
|
12370
|
-
newCcphone: kind === "phone" ?
|
|
12471
|
+
newCcphone: kind === "phone" ? profileUser.ccphone || "+221" : "+221",
|
|
12371
12472
|
newPhone: "",
|
|
12372
12473
|
oldOtp: "",
|
|
12373
12474
|
newOtp: "",
|
|
@@ -12375,18 +12476,18 @@ function OnboardingModal({ open, onOpenChange, onDismiss, user, variant = "missi
|
|
|
12375
12476
|
error: "",
|
|
12376
12477
|
resendAvailableAt: null
|
|
12377
12478
|
});
|
|
12378
|
-
}, [currentDialCode,
|
|
12479
|
+
}, [currentDialCode, profileUser.ccphone]);
|
|
12379
12480
|
const closeContactFlow = useCallback(() => {
|
|
12380
12481
|
setContactFlow(null);
|
|
12381
12482
|
}, []);
|
|
12382
12483
|
const updateFlow = useCallback((patch) => {
|
|
12383
12484
|
setContactFlow((prev) => prev ? { ...prev, ...patch } : prev);
|
|
12384
12485
|
}, []);
|
|
12385
|
-
const currentPhoneDialDisplay =
|
|
12386
|
-
const currentPhoneNumberDisplay =
|
|
12387
|
-
const currentEmailLabel =
|
|
12486
|
+
const currentPhoneDialDisplay = profileUser.ccphone || ccphone || "+221";
|
|
12487
|
+
const currentPhoneNumberDisplay = profileUser.phone || phone || "";
|
|
12488
|
+
const currentEmailLabel = profileUser.email || email || "";
|
|
12388
12489
|
const currentPhoneDialCode = currentPhoneDialDisplay.trim() || "+221";
|
|
12389
|
-
const currentPhoneDigits = (
|
|
12490
|
+
const currentPhoneDigits = (profileUser.phone || phone || "").replace(/\D/g, "");
|
|
12390
12491
|
const formatPhoneDisplay = useCallback((dial, digits) => {
|
|
12391
12492
|
const cleanDial = (dial || "+221").trim() || "+221";
|
|
12392
12493
|
const cleanDigits = (digits || "").replace(/\D/g, "");
|
|
@@ -12442,13 +12543,15 @@ function OnboardingModal({ open, onOpenChange, onDismiss, user, variant = "missi
|
|
|
12442
12543
|
const response = await profileChangeService.verifyNewOTP(contactFlow.requestId, contactFlow.newOtp);
|
|
12443
12544
|
if (!response.success) throw new Error(response.message || "Code OTP incorrect");
|
|
12444
12545
|
const updatedUser = {
|
|
12445
|
-
...
|
|
12546
|
+
...profileUser,
|
|
12446
12547
|
...contactFlow.kind === "email" ? { email: contactFlow.newEmail.trim() } : { ccphone: contactFlow.newCcphone, phone: contactFlow.newPhone.trim() }
|
|
12447
12548
|
};
|
|
12448
12549
|
if (response.user && typeof response.user === "object") {
|
|
12449
12550
|
Object.assign(updatedUser, response.user);
|
|
12450
12551
|
}
|
|
12552
|
+
setHydratedUser(updatedUser);
|
|
12451
12553
|
setContactFlow(null);
|
|
12554
|
+
onUserInfosSync == null ? void 0 : onUserInfosSync({ source: "contact", user_infos: toUserInfos(updatedUser) });
|
|
12452
12555
|
onComplete({
|
|
12453
12556
|
name: updatedUser.name,
|
|
12454
12557
|
image_url: updatedUser.image_url,
|
|
@@ -12474,7 +12577,7 @@ function OnboardingModal({ open, onOpenChange, onDismiss, user, variant = "missi
|
|
|
12474
12577
|
} catch (error) {
|
|
12475
12578
|
updateFlow({ loading: false, error: error instanceof Error ? error.message : "Code OTP incorrect" });
|
|
12476
12579
|
}
|
|
12477
|
-
}, [contactFlow, onComplete, updateFlow,
|
|
12580
|
+
}, [contactFlow, onComplete, onUserInfosSync, updateFlow, profileUser, toUserInfos, markSuccess]);
|
|
12478
12581
|
const resendFlowOtp = useCallback(async () => {
|
|
12479
12582
|
if (!(contactFlow == null ? void 0 : contactFlow.requestId) || contactFlow.loading) return;
|
|
12480
12583
|
updateFlow({ loading: true, error: "" });
|
|
@@ -12627,7 +12730,7 @@ function OnboardingModal({ open, onOpenChange, onDismiss, user, variant = "missi
|
|
|
12627
12730
|
cursor: avatarUploading ? "not-allowed" : "pointer"
|
|
12628
12731
|
},
|
|
12629
12732
|
children: [
|
|
12630
|
-
photoPreview ||
|
|
12733
|
+
photoPreview || profileUser.image_url ? /* @__PURE__ */ jsx("img", { src: photoPreview || profileUser.image_url, alt: "Photo de profil", style: { width: "100%", height: "100%", objectFit: "cover" } }) : /* @__PURE__ */ jsx("div", { style: { width: "100%", height: "100%", display: "flex", alignItems: "center", justifyContent: "center", color: C.gray500 }, children: /* @__PURE__ */ jsxs("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
12631
12734
|
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "8", r: "4" }),
|
|
12632
12735
|
/* @__PURE__ */ jsx("path", { d: "M5.5 21a8.38 8.38 0 0 1 13 0" })
|
|
12633
12736
|
] }) }),
|
|
@@ -13804,6 +13907,28 @@ function NativeSSOPage({
|
|
|
13804
13907
|
}
|
|
13805
13908
|
void refreshSessionProfile(true);
|
|
13806
13909
|
}, [pendingSession, debugOnboardingState, onOnboardingComplete, persistSessionUser, refreshSessionProfile]);
|
|
13910
|
+
const handleOnboardingUserInfosSync = useCallback((payload) => {
|
|
13911
|
+
const activeSession = debugOnboardingState || pendingSession;
|
|
13912
|
+
if (!activeSession) return;
|
|
13913
|
+
const syncedUser = {
|
|
13914
|
+
...activeSession.sourceUser,
|
|
13915
|
+
...payload.user_infos
|
|
13916
|
+
};
|
|
13917
|
+
persistSessionUser(activeSession.token, syncedUser);
|
|
13918
|
+
if (debugOnboardingState) {
|
|
13919
|
+
setDebugOnboardingState((prev) => prev ? {
|
|
13920
|
+
...prev,
|
|
13921
|
+
user: syncedUser,
|
|
13922
|
+
sourceUser: syncedUser
|
|
13923
|
+
} : prev);
|
|
13924
|
+
} else {
|
|
13925
|
+
setPendingSession((prev) => prev ? {
|
|
13926
|
+
...prev,
|
|
13927
|
+
user: syncedUser,
|
|
13928
|
+
sourceUser: syncedUser
|
|
13929
|
+
} : prev);
|
|
13930
|
+
}
|
|
13931
|
+
}, [debugOnboardingState, pendingSession, persistSessionUser]);
|
|
13807
13932
|
const handleOnboardingSkip = useCallback(() => {
|
|
13808
13933
|
const activeSession = debugOnboardingState || pendingSession;
|
|
13809
13934
|
if (!activeSession) return;
|
|
@@ -14011,6 +14136,8 @@ function NativeSSOPage({
|
|
|
14011
14136
|
user: (debugOnboardingState || pendingSession).user,
|
|
14012
14137
|
variant: debugOnboardingState ? "edit" : "missing",
|
|
14013
14138
|
profileHydrating,
|
|
14139
|
+
hydrateProfile: false,
|
|
14140
|
+
onUserInfosSync: handleOnboardingUserInfosSync,
|
|
14014
14141
|
onComplete: handleOnboardingComplete,
|
|
14015
14142
|
onSkip: handleOnboardingSkip
|
|
14016
14143
|
}
|
|
@@ -14090,6 +14217,8 @@ function NativeSSOPage({
|
|
|
14090
14217
|
user: (debugOnboardingState || pendingSession).user,
|
|
14091
14218
|
variant: debugOnboardingState ? "edit" : "missing",
|
|
14092
14219
|
profileHydrating,
|
|
14220
|
+
hydrateProfile: false,
|
|
14221
|
+
onUserInfosSync: handleOnboardingUserInfosSync,
|
|
14093
14222
|
onComplete: handleOnboardingComplete,
|
|
14094
14223
|
onSkip: handleOnboardingSkip
|
|
14095
14224
|
}
|