fix: 🐛 fix wrong form state after change lang in bo / some other fix/improvment
This commit is contained in:
parent
b323380dca
commit
f9043400d5
11 changed files with 33 additions and 69 deletions
|
|
@ -99,16 +99,4 @@ class DocumentHelper
|
|||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a document path from his id in front blade view
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Database\Eloquent\Builder<\App\Models\Document> $query
|
||||
*/
|
||||
public static function getDocumentFromId(int $id): string
|
||||
{
|
||||
$document = Document::find($id);
|
||||
return $document->path ?? "";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4887,6 +4887,10 @@ div.wpcf7 .ajax-loader {
|
|||
align-self: center;
|
||||
}
|
||||
|
||||
.hero__block-text.description {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.hero__block-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,6 @@
|
|||
$primary-color: #ff4e4e;
|
||||
$secondary-color: #666666;
|
||||
$tertiary-color: #222222;
|
||||
$white: #fff;
|
||||
|
||||
.hero__block-text.description {
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
color: $white;
|
||||
line-height: 1.75;
|
||||
}
|
||||
|
||||
.description {
|
||||
font-weight: 500;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// * Packages
|
||||
import { motion } from "motion/react";
|
||||
import { ReactNode, useEffect, useState } from "react";
|
||||
import { Head } from "@inertiajs/react";
|
||||
import { Head, usePage } from "@inertiajs/react";
|
||||
// * Components shadcn
|
||||
import { SidebarProvider, useSidebar } from "@/components/ui/sidebar";
|
||||
import { Toaster } from "@/components/ui/toaster";
|
||||
|
|
@ -30,8 +30,12 @@ export default function AuthenticatedLayout({
|
|||
? localStorage.getItem("vite-ui-collapsed")
|
||||
: null;
|
||||
|
||||
const { locale } = usePage().props.appEnv as unknown as {
|
||||
locale: string;
|
||||
};
|
||||
|
||||
return (
|
||||
<ThemeProvider>
|
||||
<ThemeProvider key={locale}>
|
||||
<SidebarProvider defaultOpen={!isCollapsed}>
|
||||
<TooltipProvider>
|
||||
<LayoutContent
|
||||
|
|
@ -88,9 +92,8 @@ function LayoutContent({
|
|||
<div className="flex justify-start items-center">
|
||||
{beforeNode}
|
||||
<h1
|
||||
className={`scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl${
|
||||
beforeNode ? " ms-2" : ""
|
||||
}`}
|
||||
className={`scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl${beforeNode ? " ms-2" : ""
|
||||
}`}
|
||||
>
|
||||
{title}
|
||||
</h1>
|
||||
|
|
|
|||
|
|
@ -168,24 +168,6 @@ export default function Form({
|
|||
return buildPath(current);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const modelTitleValue = model?.title ? model?.title[locale] : "";
|
||||
setData("title", modelTitleValue);
|
||||
setData(
|
||||
"slug",
|
||||
model?.slug
|
||||
? model?.slug[locale]
|
||||
: str(modelTitleValue).slug().value(),
|
||||
);
|
||||
setData("content", model?.content ? model?.content[locale] : "");
|
||||
setData(
|
||||
"config_id",
|
||||
model?.config_id ?? configOptions[defaultConfigId].id,
|
||||
);
|
||||
setData("status", model?.status ?? enumDynamicPageStatus.draft.value);
|
||||
setData("isLocked", model?.isLocked ?? false);
|
||||
}, [locale]);
|
||||
|
||||
return (
|
||||
<form onSubmit={submit}>
|
||||
<InputError all />
|
||||
|
|
|
|||
|
|
@ -64,20 +64,18 @@ export default function Form({
|
|||
/** Form section */
|
||||
const { post, setData, data, reset } = useForm({
|
||||
_method: method === Methods.POST ? "post" : "put",
|
||||
seo_title: model?.seo_title ? model?.seo_title[locale] : "",
|
||||
seo_description: model?.seo_description
|
||||
? model?.seo_description[locale]
|
||||
: "",
|
||||
title: model?.title ? model?.title[locale] : "",
|
||||
slug: model?.slug ? model?.slug[locale] : "",
|
||||
content: model?.content ? model?.content[locale] : "",
|
||||
seo_title: model?.seo_title?.[locale] ?? "",
|
||||
seo_description: model?.seo_description?.[locale] ?? "",
|
||||
title: model?.title?.[locale] ?? "",
|
||||
slug: model?.slug?.[locale] ?? "",
|
||||
content: model?.content?.[locale] ?? "",
|
||||
picture_alt: model?.picture_alt?.[locale] ?? "",
|
||||
picture_title: model?.picture_title?.[locale] ?? "",
|
||||
inverted: model?.inverted ?? false,
|
||||
has_show_picture: model?.has_show_picture ?? true,
|
||||
vimeo_id: model?.vimeo_id ?? "",
|
||||
status: model?.status ?? enumNewsStatus.unpublished.value,
|
||||
picture: model?.picture,
|
||||
picture_alt: model?.picture_alt ? model?.picture_alt[locale] : "",
|
||||
picture_title: model?.picture_title ? model?.picture_title[locale] : "",
|
||||
tags: model?.tags ? defaultTagOptions : [],
|
||||
categories: model?.categories ? defaultCategoriesOptions : [],
|
||||
published_at: model?.published_at ? model?.published_at : null,
|
||||
|
|
@ -116,6 +114,8 @@ export default function Form({
|
|||
});
|
||||
}, []);
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<form onSubmit={submitCrud}>
|
||||
<InputError all />
|
||||
|
|
|
|||
|
|
@ -107,13 +107,6 @@ export default function Form({
|
|||
&& data.config !== model?.config[appEnv.locale]
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setData("label", model?.label ? model?.label[appEnv.locale] : "");
|
||||
setData("view", model?.view ?? null);
|
||||
resetConfig(appEnv.locale);
|
||||
setSelectedConfig(null);
|
||||
}, [appEnv.locale]);
|
||||
|
||||
useEffect(() => {
|
||||
const isEmpty = data.config === null || (typeof data.config === "object" && Object.keys(data.config).length === 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
@if (!empty($bourseSection['list_downloads']))
|
||||
@foreach ($bourseSection['list_downloads'] as $btn)
|
||||
<x-front.cta :title="$btn['string_button_label']" :download="$btn['boolean_force_download']" :target="$btn['boolean_target_blank'] ? '_blank' : '_self'"
|
||||
class="finance-api__btn" :url="\App\Helpers\DocumentHelper::getDocumentFromId($btn['model_internal_link'])" buttonIcon="btn__icon_dl" />
|
||||
class="finance-api__btn" :url="\App\Models\Document::getAccessModel($btn['model_internal_link'])" buttonIcon="btn__icon_dl" />
|
||||
@endforeach
|
||||
@endif
|
||||
</div>
|
||||
|
|
@ -125,7 +125,7 @@
|
|||
</div>
|
||||
@if (!empty($closedWindows['list_document'][0]))
|
||||
<div class="finance-price__btn-wrap"">
|
||||
<x-front.cta :title="$closedWindows['list_document'][0]['string_button_label'] ?? ''" :url="\App\Helpers\DocumentHelper::getDocumentFromId($closedWindows['list_document'][0]['model_internal_link'])" :download="$closedWindows['list_document'][0]['boolean_force_download'] ?? false" :target="$closedWindows['list_document'][0]['boolean_target_blank'] ?? false
|
||||
<x-front.cta :title="$closedWindows['list_document'][0]['string_button_label'] ?? ''" :url="\App\Models\Document::getAccessModel($closedWindows['list_document'][0]['model_internal_link'])" :download="$closedWindows['list_document'][0]['boolean_force_download'] ?? false" :target="$closedWindows['list_document'][0]['boolean_target_blank'] ?? false
|
||||
? '_blank'
|
||||
: '_self'"
|
||||
buttonIcon="btn__icon_view" class="finance-price__btn" />
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
$btn = $data['list_became_shareholders'][0]['list_button'][0];
|
||||
@endphp
|
||||
<x-front.cta :title="$btn['string_label']" class="finance-shareholders__block-btn" :download="$btn['boolean_force_download']"
|
||||
:target="$btn['boolean_target_blank'] ? '_blank' : '_self'" :url="\App\Helpers\DocumentHelper::getDocumentFromId(
|
||||
:target="$btn['boolean_target_blank'] ? '_blank' : '_self'" :url="\App\Models\Document::getAccessModel(
|
||||
$btn['model_internal_link'],
|
||||
)" buttonIcon="btn__icon_arrow-right" />
|
||||
@endif
|
||||
|
|
@ -144,7 +144,7 @@
|
|||
</div>
|
||||
<div class="document__text">{{ $slide['string_label'] }}</div>
|
||||
<x-front.cta :title="$btnConfig['string_document_label']" class="document__btn"
|
||||
url="{{ \App\Helpers\DocumentHelper::getDocumentFromId($slide['model_internal_link']) }}"
|
||||
url="{{ \App\Models\Document::getAccessModel($slide['model_internal_link']) }}"
|
||||
:download="$btnConfig['string_document_label']" buttonIcon="btn__icon_dl" />
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -32,13 +32,13 @@
|
|||
];
|
||||
@endphp
|
||||
<ul class="sub-menu">
|
||||
@if(array_intersect($sections, array_keys($pageNosEngagements->content)))
|
||||
@if(array_intersect($sections, array_keys($pageNousConnaitre->content)))
|
||||
<li id="menu-item-7003"
|
||||
class="link-title menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-7003">
|
||||
<p>{{ trans('front.nous-connaitre.key') }}</p>
|
||||
<ul class="sub-menu">
|
||||
@foreach ($sections as $key => $item)
|
||||
@if (array_key_exists($item, array_keys($pageNosEngagements->content)))
|
||||
@if (array_key_exists($item, $pageNousConnaitre->content))
|
||||
@php $title = $pageNousConnaitre->content[$item][0]['string_title']; @endphp
|
||||
<li id="menu-item-{{ $id + $key }}"
|
||||
class="menu-item menu-item-type-custom menu-item-object-custom menu-item-{{ $id + $key }}">
|
||||
|
|
@ -119,7 +119,7 @@
|
|||
<p>{{ trans('front.nos-engagements.key') }}</p>
|
||||
<ul class="sub-menu">
|
||||
@foreach ($sections as $key => $item)
|
||||
@if (array_key_exists($item, array_keys($pageNosEngagements->content)))
|
||||
@if (array_key_exists($item, $pageNosEngagements->content))
|
||||
@php $title = $pageNosEngagements->content[$item][0]['string_title']; @endphp
|
||||
<li id="menu-item-{{ $id + $key }}"
|
||||
class="menu-item menu-item-type-custom menu-item-object-custom menu-item-{{ $id + $key }}">
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (isset($pageNousConnaitre))
|
||||
<div class="mobile-menu__block mobile-menu__block_sub" data-menu="submenu-2935">
|
||||
<div class="mobile-menu__block-title">
|
||||
|
|
@ -163,8 +164,9 @@
|
|||
@if(array_intersect($sections, array_keys($pageNousConnaitre->content)))
|
||||
<p class="menu-mobile-message">{{ trans('front.nous-connaitre.key') }}</p>
|
||||
@foreach ($sections as $key => $item)
|
||||
@if (array_key_exists($item, array_keys($pageNousConnaitre->content)))
|
||||
@php $title = $pageNousConnaitre->content[$item][0]['string_title']; @endphp
|
||||
@if (array_key_exists($item, $pageNousConnaitre->content))
|
||||
@php $title = $pageNousConnaitre->content[$item][0]['string_title'];
|
||||
@endphp
|
||||
<li class="mobile-menu__item">
|
||||
<a class="mobile-menu__link"
|
||||
href="{{ \App\Helpers\RouteHelper::routeNameChecker('front.dynamic-pages.nous-connaitre') }}#{{ Str::slug($title) }}">
|
||||
|
|
@ -334,4 +336,4 @@
|
|||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue