From 24e0e3bfdb6ddd8fc0edabb4e334c8055a6c448c Mon Sep 17 00:00:00 2001 From: Joerg Date: Fri, 23 Jan 2026 09:33:42 +0100 Subject: [PATCH] fix: correct target and needed calculation in award detail view Fixes incorrect calculation of target and needed values in award detail page: - Changed award.target to award.rules?.target (correct path in JSON structure) - Added missing Target display card for non-points awards (DXCC, DLD, etc.) - Added null checks to prevent broken calculations for awards without targets Co-Authored-By: Claude --- .../src/routes/awards/[id]/+page.svelte | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/src/frontend/src/routes/awards/[id]/+page.svelte b/src/frontend/src/routes/awards/[id]/+page.svelte index 47023f0..dc7855b 100644 --- a/src/frontend/src/routes/awards/[id]/+page.svelte +++ b/src/frontend/src/routes/awards/[id]/+page.svelte @@ -550,8 +550,8 @@
{#if entities.length > 0 && entities[0].points !== undefined} {@const earnedPoints = filteredEntities.reduce((sum, e) => sum + (e.confirmed ? e.points : 0), 0)} - {@const targetPoints = award.target} - {@const neededPoints = Math.max(0, targetPoints - earnedPoints)} + {@const targetPoints = award.rules?.target} + {@const neededPoints = targetPoints !== undefined ? Math.max(0, targetPoints - earnedPoints) : null}
Total Combinations: {filteredEntities.length} @@ -564,16 +564,19 @@ Points: {earnedPoints}
-
- Needed: - {neededPoints} -
-
- Target: - {targetPoints} -
+ {#if neededPoints !== null} +
+ Needed: + {neededPoints} +
+
+ Target: + {targetPoints} +
+ {/if} {:else} - {@const neededCount = award.target ? Math.max(0, award.target - uniqueEntityProgress.worked) : uniqueEntityProgress.total - uniqueEntityProgress.worked} + {@const targetCount = award.rules?.target} + {@const neededCount = targetCount !== undefined ? Math.max(0, targetCount - uniqueEntityProgress.worked) : null}
Total: {uniqueEntityProgress.total} @@ -586,10 +589,16 @@ Worked: {uniqueEntityProgress.worked}
-
- Needed: - {neededCount} -
+ {#if neededCount !== null} +
+ Needed: + {neededCount} +
+
+ Target: + {targetCount} +
+ {/if} {/if}