decord/source/modules/activate_device/useUserCodeSubmit.tsx

82 lines
2.7 KiB
TypeScript
Raw Normal View History

// Module ID: 13976
// Function ID: 13977
2026-07-20 16:05:17 +00:00
// Name: useUserCodeSubmit
// Dependencies: [5, 32, 19, 13975, 1115, 9376, 2]
2026-07-20 16:05:17 +00:00
// Exports: useUserCodeSubmit
// Module 13976 (useUserCodeSubmit)
import asyncGeneratorStep from "asyncGeneratorStep" /* 5 */;
import _slicedToArray from "module_32" /* 32 */;
import noop from "module_19" /* 19 */;
2026-07-23 10:11:24 +00:00
const require = fn;
const OAuthConstants = fn(13975).OAuthConstants;
const size = fn(2);
const result = size.fileFinishedImporting("modules/activate_device/useUserCodeSubmit.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export const useUserCodeSubmit = function useUserCodeSubmit(arr, onUserCodeAccepted, onClose) {
2026-08-24 06:08:38 +00:00
closure_0 = arr;
closure_1 = onUserCodeAccepted;
asyncGeneratorStep = onClose;
const submitting = _slicedToArray(noop.useState(false), 2);
_slicedToArray = submitting[1];
const error = _slicedToArray(noop.useState(null), 2);
noop = error[1];
2026-07-29 08:29:29 +00:00
const items = [arr, onUserCodeAccepted, onClose];
const manualSubmit = noop.useCallback(asyncGeneratorStep(async () => {
2026-08-04 21:03:28 +00:00
v0(true);
await closure_0(tmp3[5]).verifyUserCode(closure_0);
2026-08-04 21:03:28 +00:00
if (1 === tmp7) {
c3 = 0;
closure_128_1 = closure_2;
2026-08-04 21:03:28 +00:00
let status;
if (closure_128_1 != null) {
status = closure_128_1.status;
2026-07-29 08:29:29 +00:00
}
closure_129_4((function verifyUserCodeStatusToErrorMessage(status) {
2026-08-04 21:03:28 +00:00
if (429 === status) {
const intl3 = closure_1_0(1115).intl;
let stringResult = intl3.string(closure_1_0(1115).t.BPmZvj);
2026-07-29 08:29:29 +00:00
} else {
2026-08-04 21:03:28 +00:00
if (404 !== status) {
if (400 !== status) {
const intl = closure_1_0(1115).intl;
stringResult = intl.string(closure_1_0(1115).t.JNQRU4);
2026-07-29 08:29:29 +00:00
}
}
const intl2 = closure_1_0(1115).intl;
stringResult = intl2.string(closure_1_0(1115).t.aWa1Pw);
2026-07-29 08:29:29 +00:00
}
2026-08-04 21:03:28 +00:00
return stringResult;
})(status));
closure_129_3(false);
2026-08-04 21:03:28 +00:00
let status1;
if (closure_128_1 != null) {
status1 = closure_128_1.status;
2026-07-29 08:29:29 +00:00
}
2026-08-04 21:03:28 +00:00
if (401 === status1) {
closure_129_2();
2026-08-04 21:03:28 +00:00
}
2026-08-24 06:08:38 +00:00
c5 = 3;
2026-08-04 21:03:28 +00:00
} else if (arg0 === 1) {
c5 = 3;
throw arg1;
} else if (arg0 !== 2) {
closure_128_0 = arg1;
closure_129_3(false);
closure_129_1({ userCode: closure_129_0, clientId: closure_128_0.body.client_id, scopes: closure_128_0.body.scopes, twoWayLinkCode: closure_128_0.body.two_way_link_code });
c3 = 0;
2026-07-29 08:29:29 +00:00
}
2026-08-04 21:03:28 +00:00
return arg1;
2026-07-29 08:29:29 +00:00
}), items);
const items1 = [arr, manualSubmit];
const effect = noop.useEffect(() => {
if (closure_0.length === OAuthConstants.USER_CODE_LENGTH) {
2026-07-20 16:05:17 +00:00
manualSubmit();
} else {
closure_4(null);
2026-07-20 16:05:17 +00:00
}
}, items1);
return { manualSubmit, error: error[0], submitting: submitting[0] };
};