update ui view for member

This commit is contained in:
JCEEE
2026-08-02 18:29:00 +01:00
parent 673b134cfc
commit ccbbd302d4
+399 -359
View File
@@ -202,10 +202,13 @@
const isCurrentWeek = $derived(weekStart === currentWeek); const isCurrentWeek = $derived(weekStart === currentWeek);
const daysLeft = $derived( const daysLeft = $derived(
Math.max(
0,
Math.round( Math.round(
(new Date(weekEnd + 'T00:00:00').getTime() - new Date(todayIso + 'T00:00:00').getTime()) / (new Date(weekEnd + 'T00:00:00').getTime() - new Date(todayIso + 'T00:00:00').getTime()) /
86400000 86400000
) )
)
); );
let memberChores = $derived.by(() => { let memberChores = $derived.by(() => {
@@ -682,11 +685,18 @@
</Card> </Card>
</CardGrid> </CardGrid>
{:else} {:else}
<!-- Child View: Member Kanban --> <!-- Child View -->
<div class="wk-head"> {#if loading}
<div class="wk-head-main"> <p class="empty">Loading...</p>
{:else if error}
<p class="error">{error}</p>
{:else}
<!-- HERO -->
<header class="hero">
<div class="hero-top">
<div class="hero-id">
<span <span
class="color-dot" class="color-dot hero-dot"
style="background:{memberColor}" style="background:{memberColor}"
role="button" role="button"
tabindex="0" tabindex="0"
@@ -700,7 +710,7 @@
<input <input
type="text" type="text"
bind:value={nameInput} bind:value={nameInput}
class="name-edit" class="name-edit name-edit-dark"
onkeydown={async (e: KeyboardEvent) => { onkeydown={async (e: KeyboardEvent) => {
if (e.key === 'Enter') { if (e.key === 'Enter') {
editingName = false; editingName = false;
@@ -735,19 +745,25 @@
/> />
{:else} {:else}
<span <span
class="name-display" class="hero-name"
role="button" role="button"
tabindex="0" tabindex="0"
onclick={() => { onclick={() => {
nameInput = memberName; nameInput = memberName;
editingName = true; editingName = true;
}} }}
onkeydown={(e) => e.key === 'Enter' && ((nameInput = memberName), (editingName = true))} onkeydown={(e) =>
e.key === 'Enter' && ((nameInput = memberName), (editingName = true))}
> >
{memberName || username} {memberName || username}
</span> </span>
{/if} {/if}
</div> </div>
<div class="hero-date">
<span class="hero-day">{headDay()}</span>
<span class="hero-month">{headMonth()}</span>
</div>
</div>
{#if showColorPicker} {#if showColorPicker}
<!-- svelte-ignore a11y_no_static_element_interactions --> <!-- svelte-ignore a11y_no_static_element_interactions -->
@@ -786,134 +802,56 @@
</div> </div>
{/if} {/if}
<div class="wk-date"> <div class="hero-progress">
<div class="wk-date-left"> <span class="hero-pct">{weeklyTotal > 0 ? weeklyPct : 0}%</span>
<span class="wk-day">{headDay()}</span> <div class="bar-wrap hero-bar">
<span class="wk-month">{headMonth()}</span> <div class="bar-fill hero-fill" style="width:{weeklyPct}%"></div>
</div>
<div class="wk-days-left">
<span class="wk-days-num">{daysLeft}</span>
<span class="wk-days-label">days left</span>
</div> </div>
<span class="hero-count">
{weeklyTotal > 0 ? `${weeklyDone}/${weeklyTotal} done` : 'no chores yet'}
</span>
</div> </div>
<div class="wk-nav"> <div class="hero-meta">
<button class="wk-nav-btn" onclick={() => navigate(-1)}> last week</button> {#if weekBonusTallies.length > 0}
<button class="wk-nav-btn" class:active={isCurrentWeek} onclick={jumpToNow}> <div class="hero-pills">
current week
</button>
<button class="wk-nav-btn" onclick={() => navigate(1)}>
{shortDate(weekStart)}
</button>
</div>
</div>
{#if loading}
<p class="empty">Loading...</p>
{:else if error}
<p class="error">{error}</p>
{:else}
<!-- Row 1: progress, bonuses, all-time -->
<CardGrid cols={6}>
<Card cols={2} title="This week progress">
{#if weeklyTotal > 0}
{@const wpct = Math.max(0, Math.min(100, weeklyPct))}
<div class="big-stat">{weeklyDone}<span class="big-sub">/{weeklyTotal} done</span></div>
<div class="bar-wrap lg">
<div class="bar-fill" style="width:{wpct}%"></div>
</div>
<div class="row-spacer"></div>
{:else}
<p class="empty">No chores assigned</p>
{/if}
</Card>
<Card cols={2} title="This weeks bonuses">
{#if weekBonusTallies.length === 0}
<p class="empty">No bonuses yet</p>
{:else}
<div class="bonus-tallies">
{#each weekBonusTallies as t} {#each weekBonusTallies as t}
<div class="bonus-tally"> <span class="hero-pill">🎉 {t.name} ×{t.count}</span>
<span class="bt-name">{t.name}</span>
<span class="bt-count">{t.count}</span>
</div>
{/each} {/each}
</div> </div>
{:else}
<span class="hero-null">no bonuses earned yet</span>
{/if} {/if}
</Card> <div class="hero-days"><b>{daysLeft}</b> days left</div>
<Card cols={2} title="All time">
<div class="alltime">
<div class="alltime-row">
<span class="alltime-label">Cash</span>
<span class="alltime-value cash">£{allTimeCash.toFixed(2)}</span>
</div> </div>
<div class="alltime-row">
<span class="alltime-label">Points</span>
<span class="alltime-value points">{allTimePoints}</span>
</div>
</div>
</Card>
<Card cols={2} title="End of week cash" accent="#10b981"> <nav class="hero-nav">
<div class="big-stat cash">£{pendingCash.toFixed(2)}</div> <button class="hero-nav-btn" onclick={() => navigate(-1)} aria-label="Previous week"
<p class="stat-sub">pending this week</p> ></button
</Card>
<Card cols={2} title="End of week points" accent="#8b5cf6">
<div class="big-stat points">{pendingPoints}</div>
<p class="stat-sub">pending this week</p>
</Card>
<Card cols={2} title="Claims" accent="#f59e0b">
{#if pendingRewards.length === 0}
<p class="empty">Nothing to claim</p>
{:else}
{#each pendingRewards as r}
{@const isRequested = r.status === 'requested'}
<div class="claim-list-row" class:requested={isRequested}>
<span class="cl-status">
{#if isRequested}🕓 requested{:else}▪️ claimable{/if}
</span>
<span class="cl-label">{r.label}</span>
<span class="cl-value">
{#if r.rewardType === 'cash'}
£{Number(r.value).toFixed(2)}
{:else if r.rewardType === 'prize'}
🎁 {r.value}
{:else}
{r.value} pts
{/if}
</span>
{#if isRequested}
<span class="cl-wait">waiting</span>
{:else}
<button
class="cl-cta"
onclick={async () => {
try {
await memberApi.claimReward(deviceToken, famId, r.id);
} catch (e) {
claimError = e instanceof Error ? e.message : 'Claim failed';
}
}}
> >
Request <button class="hero-nav-btn cur" onclick={jumpToNow}
</button> >{isCurrentWeek ? 'This week' : `${shortDate(weekStart)}`}</button
{/if} >
</div> <button class="hero-nav-btn" onclick={() => navigate(1)} aria-label="Next week"></button>
{/each} </nav>
{/if} </header>
</Card>
</CardGrid>
<!-- Kanban --> <!-- PENDING TILES -->
<CardGrid cols={6}> <div class="tiles">
<Card cols={6}> <div class="tile tile-cash">
<span class="tile-val">£{pendingCash.toFixed(2)}</span>
<span class="tile-lbl">pending cash</span>
</div>
<div class="tile tile-pts">
<span class="tile-val">{pendingPoints}</span>
<span class="tile-lbl">pending points</span>
</div>
</div>
<!-- KANBAN -->
<div class="kanban"> <div class="kanban">
<div class="column"> <div class="column col-daily">
<h2>Daily Pending ({dailyPending.length})</h2> <h2>🎯 Daily ({dailyPending.length})</h2>
{#if dailyPending.length === 0} {#if dailyPending.length === 0}
<p class="empty">All done!</p> <p class="empty">All done!</p>
{:else} {:else}
@@ -926,9 +864,8 @@
{/each} {/each}
{/if} {/if}
</div> </div>
<div class="column col-weekly">
<div class="column"> <h2>📅 Weekly ({weeklyPending.length})</h2>
<h2>Weekly Pending ({weeklyPending.length})</h2>
{#if weeklyPending.length === 0} {#if weeklyPending.length === 0}
<p class="empty">All done!</p> <p class="empty">All done!</p>
{:else} {:else}
@@ -941,9 +878,8 @@
{/each} {/each}
{/if} {/if}
</div> </div>
<div class="column col-done">
<div class="column"> <h2>✅ Done ({completedToday.length})</h2>
<h2>Completed Today ({completedToday.length})</h2>
{#if completedToday.length === 0} {#if completedToday.length === 0}
<p class="empty">Nothing yet</p> <p class="empty">Nothing yet</p>
{:else} {:else}
@@ -960,8 +896,55 @@
{/if} {/if}
</div> </div>
</div> </div>
</Card>
</CardGrid> <!-- WALLET / CLAIMS -->
<div class="wallet">
<div class="wallet-top">
<span class="wallet-lbl">💰 Wallet</span>
{#if allTimeCash > 0 || allTimePoints > 0}
<span class="wallet-total">
<span class="wallet-cash">£{allTimeCash.toFixed(2)}</span>
<span class="wallet-dot">·</span>
<span class="wallet-pts">{allTimePoints} pts</span>
</span>
{/if}
</div>
{#if pendingRewards.length === 0}
<p class="wallet-empty">No rewards waiting</p>
{:else}
<div class="wallet-rewards">
{#each pendingRewards as r}
{@const isReq = r.status === 'requested'}
<div class="wallet-reward">
<span class="wr-label">{r.label}</span>
<span class="wr-val">
{#if r.rewardType === 'cash'}
£{Number(r.value).toFixed(2)}
{:else if r.rewardType === 'prize'}
🎁
{:else}
{r.value} pts
{/if}
</span>
{#if isReq}
<span class="wr-pending">⏳ waiting</span>
{:else}
<button
class="wr-cta"
onclick={async () => {
try {
await memberApi.claimReward(deviceToken, famId, r.id);
} catch (e) {
claimError = e instanceof Error ? e.message : 'Claim failed';
}
}}>Request</button
>
{/if}
</div>
{/each}
</div>
{/if}
</div>
{/if} {/if}
{/if} {/if}
@@ -1207,68 +1190,6 @@
text-align: center; text-align: center;
} }
.bar-wrap.lg {
height: 14px;
}
.kanban {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 0.75rem;
}
.column {
border: 1px solid #e5e7eb;
border-radius: 8px;
padding: 0.75rem;
background: #f9fafb;
}
.column h2 {
margin: 0 0 0.75rem;
font-size: 0.95rem;
}
.chore {
display: flex;
align-items: center;
gap: 0.4rem;
width: 100%;
padding: 0.5rem 0.6rem;
margin-bottom: 0.4rem;
border: 1px solid #e5e7eb;
border-radius: 6px;
background: white;
cursor: pointer;
text-align: left;
font-size: 0.85rem;
}
.chore:hover {
background: #f3f4f6;
}
.chore:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.done {
opacity: 0.65;
}
.checkbox {
font-size: 1rem;
flex-shrink: 0;
}
.chore-name {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.chore-value {
font-size: 0.75rem;
color: #6b7280;
font-weight: 600;
white-space: nowrap;
}
.section-label { .section-label {
font-size: 0.75rem; font-size: 0.75rem;
font-weight: 600; font-weight: 600;
@@ -1296,10 +1217,6 @@
cursor: pointer; cursor: pointer;
flex-shrink: 0; flex-shrink: 0;
} }
.name-display {
cursor: pointer;
border-bottom: 1px dashed #d1d5db;
}
.name-edit { .name-edit {
font-size: 1.2rem; font-size: 1.2rem;
padding: 0.1rem 0.3rem; padding: 0.1rem 0.3rem;
@@ -1345,221 +1262,344 @@
transform: scale(1.1); transform: scale(1.1);
} }
.wk-head { /* ── Child view ── */
.hero {
background: linear-gradient(135deg, #6366f1, #8b5cf6 55%, #a855f7);
border-radius: 16px;
padding: 1.25rem 1.5rem;
margin-bottom: 1rem;
color: #fff;
box-shadow: 0 10px 30px rgba(99, 102, 241, 0.35);
}
.hero-top {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 1.5rem;
flex-wrap: wrap;
justify-content: space-between; justify-content: space-between;
margin-bottom: 1.25rem; gap: 0.75rem;
margin-bottom: 1rem;
} }
.wk-head-main { .hero-id {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 0.5rem; gap: 0.6rem;
min-width: 0;
} }
.wk-date { .hero-dot {
display: flex; border-color: rgba(255, 255, 255, 0.6);
align-items: center; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
gap: 1.25rem;
} }
.wk-date-left { .hero-name {
font-size: 1.5rem;
font-weight: 800;
color: #fff;
cursor: pointer;
border-bottom: 1px dashed rgba(255, 255, 255, 0.4);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.name-edit-dark {
background: rgba(255, 255, 255, 0.92);
color: #1e1b4b;
border-color: #fff;
font-size: 1.2rem;
}
.hero-date {
display: flex; display: flex;
align-items: baseline; align-items: baseline;
gap: 0.5rem; gap: 0.45rem;
flex-shrink: 0;
} }
.wk-day { .hero-day {
font-size: 3.5rem; font-size: 1.7rem;
font-weight: 800; font-weight: 800;
line-height: 1; line-height: 1;
color: #111827; color: #fff;
} }
.wk-month { .hero-month {
font-size: 1rem; font-size: 0.85rem;
color: #6b7280;
font-weight: 600; font-weight: 600;
color: rgba(255, 255, 255, 0.85);
} }
.wk-days-left { .hero-progress {
display: flex;
align-items: center;
gap: 0.75rem;
margin-bottom: 0.7rem;
}
.hero-pct {
font-size: 1.5rem;
font-weight: 800;
color: #fff;
flex-shrink: 0;
min-width: 3.4rem;
}
.hero-bar {
flex: 1;
height: 12px;
background: rgba(255, 255, 255, 0.28);
}
.hero-fill {
background: #fff;
}
.hero-count {
font-size: 0.8rem;
font-weight: 700;
color: rgba(255, 255, 255, 0.95);
flex-shrink: 0;
white-space: nowrap;
}
.hero-meta {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.75rem;
margin-bottom: 0.9rem;
flex-wrap: wrap;
}
.hero-pills {
display: flex;
gap: 0.4rem;
flex-wrap: wrap;
}
.hero-pill {
font-size: 0.75rem;
font-weight: 700;
padding: 3px 10px;
border-radius: 999px;
background: rgba(255, 255, 255, 0.2);
color: #fff;
border: 1px solid rgba(255, 255, 255, 0.5);
}
.hero-null {
font-size: 0.75rem;
color: rgba(255, 255, 255, 0.7);
}
.hero-days {
font-size: 0.85rem;
color: rgba(255, 255, 255, 0.9);
}
.hero-days b {
font-size: 1.4rem;
margin-right: 0.15rem;
}
.hero-nav {
display: flex;
gap: 0.4rem;
}
.hero-nav-btn {
font-size: 0.85rem;
font-weight: 700;
padding: 0.35rem 0.9rem;
border: none;
border-radius: 8px;
background: rgba(255, 255, 255, 0.2);
color: #fff;
cursor: pointer;
}
.hero-nav-btn:hover {
background: rgba(255, 255, 255, 0.32);
}
.hero-nav-btn.cur {
flex: 1;
background: #fff;
color: #6d28d9;
}
.tiles {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 0.75rem;
margin-bottom: 1rem;
}
.tile {
border-radius: 14px;
padding: 0.9rem 1.1rem;
color: #fff;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; gap: 0.15rem;
padding-left: 1.25rem; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
border-left: 2px solid #e5e7eb;
} }
.wk-days-num { .tile-cash {
font-size: 2.5rem; background: linear-gradient(135deg, #059669, #10b981);
}
.tile-pts {
background: linear-gradient(135deg, #7c3aed, #a855f7);
}
.tile-val {
font-size: 1.6rem;
font-weight: 800; font-weight: 800;
line-height: 1;
color: #6366f1;
} }
.wk-days-label { .tile-lbl {
font-size: 0.75rem;
text-transform: uppercase;
letter-spacing: 0.06em;
opacity: 0.9;
}
/* ── Kanban ── */
.kanban {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 0.75rem;
margin-bottom: 1rem;
}
.column {
border: 1px solid #e5e7eb;
border-top: 4px solid #6366f1;
border-radius: 12px;
padding: 0.75rem;
background: #fafbff;
}
.column h2 {
margin: 0 0 0.75rem;
font-size: 0.95rem;
}
.col-daily {
border-top-color: #6366f1;
background: #eef2ff;
}
.col-weekly {
border-top-color: #f59e0b;
background: #fffbeb;
}
.col-done {
border-top-color: #10b981;
background: #ecfdf5;
}
.chore {
display: flex;
align-items: center;
gap: 0.4rem;
width: 100%;
padding: 0.5rem 0.6rem;
margin-bottom: 0.4rem;
border: 1px solid #e5e7eb;
border-radius: 8px;
background: white;
cursor: pointer;
text-align: left;
font-size: 0.85rem;
}
.chore:hover {
transform: translateY(-1px);
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
border-color: #c7d2fe;
}
.chore:disabled {
opacity: 0.5;
cursor: not-allowed;
transform: none;
box-shadow: none;
}
.done {
opacity: 0.7;
}
.checkbox {
font-size: 1rem;
flex-shrink: 0;
}
.chore-name {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.chore-value {
font-size: 0.75rem; font-size: 0.75rem;
color: #6b7280; color: #6b7280;
font-weight: 600;
white-space: nowrap;
}
.wallet {
background: #fff;
border: 1px solid #e5e7eb;
border-radius: 14px;
padding: 1rem 1.25rem;
}
.wallet-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.5rem;
margin-bottom: 0.5rem;
}
.wallet-lbl {
font-size: 0.8rem;
font-weight: 800;
color: #374151;
text-transform: uppercase; text-transform: uppercase;
letter-spacing: 0.05em; letter-spacing: 0.05em;
} }
.wk-nav { .wallet-total {
display: flex; display: flex;
gap: 0.4rem; gap: 0.4rem;
align-items: center; align-items: center;
}
.wk-nav-btn {
font-size: 0.8rem;
padding: 0.4rem 0.7rem;
border: 1px solid #d1d5db;
border-radius: 6px;
background: white;
cursor: pointer;
font-weight: 600;
color: #374151;
}
.wk-nav-btn:hover {
background: #f3f4f6;
}
.wk-nav-btn.active {
background: #6366f1;
color: white;
border-color: #6366f1;
}
.big-stat {
font-size: 2.2rem;
font-weight: 800;
line-height: 1.1;
margin-bottom: 0.25rem;
}
.big-stat.cash {
color: #059669;
}
.big-stat.points {
color: #7c3aed;
}
.big-sub {
font-size: 1rem;
font-weight: 600;
color: #6b7280;
}
.row-spacer {
height: 1.25rem;
}
.stat-sub {
font-size: 0.8rem;
color: #6b7280;
margin: 0;
}
.bonus-tallies {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.bonus-tally {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.5rem;
padding: 0.4rem 0.6rem;
border: 1px solid #e5e7eb;
border-left: 4px solid #f59e0b;
border-radius: 8px;
background: white;
}
.bt-name {
font-size: 0.85rem;
font-weight: 600;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.bt-count {
font-size: 0.9rem; font-size: 0.9rem;
font-weight: 700; font-weight: 800;
}
.wallet-cash {
color: #059669;
}
.wallet-pts {
color: #7c3aed; color: #7c3aed;
} }
.wallet-dot {
.alltime { color: #d1d5db;
}
.wallet-empty {
margin: 0;
font-size: 0.85rem;
color: #9ca3af;
}
.wallet-rewards {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 0.5rem; gap: 0.5rem;
} }
.alltime-row { .wallet-reward {
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid #f3f4f6;
padding-bottom: 0.4rem;
}
.alltime-row:last-child {
border-bottom: none;
}
.alltime-label {
font-size: 0.85rem;
color: #6b7280;
}
.alltime-value {
font-size: 1.1rem;
font-weight: 700;
}
.alltime-value.cash {
color: #059669;
}
.alltime-value.points {
color: #7c3aed;
}
.claim-list-row {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 0.5rem; gap: 0.6rem;
padding: 0.5rem 0; padding: 0.6rem 0.8rem;
border-bottom: 1px solid #f3f4f6; border-radius: 10px;
background: #fafbfc;
border: 1px solid #eeeff2;
} }
.claim-list-row:last-child { .wr-label {
border-bottom: none;
}
.cl-status {
font-size: 0.7rem;
font-weight: 600;
min-width: 5.5rem;
}
.cl-label {
flex: 1; flex: 1;
font-size: 0.85rem;
font-weight: 600; font-weight: 600;
font-size: 0.85rem;
min-width: 0; min-width: 0;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
} }
.cl-value { .wr-val {
font-size: 0.85rem; font-weight: 800;
font-weight: 700;
color: #059669; color: #059669;
white-space: nowrap;
} }
.cl-wait { .wr-pending {
font-size: 0.7rem; font-size: 0.75rem;
padding: 2px 8px;
border-radius: 10px;
background: #dbeafe;
color: #1e40af;
font-weight: 600; font-weight: 600;
color: #6b7280;
} }
.cl-cta { .wr-cta {
font-size: 0.72rem; font-size: 0.72rem;
padding: 3px 10px; font-weight: 700;
background: #6366f1; padding: 3px 12px;
color: white; background: linear-gradient(135deg, #6366f1, #8b5cf6);
color: #fff;
border: none; border: none;
border-radius: 5px; border-radius: 6px;
cursor: pointer; cursor: pointer;
font-weight: 600;
} }
.cl-cta:hover { .wr-cta:hover {
background: #4f46e5; filter: brightness(1.1);
}
.claim-list-row.requested {
opacity: 0.7;
} }
</style> </style>