diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..987bd39 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,65 @@ +# AzuuCine — contexte projet (lu automatiquement par Claude Code) + +PWA de suivi de films, séries, animes, K-dramas et C-dramas. Interface en français +(18 langues). Thème sombre par défaut, accent rouge, sans dégradés, police Inter. + +## Stack +- **Vite + React 19 + TypeScript**, **Tailwind CSS v4**, PWA (vite-plugin-pwa, service worker auto-update). +- **Supabase** (Postgres + Auth + Storage + Edge Functions) pour les comptes et le social. +- Local-first : IndexedDB par utilisateur + outbox + synchro last-write-wins. +- Dossier local : `C:\Users\romai\Documents\FICHIER\PROJET\AzuuCine`. + +## Lancer / vérifier +```bash +npm install +npm run dev # dev local +npm run typecheck # tsc --noEmit ← LANCER APRÈS CHAQUE MODIF, doit finir sans erreur +npm run build # build de prod +``` + +## Déploiement +- Remote git : **Gitea** `https://gitea.rdacet.fr/romain/azuucine.git` (branche `main`). +- Push via **PowerShell** : `git push` (GitHub Desktop n'authentifie pas Gitea). +- **Gitea Actions** (`.gitea/workflows/deploy.yml`) build et publie sur le **VPS** (nginx en LXC) à chaque push sur `main`. Site : https://azuucine.rdacet.fr +- `vite.config.ts` contient un garde-fou : le build échoue si `VITE_SUPABASE_URL` / `VITE_SUPABASE_ANON_KEY` manquent en CI (variables/secrets Gitea Actions). La CSP et les en-têtes de sécurité y sont aussi définis (source unique → convertis en conf nginx par `deploy/headers-to-nginx.mjs`). + +## Supabase +- Project ref : `qfgnxonqwldcfdjqhhjz` — URL `https://qfgnxonqwldcfdjqhhjz.supabase.co` +- Clé **publishable** (publique, déjà dans le bundle client) : `sb_publishable_s459lWM86bjiteGzWxSYcw_WbiRYydR` +- **Secrets (JAMAIS dans le dépôt, jamais dans .env/VITE_)** : la clé TMDB et la `service_role` vivent dans les **secrets Supabase** / Edge Functions. Ne jamais les committer ni les coller dans le chat. +- **Migrations** : `supabase/migrations/*.sql`. ⚠️ L'outil MCP `apply_migration` **tombe souvent en timeout** sur ce projet (création de fonctions). **Appliquer le SQL en le collant dans Supabase → SQL Editor → Run.** Tous les fichiers sont écrits **idempotents** (`create or replace`, `if not exists`, `drop ... if exists`). +- Edge functions : `tmdb` (proxy pour cacher la clé TMDB), `delete-account`. Storage bucket `profile-media`. +- Compte **admin** = Romain, user id `4529202d-618c-4b40-ab13-228eef3f71ad` (table `public.admins`). + +### Règles de sécurité Supabase (NON négociables — « aucune faille ») +- **RLS activé partout** ; chaque utilisateur ne voit que ses données. +- Toute fonction exposée est **`security definer` + `set search_path = ''`** et **vérifie les droits en interne** (`auth.uid()`, `can_view()`, `is_admin()`), puis `revoke ... from public, anon` / `grant execute ... to authenticated`. +- La clé TMDB ne doit jamais fuiter côté client (passe par l'edge function `tmdb`). + +## Architecture client (repères) +- `src/store.tsx` — fournisseur de données (IndexedDB = source locale, état React = copie de travail), synchro, thème. +- `src/lib/cloud/` — `auth.ts` (GoTrue maison, PKCE Google), `sync.ts` (push/pull LWW), `social.ts`, `admin.ts`, `reviews.ts`, `notifications.ts`, `api.ts` (`cloudFetch`). +- `src/lib/airing.ts` — suivi des sorties d'épisodes (TMDB/AniList), cache local. +- `src/lib/franchise.ts` — saisons & dédoublonnage de franchises (TMDB 1 fiche multi-saisons vs AniList 1 entrée/saison). +- `src/components/social/` — profils, recherche, fil d'amis, avis par titre (`TitleReviews`), réactions (`Reactions`), notifications (`Notifications`), aperçu d'une fiche (`ItemPeek`), `SocialProvider` (pile d'overlays). +- `src/pages/` — `HomePage`, `CatalogPage`, `StatsPage`, `SettingsPage`, `AdminPage`. +- `src/App.tsx` — shell + routes par hash (`#/home`, `#/admin`…), `BottomNav` (mobile) + `SideNav` (desktop ≥ lg). + +## i18n (IMPORTANT) +- 18 langues dans `src/i18n/locales/*.ts`. **`fr` est la référence** : toute clé doit exister dans **toutes** les langues (sinon erreur TS). +- Textes vus par les membres → traduire dans les 18. Un écran réservé à l'admin → `fr` + `en` suffit. +- Clés plurielles `xxx_one`/`xxx_other` (+ `_few`/`_many` pour ar/ru/pl). Variables `{x}`. +- Thèmes d'apparence : `auto` (suit le navigateur), `light`, `dark`, `night`, `starfield` (fond étoilé CSS). Toujours utiliser les **tokens de thème** (`bg-bg`, `text-ink`, `bg-accent-fill`…), **jamais de couleur hex en dur**. + +## Conventions +- `npm run typecheck` doit passer après chaque modif. +- Ne pas mettre `localStorage`/`sessionStorage` sans try/catch. +- Garder les fichiers idempotents côté SQL. +- RTL géré (arabe) : préférer les classes logiques (`ps-`/`pe-`, `ms-`/`me-`, `start-`/`end-`, `border-e`). + +## État / en attente (au 8 oct. 2026) +- **À appliquer dans Supabase SQL Editor** : `supabase/migrations/20261007120000_social_notifications.sql` + (avis par titre, réactions emoji, notifications : abonnements / demandes acceptées / réactions reçues / + **nouveaux épisodes** des séries suivies, + préférences `notifPrefs` dans les réglages). Testé localement, jamais encore exécuté sur le projet réel. +- Ensuite : `git push` pour déployer le client. +- Recommandé dans le tableau de bord Supabase : activer **Leaked Password Protection** (Authentication → Passwords). diff --git a/src/components/social/ItemPeek.tsx b/src/components/social/ItemPeek.tsx index c4e4d36..4fa7410 100644 --- a/src/components/social/ItemPeek.tsx +++ b/src/components/social/ItemPeek.tsx @@ -1,8 +1,9 @@ import { Check, Loader2, MessagesSquare, Plus, Star } from 'lucide-react' -import { useState } from 'react' +import { useEffect, useState } from 'react' import { t } from '../../i18n' import { genreLabel } from '../../lib/genres' import { useScrollLock } from '../../lib/scrollLock' +import { titleReviews, type TitleReview } from '../../lib/cloud/reviews' import { useSocial } from './SocialProvider' import { cx, formatDate, formatRating, normalizeText } from '../../lib/utils' import { useMedia } from '../../store' @@ -10,6 +11,7 @@ import type { MediaInput, MediaItem } from '../../types' import { StatusPill, TypeBadge } from '../Badges' import Poster from '../Poster' import Avatar from './Avatar' +import Reactions from './Reactions' import { useEscape } from '../../lib/escape' export interface PeekOwner { @@ -24,6 +26,23 @@ export default function ItemPeek({ item, owner, onClose }: { item: MediaItem; ow const social = useSocial() const [busy, setBusy] = useState(false) const [added, setAdded] = useState(false) + // Avis d'un autre membre : on récupère les réactions pour pouvoir réagir ici même + const [review, setReview] = useState() + const canReact = !!owner && owner.username !== social.me?.username && !!item.notes && !!item.externalId + useEffect(() => { + if (!canReact) return + let alive = true + titleReviews(item.externalId!) + .then((d) => { + if (!alive) return + const all = [...d.friends, ...d.others] + setReview(all.find((r) => r.user.username === owner!.username)) + }) + .catch(() => {}) + return () => { + alive = false + } + }, [canReact, item.externalId, owner]) const owned = items.some( (i) => (item.externalId && i.externalId === item.externalId) || normalizeText(i.title) === normalizeText(item.title), ) @@ -106,11 +125,16 @@ export default function ItemPeek({ item, owner, onClose }: { item: MediaItem; ow {item.favorite && ♥ {t('form.favorite')}} {item.notes &&

{item.notes}

} + {canReact && review && ( +
+ +
+ )} )} {item.externalId && ( - )} diff --git a/src/components/social/Notifications.tsx b/src/components/social/Notifications.tsx index ae37170..de25875 100644 --- a/src/components/social/Notifications.tsx +++ b/src/components/social/Notifications.tsx @@ -62,7 +62,7 @@ export default function Notifications({ onClose, onOpenProfile, onOpenItem }: { } return ( - + {items === undefined ? (

diff --git a/src/components/social/Reactions.tsx b/src/components/social/Reactions.tsx new file mode 100644 index 0000000..e40e216 --- /dev/null +++ b/src/components/social/Reactions.tsx @@ -0,0 +1,71 @@ +import { useState } from 'react' +import { REACTION_EMOJIS, reactToReview, unreactReview, type ReactionEmoji } from '../../lib/cloud/reviews' +import { cx } from '../../lib/utils' + +/** Barre de réactions (emoji) sur un avis. Une seule réaction par personne ; retoucher la sienne l'enlève. */ +export default function Reactions({ + authorId, + itemId, + reactions: initial, + mine: initialMine, +}: { + authorId: string + itemId: string + reactions: Record + mine: string | null +}) { + const [reactions, setReactions] = useState>(initial) + const [mine, setMine] = useState(initialMine) + const [busy, setBusy] = useState(false) + + const toggle = async (emoji: ReactionEmoji) => { + if (busy) return + const prev = { reactions, mine } + const next: Record = { ...reactions } + if (mine === emoji) { + next[emoji] = Math.max(0, (next[emoji] ?? 0) - 1) + setReactions(next) + setMine(null) + } else { + if (mine) next[mine] = Math.max(0, (next[mine] ?? 0) - 1) + next[emoji] = (next[emoji] ?? 0) + 1 + setReactions(next) + setMine(emoji) + } + setBusy(true) + try { + if (prev.mine === emoji) await unreactReview(authorId, itemId) + else await reactToReview(authorId, itemId, emoji) + } catch { + setReactions(prev.reactions) + setMine(prev.mine) + } finally { + setBusy(false) + } + } + + return ( +

+ {REACTION_EMOJIS.map((emoji) => { + const count = reactions[emoji] ?? 0 + const on = mine === emoji + return ( + + ) + })} +
+ ) +} diff --git a/src/components/social/Sheet.tsx b/src/components/social/Sheet.tsx index c9bba80..779067e 100644 --- a/src/components/social/Sheet.tsx +++ b/src/components/social/Sheet.tsx @@ -3,13 +3,14 @@ import { type ReactNode } from 'react' import { t } from '../../i18n' import { useScrollLock } from '../../lib/scrollLock' import { useEscape } from '../../lib/escape' +import { cx } from '../../lib/utils' /** Écran plein (profil, recherche…) avec en-tête et bouton fermer. */ -export default function Sheet({ title, onClose, right, children, label }: { title: ReactNode; onClose: () => void; right?: ReactNode; children: ReactNode; label: string }) { +export default function Sheet({ title, onClose, right, children, label, elevated }: { title: ReactNode; onClose: () => void; right?: ReactNode; children: ReactNode; label: string; elevated?: boolean }) { useScrollLock() useEscape(onClose) return ( -
+
- ) - })} + {r.notes &&

{r.notes}

} +
+
) diff --git a/tsconfig.tsbuildinfo b/tsconfig.tsbuildinfo index a3573d9..a3c2665 100644 --- a/tsconfig.tsbuildinfo +++ b/tsconfig.tsbuildinfo @@ -1 +1 @@ -{"root":["./src/App.tsx","./src/Root.tsx","./src/main.tsx","./src/store.tsx","./src/types.ts","./src/vite-env.d.ts","./src/components/AccountSection.tsx","./src/components/AuthScreen.tsx","./src/components/Badges.tsx","./src/components/BottomNav.tsx","./src/components/CalendarView.tsx","./src/components/ConfirmDialog.tsx","./src/components/DatabaseSearch.tsx","./src/components/Disagreements.tsx","./src/components/EpisodeList.tsx","./src/components/HomeHero.tsx","./src/components/ItemHero.tsx","./src/components/JournalView.tsx","./src/components/ListsView.tsx","./src/components/MediaCard.tsx","./src/components/MediaForm.tsx","./src/components/Poster.tsx","./src/components/Rating.tsx","./src/components/Recommendations.tsx","./src/components/Roulette.tsx","./src/components/SharePreview.tsx","./src/components/SideNav.tsx","./src/components/TagInput.tsx","./src/components/TopFive.tsx","./src/components/TopFiveEditor.tsx","./src/components/ui.tsx","./src/components/social/Avatar.tsx","./src/components/social/EditProfile.tsx","./src/components/social/FollowList.tsx","./src/components/social/FriendsFeed.tsx","./src/components/social/ItemPeek.tsx","./src/components/social/Notifications.tsx","./src/components/social/PeopleSearch.tsx","./src/components/social/PersonRow.tsx","./src/components/social/ProfileView.tsx","./src/components/social/Sheet.tsx","./src/components/social/SocialProvider.tsx","./src/components/social/TitleReviews.tsx","./src/components/social/WelcomeProfile.tsx","./src/i18n/index.ts","./src/i18n/react.tsx","./src/i18n/locales/ar.ts","./src/i18n/locales/de.ts","./src/i18n/locales/en.ts","./src/i18n/locales/es.ts","./src/i18n/locales/fr.ts","./src/i18n/locales/hi.ts","./src/i18n/locales/id.ts","./src/i18n/locales/it.ts","./src/i18n/locales/ja.ts","./src/i18n/locales/ko.ts","./src/i18n/locales/nl.ts","./src/i18n/locales/pl.ts","./src/i18n/locales/pt.ts","./src/i18n/locales/ru.ts","./src/i18n/locales/th.ts","./src/i18n/locales/tr.ts","./src/i18n/locales/vi.ts","./src/i18n/locales/zh.ts","./src/lib/airing.ts","./src/lib/backup.ts","./src/lib/catalogApi.ts","./src/lib/constants.ts","./src/lib/db.ts","./src/lib/dragScroll.ts","./src/lib/escape.ts","./src/lib/franchise.ts","./src/lib/genres.ts","./src/lib/globalReleases.ts","./src/lib/image.ts","./src/lib/legacyImport.ts","./src/lib/onResume.ts","./src/lib/publicRatings.ts","./src/lib/pwa.ts","./src/lib/releases.ts","./src/lib/roulette.ts","./src/lib/scope.ts","./src/lib/scrollLock.ts","./src/lib/security.ts","./src/lib/shareCard.ts","./src/lib/stats.ts","./src/lib/theme.ts","./src/lib/timeAgo.ts","./src/lib/utils.ts","./src/lib/cloud/admin.ts","./src/lib/cloud/api.ts","./src/lib/cloud/auth.ts","./src/lib/cloud/config.ts","./src/lib/cloud/notifications.ts","./src/lib/cloud/reviews.ts","./src/lib/cloud/social.ts","./src/lib/cloud/sync.ts","./src/pages/AdminPage.tsx","./src/pages/CatalogPage.tsx","./src/pages/HomePage.tsx","./src/pages/SettingsPage.tsx","./src/pages/StatsPage.tsx","./vite.config.ts"],"version":"5.9.3"} \ No newline at end of file +{"root":["./src/App.tsx","./src/Root.tsx","./src/main.tsx","./src/store.tsx","./src/types.ts","./src/vite-env.d.ts","./src/components/AccountSection.tsx","./src/components/AuthScreen.tsx","./src/components/Badges.tsx","./src/components/BottomNav.tsx","./src/components/CalendarView.tsx","./src/components/ConfirmDialog.tsx","./src/components/DatabaseSearch.tsx","./src/components/Disagreements.tsx","./src/components/EpisodeList.tsx","./src/components/HomeHero.tsx","./src/components/ItemHero.tsx","./src/components/JournalView.tsx","./src/components/ListsView.tsx","./src/components/MediaCard.tsx","./src/components/MediaForm.tsx","./src/components/Poster.tsx","./src/components/Rating.tsx","./src/components/Recommendations.tsx","./src/components/Roulette.tsx","./src/components/SharePreview.tsx","./src/components/SideNav.tsx","./src/components/TagInput.tsx","./src/components/TopFive.tsx","./src/components/TopFiveEditor.tsx","./src/components/ui.tsx","./src/components/social/Avatar.tsx","./src/components/social/EditProfile.tsx","./src/components/social/FollowList.tsx","./src/components/social/FriendsFeed.tsx","./src/components/social/ItemPeek.tsx","./src/components/social/Notifications.tsx","./src/components/social/PeopleSearch.tsx","./src/components/social/PersonRow.tsx","./src/components/social/ProfileView.tsx","./src/components/social/Reactions.tsx","./src/components/social/Sheet.tsx","./src/components/social/SocialProvider.tsx","./src/components/social/TitleReviews.tsx","./src/components/social/WelcomeProfile.tsx","./src/i18n/index.ts","./src/i18n/react.tsx","./src/i18n/locales/ar.ts","./src/i18n/locales/de.ts","./src/i18n/locales/en.ts","./src/i18n/locales/es.ts","./src/i18n/locales/fr.ts","./src/i18n/locales/hi.ts","./src/i18n/locales/id.ts","./src/i18n/locales/it.ts","./src/i18n/locales/ja.ts","./src/i18n/locales/ko.ts","./src/i18n/locales/nl.ts","./src/i18n/locales/pl.ts","./src/i18n/locales/pt.ts","./src/i18n/locales/ru.ts","./src/i18n/locales/th.ts","./src/i18n/locales/tr.ts","./src/i18n/locales/vi.ts","./src/i18n/locales/zh.ts","./src/lib/airing.ts","./src/lib/backup.ts","./src/lib/catalogApi.ts","./src/lib/constants.ts","./src/lib/db.ts","./src/lib/dragScroll.ts","./src/lib/escape.ts","./src/lib/franchise.ts","./src/lib/genres.ts","./src/lib/globalReleases.ts","./src/lib/image.ts","./src/lib/legacyImport.ts","./src/lib/onResume.ts","./src/lib/publicRatings.ts","./src/lib/pwa.ts","./src/lib/releases.ts","./src/lib/roulette.ts","./src/lib/scope.ts","./src/lib/scrollLock.ts","./src/lib/security.ts","./src/lib/shareCard.ts","./src/lib/stats.ts","./src/lib/theme.ts","./src/lib/timeAgo.ts","./src/lib/utils.ts","./src/lib/cloud/admin.ts","./src/lib/cloud/api.ts","./src/lib/cloud/auth.ts","./src/lib/cloud/config.ts","./src/lib/cloud/notifications.ts","./src/lib/cloud/reviews.ts","./src/lib/cloud/social.ts","./src/lib/cloud/sync.ts","./src/pages/AdminPage.tsx","./src/pages/CatalogPage.tsx","./src/pages/HomePage.tsx","./src/pages/SettingsPage.tsx","./src/pages/StatsPage.tsx","./vite.config.ts"],"version":"5.9.3"} \ No newline at end of file