fix: add join agency cancel action
This commit is contained in:
parent
72031c5b08
commit
d72a0502ec
@ -4,7 +4,7 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" />
|
||||
<title>Host Center</title>
|
||||
<link rel="stylesheet" href="./style.css?v=20260428-2110" />
|
||||
<link rel="stylesheet" href="./style.css?v=20260428-2120" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="host-center" aria-label="Host Center" data-i18n-aria="page_label" data-loading="true" data-view="loading">
|
||||
@ -175,6 +175,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<p class="join-agency-pending-note" data-i18n="join_pending_note">Application is pending. Please wait for agency approval.</p>
|
||||
<button class="join-agency-cancel-button" id="joinAgencyCancelButton" type="button" data-i18n="cancel">Cancel</button>
|
||||
</section>
|
||||
</div>
|
||||
</section>
|
||||
@ -194,6 +195,6 @@
|
||||
<div class="loading-copy">loading....</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="./script.js?v=20260428-2110" defer></script>
|
||||
<script src="./script.js?v=20260428-2120" defer></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -43,6 +43,10 @@
|
||||
application_records: "Application Records",
|
||||
pending: "Pending",
|
||||
join_pending_note: "Application is pending. Please wait for agency approval.",
|
||||
cancel: "Cancel",
|
||||
cancelling: "Cancelling...",
|
||||
cancellation_failed: "Cancellation failed",
|
||||
application_cancelled: "Application cancelled",
|
||||
missing_token: "Missing token",
|
||||
network_error: "Network error. Please try again.",
|
||||
withdraw_exchange: "Withdraw/Exchange",
|
||||
@ -95,6 +99,10 @@
|
||||
application_records: "سجلات الطلب",
|
||||
pending: "قيد الانتظار",
|
||||
join_pending_note: "الطلب قيد الانتظار. يرجى انتظار موافقة الوكالة.",
|
||||
cancel: "إلغاء",
|
||||
cancelling: "جار الإلغاء...",
|
||||
cancellation_failed: "فشل الإلغاء",
|
||||
application_cancelled: "تم إلغاء الطلب",
|
||||
missing_token: "رمز الدخول مفقود",
|
||||
network_error: "خطأ في الشبكة. حاول مرة أخرى.",
|
||||
withdraw_exchange: "سحب/استبدال",
|
||||
@ -147,6 +155,10 @@
|
||||
application_records: "Başvuru Kayıtları",
|
||||
pending: "Beklemede",
|
||||
join_pending_note: "Başvuru beklemede. Lütfen ajans onayını bekleyin.",
|
||||
cancel: "İptal",
|
||||
cancelling: "İptal ediliyor...",
|
||||
cancellation_failed: "İptal başarısız",
|
||||
application_cancelled: "Başvuru iptal edildi",
|
||||
missing_token: "Token eksik",
|
||||
network_error: "Ağ hatası. Lütfen tekrar deneyin.",
|
||||
withdraw_exchange: "Çek/Değiştir",
|
||||
@ -199,6 +211,10 @@
|
||||
application_records: "Catatan Pengajuan",
|
||||
pending: "Menunggu",
|
||||
join_pending_note: "Pengajuan sedang menunggu. Harap tunggu persetujuan agensi.",
|
||||
cancel: "Batal",
|
||||
cancelling: "Membatalkan...",
|
||||
cancellation_failed: "Gagal membatalkan",
|
||||
application_cancelled: "Pengajuan dibatalkan",
|
||||
missing_token: "Token tidak ditemukan",
|
||||
network_error: "Kesalahan jaringan. Silakan coba lagi.",
|
||||
withdraw_exchange: "Tarik/Tukar",
|
||||
@ -802,6 +818,13 @@
|
||||
function syncJoinAgencyApplyAvailability() {
|
||||
const button = document.querySelector("#joinAgencyApplyButton");
|
||||
if (button) button.hidden = Boolean(pendingJoinRecord) || !foundJoinAgency?.id;
|
||||
|
||||
const cancelButton = document.querySelector("#joinAgencyCancelButton");
|
||||
if (cancelButton) cancelButton.hidden = !pendingJoinRecord || !pickPendingJoinRecordId(pendingJoinRecord);
|
||||
}
|
||||
|
||||
function pickPendingJoinRecordId(record) {
|
||||
return record?.messageId || record?.id || "";
|
||||
}
|
||||
|
||||
function renderFoundJoinAgency(profile = foundJoinAgency) {
|
||||
@ -941,6 +964,37 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function cancelJoinApplication() {
|
||||
const id = pickPendingJoinRecordId(pendingJoinRecord);
|
||||
if (!id) return;
|
||||
|
||||
const button = document.querySelector("#joinAgencyCancelButton");
|
||||
if (button) {
|
||||
button.disabled = true;
|
||||
button.textContent = message("cancelling");
|
||||
}
|
||||
showJoinAgencyStatus("");
|
||||
|
||||
try {
|
||||
await requestJSON("/team/user/join-apply-cancel", {
|
||||
method: "POST",
|
||||
body: { id }
|
||||
});
|
||||
|
||||
pendingJoinRecord = null;
|
||||
renderPendingJoinRecord(null);
|
||||
showJoinAgencyStatus(message("application_cancelled"), "success");
|
||||
} catch (error) {
|
||||
showJoinAgencyStatus(joinAgencyErrorMessage(error, "cancellation_failed"), "error");
|
||||
} finally {
|
||||
if (button) {
|
||||
button.disabled = false;
|
||||
button.textContent = message("cancel");
|
||||
}
|
||||
syncJoinAgencyApplyAvailability();
|
||||
}
|
||||
}
|
||||
|
||||
function setJoinAgencyModalOpen(open) {
|
||||
const modal = document.querySelector("#joinAgencyModal");
|
||||
if (!modal) return;
|
||||
@ -1238,6 +1292,10 @@
|
||||
applyToJoinAgency();
|
||||
});
|
||||
|
||||
document.querySelector("#joinAgencyCancelButton")?.addEventListener("click", () => {
|
||||
cancelJoinApplication();
|
||||
});
|
||||
|
||||
document.querySelectorAll("[data-close-join-agency]").forEach((node) => {
|
||||
node.addEventListener("click", () => {
|
||||
setJoinAgencyModalOpen(false);
|
||||
|
||||
@ -1213,7 +1213,8 @@ a {
|
||||
}
|
||||
|
||||
.join-agency-search-button,
|
||||
.join-agency-apply-button {
|
||||
.join-agency-apply-button,
|
||||
.join-agency-cancel-button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@ -1231,7 +1232,8 @@ a {
|
||||
}
|
||||
|
||||
.join-agency-search-button:disabled,
|
||||
.join-agency-apply-button:disabled {
|
||||
.join-agency-apply-button:disabled,
|
||||
.join-agency-cancel-button:disabled {
|
||||
opacity: 0.58;
|
||||
}
|
||||
|
||||
@ -1324,6 +1326,13 @@ a {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.join-agency-cancel-button {
|
||||
width: 100%;
|
||||
border: 1px solid #e9edf0;
|
||||
background: #fff;
|
||||
color: #4b4e55;
|
||||
}
|
||||
|
||||
.join-agency-pending-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user