chore: specific 422 error page

This commit is contained in:
Colin Darie 2024-04-09 00:00:31 +02:00
parent 5b98fd7c6d
commit a93a4cd5ce
No known key found for this signature in database
GPG key ID: 8C76CADD40253590
6 changed files with 57 additions and 59 deletions

View file

@ -16,6 +16,7 @@ class ErrorsController < ApplicationController
end
def not_found = render_error 404
def unprocessable_entity = render_error 422
def show # generic page for others errors
@status = params[:status].to_i

View file

@ -0,0 +1,24 @@
%main#content{ role: "main" }
.fr-container
.fr-my-7w.fr-mt-md-12w.fr-mb-md-10w.fr-grid-row.fr-grid-row--gutters.fr-grid-row--middle.fr-grid-row--center
.fr-py-0.fr-col-12.fr-col-md-6
%h1 The requested action has been rejected
%p.fr-text--sm.fr-mb-3w Error 422
%p.fr-text--lead.fr-mb-3w We're sorry, but we can't process your request.
%p.fr-text--sm.fr-mb-5w
This may be due to a request that cannot be processed in its current state.
%br
Go back to
= link_to("the previous page", "javascript:window.location = document.referrer", class: "fr-link")
and then try again.
%br
If the problem persists, please don't hesitate to contact us for assistance.
%ul.fr-btns-group.fr-btns-group--inline-md
%li
= link_to 'Back', 'javascript:window.location = document.referrer', class: 'fr-btn'
%li
= link_to 'Contact us', contact_path, class: 'fr-btn fr-btn--secondary'
= render partial: "artwork"

View file

@ -0,0 +1,24 @@
%main#content{ role: "main" }
.fr-container
.fr-my-7w.fr-mt-md-12w.fr-mb-md-10w.fr-grid-row.fr-grid-row--gutters.fr-grid-row--middle.fr-grid-row--center
.fr-py-0.fr-col-12.fr-col-md-6
%h1 Laction demandée a été rejetée
%p.fr-text--sm.fr-mb-3w Erreur 422
%p.fr-text--lead.fr-mb-3w Nous sommes désolés, mais nous ne pouvons pas traiter votre requête.
%p.fr-text--sm.fr-mb-5w
Cela peut être dû à une requête qui ne peut être traitée dans son état actuel.
%br
Revenez à
= link_to("la page précédente", "javascript:window.location = document.referrer", class: "fr-link")
puis réessayez.
%br
Si le problème persiste, nhésitez pas à nous contacter pour obtenir de laide.
%ul.fr-btns-group.fr-btns-group--inline-md
%li
= link_to 'Retour', 'javascript:window.location = document.referrer', class: 'fr-btn'
%li
= link_to 'Contactez-nous', contact_path, class: 'fr-btn fr-btn--secondary'
= render partial: "artwork"

View file

@ -699,6 +699,7 @@ Rails.application.routes.draw do
resources :release_notes, only: [:index]
get '/404', to: 'errors#not_found'
get '/422', to: 'errors#unprocessable_entity'
get '/500', to: 'errors#internal_server_error'
get '/:status', to: 'errors#show', constraints: { status: /[4-5][0-5]\d/ }

View file

@ -1,59 +0,0 @@
<!DOCTYPE html>
<html lang='fr'>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
<meta content='IE=edge' http-equiv='X-UA-Compatible'>
<meta content='no-cache' name='turbolinks-cache-control'>
<meta content='width=device-width, initial-scale=1' name='viewport'>
<title>
Erreur 422 · demarches-simplifiees.fr
</title>
<style>
html,body,div,span,h1,p,a,img,table,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline;}
html,body{height:100%;}
body{line-height:1;font-family:"Muli";color:#333333;font-size:16px;line-height:1.42857143;}
html{box-sizing:border-box;}
*,*::before,*::after{box-sizing:inherit;}
a{text-decoration:none;}
.page-wrapper{position:relative;min-height:100%;}
.container{padding-left:16px;padding-right:16px;max-width:700px;margin:0 auto;}
.flex{display:flex;}
.flex.align-center{align-items:center;}
.header-inner-content{padding-left:16px;padding-right:16px;max-width:1072px;margin:0 auto;display:flex;justify-content:space-between;min-height:72px;}
.new-header{background-color:#FFFFFF;}
.new-header-with-border{border-bottom:1px solid #CCCCCC;}
.header-logo{display:inline-block;margin-right:32px;}
.header-logo img{height:34px;}
@media (max-width: 1040px){
.header-logo img{height:18px;}
}
.new-h1{color:#333333;text-align:center;font-weight:bold;margin-bottom:60px;font-size:41px;margin-top:60px;}
.description{font-size: 18px; margin-bottom: 8px;}
/*! CSS Used fontfaces */
@font-face{font-family:"Muli";src:url(/fonts/muli/Muli-Regular.woff) format("woff");font-weight:normal;font-style:normal;}
</style>
</head>
<body>
<div class='page-wrapper'>
<div class='new-header new-header-with-border'>
<div class='header-inner-content'>
<div class='flex align-center'>
<a class="header-logo" href="/"><img alt='demarches-simplifiees.fr' src='/logo-ds.svg'>
</a>
</div>
</div>
</div>
<div class='container'>
<h1 class='new-h1'>Laction demandée a été rejetée.</h1>
<p class='description'>
Pas de panique, cest probablement temporaire.
</p>
<p class='description'>
Essayez de
<a href="javascript:window.location=document.referrer;">recharger la page précédente</a>,
et tout devrait rentrer dans lordre.
</p>
</div>
</div>
</body>
</html>

View file

@ -48,5 +48,12 @@ RSpec.describe ErrorsController, type: :controller do
it_behaves_like 'specific action'
end
context "422" do
let(:status_code) { 422 }
let(:action_name) { :unprocessable_entity }
it_behaves_like 'specific action'
end
end
end