Notes par saison : note + avis par saison, note finale = moyenne arrondie
deploy / deploy (push) Successful in 43s

- Section « Mes saisons » dans la fiche d'une série (≥ 2 saisons) : une note et un avis (avec spoiler) par saison.
- Quand la série est terminée, la note finale = moyenne des saisons notées, arrondie (étoiles et /10).
- Les séries déjà notées sans notes de saison restent intactes.
- Un +1 qui termine une saison ouvre la fiche sur cette saison à noter ; « Reprendre » passe à S02 É01.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
Claude committed 2026-10-14 10:26:48 +00:00
1 parent aa5442e02a
commit ed905a3278
26 files changed
+540 -11

No files matched your search

+6 -4
View File
@@ -1,3 +1,4 @@
import type { Completion } from '../lib/seasons'
import { Check, Info, Plus } from 'lucide-react'
import { useEffect, useRef, useState } from 'react'
import { t } from '../i18n'
@@ -27,7 +28,7 @@ export function waitingLabel(item: MediaItem): string {
}
/** Grande bannière de l'accueil : défile entre les titres que je regarde en ce moment (ou le prochain à voir). */
export default function HomeHero({ items, onOpen }: { items: MediaItem[]; onOpen: (item: MediaItem) => void }) {
export default function HomeHero({ items, onOpen }: { items: MediaItem[]; onOpen: (item: MediaItem, focus?: Completion) => void }) {
const { incrementEpisode } = useMedia()
// On retient le titre affiché (et pas sa position) : la liste se réordonne quand on avance un épisode
const [currentId, setCurrentId] = useState<string>()
@@ -106,7 +107,8 @@ export default function HomeHero({ items, onOpen }: { items: MediaItem[]; onOpen
<button
onClick={() => {
setPausedAt(Date.now())
void incrementEpisode(item.id)
// Saison (ou série) terminée : on ouvre la fiche sur la note
void incrementEpisode(item.id).then((done) => done && onOpen(item, done))
}}
className="btn btn-primary px-5"
>
@@ -140,7 +142,7 @@ export default function HomeHero({ items, onOpen }: { items: MediaItem[]; onOpen
}
/** Carte horizontale « Reprendre » : image, barre de progression, prochain épisode. */
export function ContinueCard({ item, onOpen }: { item: MediaItem; onOpen: (item: MediaItem) => void }) {
export function ContinueCard({ item, onOpen }: { item: MediaItem; onOpen: (item: MediaItem, focus?: Completion) => void }) {
const { incrementEpisode } = useMedia()
const image = item.backdrop ?? item.poster
const next = nextEpisodeLabel(item)
@@ -153,7 +155,7 @@ export function ContinueCard({ item, onOpen }: { item: MediaItem; onOpen: (item:
</button>
{next && (
<button
onClick={() => incrementEpisode(item.id)}
onClick={() => void incrementEpisode(item.id).then((done) => done && onOpen(item, done))}
className="absolute bottom-3 end-2 flex h-8 items-center gap-0.5 rounded-full bg-accent-fill px-3 text-xs font-semibold text-on-accent transition active:scale-90"
aria-label={t('card.plusOne', { title: item.title })}
>
+182
View File
@@ -0,0 +1,182 @@
import { Check, Pencil } from 'lucide-react'
import { useEffect, useRef, useState } from 'react'
import { t } from '../../i18n'
import { episodesBeforeSeason } from '../../lib/franchise'
import { seasonsAverage } from '../../lib/seasons'
import { cx, formatRating } from '../../lib/utils'
import type { MediaItem, RatingScale, SeasonRating } from '../../types'
import { RatingInput } from '../Rating'
/**
* « Mes saisons » : une note et un avis par saison.
* Une saison se note dès qu'on l'a commencée ; quand toute la série est vue, la note finale
* devient la moyenne des saisons notées (calculée dans le store).
*/
export default function SeasonRatings({
item,
scale,
highlight,
onChange,
}: {
item: MediaItem
scale: RatingScale
/** Saison à mettre en avant (on vient de la finir) */
highlight?: number
onChange: (seasonRatings: MediaItem['seasonRatings']) => void
}) {
const seasons = item.seasons ?? []
const ratings: Record<string, SeasonRating> = item.seasonRatings ?? {}
const avg = seasonsAverage(ratings, scale)
const set = (n: number, patch: Partial<SeasonRating>) => {
const key = String(n)
const next: Record<string, SeasonRating> = { ...ratings, [key]: { ...ratings[key], ...patch } }
const cur = next[key]
if (cur.rating == null && !cur.notes) delete next[key]
onChange(Object.keys(next).length ? next : undefined)
}
return (
<section className="mx-4 mt-6" aria-label={t('seasons.title')}>
<div className="mb-2 flex items-baseline justify-between gap-3">
<h3 className="eyebrow text-ink-2">{t('seasons.title')}</h3>
{avg != null && (
<span className="text-xs text-ink-3">
{t('seasons.average')} <span className="font-semibold text-ink">{formatRating(avg, scale)}</span>
</span>
)}
</div>
<p className="mb-3 text-xs leading-relaxed text-ink-3">{t('seasons.hint')}</p>
<ul className="space-y-2">
{seasons.map((size, k) => {
const n = k + 1
const before = episodesBeforeSeason(seasons, n)
const seen = Math.max(0, Math.min(size, item.episodesWatched - before))
return (
<SeasonRow
key={n}
n={n}
size={size}
seen={seen}
value={ratings[String(n)]}
scale={scale}
highlight={highlight === n}
onChange={(patch) => set(n, patch)}
/>
)
})}
</ul>
</section>
)
}
function SeasonRow({
n,
size,
seen,
value,
scale,
highlight,
onChange,
}: {
n: number
size: number
seen: number
value?: SeasonRating
scale: RatingScale
highlight: boolean
onChange: (patch: Partial<SeasonRating>) => void
}) {
const started = seen > 0
const done = seen >= size
const [writing, setWriting] = useState(false)
const [draft, setDraft] = useState(value?.notes ?? '')
const [spoiler, setSpoiler] = useState(!!value?.spoiler)
const ref = useRef<HTMLLIElement>(null)
// Saison qu'on vient de finir : on l'amène à l'écran
useEffect(() => {
if (highlight) ref.current?.scrollIntoView({ behavior: 'smooth', block: 'center' })
}, [highlight])
return (
<li ref={ref} id={`season-${n}`} className={cx('card p-3.5 transition-shadow', highlight && 'ring-2 ring-accent')}>
<div className="flex items-center justify-between gap-3">
<div className="min-w-0">
<p className="font-semibold">{t('seasons.season', { n })}</p>
<p className={cx('text-xs', done ? 'text-ink-2' : 'text-ink-3')}>
{done ? (
<span className="inline-flex items-center gap-1">
<Check size={12} className="text-accent" /> {t('seasons.seen')}
</span>
) : started ? (
t('seasons.progress', { seen, size })
) : (
t('seasons.notStarted')
)}
</p>
</div>
{highlight && !value?.rating && <span className="eyebrow shrink-0 text-accent">{t('seasons.rateNow')}</span>}
</div>
{started && (
<div className="mt-2.5">
<RatingInput value={value?.rating} onChange={(rating) => onChange({ rating })} scale={scale} size="sm" label={t('seasons.season', { n })} />
</div>
)}
{started &&
(writing ? (
<div className="mt-3">
<textarea
value={draft}
onChange={(e) => setDraft(e.target.value)}
maxLength={5000}
rows={4}
autoFocus
placeholder={t('seasons.reviewPh', { n })}
className="field resize-y text-sm"
/>
<label className="mt-2 flex items-center gap-2 text-xs text-ink-2">
<input type="checkbox" checked={spoiler} onChange={(e) => setSpoiler(e.target.checked)} className="accent-[var(--color-accent)]" />
{t('spoiler.checkbox')}
</label>
<div className="mt-2.5 flex justify-end gap-2">
<button
onClick={() => {
setDraft(value?.notes ?? '')
setWriting(false)
}}
className="btn btn-ghost px-4 py-2 text-sm"
>
{t('common.cancel')}
</button>
<button
onClick={() => {
const notes = draft.trim() || undefined
onChange({ notes, spoiler: notes && spoiler ? true : undefined })
setWriting(false)
}}
className="btn btn-primary px-4 py-2 text-sm"
>
{t('common.save')}
</button>
</div>
</div>
) : value?.notes ? (
<button onClick={() => setWriting(true)} className="mt-3 block w-full text-start">
<span className="flex items-center gap-1.5 text-xs text-ink-3">
{t('form.review')}
{value.spoiler && <span className="rounded-full border border-accent/50 px-1.5 py-px text-[10px] text-accent">{t('spoiler.badge')}</span>}
<Pencil size={11} />
</span>
<p className="mt-1 line-clamp-4 whitespace-pre-line text-sm leading-relaxed">{value.notes}</p>
</button>
) : (
<button onClick={() => setWriting(true)} className="mt-2.5 inline-flex items-center gap-1.5 text-xs font-medium text-ink-2">
<Pencil size={12} /> {t('seasons.writeReview')}
</button>
))}
</li>
)
}
+30 -3
View File
@@ -29,6 +29,8 @@ import SharePreview from '../SharePreview'
import EditDetails from './EditDetails'
import ReviewEditor from './ReviewEditor'
import WhereToWatch from './WhereToWatch'
import SeasonRatings from './SeasonRatings'
import { completionOf, hasSeasons, seasonsAverage, type Completion } from '../../lib/seasons'
import ReviewComments from '../social/ReviewComments'
import SharedListPicker from '../social/SharedListPicker'
@@ -44,13 +46,15 @@ interface Props {
onGoToSettings?: () => void
/** Ouvre la page d'un acteur / réalisateur (sa filmographie) */
onOpenPerson?: (p: { id: string; name?: string; photo?: string }) => void
/** Ouverte après un +1 qui termine une saison (ou la série) : on amène l'utilisateur à la note */
focus?: Completion
}
/**
* Fiche d'un titre, façon Letterboxd : tout se fait ici, et chaque geste est enregistré tout de suite.
* Vu / En cours / À voir, note, coup de cœur, avis, épisodes, casting et note moyenne du public.
*/
export default function TitleSheet({ item: initial, seed, onClose, onGoToSettings, onOpenPerson }: Props) {
export default function TitleSheet({ item: initial, seed, onClose, onGoToSettings, onOpenPerson, focus: initialFocus }: Props) {
const { items, settings, add, update, lists, patchMany } = useMedia()
const actions = useLibraryActions()
const social = useSocial()
@@ -222,9 +226,17 @@ export default function TitleSheet({ item: initial, seed, onClose, onGoToSetting
}
/** Nouveaux épisodes vus : le statut et les dates suivent (comme la liste d'épisodes). */
// Saison (ou série) qu'on vient de finir : on montre où la noter
const [focus, setFocus] = useState<Completion | undefined>(initialFocus)
const ratingRef = useRef<HTMLDivElement>(null)
useEffect(() => {
if (focus && 'final' in focus) ratingRef.current?.scrollIntoView({ behavior: 'smooth', block: 'center' })
}, [focus])
const setEpisodes = (n: number, season?: number) => {
if (!item) return
void update(item.id, episodesPatch(item, n, season))
const done = completionOf(item, item.episodesWatched, n)
void update(item.id, episodesPatch(item, n, season)).then(() => done && setFocus(done))
}
// Épisodes déjà sortis (fiche suivie) : on ne coche pas un épisode à venir
@@ -413,7 +425,7 @@ export default function TitleSheet({ item: initial, seed, onClose, onGoToSetting
</div>
)}
<div className="mt-5 border-t border-line pt-4">
<div ref={ratingRef} className={cx('mt-5 border-t border-line pt-4', focus && 'final' in focus && !item?.rating && 'rounded-xl ring-2 ring-accent ring-offset-4 ring-offset-surface')}>
<div className="mb-2 flex items-center justify-between">
<span className="eyebrow">{t('title.yourRating')}</span>
{episodic && (
@@ -427,6 +439,11 @@ export default function TitleSheet({ item: initial, seed, onClose, onGoToSetting
)}
</div>
<RatingInput value={item?.rating} onChange={rate} scale={settings.ratingScale} />
{item && hasSeasons(item) && (
<p className="mt-1.5 text-xs text-ink-3">
{seasonsAverage(item.seasonRatings, settings.ratingScale) != null && item.status === 'termine' ? t('seasons.finalApplied') : t('seasons.finalHint')}
</p>
)}
{item?.rating != null && <Criteria item={item} scale={settings.ratingScale} onChange={(criteria) => void update(item.id, { criteria })} />}
</div>
{busy && (
@@ -480,6 +497,16 @@ export default function TitleSheet({ item: initial, seed, onClose, onGoToSetting
</section>
)}
{/* Notes et avis par saison */}
{item && hasSeasons(item) && (
<SeasonRatings
item={item}
scale={settings.ratingScale}
highlight={focus && 'season' in focus ? focus.season : undefined}
onChange={(seasonRatings) => void update(item.id, { seasonRatings })}
/>
)}
</div>
<div className="order-2 min-w-0 lg:col-start-1 lg:row-start-1">