From 1de77bfadc3eaa18806157a59e81f22b0c842b97 Mon Sep 17 00:00:00 2001
From: SofianeLasri <alasri250@gmail.com>
Date: Thu, 20 Feb 2025 12:22:27 +0100
Subject: [PATCH] feat: Add Terms and Conditions page

- Created a new TermsController to handle the display of active terms.
- Added a terms view with a markdown component for displaying content.
- Updated the generic page header component to allow empty descriptions.
- Modified the footer to include a link to the Terms and Conditions page.
- Added a new route for the Terms and Conditions page.
---
 .../Controllers/Public/TermsController.php    | 22 +++++++++++++++++++
 .../views/components/public/footer.blade.php  |  6 ++---
 .../public/generic-page-header.blade.php      |  2 +-
 resources/views/public/terms.blade.php        | 16 ++++++++++++++
 routes/web.php                                |  2 ++
 5 files changed, 43 insertions(+), 5 deletions(-)
 create mode 100644 app/Http/Controllers/Public/TermsController.php
 create mode 100644 resources/views/public/terms.blade.php

diff --git a/app/Http/Controllers/Public/TermsController.php b/app/Http/Controllers/Public/TermsController.php
new file mode 100644
index 0000000..a20736b
--- /dev/null
+++ b/app/Http/Controllers/Public/TermsController.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Http\Controllers\Public;
+
+use App\Http\Controllers\Controller;
+use App\Models\TermsSection;
+use Illuminate\View\View;
+
+class TermsController extends Controller
+{
+    public function __invoke(): View
+    {
+        $activeTermsText = TermsSection::where('active', true)->first();
+
+        if (! $activeTermsText) {
+            abort(404);
+        }
+        $activeTermsText = $activeTermsText->contentTranslationKey->getTranslation();
+
+        return view('public.terms', compact('activeTermsText'));
+    }
+}
diff --git a/resources/views/components/public/footer.blade.php b/resources/views/components/public/footer.blade.php
index 05142fd..82765bb 100644
--- a/resources/views/components/public/footer.blade.php
+++ b/resources/views/components/public/footer.blade.php
@@ -36,14 +36,12 @@
                     <div class="self-stretch text-2xl font-bold">Informations légales</div>
                     <ul class="flex flex-col gap-2">
                         <li>
-                            <a href="#" class="text-muted hover:text-primary">Mentions légales</a>
+                            <a href="{{ route('legal-mentions') }}" class="text-muted hover:text-primary">Mentions
+                                légales</a>
                         </li>
                         <li>
                             <a href="#" class="text-muted hover:text-primary">Conditions générales de vente</a>
                         </li>
-                        <li>
-                            <a href="#" class="text-muted hover:text-primary">Politique de confidentialité</a>
-                        </li>
                     </ul>
                 </div>
             </div>
diff --git a/resources/views/components/public/generic-page-header.blade.php b/resources/views/components/public/generic-page-header.blade.php
index 7883746..defaac7 100644
--- a/resources/views/components/public/generic-page-header.blade.php
+++ b/resources/views/components/public/generic-page-header.blade.php
@@ -1,6 +1,6 @@
 @props([
     'title' => 'Title',
-    'description' => 'Description',
+    'description' => '',
 ])
 
 <div {{ $attributes->class(['relative flex flex-col max-w-2xl gap-3']) }}>
diff --git a/resources/views/public/terms.blade.php b/resources/views/public/terms.blade.php
new file mode 100644
index 0000000..65b7b67
--- /dev/null
+++ b/resources/views/public/terms.blade.php
@@ -0,0 +1,16 @@
+@extends('layouts.public', ['title' => "Mentions légales"])
+
+@section('content')
+    <x-public.navbar class="container mx-auto px-4"/>
+
+    <div class="container mx-auto px-4 py-24 flex flex-col gap-16">
+        <x-public.generic-page-header title="Mentions légales"/>
+        <div class="">
+            <x-markdown class="markdown">
+                {{ $activeTermsText }}
+            </x-markdown>
+        </div>
+    </div>
+
+    <x-public.footer/>
+@endsection
\ No newline at end of file
diff --git a/routes/web.php b/routes/web.php
index aa637dc..d92fdd4 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -13,6 +13,7 @@
 use App\Http\Controllers\Public\IndexController;
 use App\Http\Controllers\Public\PortfolioController;
 use App\Http\Controllers\Public\PrestationController as PublicPrestationController;
+use App\Http\Controllers\Public\TermsController;
 use App\Http\Middleware\CheckPrivateModeMiddleware;
 use App\Http\Middleware\RedirectIfUserExistsMiddleware;
 use Illuminate\Support\Facades\Route;
@@ -29,6 +30,7 @@
     Route::get('/portfolio/api', [PortfolioController::class, 'api'])->name('portfolio.api');
     Route::get('/portfolio/{slug}', [PortfolioController::class, 'show'])->name('portfolio.show');
     Route::get('/prestations/{slug}', [PublicPrestationController::class, 'index'])->name('prestations.show');
+    Route::get('/mentions-legales', TermsController::class)->name('legal-mentions');
 
     Route::view('/maintenance', 'public.maintenance')->name('maintenance');
 });
-- 
GitLab