From d5efe3f6b01804fed03c80691b5672e60f2f6139 Mon Sep 17 00:00:00 2001
From: Abdel LAMRANI
Date: Fri, 7 Aug 2026 13:34:22 +0200
Subject: [PATCH 1/3] fix: :bug: review from re7
---
lang/de/front.php | 7 +--
lang/fr/front.php | 2 +-
.../ts/front/Components/ControlSection.tsx | 5 ++-
.../ts/front/Components/EngagementSection.tsx | 43 ++++++++-----------
resources/ts/front/Components/Header.tsx | 10 ++++-
.../ts/front/Components/Layout/Footer.tsx | 2 +-
resources/ts/front/Components/Layout/Logo.tsx | 2 +-
.../Components/Layout/ScrollToTopButton.tsx | 1 -
.../front/Components/cookie/CookieNotice.tsx | 6 +--
.../ts/front/Components/cookie/constants.tsx | 2 +-
resources/ts/front/Layouts/AppLayout.tsx | 7 +++
11 files changed, 50 insertions(+), 37 deletions(-)
diff --git a/lang/de/front.php b/lang/de/front.php
index 1fa142c..5654b44 100644
--- a/lang/de/front.php
+++ b/lang/de/front.php
@@ -104,9 +104,10 @@ return [
],
'independentControls' => [
'title' => 'Unabhängige Kontrollen',
- 'text1' => 'Die externen Kontrollen der QUALIMAINE-Aufzuchtprogramme werden von Certipaq gemäß den in den Lastenheften vorgegebenen Kontrollplänen durchgeführt',
- 'chargesLabel' => '',
- 'chargesUrl' => '/cahiers-des-charges',
+ 'text1' => 'Die externen Kontrollen der QUALIMAINE-Aufzuchtprogramme werden von Certipaq gemäß den in den',
+ 'text1_1' => 'vorgegebenen Kontrollplänen durchgeführt',
+ 'chargesLabel' => 'Lastenheften',
+ 'chargesUrl' => '/de#aufzuchtstandards',
'text2' => 'Certipaq ist eine gem äß DIN EN ISO/IEC 17065 akkreditierte Zertifizierungsstelle.',
'text3' => 'Weitere Informationen unter',
],
diff --git a/lang/fr/front.php b/lang/fr/front.php
index d59b0e6..bb23c76 100644
--- a/lang/fr/front.php
+++ b/lang/fr/front.php
@@ -104,7 +104,7 @@ return [
'title' => 'Contrôles indépendants',
'text1' => 'Certipaq réalise le contrôle externe des programmes d\'élevage QUALIMAINE selon des plans de contrôle associés aux',
'chargesLabel' => 'cahiers des charges',
- 'chargesUrl' => '/cahiers-des-charges',
+ 'chargesUrl' => '/#normes-delevage',
'text2' => 'Certipaq est un organisme accrédité selon la norme ISO/CEI 17065.',
'text3' => 'Plus d\'informations sur',
],
diff --git a/resources/ts/front/Components/ControlSection.tsx b/resources/ts/front/Components/ControlSection.tsx
index 641c8ab..529ea2c 100644
--- a/resources/ts/front/Components/ControlSection.tsx
+++ b/resources/ts/front/Components/ControlSection.tsx
@@ -31,7 +31,10 @@ export default function ControlsSection() {
>
{useTrans("front.controls.independentControls.chargesLabel")}
- .
+ {useTrans("front.controls.independentControls.text1_1") !==
+ "front.controls.independentControls.text1_1"
+ ? ` ${useTrans("front.controls.independentControls.text1_1")}`
+ : "."}
{useTrans("front.controls.independentControls.text2")}
diff --git a/resources/ts/front/Components/EngagementSection.tsx b/resources/ts/front/Components/EngagementSection.tsx
index 7903107..154cd19 100644
--- a/resources/ts/front/Components/EngagementSection.tsx
+++ b/resources/ts/front/Components/EngagementSection.tsx
@@ -14,6 +14,7 @@ import farmersWebp from "&/images/engagements/formation-eleveurs.webp";
import monitoringJpg from "&/images/engagements/surveillance-renforcee.jpg";
import monitoringWebp from "&/images/engagements/surveillance-renforcee.webp";
import { GetTranslation } from "@/lib/utils";
+import useDeviceType from "@/hooks/use-device-type";
const ENGAGEMENTS = [
{
@@ -69,31 +70,25 @@ const ENGAGEMENTS = [
},
];
+
export default function EngagementsSection() {
const scrollerRef = useRef(null);
const cardRefs = useRef<(HTMLDivElement | null)[]>([]);
const [activeIndex, setActiveIndex] = useState(0);
+ const { isMobile } = useDeviceType();
+
+ const visibleCount = isMobile ? 1 : 3;
+ const dotsCount = Math.max(ENGAGEMENTS.length - visibleCount + 1, 1);
useEffect(() => {
const scroller = scrollerRef.current;
if (!scroller) return;
const handleScroll = () => {
- const scrollerCenter = scroller.scrollLeft + scroller.clientWidth / 2;
- let closestIndex = 0;
- let closestDistance = Infinity;
-
- cardRefs.current.forEach((card, index) => {
- if (!card) return;
- const cardCenter = card.offsetLeft + card.offsetWidth / 2;
- const distance = Math.abs(cardCenter - scrollerCenter);
- if (distance < closestDistance) {
- closestDistance = distance;
- closestIndex = index;
- }
- });
-
- setActiveIndex(closestIndex);
+ const maxScroll = scroller.scrollWidth - scroller.clientWidth;
+ const ratio = maxScroll > 0 ? scroller.scrollLeft / maxScroll : 0;
+ const index = Math.round(ratio * (dotsCount - 1));
+ setActiveIndex(index);
};
scroller.addEventListener("scroll", handleScroll, { passive: true });
@@ -101,17 +96,15 @@ export default function EngagementsSection() {
return () => {
scroller.removeEventListener("scroll", handleScroll);
};
- }, []);
+ }, [dotsCount]);
const scrollToIndex = (index: number) => {
- const clamped = (index + ENGAGEMENTS.length) % ENGAGEMENTS.length;
+ const clamped = Math.max(0, Math.min(index, dotsCount - 1));
const card = cardRefs.current[clamped];
const scroller = scrollerRef.current;
if (!card || !scroller) return;
- const targetLeft =
- card.offsetLeft - (scroller.clientWidth - card.offsetWidth) / 2;
- scroller.scrollTo({ left: targetLeft, behavior: "smooth" });
+ scroller.scrollTo({ left: card.offsetLeft, behavior: "smooth" });
};
return (
@@ -195,15 +188,17 @@ export default function EngagementsSection() {
- {ENGAGEMENTS.map((_, index) => (
+ {Array.from({ length: dotsCount }).map((_, index) => (
diff --git a/resources/ts/front/Components/Header.tsx b/resources/ts/front/Components/Header.tsx
index 4a75919..9df4280 100644
--- a/resources/ts/front/Components/Header.tsx
+++ b/resources/ts/front/Components/Header.tsx
@@ -3,8 +3,12 @@ import heroWebp from "&/images/header/header.webp";
import useTrans from "@/hooks/use-translations";
import Navbar from "./Layout/Navbar";
+import { usePage } from "@inertiajs/react";
export default function Header() {
+ const { props } = usePage() as unknown as {
+ props: { appEnv: { locale: string, fallbackLocale:string, locales: string[] } };
+ };
return (