diff --git a/app/components/side_menu_component.rb b/app/components/side_menu_component.rb index 08b6c9d42..95f95138b 100644 --- a/app/components/side_menu_component.rb +++ b/app/components/side_menu_component.rb @@ -1,9 +1,11 @@ # frozen_string_literal: true class SideMenuComponent < ApplicationComponent - def initialize(candidatures_notice: , - agreements_notice: , - agreements_authorization: , + delegate :employers_only?, to: :helpers + + def initialize(candidatures_notice:, + agreements_notice:, + agreements_authorization:, current_page_offers: false, current_page_candidatures: false, current_page_agreements: false) @@ -13,43 +15,46 @@ def initialize(candidatures_notice: , @current_page_offers = current_page_offers @current_page_candidatures = current_page_candidatures @current_page_agreements = current_page_agreements - end def link_options(menu_item) - link_options = {class: 'fr-sidemenu__link'} - link_options.merge!({:'aria-current'=>'page'}) if menu_item[:current_page] + link_options = { class: 'fr-sidemenu__link' } + link_options.merge!({ 'aria-current': 'page' }) if menu_item[:current_page] link_options end def li_extra_class(menu_item) - menu_item[:current_page] ? "fr-sidemenu__item--active" : "" + menu_item[:current_page] ? 'fr-sidemenu__item--active' : '' end def before_render @menu_collection = [ { - label: "Offres de stage", + label: 'Offres de stage', path: helpers.dashboard_internship_offers_path, notice: nil, authorization: true, current_page: @current_page_offers - }, + } + ] + # return if employers_only? + + @menu_collection << [ { - label: "Candidatures", + label: 'Candidatures', path: helpers.dashboard_candidatures_path, notice: @candidatures_notice, authorization: true, current_page: @current_page_candidatures }, { - label: "Conventions", + label: 'Conventions', path: helpers.dashboard_internship_agreements_path, notice: @agreements_notice, authorization: @agreements_authorization, current_page: @current_page_agreements } ] + @menu_collection.flatten! end - end diff --git a/app/front_assets/stylesheets/pages/home.scss b/app/front_assets/stylesheets/pages/home.scss index fcfd8cf45..f2eadd41b 100644 --- a/app/front_assets/stylesheets/pages/home.scss +++ b/app/front_assets/stylesheets/pages/home.scss @@ -314,6 +314,19 @@ p.fr-card__desc.std-height { .fr-nav__link[aria-current] { background-color: $blue-france-light; + .disabled_tab{ + opacity: 0.5; + } +} + +.disabled_tab{ + background-color: $grey-975 !important; + opacity: 0.5; + .fr-card__content{ + h3.fr-h4 { + color: grey + } + } } h1, diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6fa8ba371..dfe2e1a1e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -44,6 +44,10 @@ def homepage? current_page?(root_path) end + def employers_only? + ENV.fetch('EMPLOYERS_ONLY', false) == 'true' + end + # def in_dashboard? # request.path.include?('dashboard') || request.path.include?('tableau-de-bord') # end diff --git a/app/libs/services/api_requests_helper.rb b/app/libs/services/api_requests_helper.rb index 8a0c6c0d3..8dc4a60fe 100644 --- a/app/libs/services/api_requests_helper.rb +++ b/app/libs/services/api_requests_helper.rb @@ -1,6 +1,7 @@ module Services class ApiRequestsHelper def get_request + # TODO: specific implementation not ok with inheritance ! uri = get_request_uri http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true diff --git a/app/libs/services/immersion_facile.rb b/app/libs/services/immersion_facile.rb index 246fcb4f6..0a93cace1 100644 --- a/app/libs/services/immersion_facile.rb +++ b/app/libs/services/immersion_facile.rb @@ -1,6 +1,6 @@ module Services class ImmersionFacile < ApiRequestsHelper - IMMERSION_FACILE_ENDPOINT_URL = ENV['IMMERSION_FACILE_API_URL'] + '/search' + IMMERSION_FACILE_ENDPOINT_URL = "#{ENV['IMMERSION_FACILE_API_URL']}/search".freeze # sample of json response : { # [ diff --git a/app/models/concerns/phone_computation.rb b/app/models/concerns/phone_computation.rb index ce18c3194..ea4ccb53a 100644 --- a/app/models/concerns/phone_computation.rb +++ b/app/models/concerns/phone_computation.rb @@ -1,4 +1,3 @@ - module PhoneComputation extend ActiveSupport::Concern @@ -10,10 +9,10 @@ def compute_mobile_phone_prefix return nil if phone.blank? bare_prefix = phone[0..4] - french_prefix = %w(+3306 +3307 +2620 +5960 +5940 +6870 +6890) + french_prefix = %w[+3306 +3307 +2620 +5960 +5940 +6870 +6890] return nil unless bare_prefix.in?(french_prefix) - bare_prefix.in?(%w(+3306 +3307)) ? '33' : bare_prefix[1..-2] + bare_prefix.in?(%w[+3306 +3307]) ? '33' : bare_prefix[1..-2] end def formatted_phone @@ -25,7 +24,7 @@ def formatted_phone def self.sanitize_mobile_phone_number(number, prefix = '') return nil if number.blank? - thin_number = number.gsub(/[\s|;\,\.\:\(\)]/, '') + thin_number = number.gsub(/[\s|;,.:()]/, '') if thin_number.match?(/\A\+(33|262|594|596|687|689)0[6|7]\d{8}\z/) "#{prefix}#{thin_number[4..]}" elsif thin_number.match?(/\A\+(33|262|594|596|687|689)[6|7]\d{8}\z/) @@ -57,4 +56,4 @@ def clean_phone self.phone = nil if phone == '+33' end end -end \ No newline at end of file +end diff --git a/app/views/dashboard/internship_offers/_sidemenu.html.slim b/app/views/dashboard/internship_offers/_sidemenu.html.slim index 0b249010d..6f6c79d57 100644 --- a/app/views/dashboard/internship_offers/_sidemenu.html.slim +++ b/app/views/dashboard/internship_offers/_sidemenu.html.slim @@ -17,9 +17,17 @@ - else h1#fr-sidemenu-title.h3.text-dark Tableau de bord -= render SideMenuComponent.new(candidatures_notice: applications_notice, +- side_menu_parameters = {current_page_offers: true, + candidatures_notice: nil, + agreements_notice: nil, + agreements_authorization: false, + current_page_candidatures: false, + current_page_agreements: false } +- unless employers_only? + - side_menu_parameters.merge!(current_page_offers: current_page?(dashboard_internship_offers_path), + candidatures_notice: applications_notice, agreements_notice: agreements_notice, agreements_authorization: can?(:index, InternshipAgreement), - current_page_offers: current_page?(dashboard_internship_offers_path), current_page_candidatures: current_page?(dashboard_candidatures_path), current_page_agreements: current_page?(dashboard_internship_agreements_path)) += render SideMenuComponent.new(**side_menu_parameters) diff --git a/app/views/layouts/_footer.html.slim b/app/views/layouts/_footer.html.slim index 6d4523148..41d78d442 100644 --- a/app/views/layouts/_footer.html.slim +++ b/app/views/layouts/_footer.html.slim @@ -2,12 +2,17 @@ footer#footer.fr-footer role="contentinfo" data-controller='footer' .fr-footer__top.fr-px-2w .fr-container .row + - klass = employers_only? ? 'disabled_tab' : '' .col-12.col-md-3 .fr-footer__top-column - .title.fr-text--sm.fr-mb-1w = "Élèves" - .fr-py-1w = link_to "Trouver un stage", eleves_path, class: 'fr-raw-link fr-text--sm link' - .fr-py-1w = link_to "Découvrir le dispositif", eleves_path(anchor: 'discover'), class: 'fr-raw-link fr-text--sm link' - .fr-py-1w = link_to "Ressources utiles", eleves_path(anchor: 'resources'), class: 'fr-raw-link fr-text--sm link' + div class="title fr-text--sm fr-mb-1w #{klass}" + = "Élèves" + - path = employers_only? ? '#' : eleves_path + - path_anchor = employers_only? ? '#' : eleves_path(anchor: 'discover') + - path_resources = employers_only? ? '#' : eleves_path(anchor: 'resources') + .fr-py-1w = link_to "Trouver un stage", path, class: "fr-raw-link fr-text--sm link #{klass}" + .fr-py-1w = link_to "Découvrir le dispositif", path_anchor, class: "fr-raw-link fr-text--sm link #{klass}" + .fr-py-1w = link_to "Ressources utiles", path_resources, class: "fr-raw-link fr-text--sm link #{klass}" .col-12.col-md-3 .fr-footer__top-column .title.fr-text--sm.fr-mb-1w = "Professionnels" @@ -16,10 +21,12 @@ footer#footer.fr-footer role="contentinfo" data-controller='footer' .fr-py-1w = link_to "Ressources utiles", professionnels_path(anchor: 'resources'), class: 'fr-raw-link fr-text--sm link' .col-12.col-md-3 .fr-footer__top-column - .title.fr-text--sm.fr-mb-1w = "Établissements scolaires" - .fr-py-1w = link_to "Suivez vos élèves", equipe_pedagogique_path, class: 'fr-raw-link fr-text--sm link' - .fr-py-1w = link_to "Découvrir le dispositif", equipe_pedagogique_path, class: 'fr-raw-link fr-text--sm link' - .fr-py-1w = link_to "Ressources utiles", equipe_pedagogique_path, class: 'fr-raw-link fr-text--sm link' + - path = employers_only? ? '#' : equipe_pedagogique_path + div class="title fr-text--sm fr-mb-1w #{klass}" + = "Établissements scolaires" + .fr-py-1w = link_to "Suivez vos élèves", path, class: "fr-raw-link fr-text--sm link #{klass}" + .fr-py-1w = link_to "Découvrir le dispositif", path, class: "fr-raw-link fr-text--sm link #{klass}" + .fr-py-1w = link_to "Ressources utiles", path, class: "fr-raw-link fr-text--sm link #{klass}" .col-12.col-md-3 .fr-footer__top-column .title.fr-text--sm.fr-mb-1w = "Référents" diff --git a/app/views/layouts/navbar/_nav.html.slim b/app/views/layouts/navbar/_nav.html.slim index 36323ec45..94fa29402 100644 --- a/app/views/layouts/navbar/_nav.html.slim +++ b/app/views/layouts/navbar/_nav.html.slim @@ -1,3 +1,4 @@ +- disabled_class = employers_only? ? 'disabled' : '' .fr-header__tools .fr-header__tools-links ul.fr-links-group.custom-navbar @@ -9,8 +10,8 @@ - active = current_page?(root_path) ? 'active' : '' = link_to 'Accueil', root_path, - class: "fr-link text-decoration-none mr-4 #{active}" - - if current_user.is_a?(Users::Student) + class: "fr-link text-decoration-none mr-4 #{active}" + - if current_user.is_a?(Users::Student) && !employers_only? li - active = current_page?(internship_offers_path) && !request.url.include?('origine=dashboard') ? 'active' : '' = link_to 'Recherche', diff --git a/app/views/pages/home/_top_nav.html.slim b/app/views/pages/home/_top_nav.html.slim index f39984799..2c2777155 100644 --- a/app/views/pages/home/_top_nav.html.slim +++ b/app/views/pages/home/_top_nav.html.slim @@ -1,28 +1,35 @@ +- disabled_class = employers_only? ? 'disabled_tab' : '' + .d-none.d-md-block.fr-px-2w nav.fr-nav id="header-navigation" role="navigation" aria-label="Menu principal" ul.fr-nav__list li.fr-nav__item + - path = employers_only? ? '#' : root_path = link_to 'Accueil', root_path, - class: 'fr-nav__link', + class: "fr-nav__link #{disabled_class}", aria: { current: (current_page?(root_path) ? 'page' : nil) } li.fr-nav__item + - path = employers_only? ? '#' : eleves_path = link_to 'Élèves', - eleves_path, - class: 'fr-nav__link', + path, + class: "fr-nav__link #{disabled_class}", + disabled: employers_only? , aria: { current: (current_page?(eleves_path) || current_page?(companies_path) || current_page?(recherche_entreprises_path) ? 'page' : nil) } li.fr-nav__item = link_to 'Professionnels', professionnels_path, - class: 'fr-nav__link', + class: "fr-nav__link ", aria: { current: (current_page?(professionnels_path) ? 'page' : nil) } li.fr-nav__item + - path = employers_only? ? '#' : equipe_pedagogique_path = link_to 'Équipes pédagogiques', - equipe_pedagogique_path, - class: 'fr-nav__link', + path, + class: "fr-nav__link #{disabled_class}", + disabled: employers_only? , aria: { current: (current_page?(equipe_pedagogique_path) ? 'page' : nil) } li.fr-nav__item = link_to 'Référents', referents_path, - class: 'fr-nav__link', + class: "fr-nav__link", aria: { current: (current_page?(referents_path) ? 'page' : nil) } \ No newline at end of file diff --git a/app/views/pages/home/pros/_hero_pro.html.slim b/app/views/pages/home/pros/_hero_pro.html.slim index 6740a0b13..dd9a79611 100644 --- a/app/views/pages/home/pros/_hero_pro.html.slim +++ b/app/views/pages/home/pros/_hero_pro.html.slim @@ -25,6 +25,18 @@ header.container-xl.px-0 = image_tag asset_pack_path('media/images/homepage/1eleve1stage_tag.png'), alt: 'Illustration élèves', class: 'img-fluid' - .row.fr-my-3w + .row.fr-my-1w .col-12 = link_to 'Déposer une offre de stage', new_user_registration_path(as: 'Employer'), class: 'fr-btn' + - if employers_only? + .row.fr-mb-3w + .col-12 + .fr-mt-1w.fr-mb-4w.header-cartel.fr-px-6v.fr-py-1w + p.blue-france + strong + = link_to "Vous êtes en 4ème, 3e ou 2nde générale ou technologique ?", + "https://forms.sbc36.com/62553f47462f0e1887f81bfe/xtszW7joSFu4cBSfyOLMdw/form.html", + target: '_blank', + class: 'fr-raw-link' + p.default-grey + = "L'ouverture du service est prévue le #{ENV.fetch 'STUDENTS_OPENING_DAY','3 février 2024'} ." diff --git a/app/views/users/registrations/cards/_education.html.slim b/app/views/users/registrations/cards/_education.html.slim index 0ede6f8c4..a3610cc3c 100644 --- a/app/views/users/registrations/cards/_education.html.slim +++ b/app/views/users/registrations/cards/_education.html.slim @@ -1,4 +1,4 @@ -.fr-card +div class="fr-card #{employers_only? ? 'disabled_tab' : ''}" .fr-card__body .fr-card__content h3.fr-h4 @@ -12,7 +12,10 @@ .fr-card__footer ul.fr-btns-group li - = link_to "Inscription", new_user_registration_path(as: 'SchoolManagement'), class: 'fr-btn fr-btn--secondary' + - path = employers_only? ? '#' : new_user_registration_path(as: 'SchoolManagement') + - label = employers_only? ? 'Inscription à venir' : 'Inscription' + - klass = employers_only? ? 'fr-btn--tertiary' : 'fr-btn--secondary' + = link_to label, path, class: "fr-btn #{klass}", disabled: employers_only? .fr-card__header .fr-ml-4w.fr-mt-5w .fr-badge.fr-badge--info.fr-badge--no-icon éducation \ No newline at end of file diff --git a/app/views/users/registrations/cards/_student.html.slim b/app/views/users/registrations/cards/_student.html.slim index 2e64770cf..96e8ec4ca 100644 --- a/app/views/users/registrations/cards/_student.html.slim +++ b/app/views/users/registrations/cards/_student.html.slim @@ -1,4 +1,4 @@ -.fr-card +div class="fr-card #{employers_only? ? 'disabled_tab' : ''}" .fr-card__body .fr-card__content h3.fr-h4 @@ -12,7 +12,10 @@ .fr-card__footer ul.fr-btns-group li - = link_to "Inscription", new_identity_path(as: 'Student'), class: 'fr-btn fr-btn--secondary' + - path = employers_only? ? '#' : new_identity_path(as: 'Student') + - label = employers_only? ? 'Inscription à venir' : 'Inscription' + - klass = employers_only? ? 'fr-btn--tertiary' : 'fr-btn--secondary' + = link_to label, path, class: "fr-btn #{klass}", disabled: employers_only? .fr-card__header .fr-ml-4w.fr-mt-5w .fr-badge.fr-badge--purple-glycine.fr-badge--no-icon élève \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 57531a351..a99f5fdf8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,14 @@ # frozen_string_literal: true require 'sidekiq/web' +when_employers_only = ENV.fetch('EMPLOYERS_ONLY', false) == 'true' +root_destination = if ENV.fetch('HOLIDAYS_MAINTENANCE', false) == 'true' + 'maintenance_estivale' + elsif when_employers_only + 'pro_landing' + else + 'home' + end Rails.application.routes.draw do # ------------------ SCOPE START ------------------ @@ -45,10 +53,11 @@ end resources :identities, path: 'identites', only: %i[new create] - resources :url_shrinkers, path: 'c', only: %i[] do - get :o, on: :member + unless when_employers_only + resources :url_shrinkers, path: 'c', only: %i[] do + get :o, on: :member + end end - resources :schools, path: 'ecoles', only: %i[new create] resources :coded_crafts, only: [] do collection do @@ -56,6 +65,8 @@ end end + resources :schools, path: 'ecoles', only: %i[new create] + resources :internship_offer_keywords, only: [] do collection do post :search @@ -86,7 +97,6 @@ get :search, path: 'recherche' end end - resources :favorites, only: %i[create destroy index] get '/utilisateurs/transform_input', to: 'users#transform_input' # display @@ -145,31 +155,34 @@ resources :team_member_invitations, path: 'invitation-equipes', only: %i[create index new destroy] do patch :join, to: 'team_member_invitations#join', on: :member end - resources :internship_agreements, path: 'conventions-de-stage', except: %i[destroy], param: :uuid - resources :users, path: 'signatures', only: %i[update], module: 'group_signing' do - member do - post 'start_signing' - post 'reset_phone_number' - post 'resend_sms_code' - post 'signature_code_validate' - post 'handwrite_sign' - end - end post 'internship_applications/update_multiple', to: 'internship_applications#update_multiple', as: :update_multiple_internship_applications - resources :schools, path: 'ecoles', only: %i[index edit update show] do - resources :invitations, only: %i[new create index destroy], module: 'schools' - get '/resend_invitation', to: 'schools/invitations#resend_invitation', module: 'schools' - resources :users, path: 'utilisateurs', only: %i[destroy update index], module: 'schools' + resources :internship_agreements, path: 'conventions-de-stage', except: %i[destroy], param: :uuid + unless when_employers_only + resources :users, path: 'signatures', only: %i[update], module: 'group_signing' do + member do + post 'start_signing' + post 'reset_phone_number' + post 'resend_sms_code' + post 'signature_code_validate' + post 'handwrite_sign' + end + end - resources :class_rooms, path: 'classes', only: %i[index new create edit update show destroy], - module: 'schools' do - resources :students, path: 'eleves', only: %i[update index new create], module: 'class_rooms' + resources :schools, path: 'ecoles', only: %i[index edit update show] do + resources :invitations, only: %i[new create index destroy], module: 'schools' + get '/resend_invitation', to: 'schools/invitations#resend_invitation', module: 'schools' + resources :users, path: 'utilisateurs', only: %i[destroy update index], module: 'schools' + + resources :class_rooms, path: 'classes', only: %i[index new create edit update show destroy], + module: 'schools' do + resources :students, path: 'eleves', only: %i[update index new create], module: 'class_rooms' + end + put '/update_students_by_group', to: 'schools/students#update_by_group', module: 'schools' + get '/information', to: 'schools#information', module: 'schools' end - put '/update_students_by_group', to: 'schools/students#update_by_group', module: 'schools' - get '/information', to: 'schools#information', module: 'schools' end resources :internship_offer_areas, path: 'espaces', except: %i[show] do @@ -209,21 +222,21 @@ post :resend_application, on: :member end end - get 'candidatures', to: 'internship_offers/internship_applications#user_internship_applications' end # ------------------ DASHBOARD END ------------------ end # ------------------ SCOPE END ------------------ - - namespace :reporting, path: 'reporting' do - get '/dashboards', to: 'dashboards#index' - - get '/schools', to: 'schools#index' - get '/employers_internship_offers', to: 'internship_offers#employers_offers' - get 'internship_offers', to: 'internship_offers#index' - get 'operators', to: 'operators#index' - put 'operators', to: 'operators#update' + unless when_employers_only + namespace :reporting, path: 'reporting' do + get '/dashboards', to: 'dashboards#index' + + get '/schools', to: 'schools#index' + get '/employers_internship_offers', to: 'internship_offers#employers_offers' + get 'internship_offers', to: 'internship_offers#index' + get 'operators', to: 'operators#index' + put 'operators', to: 'operators#update' + end end get 'api_address_proxy/search', to: 'api_address_proxy#search', as: :api_address_proxy_search @@ -253,10 +266,10 @@ # TODO # To be removed after june 2023 get '/register_to_webinar', to: 'pages#register_to_webinar' - get '/eleves', to: 'pages#student_landing' + get '/eleves', to: when_employers_only ? 'pages#home' : 'pages#student_landing' get '/professionnels', to: 'pages#pro_landing' get '/partenaires_regionaux', to: 'pages#regional_partners_index' - get '/equipe-pedagogique', to: 'pages#school_management_landing' + get '/equipe-pedagogique', to: when_employers_only ? 'pages#home' : 'pages#school_management_landing' get '/referents', to: 'pages#statistician_landing' get '/maintenance_estivale', to: 'pages#maintenance_estivale' post '/maintenance_messaging', to: 'pages#maintenance_messaging' @@ -264,7 +277,6 @@ # Redirects get '/dashboard/internship_offers/:id', to: redirect('/internship_offers/#{id}', status: 302) - root_destination = ENV.fetch('HOLIDAYS_MAINTENANCE', 'false') == 'true' ? 'maintenance_estivale' : 'home' root to: "pages##{root_destination}" get '/400', to: 'errors#bad_request'