From 76f533f30729ca9686fb5e9d3b2dbf28767570b7 Mon Sep 17 00:00:00 2001 From: Arthur Dodin Date: Thu, 27 Aug 2026 00:09:15 +0200 Subject: [PATCH 1/3] WIP: Maker Battle Frontend (Admin & User faces) --- frontend/src/App.tsx | 9 ++ .../adminMakerBattleDownload.tsx | 81 +++++++++++++++++ .../adminMakerBattleTeamGeneration.tsx | 89 +++++++++++++++++++ frontend/src/components/Admin/adminEvent.tsx | 12 ++- frontend/src/components/home/infosSection.tsx | 6 ++ .../components/home/makerBattleSection.tsx | 79 ++++++++++++++++ frontend/src/components/home/teamSection.tsx | 30 +++---- frontend/src/components/navbar.tsx | 1 + .../src/interfaces/maker_battle.interface.ts | 12 +++ frontend/src/pages/admin/adminMakerBattle.tsx | 26 ++++++ .../src/services/requests/event.service.ts | 33 +++++-- .../services/requests/maker_battle.service.ts | 21 +++++ 12 files changed, 371 insertions(+), 28 deletions(-) create mode 100644 frontend/src/components/Admin/AdminMakerBattle/adminMakerBattleDownload.tsx create mode 100644 frontend/src/components/Admin/AdminMakerBattle/adminMakerBattleTeamGeneration.tsx create mode 100644 frontend/src/components/home/makerBattleSection.tsx create mode 100644 frontend/src/interfaces/maker_battle.interface.ts create mode 100644 frontend/src/pages/admin/adminMakerBattle.tsx create mode 100644 frontend/src/services/requests/maker_battle.service.ts diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 46b0562..04f5bb6 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -7,6 +7,7 @@ import ProtectedRoute from './components/utils/protectedroute'; import { OnboardingProvider } from './contexts/onboarding'; import { PermanencesProvider } from './contexts/permanences'; import { UserProvider } from './contexts/user'; +import AdminPageMakerBattle from './pages/admin/adminMakerBattle'; const AdminPageBanned = lazy(() => import('./pages/admin/adminBanned')); const AdminPageBus = lazy(() => import('./pages/admin/adminBus')); @@ -327,6 +328,14 @@ const App: React.FC = () => { } /> + + + + } + /> {/* Fallback */} } /> diff --git a/frontend/src/components/Admin/AdminMakerBattle/adminMakerBattleDownload.tsx b/frontend/src/components/Admin/AdminMakerBattle/adminMakerBattleDownload.tsx new file mode 100644 index 0000000..23e72ea --- /dev/null +++ b/frontend/src/components/Admin/AdminMakerBattle/adminMakerBattleDownload.tsx @@ -0,0 +1,81 @@ +import { useState } from 'react'; +import Select from 'react-select'; +import Swal from 'sweetalert2'; + +import type { MakerBattleGroupTypeOption } from '../../../interfaces/maker_battle.interface'; +import { exportGroups } from '../../../services/requests/maker_battle.service'; +import { Button } from '../../ui/button'; +import { Card, CardContent, CardHeader, CardTitle } from '../../ui/card'; + +type Props = { + groupTypeOptions: MakerBattleGroupTypeOption[]; +}; + +export const AdminMakerBattleTeamDownload = ({ groupTypeOptions }: Props) => { + const [selectedGroupType, setSelectedGroupType] = useState(null); + + const handleDownloadGroup = async () => { + if (!selectedGroupType) { + Swal.fire({ + icon: 'error', + title: 'Erreur', + text: 'Veuillez sélectionner un groupe.', + }); + return; + } + + const newTab = window.open('', '_blank'); + + try { + const { filename } = await exportGroups(selectedGroupType); + + const url = `${import.meta.env.VITE_API_URL}/exports/makerbattlegroups${filename}`; + + if (newTab) { + newTab.location.href = url; + } + } catch (error) { + newTab?.close(); + console.error('Erreur lors du téléchargement des groupes:', error); + Swal.fire({ + icon: 'error', + title: 'Erreur', + text: 'Une erreur est survenue lors du téléchargement des groupes.', + }); + } + }; + + return ( + + + Téléchargement + + + +
+ + + + inputId="maker-battle-group-types" + options={groupTypeOptions} + value={selectedGroupType} + onChange={setSelectedGroupType} + placeholder="Sélectionner un type" + isClearable + /> +
+
+ +
+
+
+ ); +}; diff --git a/frontend/src/components/Admin/AdminMakerBattle/adminMakerBattleTeamGeneration.tsx b/frontend/src/components/Admin/AdminMakerBattle/adminMakerBattleTeamGeneration.tsx new file mode 100644 index 0000000..f3b0175 --- /dev/null +++ b/frontend/src/components/Admin/AdminMakerBattle/adminMakerBattleTeamGeneration.tsx @@ -0,0 +1,89 @@ +import { useState } from 'react'; +import Select, { type MultiValue } from 'react-select'; +import Swal from 'sweetalert2'; + +import type { MakerBattleGroupTypeOption } from '../../../interfaces/maker_battle.interface'; +import { allocateGroups } from '../../../services/requests/maker_battle.service'; +import { Button } from '../../ui/button'; +import { Card, CardContent, CardHeader, CardTitle } from '../../ui/card'; + +type Props = { + groupTypeOptions: MakerBattleGroupTypeOption[]; +}; + +export const AdminMakerBattleTeamGeneration = ({ groupTypeOptions }: Props) => { + const [selectedGroupTypes, setSelectedGroupTypes] = useState([]); + + const handleGenerateGroups = async () => { + if (selectedGroupTypes.length === 0) { + Swal.fire({ + icon: 'error', + title: 'Erreur', + text: 'Veuillez sélectionner au moins un type de groupe.', + }); + return; + } + + try { + await allocateGroups(selectedGroupTypes); + } catch (error) { + console.error('Erreur lors de la répartition des groupes:', error); + Swal.fire({ + icon: 'error', + title: 'Erreur', + text: 'Une erreur est survenue lors de la répartition des groupes.', + }); + } + }; + + return ( + + + + Répartition des nouveaux +
+ Batailles de conception +
+
+ +
+ +