Spaces:
Sleeping
Sleeping
Keith Yu commited on
Commit ·
da7cb4e
1
Parent(s): 96bce34
backend
Browse files
script.js
CHANGED
|
@@ -1279,13 +1279,21 @@ async function refreshPendingProposals() {
|
|
| 1279 |
const id = el.getAttribute("data-id");
|
| 1280 |
if (!id || !action) return;
|
| 1281 |
|
| 1282 |
-
|
|
|
|
|
|
|
| 1283 |
try {
|
| 1284 |
const reviewer = requireReviewerName();
|
| 1285 |
if (!reviewer) {
|
| 1286 |
-
|
| 1287 |
return;
|
| 1288 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1289 |
if (action === "apply" && getSupabaseClient()) {
|
| 1290 |
const p = byId.get(String(id));
|
| 1291 |
if (!p) throw new Error("Missing proposal payload in UI.");
|
|
@@ -1302,7 +1310,7 @@ async function refreshPendingProposals() {
|
|
| 1302 |
// Applying should also refresh claims data next run; for now just refresh the list.
|
| 1303 |
await refreshPendingProposals();
|
| 1304 |
} catch (e) {
|
| 1305 |
-
|
| 1306 |
alert(`Proposal ${action} failed: ${e.message || String(e)}`);
|
| 1307 |
}
|
| 1308 |
});
|
|
|
|
| 1279 |
const id = el.getAttribute("data-id");
|
| 1280 |
if (!id || !action) return;
|
| 1281 |
|
| 1282 |
+
const card = el.closest("article");
|
| 1283 |
+
const cardButtons = card ? Array.from(card.querySelectorAll("button[data-action]")) : [el];
|
| 1284 |
+
cardButtons.forEach((b) => (b.disabled = true));
|
| 1285 |
try {
|
| 1286 |
const reviewer = requireReviewerName();
|
| 1287 |
if (!reviewer) {
|
| 1288 |
+
cardButtons.forEach((b) => (b.disabled = false));
|
| 1289 |
return;
|
| 1290 |
}
|
| 1291 |
+
// Apply implies approval: approve first, then apply.
|
| 1292 |
+
if (action === "apply") {
|
| 1293 |
+
await postJson(`/api/proposals/${encodeURIComponent(id)}/approve`, {
|
| 1294 |
+
reviewer_name: reviewer,
|
| 1295 |
+
});
|
| 1296 |
+
}
|
| 1297 |
if (action === "apply" && getSupabaseClient()) {
|
| 1298 |
const p = byId.get(String(id));
|
| 1299 |
if (!p) throw new Error("Missing proposal payload in UI.");
|
|
|
|
| 1310 |
// Applying should also refresh claims data next run; for now just refresh the list.
|
| 1311 |
await refreshPendingProposals();
|
| 1312 |
} catch (e) {
|
| 1313 |
+
cardButtons.forEach((b) => (b.disabled = false));
|
| 1314 |
alert(`Proposal ${action} failed: ${e.message || String(e)}`);
|
| 1315 |
}
|
| 1316 |
});
|