Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
api/storage/pail/
6 changes: 6 additions & 0 deletions front/src/app/auth/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import React, { useState } from 'react';
import Link from 'next/link';
import { useRouter } from 'next/navigation';
import { ApiError, loginUser } from '@/shared/utils/api';
import { useAuth } from '@/shared/hooks/useAuth';
import { useActiveCharacter } from '@/shared/contexts/CharacterContext';
import { useToast } from '@/shared/contexts/ToastContext';
import { Button } from '@/shared/components/ui/Button';
import { Input } from '@/shared/components/ui/Input';
Expand All @@ -12,6 +14,8 @@ import { Mail, Lock, LogIn, AlertCircle } from 'lucide-react';

export default function LoginPage() {
const router = useRouter();
const { refresh } = useAuth();
const { refreshActiveCharacter } = useActiveCharacter();
const { showToast } = useToast();
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
Expand All @@ -25,6 +29,8 @@ export default function LoginPage() {

try {
await loginUser({ email, password });
// Propager la session dans toute l'app (Header, personnage actif…)
await Promise.all([refresh(), refreshActiveCharacter()]);
showToast('Connexion réussie ! Heureux de vous revoir.', 'success');
router.push('/');
router.refresh();
Expand Down
5 changes: 5 additions & 0 deletions front/src/app/auth/signup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React, { useState } from 'react';
import Link from 'next/link';
import { useRouter } from 'next/navigation';
import { ApiError, registerUser } from '@/shared/utils/api';
import { useAuth } from '@/shared/hooks/useAuth';
import { useToast } from '@/shared/contexts/ToastContext';
import { Button } from '@/shared/components/ui/Button';
import { Input } from '@/shared/components/ui/Input';
Expand All @@ -12,6 +13,7 @@ import { Mail, Lock, UserPlus, AlertCircle, CheckCircle2 } from 'lucide-react';

export default function SignupPage() {
const router = useRouter();
const { refresh } = useAuth();
const { showToast } = useToast();
const [email, setEmail] = useState('');
const [username, setUsername] = useState('');
Expand Down Expand Up @@ -41,6 +43,9 @@ export default function SignupPage() {
password_confirmation: confirmPassword,
});

// La session est ouverte dès l'inscription : propager dans toute l'app
await refresh();

if (response.user.email_verified_at) {
showToast('Bienvenue ! Votre compte a été créé avec succès.', 'success');
router.push('/');
Expand Down
3 changes: 3 additions & 0 deletions front/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Footer from "@/shared/components/Footer";
import ChatBox from "@/features/chat/components/ChatBox";
import { CharacterProvider } from "@/shared/contexts/CharacterContext";
import { ToastProvider } from "@/shared/contexts/ToastContext";
import { AuthProvider } from "@/shared/hooks/useAuth";

const inter = Inter({ subsets: ["latin"], variable: "--font-inter" });
const outfit = Outfit({ subsets: ["latin"], variable: "--font-outfit" });
Expand Down Expand Up @@ -57,6 +58,7 @@ export default function RootLayout({
<html lang="fr">
<body className={`${inter.variable} ${outfit.variable} ${starWars.variable} font-sans bg-black min-h-screen text-gray-200 antialiased`}>
<ToastProvider>
<AuthProvider>
<CharacterProvider>
<div className="min-h-screen bg-black flex flex-col">
<Header />
Expand All @@ -69,6 +71,7 @@ export default function RootLayout({
<ChatBox />
</div>
</CharacterProvider>
</AuthProvider>
</ToastProvider>
</body>
</html>
Expand Down
9 changes: 5 additions & 4 deletions front/src/features/profile/components/ProfileContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { Badge } from '@/shared/components/ui/Badge';
import { Avatar } from '@/shared/components/ui/Avatar';
import { CategoryHeader } from '@/shared/components/forum/CategoryHeader';
import { cn } from '@/shared/utils/cn';
import { apiFetch, fetchCurrentUser, logoutUser } from '@/shared/utils/api';
import { apiFetch, fetchCurrentUser } from '@/shared/utils/api';
import { useAuth } from '@/shared/hooks/useAuth';
import { useActiveCharacter } from '@/shared/contexts/CharacterContext';

// Système de grades forum (HRP)
Expand All @@ -34,6 +35,7 @@ export default function ProfileContent({ userId }: ProfileContentProps) {
const [currentUser, setCurrentUser] = useState<any>(null);
const [profileData, setProfileData] = useState<any>(null);
const [characters, setCharacters] = useState<any[]>([]);
const { logout } = useAuth();
const { activeCharacter, setActiveCharacter } = useActiveCharacter();
const [switchingId, setSwitchingId] = useState<string | null>(null);

Expand Down Expand Up @@ -80,9 +82,8 @@ export default function ProfileContent({ userId }: ProfileContentProps) {
const isOwnProfile = !userId || userId === currentUser?.id;

const handleLogout = async () => {
await logoutUser();
router.push('/');
router.refresh();
await logout();
window.location.href = '/';
};

const handleSwitchCharacter = async (e: React.MouseEvent, charId: string) => {
Expand Down
71 changes: 19 additions & 52 deletions front/src/features/rules/components/RulesLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
'use client';

import React from 'react';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import { Book, Shield, UserPlus, Info, Wallet } from 'lucide-react';
import { cn } from '@/shared/utils/cn';
import { Book, Info, Shield, UserPlus, Wallet } from 'lucide-react';
import WikiShell, { type WikiNavCategory } from '@/shared/components/wiki/WikiShell';

const ruleSections = [
{ id: 'overview', title: 'Vue d\'ensemble', path: '/rules', icon: Info },
Expand All @@ -21,54 +19,23 @@ export default function RulesLayoutComponent({
}) {
const pathname = usePathname();

return (
<div className="py-12">
<div className="flex flex-col md:flex-row gap-12">
{/* Sidebar Navigation */}
<aside className="md:w-64 space-y-8 shrink-0">
<div className="space-y-4">
<h1 className="text-3xl font-bold font-outfit text-white px-4">Règlement</h1>
<p className="text-zinc-500 text-sm px-4">Les lois qui régissent la galaxie Swor.</p>
</div>

<nav className="space-y-1">
{ruleSections.map((section) => {
const isActive = pathname === section.path;
return (
<Link
key={section.id}
href={section.path}
className={cn(
"flex items-center gap-3 px-4 py-3 rounded-2xl transition-all duration-200 group",
isActive
? "bg-white/10 text-white"
: "text-zinc-500 hover:text-white hover:bg-white/5"
)}
>
<section.icon className={cn(
"w-4 h-4 transition-colors",
isActive ? "text-yellow-500" : "text-zinc-600 group-hover:text-zinc-400"
)} />
<span className="font-medium text-sm">{section.title}</span>
</Link>
);
})}
</nav>

<div className="p-6 rounded-3xl bg-yellow-500/5 border border-yellow-500/10">
<p className="text-[10px] uppercase font-bold text-yellow-500 tracking-widest mb-2">Note Staff</p>
<p className="text-xs text-zinc-500 leading-relaxed italic">
"L'ignorance de la loi n'est pas une excuse sur Coruscant."
</p>
</div>
</aside>
const categories: WikiNavCategory[] = ruleSections.map((section) => ({
id: section.id,
title: section.title,
icon: section.icon,
href: section.path,
active: pathname === section.path,
}));

{/* Content Area */}
<main className="flex-grow min-h-[600px]">
{children}
</main>
</div>
</div>
return (
<WikiShell
title="Règlement"
subtitle="Les lois qui régissent la galaxie Swor."
categories={categories}
footnoteLabel="Note Staff"
footnote={`"L'ignorance de la loi n'est pas une excuse sur Coruscant."`}
>
{children}
</WikiShell>
);
}

71 changes: 11 additions & 60 deletions front/src/features/rules/components/RulesOverview.tsx
Original file line number Diff line number Diff line change
@@ -1,66 +1,17 @@
import React from 'react';
import Link from 'next/link';
import { ChevronRight, ShieldCheck, BookOpen } from 'lucide-react';
import { RULES_DATA } from '../data/rules-data';
import { Card, CardTitle } from '@/shared/components/ui/Card';
import { CategoryHeader } from '@/shared/components/forum/CategoryHeader';
'use client';

import { RULES_OVERVIEW_CONTENT } from '../types';
import { WikiArticleHeader, WikiMarkdown } from '@/shared/components/wiki/WikiArticle';

export default function RulesOverview() {
return (
<div className="space-y-16">
<header className="space-y-6">
<h2 className="text-5xl font-black font-outfit text-white uppercase tracking-tighter">Code Galactique</h2>
<div className="relative">
<div className="absolute left-0 top-0 bottom-0 w-1 bg-yellow-500 rounded-full" />
<p className="text-xl text-zinc-400 max-w-2xl leading-relaxed pl-8 italic">
Bienvenue sur le règlement officiel de Swor. Pour assurer une expérience de jeu de qualité et une ambiance saine, nous vous demandons de lire attentivement chaque section.
</p>
</div>
</header>

<div className="space-y-8">
<CategoryHeader title="Sections du Règlement" icon={BookOpen} />
<div className="grid gap-4">
{RULES_DATA.map((section) => (
<Link
key={section.id}
href={`/rules/${section.id}`}
className="group"
>
<Card hover className="p-8 flex items-center justify-between border-white/5 bg-zinc-900/40">
<div className="flex items-center gap-8">
<div className="w-14 h-14 rounded-2xl bg-black/40 border border-white/5 flex items-center justify-center shrink-0 group-hover:border-yellow-500/20 transition-all">
<ShieldCheck className="w-6 h-6 text-zinc-600 group-hover:text-yellow-500 transition-colors" />
</div>
<div className="space-y-1">
<CardTitle className="text-xl group-hover:text-white transition-colors uppercase tracking-tight">{section.title}</CardTitle>
<p className="text-zinc-500 text-[10px] font-black uppercase tracking-widest">{section.description}</p>
<p className="text-[9px] font-mono text-zinc-700 uppercase tracking-[0.2em] pt-1">
{section.rules.length} protocoles établis
</p>
</div>
</div>
<div className="w-12 h-12 rounded-full border border-white/5 flex items-center justify-center group-hover:bg-yellow-500 group-hover:border-yellow-500 transition-all duration-300">
<ChevronRight className="w-5 h-5 text-zinc-800 group-hover:text-black" />
</div>
</Card>
</Link>
))}
</div>
</div>

<Card className="p-10 bg-yellow-500/[0.02] border-yellow-500/10 rounded-[2.5rem] relative overflow-hidden group">
<div className="absolute top-0 right-0 p-8 opacity-5 group-hover:opacity-10 transition-opacity">
<ShieldCheck className="w-24 h-24 text-yellow-500" />
</div>
<div className="relative z-10 space-y-4">
<h3 className="text-xl font-black font-outfit text-white uppercase tracking-widest">Engagement du Joueur</h3>
<p className="text-sm text-zinc-500 leading-relaxed font-medium">
En vous inscrivant et en créant un personnage sur Swor, vous acceptez de respecter ce règlement dans son intégralité. L'équipe administrative se réserve le droit de modifier ces règles à tout moment pour le bien de la communauté.
</p>
</div>
</Card>
<div className="space-y-8">
<WikiArticleHeader
badge="Code galactique"
title="Règlement officiel"
excerpt="Pour assurer une expérience de jeu de qualité et une ambiance saine, lisez chaque section avant de créer votre personnage et d'écrire sur le forum."
/>
<WikiMarkdown>{RULES_OVERVIEW_CONTENT}</WikiMarkdown>
</div>
);
}

55 changes: 10 additions & 45 deletions front/src/features/rules/components/RulesSectionDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,56 +1,21 @@
'use client';

import { RuleSection } from '../types';
import { Card, CardTitle } from '@/shared/components/ui/Card';
import { Badge } from '@/shared/components/ui/Badge';
import { CategoryHeader } from '@/shared/components/forum/CategoryHeader';
import { ShieldAlert } from 'lucide-react';
import { WikiArticleHeader, WikiMarkdown } from '@/shared/components/wiki/WikiArticle';

interface RulesSectionDetailProps {
section: RuleSection;
}

export default function RulesSectionDetail({ section }: RulesSectionDetailProps) {
return (
<div className="space-y-16 animate-in fade-in slide-in-from-bottom-4 duration-700">
<header className="space-y-6">
<div className="flex items-center gap-3 bg-yellow-500/5 w-fit px-4 py-1.5 rounded-full border border-yellow-500/10">
<Badge variant="yellow" className="bg-transparent border-0 p-0 text-[10px] font-black tracking-[0.2em]">DIRECTIVES_PROTOCOL</Badge>
</div>
<h2 className="text-5xl font-black font-outfit text-white leading-tight uppercase tracking-tighter">{section.title}</h2>
<div className="relative pl-10">
<div className="absolute left-0 top-0 bottom-0 w-1 bg-white/10 rounded-full" />
<p className="text-xl text-zinc-500 max-w-3xl leading-relaxed italic font-medium">
{section.description}
</p>
</div>
</header>

<div className="space-y-6">
<CategoryHeader title="Protocoles en Vigueur" icon={ShieldAlert} />
<div className="grid gap-4">
{section.rules.map((rule) => (
<Card
key={rule.id}
hover
className="p-10 group bg-zinc-900/40 border-white/5"
>
<div className="flex flex-col md:flex-row items-start gap-10">
<div className="w-16 h-16 rounded-[1.25rem] bg-black/40 flex items-center justify-center shrink-0 border border-white/5 font-mono text-xl font-black text-yellow-500 shadow-2xl group-hover:border-yellow-500/20 transition-all">
{rule.id}
</div>
<div className="space-y-4">
<CardTitle className="text-2xl group-hover:text-yellow-500 transition-colors uppercase tracking-tight">
{rule.title}
</CardTitle>
<p className="text-zinc-400 leading-relaxed text-lg font-medium">
{rule.content}
</p>
</div>
</div>
</Card>
))}
</div>
</div>
<div className="space-y-8">
<WikiArticleHeader
badge="Directives"
title={section.title}
excerpt={section.description}
/>
<WikiMarkdown>{section.content}</WikiMarkdown>
</div>
);
}

Loading
Loading