decord/source/modules/auth/native/RegistrationUtils.tsx

196 lines
6.3 KiB
TypeScript
Raw Normal View History

// Module ID: 16051
// Function ID: 16052
// Name: RegistrationUtils
// Dependencies: [19, 4620, 8865, 16043, 16044, 1074, 21, 1240, 16040, 5712, 2]
2026-07-20 16:05:17 +00:00
// Exports: BackButtonWithTracking, getCommonErrorDetails, getTrackRegTransition, hasAllRegistrationFieldsCompleted
// Module 16051 (RegistrationUtils)
import AnalyticsUtilsDefault from "AnalyticsUtils" /* 1240 */;
import noop from "module_19" /* 19 */;
import InviteStore from "InviteStore" /* 4620 */;
import DisplayedInviteStore from "DisplayedInviteStore" /* 8865 */;
2026-07-23 10:11:24 +00:00
const require = globalThis.__r;
const require = fn;
2026-07-20 16:05:17 +00:00
function trackRegTransition(overrideRegistrationOptions) {
let registrationOptions = overrideRegistrationOptions.overrideRegistrationOptions;
({ step, fromStep, toStep, actionType, details } = overrideRegistrationOptions);
const displayedInviteCode = DisplayedInviteStore.getDisplayedInviteCode();
2026-07-29 08:29:29 +00:00
if (registrationOptions == null) {
2026-07-20 16:05:17 +00:00
registrationOptions = state.getState().registrationOptions;
}
let invite = null;
if (null != displayedInviteCode) {
invite = InviteStore.getInvite(displayedInviteCode);
2026-07-20 16:05:17 +00:00
}
let str = null;
if (null != invite) {
str = "invite";
}
let email;
2026-07-29 08:29:29 +00:00
if (registrationOptions != null) {
2026-07-20 16:05:17 +00:00
email = registrationOptions.email;
}
let str2 = "email";
if (null == email) {
let phone;
2026-07-29 08:29:29 +00:00
if (registrationOptions != null) {
2026-07-20 16:05:17 +00:00
phone = registrationOptions.phone;
}
str2 = null;
if (null != phone) {
str2 = "phone";
}
}
const obj2 = { step, identity_type: str2, action_type: actionType, action_details: details, registration_source: str, invite_code: null, invite_channel_id: null, invite_channel_type: null, invite_guild_id: null, invite_inviter_id: null, from_step: null, to_step: null };
2026-07-20 16:05:17 +00:00
let code;
2026-07-29 08:29:29 +00:00
if (invite != null) {
2026-07-20 16:05:17 +00:00
code = invite.code;
}
obj2.invite_code = code;
2026-07-20 16:05:17 +00:00
let id;
2026-07-29 08:29:29 +00:00
if (invite != null) {
2026-07-20 16:05:17 +00:00
const channel = invite.channel;
2026-07-29 08:29:29 +00:00
if (channel != null) {
2026-07-20 16:05:17 +00:00
id = channel.id;
}
}
obj2.invite_channel_id = id;
2026-07-20 16:05:17 +00:00
let type;
2026-07-29 08:29:29 +00:00
if (invite != null) {
2026-07-20 16:05:17 +00:00
const channel2 = invite.channel;
2026-07-29 08:29:29 +00:00
if (channel2 != null) {
2026-07-20 16:05:17 +00:00
type = channel2.type;
}
}
obj2.invite_channel_type = type;
2026-07-20 16:05:17 +00:00
let id1;
2026-07-29 08:29:29 +00:00
if (invite != null) {
2026-07-20 16:05:17 +00:00
const guild = invite.guild;
2026-07-29 08:29:29 +00:00
if (guild != null) {
2026-07-20 16:05:17 +00:00
id1 = guild.id;
}
}
obj2.invite_guild_id = id1;
2026-07-20 16:05:17 +00:00
let id2;
2026-07-29 08:29:29 +00:00
if (invite != null) {
2026-07-20 16:05:17 +00:00
const inviter = invite.inviter;
2026-07-29 08:29:29 +00:00
if (inviter != null) {
2026-07-20 16:05:17 +00:00
id2 = inviter.id;
}
}
obj2.invite_inviter_id = id2;
obj2.from_step = fromStep;
obj2.to_step = toStep;
AnalyticsUtilsDefault.track(AnalyticEvents.REGISTER_TRANSITION, obj2);
2026-07-20 16:05:17 +00:00
}
const RegistrationUIStore = fn(16043);
({ clearRegistrationErrorMessage: metroRequire, useRegistrationUIStore: closure_7 } = RegistrationUIStore);
const RegistrationConstants = fn(16044);
({ RegisterTransitionSteps: closure_8, RegistrationTransitionActionTypes: closure_9 } = RegistrationConstants);
const AnalyticEvents = fn(1074).AnalyticEvents;
const jsx = fn(21).jsx;
const size = fn(2);
const result = size.fileFinishedImporting("modules/auth/native/RegistrationUtils.tsx");
2026-07-20 16:05:17 +00:00
export const hasAllRegistrationFieldsCompleted = function hasAllRegistrationFieldsCompleted(email, isConsentRequired) {
2026-07-29 08:29:29 +00:00
isConsentRequired = isConsentRequired.isConsentRequired;
let tmp = null != email.email || null != email.phoneToken;
2026-07-20 16:05:17 +00:00
if (tmp) {
let tmp2 = null != email.username;
if (tmp2) {
let tmp3 = null != email.password;
if (tmp3) {
let tmp4 = null != email.birthday;
if (tmp4) {
let tmp5 = null != email.consent;
if (tmp5) {
2026-07-29 08:29:29 +00:00
let tmp6 = !isConsentRequired;
if (isConsentRequired) {
2026-07-20 16:05:17 +00:00
tmp6 = true === email.consent;
}
tmp5 = tmp6;
}
tmp4 = tmp5;
}
tmp3 = tmp4;
}
tmp2 = tmp3;
}
tmp = tmp2;
}
return tmp;
};
export { trackRegTransition };
export function getTrackRegTransition(arg0) {
2026-07-20 16:05:17 +00:00
return (arg0) => {
2026-07-29 08:29:29 +00:00
({ step, actionType, toStep, details, overrideRegistrationOptions } = arg0);
if (actionType === constants2.VIEWED) {
if (step === constants.CAPTCHA) {
const obj = { step, fromStep: ref.current, actionType };
trackRegTransition(obj);
2026-07-20 16:05:17 +00:00
}
}
if (actionType === constants2.VIEWED) {
2026-07-20 16:05:17 +00:00
if (null != step) {
const obj2 = { step, fromStep: ref.current, actionType };
trackRegTransition(obj2);
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
ref.current = step;
2026-07-20 16:05:17 +00:00
} else if (null != step) {
const obj3 = { step, toStep, actionType, details, overrideRegistrationOptions };
trackRegTransition(obj3);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp9;
2026-07-20 16:05:17 +00:00
};
}
export const BackButtonWithTracking = function BackButtonWithTracking(arg0) {
_require = noop.useContext(require("Auth").TrackRegistrationContext);
2026-07-23 10:11:24 +00:00
({ destinationStep: importDefault, onPress: dependencyMap } = arg0);
let obj = {};
2026-07-20 16:05:17 +00:00
const merged = Object.assign(arg0);
2026-07-29 08:29:29 +00:00
obj.onPress = function onPress() {
if (null != dependencyMap) {
timestampProducer();
const obj = { step, actionType: constants2.VIEWED };
closure_0(obj);
2026-07-29 08:29:29 +00:00
tmp();
2026-07-20 16:05:17 +00:00
}
};
return jsx(require("module_5712").HeaderBackButton, {});
2026-07-20 16:05:17 +00:00
};
export const getCommonErrorDetails = function getCommonErrorDetails(error_code) {
if (-1 === error_code) {
const _HermesInternal7 = HermesInternal;
return "" + error_code + ": Captcha was not completed";
} else if (0 === error_code) {
const _HermesInternal6 = HermesInternal;
return "" + error_code + ": Internal server error";
} else if (40333 === error_code) {
const _HermesInternal5 = HermesInternal;
return "" + error_code + ": Blocked by proxy";
} else if (50022 === error_code) {
const _HermesInternal4 = HermesInternal;
return "" + error_code + ": Phone number invalid";
} else if (70005 === error_code) {
const _HermesInternal3 = HermesInternal;
return "" + error_code + ": Phone number not mobile";
} else if (70003 === error_code) {
const _HermesInternal2 = HermesInternal;
return "" + error_code + ": Unable to send sms to phone number";
} else {
if (70008 !== error_code) {
if (70011 !== error_code) {
if (undefined === error_code) {
return "No error code";
} else {
return error_code.toString();
}
}
}
const _HermesInternal = HermesInternal;
return "" + error_code + ": Phone number already associated with an account";
}
};