From 6b11004c782b6be730b5f6f031ca6a6b0730139d Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Thu, 15 Feb 2024 03:04:52 +0000 Subject: [PATCH 1/4] feat: cosmetics --- package.json | 2 +- static/index.html | 6 +-- .../render-transaction/render-transaction.ts | 53 +++++++++++-------- static/scripts/rewards/web3/erc20-permit.ts | 2 +- 4 files changed, 36 insertions(+), 27 deletions(-) diff --git a/package.json b/package.json index 1be823f3..991069d6 100644 --- a/package.json +++ b/package.json @@ -36,4 +36,4 @@ "engines": { "node": ">=20.10.0" } -} +} \ No newline at end of file diff --git a/static/index.html b/static/index.html index ac75797f..237230c0 100644 --- a/static/index.html +++ b/static/index.html @@ -62,14 +62,14 @@ xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 490 490" xml:space="preserve" - style="cursor: pointer; padding: 10px" + style="display: none; cursor: pointer; padding: 10px" > -
1/x reward
+
diff --git a/static/scripts/rewards/render-transaction/render-transaction.ts b/static/scripts/rewards/render-transaction/render-transaction.ts index c9638ef4..7c679c46 100644 --- a/static/scripts/rewards/render-transaction/render-transaction.ts +++ b/static/scripts/rewards/render-transaction/render-transaction.ts @@ -33,6 +33,7 @@ export async function init() { console.error(error); setClaimMessage({ type: "Error", message: `Invalid claim data passed in URL` }); table.setAttribute(`data-claim`, "error"); + return false; } @@ -47,29 +48,37 @@ export async function init() { }); const rewardsCount = document.getElementById("rewardsCount"); - if (rewardsCount) { - rewardsCount.innerHTML = `${app.currentIndex + 1}/${app.claimTxs.length} reward`; - const nextTxButton = document.getElementById("nextTx"); - if (nextTxButton) { - nextTxButton.addEventListener("click", () => { - claimButton.element = removeAllEventListeners(claimButton.element) as HTMLButtonElement; - app.nextTx(); - rewardsCount.innerHTML = `${app.currentIndex + 1}/${app.claimTxs.length} reward`; - table.setAttribute(`data-claim`, "none"); - renderTransaction(); - }); - } - - const prevTxButton = document.getElementById("previousTx"); - if (prevTxButton) { - prevTxButton.addEventListener("click", () => { - claimButton.element = removeAllEventListeners(claimButton.element) as HTMLButtonElement; - app.previousTx(); - rewardsCount.innerHTML = `${app.currentIndex + 1}/${app.claimTxs.length} reward`; - table.setAttribute(`data-claim`, "none"); - renderTransaction(); - }); + if (rewardsCount) { + if (!app.claimTxs || app.claimTxs.length <= 1) { + // already hidden + } else { + document.getElementById("rewardsPaginate")?.classList.remove("hidden"); + rewardsCount.innerHTML = `${app.currentIndex + 1}/${app.claimTxs.length} reward`; + + const nextTxButton = document.getElementById("nextTx"); + if (nextTxButton) { + nextTxButton.style.display = "block"; + nextTxButton.addEventListener("click", () => { + claimButton.element = removeAllEventListeners(claimButton.element) as HTMLButtonElement; + app.nextTx(); + rewardsCount.innerHTML = `${app.currentIndex + 1}/${app.claimTxs.length} reward`; + table.setAttribute(`data-claim`, "none"); + renderTransaction(); + }); + } + + const prevTxButton = document.getElementById("previousTx"); + if (prevTxButton) { + prevTxButton.style.display = "block"; + prevTxButton.addEventListener("click", () => { + claimButton.element = removeAllEventListeners(claimButton.element) as HTMLButtonElement; + app.previousTx(); + rewardsCount.innerHTML = `${app.currentIndex + 1}/${app.claimTxs.length} reward`; + table.setAttribute(`data-claim`, "none"); + renderTransaction(); + }); + } } } diff --git a/static/scripts/rewards/web3/erc20-permit.ts b/static/scripts/rewards/web3/erc20-permit.ts index 24a521d0..d65c04fd 100644 --- a/static/scripts/rewards/web3/erc20-permit.ts +++ b/static/scripts/rewards/web3/erc20-permit.ts @@ -55,7 +55,7 @@ export function claimErc20PermitHandler(permit: Erc20Permit) { export async function checkPermitClaimable(permit: Erc20Permit, signer: ethers.providers.JsonRpcSigner | null) { const claimed = await isNonceClaimed(permit); if (claimed) { - toaster.create("error", `This reward has already been claimed or invalidated.`); + toaster.create("error", `Your reward has already been claimed or invalidated.`); return false; } From 5d415d6e586377760ded8636c35bcaf403a44f60 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Thu, 15 Feb 2024 03:07:11 +0000 Subject: [PATCH 2/4] chore: remove unused --- static/scripts/rewards/render-transaction/render-transaction.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/static/scripts/rewards/render-transaction/render-transaction.ts b/static/scripts/rewards/render-transaction/render-transaction.ts index 7c679c46..6ed55729 100644 --- a/static/scripts/rewards/render-transaction/render-transaction.ts +++ b/static/scripts/rewards/render-transaction/render-transaction.ts @@ -53,7 +53,6 @@ export async function init() { if (!app.claimTxs || app.claimTxs.length <= 1) { // already hidden } else { - document.getElementById("rewardsPaginate")?.classList.remove("hidden"); rewardsCount.innerHTML = `${app.currentIndex + 1}/${app.claimTxs.length} reward`; const nextTxButton = document.getElementById("nextTx"); From 41d21d3e12b664e67dbaeb63a43ca51401798606 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Thu, 15 Feb 2024 03:21:48 +0000 Subject: [PATCH 3/4] fix: add 'for this task' --- static/scripts/rewards/web3/erc20-permit.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/scripts/rewards/web3/erc20-permit.ts b/static/scripts/rewards/web3/erc20-permit.ts index d65c04fd..ba5cbcc1 100644 --- a/static/scripts/rewards/web3/erc20-permit.ts +++ b/static/scripts/rewards/web3/erc20-permit.ts @@ -55,7 +55,7 @@ export function claimErc20PermitHandler(permit: Erc20Permit) { export async function checkPermitClaimable(permit: Erc20Permit, signer: ethers.providers.JsonRpcSigner | null) { const claimed = await isNonceClaimed(permit); if (claimed) { - toaster.create("error", `Your reward has already been claimed or invalidated.`); + toaster.create("error", `Your reward for this task has already been claimed or invalidated.`); return false; } From bbc4a2ad11fae6f0713ca63cf855d37c3116baa9 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Thu, 15 Feb 2024 03:42:38 +0000 Subject: [PATCH 4/4] fix: inline to class styling --- static/index.html | 4 ++-- static/styles/rewards/claim-table.css | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/static/index.html b/static/index.html index 237230c0..4b6e62f0 100644 --- a/static/index.html +++ b/static/index.html @@ -62,7 +62,7 @@ xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 490 490" xml:space="preserve" - style="display: none; cursor: pointer; padding: 10px" + class="paginateClaims" > @@ -80,7 +80,7 @@ xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 490 490" xml:space="preserve" - style="display: none; cursor: pointer; padding: 10px" + class="paginateClaims" > diff --git a/static/styles/rewards/claim-table.css b/static/styles/rewards/claim-table.css index 3837b1e1..6145bc32 100644 --- a/static/styles/rewards/claim-table.css +++ b/static/styles/rewards/claim-table.css @@ -271,6 +271,12 @@ table[data-claim-rendered="true"][data-claim="none"][data-contract-loaded="true" color: #fff; } +.paginateClaims { + display: none; + cursor: pointer; + padding: 10px; +} + .show-cl { display: block; }