Compare commits
No commits in common. "a71256e353fed4658e65794ae7cc25d5cd437be2" and "1835cb9f49ebfbb8823fbde6bd2dcafca5c95a12" have entirely different histories.
a71256e353
...
1835cb9f49
1 changed files with 1 additions and 15 deletions
16
js/script.js
16
js/script.js
|
|
@ -92,17 +92,6 @@ function toLatinDigits(str) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getApiErrorMessage(body, fallback) {
|
|
||||||
const detailsMessage = body?.details?.message;
|
|
||||||
if (typeof detailsMessage === "string" && detailsMessage.trim()) {
|
|
||||||
return detailsMessage.trim();
|
|
||||||
}
|
|
||||||
if (typeof body?.status_message === "string" && body.status_message.trim()) {
|
|
||||||
return body.status_message.trim();
|
|
||||||
}
|
|
||||||
return fallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Normalizes Iranian mobile numbers (09xxxxxxxxx, 9xxxxxxxxx, 0098/98/+98 prefixed) to E.164.
|
// Normalizes Iranian mobile numbers (09xxxxxxxxx, 9xxxxxxxxx, 0098/98/+98 prefixed) to E.164.
|
||||||
function toE164(raw) {
|
function toE164(raw) {
|
||||||
let cleaned = toLatinDigits(raw.trim()).replace(/[\s-]/g, "");
|
let cleaned = toLatinDigits(raw.trim()).replace(/[\s-]/g, "");
|
||||||
|
|
@ -122,7 +111,6 @@ async function submitInviteRequest(inviteCode, mobileNumber, token) {
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
"Accept-Language": "fa",
|
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
invite_code: inviteCode,
|
invite_code: inviteCode,
|
||||||
|
|
@ -137,9 +125,7 @@ async function submitInviteRequest(inviteCode, mobileNumber, token) {
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
// no JSON body
|
// no JSON body
|
||||||
}
|
}
|
||||||
const error = new Error(
|
const error = new Error(body?.status_message || `Invite request failed (${response.status})`);
|
||||||
getApiErrorMessage(body, `Invite request failed (${response.status})`)
|
|
||||||
);
|
|
||||||
error.status = response.status;
|
error.status = response.status;
|
||||||
error.body = body;
|
error.body = body;
|
||||||
throw error;
|
throw error;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue