fix: restore WeatherAverageBar component in session header and adjust styling
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 6m12s
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 6m12s
Reintroduced the WeatherAverageBar component in the WeatherSessionPage to display team averages. Updated the styling of the WeatherAverageBar for improved spacing. Enhanced the EvolutionIndicator component to use dynamic background colors for better visibility of status indicators.
This commit is contained in:
@@ -72,9 +72,6 @@ export default async function WeatherSessionPage({ params }: WeatherSessionPageP
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* team average — auto-refreshes via router.refresh() from useLive */}
|
||||
<WeatherAverageBar entries={session.entries} />
|
||||
</div>
|
||||
|
||||
{/* Info sur les catégories */}
|
||||
@@ -90,6 +87,7 @@ export default async function WeatherSessionPage({ params }: WeatherSessionPageP
|
||||
canEdit={session.canEdit}
|
||||
userTeams={userTeams}
|
||||
>
|
||||
<WeatherAverageBar entries={session.entries} />
|
||||
<WeatherBoard
|
||||
sessionId={session.id}
|
||||
currentUserId={authSession.user.id}
|
||||
|
||||
@@ -23,7 +23,7 @@ export function WeatherAverageBar({ entries }: WeatherAverageBarProps) {
|
||||
if (entries.length === 0) return null;
|
||||
|
||||
return (
|
||||
<div className="flex flex-wrap items-center gap-3 mt-3">
|
||||
<div className="flex flex-wrap items-center gap-3 mb-4">
|
||||
<span className="text-xs font-medium text-muted uppercase tracking-wide">
|
||||
Moyenne équipe
|
||||
</span>
|
||||
|
||||
@@ -48,12 +48,45 @@ function EvolutionIndicator({
|
||||
if (direction === null) return null;
|
||||
|
||||
if (direction === 'up') {
|
||||
return <span className="inline-flex items-center justify-center w-5 h-5 rounded-full bg-green-100 text-green-700 text-xs font-bold shrink-0" title="Amélioration">↑</span>;
|
||||
return (
|
||||
<span
|
||||
className="inline-flex items-center justify-center w-5 h-5 rounded-full text-xs font-bold shrink-0"
|
||||
style={{
|
||||
backgroundColor: 'color-mix(in srgb, var(--success) 18%, transparent)',
|
||||
color: 'var(--success)',
|
||||
}}
|
||||
title="Amélioration"
|
||||
>
|
||||
↑
|
||||
</span>
|
||||
);
|
||||
}
|
||||
if (direction === 'down') {
|
||||
return <span className="inline-flex items-center justify-center w-5 h-5 rounded-full bg-red-100 text-red-700 text-xs font-bold shrink-0" title="Dégradation">↓</span>;
|
||||
return (
|
||||
<span
|
||||
className="inline-flex items-center justify-center w-5 h-5 rounded-full text-xs font-bold shrink-0"
|
||||
style={{
|
||||
backgroundColor: 'color-mix(in srgb, var(--destructive) 18%, transparent)',
|
||||
color: 'var(--destructive)',
|
||||
}}
|
||||
title="Dégradation"
|
||||
>
|
||||
↓
|
||||
</span>
|
||||
);
|
||||
}
|
||||
return <span className="inline-flex items-center justify-center w-5 h-5 rounded-full bg-muted/30 text-muted text-xs font-bold shrink-0" title="Stable">→</span>;
|
||||
return (
|
||||
<span
|
||||
className="inline-flex items-center justify-center w-5 h-5 rounded-full text-xs font-bold shrink-0"
|
||||
style={{
|
||||
backgroundColor: 'color-mix(in srgb, var(--muted) 15%, transparent)',
|
||||
color: 'var(--muted)',
|
||||
}}
|
||||
title="Stable"
|
||||
>
|
||||
→
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export function WeatherCard({ sessionId, currentUserId, entry, canEdit, previousEntry }: WeatherCardProps) {
|
||||
|
||||
@@ -203,17 +203,25 @@ export async function getPreviousWeatherEntriesForUsers(
|
||||
sessionId: { not: excludeSessionId },
|
||||
session: { date: { lt: sessionDate } },
|
||||
},
|
||||
orderBy: [{ userId: 'asc' }, { session: { date: 'desc' } }],
|
||||
select: {
|
||||
userId: true,
|
||||
performanceEmoji: true,
|
||||
moralEmoji: true,
|
||||
fluxEmoji: true,
|
||||
valueCreationEmoji: true,
|
||||
session: { select: { date: true } },
|
||||
},
|
||||
});
|
||||
|
||||
// Keep only the most recent entry per user (first occurrence since ordered by date desc)
|
||||
// Sort by session.date desc (Prisma orderBy on relation is unreliable with SQLite)
|
||||
entries.sort((a, b) => {
|
||||
const dateA = a.session.date.getTime();
|
||||
const dateB = b.session.date.getTime();
|
||||
if (dateB !== dateA) return dateB - dateA; // most recent first
|
||||
return a.userId.localeCompare(b.userId);
|
||||
});
|
||||
|
||||
// For each user, use the most recent previous value PER AXIS (fallback if latest session has null)
|
||||
const map = new Map<
|
||||
string,
|
||||
{
|
||||
@@ -224,14 +232,19 @@ export async function getPreviousWeatherEntriesForUsers(
|
||||
}
|
||||
>();
|
||||
for (const entry of entries) {
|
||||
if (!map.has(entry.userId)) {
|
||||
map.set(entry.userId, {
|
||||
performanceEmoji: entry.performanceEmoji,
|
||||
moralEmoji: entry.moralEmoji,
|
||||
fluxEmoji: entry.fluxEmoji,
|
||||
valueCreationEmoji: entry.valueCreationEmoji,
|
||||
});
|
||||
}
|
||||
const existing = map.get(entry.userId);
|
||||
const base = existing ?? {
|
||||
performanceEmoji: null as string | null,
|
||||
moralEmoji: null as string | null,
|
||||
fluxEmoji: null as string | null,
|
||||
valueCreationEmoji: null as string | null,
|
||||
};
|
||||
if (!existing) map.set(entry.userId, base);
|
||||
if (base.performanceEmoji == null && entry.performanceEmoji != null) base.performanceEmoji = entry.performanceEmoji;
|
||||
if (base.moralEmoji == null && entry.moralEmoji != null) base.moralEmoji = entry.moralEmoji;
|
||||
if (base.fluxEmoji == null && entry.fluxEmoji != null) base.fluxEmoji = entry.fluxEmoji;
|
||||
if (base.valueCreationEmoji == null && entry.valueCreationEmoji != null)
|
||||
base.valueCreationEmoji = entry.valueCreationEmoji;
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user