diff --git a/h5/hyapp/host-center/index.html b/h5/hyapp/host-center/index.html index 5300a60..181f252 100644 --- a/h5/hyapp/host-center/index.html +++ b/h5/hyapp/host-center/index.html @@ -4,7 +4,7 @@ Host Center - +
@@ -175,6 +175,7 @@

Application is pending. Please wait for agency approval.

+ @@ -194,6 +195,6 @@
loading....
- + diff --git a/h5/hyapp/host-center/script.js b/h5/hyapp/host-center/script.js index 5567f20..2092262 100644 --- a/h5/hyapp/host-center/script.js +++ b/h5/hyapp/host-center/script.js @@ -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); diff --git a/h5/hyapp/host-center/style.css b/h5/hyapp/host-center/style.css index 0830629..7f36629 100644 --- a/h5/hyapp/host-center/style.css +++ b/h5/hyapp/host-center/style.css @@ -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;