Merge branch 'trunk'

This commit is contained in:
K Muller 2026-06-01 09:42:49 +02:00
commit 625fbe73c7
9 changed files with 173 additions and 20 deletions

View file

@ -21,7 +21,7 @@ class ContactRequest extends FormRequest
*/
public function rules(): array
{
// ToolboxHelper::validateRecaptcha($this, \config('services.google.recaptcha.version'));
ToolboxHelper::validateRecaptcha($this, \config('services.google.recaptcha.version'));
$typeContactForm = $this->input('enumType');

View file

@ -37,6 +37,11 @@ return [
'google' => [
'maps' => env('GOOGLE_MAPS_KEY'),
'recaptcha' => [
'public' => env('GOOGLE_RECAPTCHA_PUBLIC'),
'private' => env('GOOGLE_RECAPTCHA_PRIVATE'),
'version' => env('GOOGLE_RECAPTCHA_VERSION', "3") === "3" ? true : false
]
],
'matomo' => [

View file

@ -13,3 +13,43 @@
display: none;
}
}
#r_captcha {
display: flex;
justify-content: center;
margin-bottom: 30px;
}
.error-recaptcha {
color: red;
text-align: center;
padding-bottom: 5px;
}
.custom-alert-danger {
background: #ffe5e5;
border: 1px solid #ffb3b3;
border-left: 5px solid #dc3545;
color: #842029;
padding: 15px 20px;
border-radius: 10px;
margin-bottom: 20px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
animation: fadeIn 0.3s ease-in-out;
.alert-title {
font-weight: 700;
margin-bottom: 10px;
display: flex;
align-items: center;
gap: 8px;
}
li {
margin-bottom: 5px;
font-size: 0.95rem;
}
ul {
margin: 0;
padding-left: 20px;
}
}

View file

@ -0,0 +1,30 @@
@push('scripts')
<script nonce="{{ $nonce }}">
document.addEventListener('DOMContentLoaded', function() {
const formId = @json($formId);
const initFormCaptcha = () => {
const newDiv = document.createElement("div");
newDiv.classList.add('g-recaptcha');
document.getElementById('r_captcha').appendChild(newDiv);
};
window.__CN_Recaptcha = function() {
initFormCaptcha();
(function(d, t) {
let g = d.createElement(t),
s = d.getElementsByTagName(t)[0];
g.src =
'https://www.google.com/recaptcha/api.js?render=explicit&onload=__CN_Recaptcha_Loaded';
s.parentNode.insertBefore(g, s)
}(document, 'script'));
};
window.__CN_Recaptcha_Reset = function() {
document.querySelector('#r_captcha > div')?.remove();
};
window.__CN_Recaptcha_Loaded = function() {
grecaptcha.render(document.querySelector('#r_captcha > div'), {
'sitekey': '{{ config('services.google.recaptcha.public') }}'
});
};
});
</script>
@endpush

View file

@ -1,5 +1,10 @@
<form id="contact-form" method="POST" action="{{ route('front.contact.send') }}" inert>
@csrf
<input type="hidden" name="enumType" value="{{ $enumType }}">
<div>
@include('modules.flash-messages')
</div>
{{ $slot }}
</form>

View file

@ -1,29 +1,39 @@
<div class="form__row">
@if (\App\Enums\Contact\ContactFormType::press->equals($contactFormType))
<div class="form__field">
<label class="form__field-pseudolabel">
<input type="checkbox" name="newsletter" value="1">
<span class="form__field-pseudosquare">{{ __('front.inputs.newsletter.label') }}</span>
</label>
</div>
@endif
<div class="form__row">
@if (\App\Enums\Contact\ContactFormType::press->equals($contactFormType))
<div class="form__field">
<span class="form__field-label-text">{{ __('front.contact.info_personal_data') }}
<br> <a href="/politique-de-confidentialite/" target="_blank"
rel="noreferer noopener">{{ __('front.contact.confidentiality') }}</a></span>
<label class="form__field-pseudolabel">
<input type="checkbox" name="newsletter" value="1">
<span class="form__field-pseudosquare">{{ __('front.inputs.newsletter.label') }}</span>
</label>
</div>
@endif
<div class="form__field">
<div class="form__tip">* {{ ucfirst(__('front.required_field')) }}</div>
</div>
<div class="form__field">
<span class="form__field-label-text">{{ __('front.contact.info_personal_data') }}
<br> <a href="/politique-de-confidentialite/" target="_blank"
rel="noreferer noopener">{{ __('front.contact.confidentiality') }}</a></span>
</div>
<div class="form__field">
<div class="form__tip">* {{ ucfirst(__('front.required_field')) }}</div>
</div>
</div>
{{-- RECAPTCHA --}}
<div>
@if ($errors->has('g-recaptcha-response'))
<div class="error-recaptcha">
<span>{{ $errors->first('g-recaptcha-response') }}</span>
</div>
@endif
<div id="r_captcha"></div>
</div>
<div class="form__row">
<div class="form-submit">
<input type="submit" value="{{ ucfirst(__('front.buttons.send')) }}" class="form-submit__btn btn">
<input data-sitekey="{{ config('services.google.recaptcha.public') }}" type="submit"
value="{{ ucfirst(__('front.buttons.send')) }}" class="form-submit__btn btn">
</div>
</div>

View file

@ -28,7 +28,10 @@
@endif
@include('front.pages.contact.partials.form-footer')
</x-front.pages.contact.form-wrapper>
</div>
</div>
</div>
<x-front.pages.contact.contact-form-script formId="contact-form" />

View file

@ -58,3 +58,5 @@
</div>
</x-front.pages.contact.form-wrapper>
<x-front.pages.contact.contact-form-script formId="contact-form" />

View file

@ -0,0 +1,58 @@
@if (!request()->routeIs('login'))
@if ($message = session()->get('success', session()->get('bo.success')))
<div class="alert alert-success alert-dismissible fade show m-0 mb-3" role="alert">
<i class="fa-solid fa-circle-check"></i>
<strong>{!! nl2br(e($message)) !!}</strong>
<button class="btn-close" data-bs-dismiss="alert" type="button" aria-label="{{ __('Fermer') }}"></button>
</div>
@endif
@if ($message = session()->get('error', session()->get('bo.error')))
<div class="alert alert-danger alert-dismissible fade show m-0 mb-3" role="alert">
<i class="fa-solid fa-circle-xmark"></i>
<strong>{!! nl2br(e($message)) !!}</strong>
<button class="btn-close" data-bs-dismiss="alert" type="button" aria-label="{{ __('Fermer') }}"></button>
</div>
@endif
@if ($message = session()->get('warning', session()->get('bo.warning')))
<div class="alert alert-warning alert-dismissible fade show m-0 mb-3" role="alert">
<i class="fa-solid fa-circle-exclamation"></i>
<strong>{!! nl2br(e($message)) !!}</strong>
<button class="btn-close" data-bs-dismiss="alert" type="button" aria-label="{{ __('Fermer') }}"></button>
</div>
@endif
@if ($message = session()->get('status', session()->get('bo.status')))
<div class="alert alert-info alert-dismissible fade show m-0 mb-3" role="alert">
<i class="fa-solid fa-circle-info"></i>
<strong>{!! nl2br(e($message)) !!}</strong>
<button class="btn-close" data-bs-dismiss="alert" type="button" aria-label="{{ __('Fermer') }}"></button>
</div>
@endif
@if ($message = session()->get('info', session()->get('bo.info')))
<div class="alert alert-info alert-dismissible fade show m-0 mb-3" role="alert">
<i class="fa-solid fa-circle-info"></i>
<strong>{!! nl2br(e($message)) !!}</strong>
<button class="btn-close" data-bs-dismiss="alert" type="button" aria-label="{{ __('Fermer') }}"></button>
</div>
@endif
@if (isset($errors) && $errors->any())
<div class="custom-alert-danger" role="alert">
<p class="alert-title">
<i class="fa-solid fa-circle-exclamation"></i>
Liste des erreurs :
</p>
@if ($errors->any())
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
@endif
</div>
@endif
@endif