Header menu via header.js

This commit is contained in:
karim hassan
2025-08-24 23:47:39 +00:00
parent f1103d67a0
commit eabd0aa50f
25 changed files with 869 additions and 185 deletions

View File

@@ -0,0 +1,53 @@
Super Sunday — Participants API + Header partagé
===============================================
Ce patch apporte :
1) **Routes backend Participants**
- `POST /api/participants` (body: { tournament_id, full_name })
- `GET /api/tournaments/:id/participants`
(via un routeur dédié + alias pratique)
2) **Header mutualisé côté frontend**
- `assets/header.js` remplace/injecte le menu dans un `<header>` unique
- Script d'injection qui ajoute la balise script à toutes les pages
Contenu
-------
- backend/src/routes/participants.js
- backend/src/index.js (baseline avec montages; optionnel si tu as déjà un index)
- frontend/public/assets/header.js
- apply_header_patch.sh
Installation
------------
1) Dézippe à la racine du projet :
unzip -o supersunday_participants_and_header_patch.zip -d .
2) Backend (si tu utilises l'index fourni) :
docker compose build --no-cache api
docker compose up -d api
Si tu conserves ton propre `backend/src/index.js`, **assure-toi d'ajouter** :
app.use('/api/participants', require('./routes/participants'));
app.get('/api/tournaments/:id/participants', (req,res,next)=>{
req.url = '/by-tournament/' + req.params.id;
return require('./routes/participants')(req,res,next);
});
3) Frontend — header partagé sur toutes les pages :
./apply_header_patch.sh .
(le script ajoute <script type="module" src="/assets/header.js"> avant </body>)
Tests rapides
-------------
# Ajouter un joueur dans le tournoi 1
curl -s -X POST http://localhost/api/participants -H 'Content-Type: application/json' -d '{"tournament_id":1,"full_name":"Nouveau Joueur"}'
# Lister les participants du tournoi 1
curl -s http://localhost/api/tournaments/1/participants
Notes
-----
- Aucun changement Docker requis.
- Les noms de tables attendus: participants(id, tournament_id, full_name).
- Si ton schéma diffère, dis-moi les colonnes exactes et je t'adapte la requête.