From 2bc388005f0a423850ffc217a88b60d4b77edfcf Mon Sep 17 00:00:00 2001 From: dramelet-pass <185903561+dramelet-pass@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:35:56 +0100 Subject: [PATCH 1/4] (PC-33377)[API] chore: Remove useless `POST /venues` route Also remove related unit and e2e tests --- api/src/pcapi/routes/pro/venues.py | 19 - api/tests/routes/pro/patch_venue_test.py | 11 +- api/tests/routes/pro/post_venue_test.py | 354 ------------------ pro/cypress/e2e/venue.cy.ts | 265 ------------- pro/src/apiClient/v1/index.ts | 2 - .../apiClient/v1/models/PostVenueBodyModel.ts | 25 -- .../apiClient/v1/models/VenueResponseModel.ts | 8 - .../apiClient/v1/services/DefaultService.ts | 22 -- 8 files changed, 9 insertions(+), 697 deletions(-) delete mode 100644 api/tests/routes/pro/post_venue_test.py delete mode 100644 pro/cypress/e2e/venue.cy.ts delete mode 100644 pro/src/apiClient/v1/models/PostVenueBodyModel.ts delete mode 100644 pro/src/apiClient/v1/models/VenueResponseModel.ts diff --git a/api/src/pcapi/routes/pro/venues.py b/api/src/pcapi/routes/pro/venues.py index 38efc1cf4d0..f379f55edd6 100644 --- a/api/src/pcapi/routes/pro/venues.py +++ b/api/src/pcapi/routes/pro/venues.py @@ -79,25 +79,6 @@ def get_venues(query: venues_serialize.VenueListQueryModel) -> venues_serialize. ) -@private_api.route("/venues", methods=["POST"]) -@login_required -@spectree_serialize( - response_model=venues_serialize.VenueResponseModel, on_success_status=201, api=blueprint.pro_private_schema -) -def post_create_venue(body: venues_serialize.PostVenueBodyModel) -> venues_serialize.VenueResponseModel: - check_user_has_access_to_offerer(current_user, body.managingOffererId) - if body.siret: - validation.check_siret_does_not_exists(body.siret) - siret_info = sirene.get_siret(body.siret) - if not siret_info.active: - raise ApiErrors(errors={"siret": ["SIRET is no longer active"]}) - body.name = siret_info.name # type: ignore[assignment] - validation.check_accessibility_compliance(body) - venue = offerers_api.create_venue(body, current_user) - - return venues_serialize.VenueResponseModel.from_orm(venue) - - @private_api.route("/venues/", methods=["PATCH"]) @login_required @spectree_serialize(response_model=venues_serialize.GetVenueResponseModel, api=blueprint.pro_private_schema) diff --git a/api/tests/routes/pro/patch_venue_test.py b/api/tests/routes/pro/patch_venue_test.py index 93d69f615b5..593076d0baa 100644 --- a/api/tests/routes/pro/patch_venue_test.py +++ b/api/tests/routes/pro/patch_venue_test.py @@ -17,11 +17,18 @@ from pcapi.core.users import testing as external_testing from pcapi.utils.date import timespan_str_to_numrange -from tests.routes.pro.post_venue_test import venue_malformed_test_data - pytestmark = pytest.mark.usefixtures("db_session") +venue_malformed_test_data = [ + ({"description": "a" * 1024}, "description"), + ({"contact": {"email": "not_an_email"}}, "contact.email"), + ({"contact": {"website": "not_an_url"}}, "contact.website"), + ({"contact": {"phoneNumber": "not_a_phone_number"}}, "contact.phoneNumber"), + ({"contact": {"social_medias": {"a": "b"}}}, "contact.socialMedias.__key__"), + ({"contact": {"social_medias": {"facebook": "not_an_url"}}}, "contact.socialMedias.facebook"), +] + def populate_missing_data_from_venue(venue_data: dict, venue: offerers_models.Venue) -> dict: return { diff --git a/api/tests/routes/pro/post_venue_test.py b/api/tests/routes/pro/post_venue_test.py deleted file mode 100644 index d07d3d8a76d..00000000000 --- a/api/tests/routes/pro/post_venue_test.py +++ /dev/null @@ -1,354 +0,0 @@ -from datetime import datetime -import pathlib -from unittest.mock import patch - -import pytest - -from pcapi.connectors.api_adresse import AddressInfo -from pcapi.core import testing -from pcapi.core.external.zendesk_sell_backends import testing as zendesk_testing -from pcapi.core.geography import models as geography_models -from pcapi.core.history import models as history_models -from pcapi.core.offerers import models -from pcapi.core.offerers import models as offerers_models -import pcapi.core.offerers.factories as offerers_factories -from pcapi.core.offerers.models import Venue -from pcapi.core.users import testing as external_testing -from pcapi.core.users.factories import ProFactory - -import tests -from tests.connectors import sirene_test_data - - -pytestmark = pytest.mark.usefixtures("db_session") -IMAGES_DIR = pathlib.Path(tests.__path__[0]) / "files" - - -def get_api_address_response(): - return { - "type": "FeatureCollection", - "version": "draft", - "features": [ - { - "type": "Feature", - "geometry": {"type": "Point", "coordinates": [3.893166, 44.626322]}, - "properties": { - "label": "Chemin de Chaniaux 48250 Laveyrune", - "score": 0.928571818181818, - "type": "locality", - "importance": 0.21429, - "id": "07136_0040", - "name": "Chemin de Chaniaux", - "postcode": "48250", - "citycode": "07136", - "x": 770848.89, - "y": 6392314.73, - "city": "Laveyrune", - "context": "07, Ardèche, Auvergne-Rhône-Alpes", - "locality": "Chemin de Chaniaux", - }, - } - ], - "attribution": "BAN", - "licence": "ETALAB-2.0", - "query": "Chemin de chaniaux Laveyrune", - "filters": {"postcode": "48250"}, - "limit": 1, - } - - -def create_valid_venue_data(user=None): - user_offerer_data = {"offerer__siren": "302559178"} - if user: - user_offerer_data["user"] = user - user_offerer = offerers_factories.UserOffererFactory(**user_offerer_data) - venue_label = offerers_factories.VenueLabelFactory(label="CAC - Centre d'art contemporain d'intérêt national") - - return { - "address": { - "street": "Chemin de Chaniaux 48250 Laveyrune", - "postalCode": "48250", - "city": "Laveyrune", - "latitude": 44.626322, - "longitude": 3.893166, - }, - "name": "MINISTERE DE LA CULTURE", - "siret": f"{user_offerer.offerer.siren}10045", - "bookingEmail": "toto@example.com", - "managingOffererId": user_offerer.offerer.id, - "publicName": "Ma venue publique", - "venueTypeCode": "BOOKSTORE", - "venueLabelId": venue_label.id, - "description": "Some description", - "audioDisabilityCompliant": True, - "mentalDisabilityCompliant": False, - "motorDisabilityCompliant": False, - "visualDisabilityCompliant": False, - "contact": {"email": "some@email.com"}, - } - - -venue_malformed_test_data = [ - ({"description": "a" * 1024}, "description"), - ({"contact": {"email": "not_an_email"}}, "contact.email"), - ({"contact": {"website": "not_an_url"}}, "contact.website"), - ({"contact": {"phoneNumber": "not_a_phone_number"}}, "contact.phoneNumber"), - ({"contact": {"social_medias": {"a": "b"}}}, "contact.socialMedias.__key__"), - ({"contact": {"social_medias": {"facebook": "not_an_url"}}}, "contact.socialMedias.facebook"), -] - - -class Returns201Test: - @pytest.mark.settings(ADRESSE_BACKEND="pcapi.connectors.api_adresse.ApiAdresseBackend") - @pytest.mark.features(ENABLE_ZENDESK_SELL_CREATION=True) - def test_register_new_venue(self, client, requests_mock): - api_adresse_response = get_api_address_response() - user = ProFactory( - lastConnectionDate=datetime.utcnow(), - ) - venue_data = create_valid_venue_data(user) - requests_mock.get( - """https://api-adresse.data.gouv.fr/search?q=Chemin+de+Chaniaux+48250+Laveyrune&postcode=48250&autocomplete=0&limit=1""", - json=api_adresse_response, - ) - - client = client.with_session_auth(email=user.email) - response = client.post("/venues", json=venue_data) - - assert response.status_code == 201 - - venue = Venue.query.filter_by(id=response.json["id"]).one() - address = geography_models.Address.query.one() - offerer_address = models.OffererAddress.query.one() - - assert venue.name == venue_data["name"] - assert venue.publicName == venue_data["publicName"] - assert venue.siret == venue_data["siret"] - assert venue.venueTypeCode.name == "BOOKSTORE" - assert venue.venueLabelId == venue_data["venueLabelId"] - assert venue.description == venue_data["description"] - assert venue.audioDisabilityCompliant == venue_data["audioDisabilityCompliant"] - assert venue.mentalDisabilityCompliant == venue_data["mentalDisabilityCompliant"] - assert venue.motorDisabilityCompliant == venue_data["motorDisabilityCompliant"] - assert venue.visualDisabilityCompliant == venue_data["visualDisabilityCompliant"] - assert venue.contact.email == venue_data["contact"]["email"] - assert venue.dmsToken - - assert not venue.isPermanent - assert not venue.contact.phone_number - assert not venue.contact.social_medias - - assert len(venue.adage_addresses) == 1 - adage_addr = venue.adage_addresses[0] - - assert adage_addr.venueId == venue.id - assert adage_addr.adageId == venue.adageId - assert adage_addr.adageInscriptionDate == venue.adageInscriptionDate - - assert len(external_testing.sendinblue_requests) == 1 - assert external_testing.zendesk_sell_requests == [ - { - "action": "create", - "type": "Venue", - "id": response.json["id"], - "parent_organization_id": zendesk_testing.TESTING_ZENDESK_ID_OFFERER, - } - ] - - assert venue.offererAddressId == offerer_address.id - assert offerer_address.addressId == address.id - assert venue.timezone == address.timezone - assert venue.city == address.city - assert venue.postalCode == address.postalCode - assert address.street == api_adresse_response["features"][0]["properties"]["locality"] - assert address.inseeCode == api_adresse_response["features"][0]["properties"]["citycode"] - assert address.inseeCode.startswith(address.departmentCode) - assert address.departmentCode == "07" - assert address.timezone == "Europe/Paris" - - assert len(venue.action_history) == 1 - assert venue.action_history[0].actionType == history_models.ActionType.VENUE_CREATED - assert venue.action_history[0].authorUser == user - - @pytest.mark.settings( - ADRESSE_BACKEND="pcapi.connectors.api_adresse.ApiAdresseBackend", - IS_INTEGRATION=True, - ) - @pytest.mark.features(ENABLE_ZENDESK_SELL_CREATION=True) - def test_register_new_venue_from_integration_env(self, client, requests_mock): - api_adresse_response = get_api_address_response() - user = ProFactory() - - requests_mock.get( - """https://api-adresse.data.gouv.fr/search?q=Chemin+de+Chaniaux+48250+Laveyrune&postcode=48250&autocomplete=0&limit=1""", - json=api_adresse_response, - ) - - client = client.with_session_auth(email=user.email) - venue_data = create_valid_venue_data(user) - - response = client.post("/venues", json=venue_data) - - assert response.status_code == 201 - - venue = Venue.query.filter_by(id=response.json["id"]).one() - - assert venue.name == venue_data["name"] - assert venue.adageId - assert venue.adageInscriptionDate - assert venue.managingOfferer.allowedOnAdage - - def test_use_venue_name_retrieved_from_sirene_api(self, client): - user = ProFactory() - client = client.with_session_auth(email=user.email) - venue_data = create_valid_venue_data(user) - venue_data = {**venue_data, "name": "edited venue name"} - - response = client.post("/venues", json=venue_data) - - assert response.status_code == 201 - venue = Venue.query.filter_by(id=response.json["id"]).one() - assert venue.name == "MINISTERE DE LA CULTURE" - - -class Returns400Test: - def test_latitude_out_of_range_and_longitude_wrong_format(self, client): - user = ProFactory() - venue_data = create_valid_venue_data(user) - - venue_data["address"]["latitude"] = -98.82387 - venue_data["address"]["longitude"] = "112°3534" - - client = client.with_session_auth(email=user.email) - response = client.post("/venues", json=venue_data) - - assert response.status_code == 400 - assert response.json["address.latitude"] == ["La latitude doit être comprise entre -90.0 et +90.0"] - assert response.json["address.longitude"] == ["Format incorrect"] - - def test_longitude_out_of_range_and_latitude_wrong_format(self, client): - user = ProFactory() - - venue_data = create_valid_venue_data(user) - venue_data["address"]["latitude"] = "76°8237" - venue_data["address"]["longitude"] = 210.43251 - - client = client.with_session_auth(email=user.email) - response = client.post("/venues", json=venue_data) - - assert response.status_code == 400 - assert response.json["address.longitude"] == ["La longitude doit être comprise entre -180.0 et +180.0"] - assert response.json["address.latitude"] == ["Format incorrect"] - - def test_mandatory_accessibility_fields(self, client): - user = ProFactory() - - venue_data = create_valid_venue_data(user) - venue_data.pop("audioDisabilityCompliant") - venue_data.pop("mentalDisabilityCompliant") - venue_data.pop("motorDisabilityCompliant") - venue_data.pop("visualDisabilityCompliant") - - client = client.with_session_auth(email=user.email) - response = client.post("/venues", json=venue_data) - - assert response.status_code == 400 - assert response.json["global"] == ["L'accessibilité du lieu doit être définie."] - - @pytest.mark.parametrize("data, key", venue_malformed_test_data) - def test_create_venue_malformed(self, client, data, key): - user_offerer = offerers_factories.UserOffererFactory() - - client = client.with_session_auth(user_offerer.user.email) - response = client.post("/venues", json=data) - - assert response.status_code == 400 - assert key in response.json - - def test_no_siret_nor_comment(self, client): - user = ProFactory() - client = client.with_session_auth(email=user.email) - venue_data = create_valid_venue_data(user) - venue_data.pop("siret") - - response = client.post("/venues", json=venue_data) - - assert response.status_code == 400 - assert response.json["siret"] == ["Veuillez saisir soit un SIRET soit un commentaire"] - - def test_both_siret_and_comment(self, client): - user = ProFactory() - client = client.with_session_auth(email=user.email) - venue_data = create_valid_venue_data(user) - venue_data["comment"] = "J'ai déjà saisi un SIRET" - - response = client.post("/venues", json=venue_data) - - assert response.status_code == 400 - assert response.json["siret"] == ["Veuillez saisir soit un SIRET soit un commentaire"] - - def test_comment_too_long(self, client) -> None: - user = ProFactory() - client = client.with_session_auth(email=user.email) - venue_data = create_valid_venue_data(user) - venue_data["siret"] = None - venue_data["comment"] = "Pas de SIRET " * 40 - - response = client.post("/venues", json=venue_data) - - assert response.status_code == 400 - assert response.json["comment"] == ["ensure this value has at most 500 characters"] - - def test_withdrawal_details_too_long(self, client) -> None: - user = ProFactory() - client = client.with_session_auth(email=user.email) - venue_data = create_valid_venue_data(user) - venue_data["withdrawalDetails"] = "Trop long " * 51 - - response = client.post("/venues", json=venue_data) - - assert response.status_code == 400 - assert response.json["withdrawalDetails"] == ["ensure this value has at most 500 characters"] - - @pytest.mark.settings(SIRENE_BACKEND="pcapi.connectors.entreprise.backends.insee.InseeBackend") - def test_with_inactive_siret(self, requests_mock, client): - siret = "30255917810045" - requests_mock.get( - f"https://api.insee.fr/entreprises/sirene/V3.11/siret/{siret}", - json=sirene_test_data.RESPONSE_SIRET_INACTIVE_COMPANY, - ) - - user = ProFactory() - client = client.with_session_auth(email=user.email) - venue_data = create_valid_venue_data(user) - - response = client.post("/venues", json=venue_data) - - assert response.status_code == 400 - assert response.json["siret"] == ["SIRET is no longer active"] - - def test_siret_already_exists(self, client): - user = ProFactory() - venue_data = create_valid_venue_data(user) - offerers_factories.VenueFactory(siret=venue_data["siret"]) - - client = client.with_session_auth(email=user.email) - - response = client.post("/venues", json=venue_data) - assert response.status_code == 400 - - assert response.json["siret"] == "Un lieu avec ce SIRET existe déjà" - - -class Returns403Test: - def test_user_is_not_managing_offerer_create_venue(self, client): - user = ProFactory() - venue_data = create_valid_venue_data() - - client = client.with_session_auth(email=user.email) - response = client.post("/venues", json=venue_data) - - assert response.status_code == 403 - assert response.json["global"] == [ - "Vous n'avez pas les droits d'accès suffisants pour accéder à cette information." - ] diff --git a/pro/cypress/e2e/venue.cy.ts b/pro/cypress/e2e/venue.cy.ts deleted file mode 100644 index 2cd2d9cac4e..00000000000 --- a/pro/cypress/e2e/venue.cy.ts +++ /dev/null @@ -1,265 +0,0 @@ -import { - MOCKED_BACK_ADDRESS_LABEL, - MOCKED_BACK_ADDRESS_STREET, -} from '../support/constants.ts' -import { interceptSearch5Adresses, sessionLogInAndGoToPage } from '../support/helpers.ts' - -describe('Create and update venue', () => { - let login: string - let siret: string - let siren: string - - before(() => { - cy.visit('/connexion') - cy.request({ - method: 'GET', - url: 'http://localhost:5001/sandboxes/pro/create_regular_pro_user', - }).then((response) => { - login = response.body.user.email - siren = response.body.siren - }) - }) - - beforeEach(() => { - cy.intercept({ method: 'PATCH', url: '/venues/*' }).as('patchVenue') - cy.intercept( - 'GET', - 'https://api-adresse.data.gouv.fr/search/?limit=1&q=*', - (req) => - req.reply({ - statusCode: 200, - body: addressInterceptionPayload, - }) - ).as('searchAddress1') - interceptSearch5Adresses() - cy.intercept({ method: 'POST', url: '/venues' }).as('postVenues') - }) - - it('As a pro user, I should be able to add a venue without SIRET', () => { - const venueNameWithoutSiret = 'Lieu sans Siret' - sessionLogInAndGoToPage('Session venue', login, '/accueil') - - cy.stepLog({ message: 'I want to add a venue' }) - cy.findByText('Ajouter un lieu', { timeout: 60 * 1000 }).click() - - cy.stepLog({ message: 'I choose a venue which already has a Siret' }) - cy.findByText('Ce lieu possède un SIRET').click() - - cy.stepLog({ message: 'I add venue without Siret details' }) - cy.findByLabelText('Commentaire du lieu sans SIRET *').type( - 'Commentaire du lieu sans SIRET' - ) - cy.findByLabelText('Raison sociale *').type(venueNameWithoutSiret) - cy.findByLabelText('Adresse postale *') - - cy.findByLabelText('Adresse postale *').type(MOCKED_BACK_ADDRESS_LABEL) - cy.wait('@search5Address').its('response.statusCode').should('eq', 200) - cy.findByTestId('list').contains(MOCKED_BACK_ADDRESS_LABEL).click() - cy.findByLabelText('Activité principale *').select('Centre culturel') - cy.findByText('Visuel').click() - cy.findByLabelText('Adresse email *').type('email@example.com') - - cy.stepLog({ message: 'I validate venue step' }) - cy.findByText('Enregistrer et créer le lieu').click() - cy.wait('@postVenues', { timeout: 60 * 1000 }) - .its('response.statusCode') - .should('eq', 201) - - cy.stepLog({ message: 'I skip offer creation' }) - cy.findByText('Plus tard').click() - cy.url().should('contain', 'accueil') - - cy.stepLog({ message: 'I open my venue without Siret resume' }) - cy.findByRole('link', { - name: 'Gérer la page de ' + venueNameWithoutSiret, - }).click() - cy.url().should('contain', 'structures').and('contain', 'lieux') - cy.findAllByTestId('spinner').should('not.exist') - cy.contains(venueNameWithoutSiret).should('be.visible') - - cy.stepLog({ message: 'I add an image to my venue' }) - cy.findByText('Ajouter une image').click() - cy.get('input[type=file]').selectFile('cypress/data/dog.jpg', { - force: true, - }) - // eslint-disable-next-line cypress/no-unnecessary-waiting - cy.wait(1000) // todo: pas réussi à attendre l'image chargée - cy.contains( - 'En utilisant ce contenu, je certifie que je suis propriétaire ou que je dispose des autorisations nécessaires pour l’utilisation de celui-ci' - ) - cy.findByText('Suivant').click() - cy.contains( - 'Prévisualisation de votre image dans l’application pass Culture' - ) - cy.findByText('Enregistrer').click() - - cy.stepLog({ message: 'I should see a success message' }) - cy.findByTestId('global-notification-success', { - timeout: 30 * 1000, - }).should('contain', 'Vos modifications ont bien été prises en compte') - - cy.stepLog({ message: 'I should see details of my venue' }) - cy.contains(venueNameWithoutSiret) - cy.findByText('Modifier l’image').should('be.visible') - }) - - it('As a pro user, I should be able to add a venue with SIRET', () => { - const venueNameWithSiret = 'Lieu avec Siret' - siret = siren + '12345' - - cy.intercept('GET', `/sirene/siret/${siret}`, (req) => - req.reply({ - statusCode: 200, - body: { - siret: siret, - name: 'Ministère de la Culture', - active: true, - address: { - street: MOCKED_BACK_ADDRESS_STREET, - postalCode: '75001', - city: 'Paris', - }, - ape_code: '90.03A', - legal_category_code: '1000', - }, - }) - ).as('getSiretVenue') - - sessionLogInAndGoToPage('Session venue', login, '/accueil') - - cy.stepLog({ message: 'I want to add a venue' }) - cy.findByText('Ajouter un lieu', { timeout: 60 * 1000 }).click() - - cy.stepLog({ message: 'I add a valid Siret' }) - cy.findByLabelText('SIRET du lieu *').type(siret + '{enter}') - cy.wait(['@getSiretVenue', '@searchAddress1']) - cy.findByTestId('error-siret').should('not.exist') - - cy.stepLog({ message: 'I add venue with Siret details' }) - cy.findByLabelText('Nom public').type(venueNameWithSiret) - cy.findByLabelText('Activité principale *').select('Festival') - cy.findByText('Moteur').click() - cy.findByText('Auditif').click() - cy.findByLabelText('Adresse email *').type('email@example.com') - - cy.stepLog({ message: 'I validate venue step' }) - cy.findByText('Enregistrer et créer le lieu').click() - cy.wait('@postVenues', { timeout: 60 * 1000 }) - .its('response.statusCode') - .should('eq', 201) - - cy.stepLog({ message: 'I skip offer creation' }) - cy.findByText('Plus tard').click() - cy.url().should('contain', 'accueil') - - cy.stepLog({ message: 'I should see my venue with Siret resume' }) - cy.reload() // newly created venue sometimes not displayed - cy.findByRole('link', { - name: 'Gérer la page de ' + venueNameWithSiret + '', - }).click() - cy.contains(venueNameWithSiret).should('be.visible') - }) - - it('As a pro user, I should be able to update a venue', () => { - const textRetrait = 'En main bien propres' - const textDesc = 'On peut ajouter des choses' - sessionLogInAndGoToPage('Session venue', login, '/accueil') - - cy.stepLog({ message: 'I go to the venue page in Individual section' }) - cy.findByText('Votre page partenaire', { - timeout: 60 * 1000, - }).scrollIntoView() - cy.findByText('Votre page partenaire').should('be.visible') - cy.findByText('Vos adresses').scrollIntoView() - cy.findByText('Vos adresses').should('be.visible') - cy.findByText('Gérer votre page pour le grand public').click() - cy.findByText('À propos de votre activité').should('be.visible') - cy.findByText('Modifier').click() - - cy.stepLog({ message: 'I update Individual section data' }) - cy.findAllByLabelText('Description').type('{selectall}{del}' + textDesc) - cy.findByText('Non accessible').click() - cy.findByText('Psychique ou cognitif').click() - cy.findByText('Auditif').click() - cy.findByText('Enregistrer').click() - cy.wait('@patchVenue') - - cy.stepLog({ message: 'Individual section data should be updated' }) - cy.url().should('include', '/structures').and('include', '/lieux') - cy.findByText('Vos informations pour le grand public').should('be.visible') - cy.findByText(textDesc).should('be.visible') - - cy.stepLog({ message: 'I go to the venue page in Paramètres généraux' }) - cy.findAllByTestId('spinner').should('not.exist') - cy.findByText('Paramètres généraux').click() - cy.url() - .should('include', '/structures') - .and('include', '/lieux') - .and('include', '/parametres') - cy.findAllByTestId('spinner').should('not.exist') - - cy.stepLog({ message: 'I update Paramètres généraux data' }) - cy.findByLabelText( - 'Label du ministère de la Culture ou du Centre national du cinéma et de l’image animée' - ).select('Musée de France') - cy.findByLabelText('Informations de retrait').type( - '{selectall}{del}' + textRetrait - ) - cy.findByText('Enregistrer').click() - cy.wait('@patchVenue') - cy.findAllByTestId('spinner').should('not.exist') - - cy.stepLog({ message: 'I go to the venue page in Paramètres généraux' }) - cy.url().should('not.include', '/parametres') - cy.findByText('Paramètres généraux').click() - cy.url().should('include', '/parametres') - cy.findAllByTestId('spinner').should('not.exist') - - cy.stepLog({ message: 'paramètres généraux data should be updated' }) - cy.findByText(textRetrait).scrollIntoView() - cy.findByText(textRetrait).should('be.visible') - - cy.findByTestId('wrapper-venueLabel').within(() => { - cy.get('select') - .invoke('val') - .then((identifiant) => { - cy.get('option[value="' + identifiant + '"]').should( - 'have.text', - 'Musée de France' - ) - }) - }) - }) -}) - -const addressInterceptionPayload = { - type: 'FeatureCollection', - version: 'draft', - features: [ - { - type: 'Feature', - geometry: { type: 'Point', coordinates: [2.337933, 48.863666] }, - properties: { - label: MOCKED_BACK_ADDRESS_LABEL, - score: 0.8136893939393939, - housenumber: '3', - id: '75101_9575_00003', - name: MOCKED_BACK_ADDRESS_STREET, - postcode: '75001', - citycode: '75101', - x: 651428.82, - y: 6862829.62, - city: 'Paris', - district: 'Paris 1er Arrondissement', - context: '75, Paris, Île-de-France', - type: 'housenumber', - importance: 0.6169, - street: 'Rue de Valois', - }, - }, - ], - attribution: 'BAN', - licence: 'ETALAB-2.0', - query: MOCKED_BACK_ADDRESS_LABEL, - limit: 1, -} diff --git a/pro/src/apiClient/v1/index.ts b/pro/src/apiClient/v1/index.ts index c7110fefd2e..6ba02237f37 100644 --- a/pro/src/apiClient/v1/index.ts +++ b/pro/src/apiClient/v1/index.ts @@ -205,7 +205,6 @@ export type { PostCollectiveOfferTemplateBodyModel } from './models/PostCollecti export type { PostDraftOfferBodyModel } from './models/PostDraftOfferBodyModel'; export type { PostOfferBodyModel } from './models/PostOfferBodyModel'; export type { PostOffererResponseModel } from './models/PostOffererResponseModel'; -export type { PostVenueBodyModel } from './models/PostVenueBodyModel'; export type { PostVenueProviderBody } from './models/PostVenueProviderBody'; export type { PriceCategoryBody } from './models/PriceCategoryBody'; export type { PriceCategoryResponseModel } from './models/PriceCategoryResponseModel'; @@ -257,7 +256,6 @@ export type { VenueListItemResponseModel } from './models/VenueListItemResponseM export type { VenueListQueryModel } from './models/VenueListQueryModel'; export type { VenueOfOffererFromSiretResponseModel } from './models/VenueOfOffererFromSiretResponseModel'; export type { VenueProviderResponse } from './models/VenueProviderResponse'; -export type { VenueResponseModel } from './models/VenueResponseModel'; export type { VenuesEducationalStatusesResponseModel } from './models/VenuesEducationalStatusesResponseModel'; export type { VenuesEducationalStatusResponseModel } from './models/VenuesEducationalStatusResponseModel'; export { VenueTypeCode } from './models/VenueTypeCode'; diff --git a/pro/src/apiClient/v1/models/PostVenueBodyModel.ts b/pro/src/apiClient/v1/models/PostVenueBodyModel.ts deleted file mode 100644 index 6729b0836c1..00000000000 --- a/pro/src/apiClient/v1/models/PostVenueBodyModel.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* generated using openapi-typescript-codegen -- do not edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { AddressBodyModel } from './AddressBodyModel'; -import type { VenueContactModel } from './VenueContactModel'; -export type PostVenueBodyModel = { - address: AddressBodyModel; - audioDisabilityCompliant?: boolean | null; - bookingEmail: string; - comment?: string | null; - contact?: VenueContactModel | null; - description?: string | null; - managingOffererId: number; - mentalDisabilityCompliant?: boolean | null; - motorDisabilityCompliant?: boolean | null; - name: string; - publicName?: string | null; - siret?: string | null; - venueLabelId?: number | null; - venueTypeCode: string; - visualDisabilityCompliant?: boolean | null; - withdrawalDetails?: string | null; -}; - diff --git a/pro/src/apiClient/v1/models/VenueResponseModel.ts b/pro/src/apiClient/v1/models/VenueResponseModel.ts deleted file mode 100644 index 7a29147ea8a..00000000000 --- a/pro/src/apiClient/v1/models/VenueResponseModel.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* generated using openapi-typescript-codegen -- do not edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export type VenueResponseModel = { - id: number; -}; - diff --git a/pro/src/apiClient/v1/services/DefaultService.ts b/pro/src/apiClient/v1/services/DefaultService.ts index 09371aaa28e..aa768dbba37 100644 --- a/pro/src/apiClient/v1/services/DefaultService.ts +++ b/pro/src/apiClient/v1/services/DefaultService.ts @@ -92,7 +92,6 @@ import type { PostCollectiveOfferTemplateBodyModel } from '../models/PostCollect import type { PostDraftOfferBodyModel } from '../models/PostDraftOfferBodyModel'; import type { PostOfferBodyModel } from '../models/PostOfferBodyModel'; import type { PostOffererResponseModel } from '../models/PostOffererResponseModel'; -import type { PostVenueBodyModel } from '../models/PostVenueBodyModel'; import type { PostVenueProviderBody } from '../models/PostVenueProviderBody'; import type { PriceCategoryBody } from '../models/PriceCategoryBody'; import type { ProFlagsQueryModel } from '../models/ProFlagsQueryModel'; @@ -120,7 +119,6 @@ import type { UserPhoneResponseModel } from '../models/UserPhoneResponseModel'; import type { UserResetEmailBodyModel } from '../models/UserResetEmailBodyModel'; import type { VenueLabelListResponseModel } from '../models/VenueLabelListResponseModel'; import type { VenueProviderResponse } from '../models/VenueProviderResponse'; -import type { VenueResponseModel } from '../models/VenueResponseModel'; import type { VenuesEducationalStatusesResponseModel } from '../models/VenuesEducationalStatusesResponseModel'; import type { VenueTypeListResponseModel } from '../models/VenueTypeListResponseModel'; import type { CancelablePromise } from '../core/CancelablePromise'; @@ -2865,26 +2863,6 @@ export class DefaultService { }, }); } - /** - * post_create_venue - * @param requestBody - * @returns VenueResponseModel Created - * @throws ApiError - */ - public postCreateVenue( - requestBody?: PostVenueBodyModel, - ): CancelablePromise { - return this.httpRequest.request({ - method: 'POST', - url: '/venues', - body: requestBody, - mediaType: 'application/json', - errors: { - 403: `Forbidden`, - 422: `Unprocessable Entity`, - }, - }); - } /** * get_venues_educational_statuses * @returns VenuesEducationalStatusesResponseModel OK From 0de7a5c4b39724362e5dadba9e59d8c4b5752eb9 Mon Sep 17 00:00:00 2001 From: jclery-pass <171674396+jclery-pass@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:16:08 +0100 Subject: [PATCH 2/4] (PC-33377)[PRO] refactor: Removes 'pages/VenueCreation' folder and moves shared components & utils where they should belong --- pro/src/app/AppRouter/routesMap.tsx | 2 +- .../commons/core/shared/utils/validation.ts | 3 - pro/src/components/Address/Address.spec.tsx | 10 +- .../Activity/ActivityForm.tsx | 2 +- .../Offerer/validationSchema.tsx | 2 +- .../CollectiveDataEdition.tsx | 3 +- .../CollectiveDmsTimeline.module.scss | 0 .../CollectiveDmsTimeline.tsx | 0 .../__specs__/CollectiveDmsTimeline.spec.tsx | 0 pro/src/pages/VenueCreation/VenueCreation.tsx | 69 ------ .../VenueCreationForm.module.scss | 5 - .../pages/VenueCreation/VenueCreationForm.tsx | 198 ------------------ .../VenueCreationFormScreen.module.scss | 33 --- .../VenueCreationFormScreen.tracker.spec.tsx | 162 -------------- .../VenueCreation/VenueCreationFormScreen.tsx | 125 ----------- .../__specs__/VenueCreation.spec.tsx | 98 --------- .../shouldBlockVenueNavigation.spec.ts | 62 ------ pro/src/pages/VenueCreation/constants.ts | 31 --- pro/src/pages/VenueCreation/serializers.ts | 46 ---- pro/src/pages/VenueCreation/types.ts | 22 -- .../pages/VenueCreation/validationSchema.ts | 34 --- .../Accessibility/Accessibility.module.scss | 0 .../Accessibility/Accessibility.tsx | 7 +- .../__specs__/Accessibility.spec.tsx | 6 +- .../pages/VenueEdition/VenueEditionForm.tsx | 6 +- .../VenueFormActionBar.module.scss | 0 .../VenueFormActionBar/VenueFormActionBar.tsx | 7 +- .../__specs__/VenueFormActionBar.spec.tsx | 0 .../buildVenueTypesOptions.ts | 0 pro/src/pages/VenueEdition/constants.ts | 7 + .../VenueEdition/setInitialFormValues.ts | 4 +- .../SiretOrCommentFields.tsx | 5 +- .../__specs__/SiretOrCommentFields.spec.tsx | 7 +- .../SiretOrCommentFields/validationSchema.ts | 0 .../pages/VenueSettings/VenueSettingsForm.tsx | 10 +- .../VenueSettings/VenueSettingsScreen.tsx | 2 +- .../WithdrawalDetails/WithdrawalDetails.tsx | 0 37 files changed, 44 insertions(+), 924 deletions(-) rename pro/src/pages/{VenueCreation => Offerers/Offerer/VenueV1/VenueEdition}/CollectiveDmsTimeline/CollectiveDmsTimeline.module.scss (100%) rename pro/src/pages/{VenueCreation => Offerers/Offerer/VenueV1/VenueEdition}/CollectiveDmsTimeline/CollectiveDmsTimeline.tsx (100%) rename pro/src/pages/{VenueCreation => Offerers/Offerer/VenueV1/VenueEdition}/CollectiveDmsTimeline/__specs__/CollectiveDmsTimeline.spec.tsx (100%) delete mode 100644 pro/src/pages/VenueCreation/VenueCreation.tsx delete mode 100644 pro/src/pages/VenueCreation/VenueCreationForm.module.scss delete mode 100644 pro/src/pages/VenueCreation/VenueCreationForm.tsx delete mode 100644 pro/src/pages/VenueCreation/VenueCreationFormScreen.module.scss delete mode 100644 pro/src/pages/VenueCreation/VenueCreationFormScreen.tracker.spec.tsx delete mode 100644 pro/src/pages/VenueCreation/VenueCreationFormScreen.tsx delete mode 100644 pro/src/pages/VenueCreation/__specs__/VenueCreation.spec.tsx delete mode 100644 pro/src/pages/VenueCreation/__specs__/shouldBlockVenueNavigation.spec.ts delete mode 100644 pro/src/pages/VenueCreation/constants.ts delete mode 100644 pro/src/pages/VenueCreation/serializers.ts delete mode 100644 pro/src/pages/VenueCreation/types.ts delete mode 100644 pro/src/pages/VenueCreation/validationSchema.ts rename pro/src/pages/{VenueCreation => VenueEdition}/Accessibility/Accessibility.module.scss (100%) rename pro/src/pages/{VenueCreation => VenueEdition}/Accessibility/Accessibility.tsx (92%) rename pro/src/pages/{VenueCreation => VenueEdition}/Accessibility/__specs__/Accessibility.spec.tsx (97%) rename pro/src/pages/{VenueCreation => VenueEdition}/VenueFormActionBar/VenueFormActionBar.module.scss (100%) rename pro/src/pages/{VenueCreation => VenueEdition}/VenueFormActionBar/VenueFormActionBar.tsx (78%) rename pro/src/pages/{VenueCreation => VenueEdition}/VenueFormActionBar/__specs__/VenueFormActionBar.spec.tsx (100%) rename pro/src/pages/{VenueCreation => VenueEdition}/buildVenueTypesOptions.ts (100%) create mode 100644 pro/src/pages/VenueEdition/constants.ts rename pro/src/pages/{VenueCreation => VenueSettings}/SiretOrCommentFields/SiretOrCommentFields.tsx (97%) rename pro/src/pages/{VenueCreation => VenueSettings}/SiretOrCommentFields/__specs__/SiretOrCommentFields.spec.tsx (97%) rename pro/src/pages/{VenueCreation => VenueSettings}/SiretOrCommentFields/validationSchema.ts (100%) rename pro/src/pages/{VenueCreation => VenueSettings}/WithdrawalDetails/WithdrawalDetails.tsx (100%) diff --git a/pro/src/app/AppRouter/routesMap.tsx b/pro/src/app/AppRouter/routesMap.tsx index ab4b7fd0073..b47bf5f6cac 100644 --- a/pro/src/app/AppRouter/routesMap.tsx +++ b/pro/src/app/AppRouter/routesMap.tsx @@ -99,7 +99,7 @@ export const routes: RouteConfig[] = [ title: 'Détails de la structure', }, { - lazy: () => import('pages/VenueCreation/VenueCreation'), + element: , path: '/structures/:offererId/lieux/creation', title: 'Créer un lieu', }, diff --git a/pro/src/commons/core/shared/utils/validation.ts b/pro/src/commons/core/shared/utils/validation.ts index 41afa6d46f6..82c3a62e6af 100644 --- a/pro/src/commons/core/shared/utils/validation.ts +++ b/pro/src/commons/core/shared/utils/validation.ts @@ -4,9 +4,6 @@ import { SelectOption } from 'commons/custom_types/form' import { parseAndValidateFrenchPhoneNumber } from './parseAndValidateFrenchPhoneNumber' -export const isOneTrue = (values: Record): boolean => - Object.values(values).includes(true) - export const isPhoneValid = (phone: string | undefined): boolean => { if (!phone) { return false diff --git a/pro/src/components/Address/Address.spec.tsx b/pro/src/components/Address/Address.spec.tsx index f02198dfaf3..2920ce54e3b 100644 --- a/pro/src/components/Address/Address.spec.tsx +++ b/pro/src/components/Address/Address.spec.tsx @@ -4,7 +4,7 @@ import { Form, Formik } from 'formik' import * as yup from 'yup' import { apiAdresse } from 'apiClient/adresse/apiAdresse' -import { VenueCreationFormValues } from 'pages/VenueCreation/types' +import { VenueSettingsFormValues } from 'pages/VenueSettings/types' import { Button } from 'ui-kit/Button/Button' import { AddressSelect } from './Address' @@ -44,7 +44,7 @@ const renderAddress = ({ initialValues, onSubmit = vi.fn(), }: { - initialValues: Partial + initialValues: Partial onSubmit: () => void }) => { const validationSchema = yup.object().shape(addressValidationSchema) @@ -74,7 +74,7 @@ const renderAddress = ({ } describe('AddressSelect', () => { - let initialValues: Partial + let initialValues: Partial const onSubmit = vi.fn() beforeEach(() => { @@ -83,8 +83,8 @@ describe('AddressSelect', () => { 'search-addressAutocomplete': '', city: '', postalCode: '', - latitude: 0, - longitude: 0, + latitude: '', + longitude: '', street: '', } vi.spyOn(apiAdresse, 'getDataFromAddress').mockResolvedValue(mockAdressData) diff --git a/pro/src/components/SignupJourneyForm/Activity/ActivityForm.tsx b/pro/src/components/SignupJourneyForm/Activity/ActivityForm.tsx index c27d22f6672..da92b9a6922 100644 --- a/pro/src/components/SignupJourneyForm/Activity/ActivityForm.tsx +++ b/pro/src/components/SignupJourneyForm/Activity/ActivityForm.tsx @@ -5,7 +5,7 @@ import { VenueTypeResponseModel } from 'apiClient/v1' import { FormLayout } from 'components/FormLayout/FormLayout' import fullMoreIcon from 'icons/full-more.svg' import fullTrashIcon from 'icons/full-trash.svg' -import { buildVenueTypesOptions } from 'pages/VenueCreation/buildVenueTypesOptions' +import { buildVenueTypesOptions } from 'pages/VenueEdition/buildVenueTypesOptions' import { Button } from 'ui-kit/Button/Button' import { ButtonVariant } from 'ui-kit/Button/types' import { CheckboxGroup } from 'ui-kit/form/CheckboxGroup/CheckboxGroup' diff --git a/pro/src/components/SignupJourneyForm/Offerer/validationSchema.tsx b/pro/src/components/SignupJourneyForm/Offerer/validationSchema.tsx index 29abda48216..457cdef40e2 100644 --- a/pro/src/components/SignupJourneyForm/Offerer/validationSchema.tsx +++ b/pro/src/components/SignupJourneyForm/Offerer/validationSchema.tsx @@ -1,6 +1,6 @@ import * as yup from 'yup' -import { valideSiretLength } from 'pages/VenueCreation/SiretOrCommentFields/validationSchema' +import { valideSiretLength } from 'pages/VenueSettings/SiretOrCommentFields/validationSchema' export const validationSchema = yup.object().shape({ siret: yup diff --git a/pro/src/pages/Offerers/Offerer/VenueV1/VenueEdition/CollectiveDataEdition/CollectiveDataEdition.tsx b/pro/src/pages/Offerers/Offerer/VenueV1/VenueEdition/CollectiveDataEdition/CollectiveDataEdition.tsx index 01922eff761..c00aca1e709 100644 --- a/pro/src/pages/Offerers/Offerer/VenueV1/VenueEdition/CollectiveDataEdition/CollectiveDataEdition.tsx +++ b/pro/src/pages/Offerers/Offerer/VenueV1/VenueEdition/CollectiveDataEdition/CollectiveDataEdition.tsx @@ -12,10 +12,11 @@ import { import { SelectOption } from 'commons/custom_types/form' import { getLastCollectiveDmsApplication } from 'commons/utils/getLastCollectiveDmsApplication' import { PartnerPageCollectiveSection } from 'pages/Homepage/components/Offerers/components/PartnerPages/components/PartnerPageCollectiveSection' -import { CollectiveDmsTimeline } from 'pages/VenueCreation/CollectiveDmsTimeline/CollectiveDmsTimeline' import { Callout } from 'ui-kit/Callout/Callout' import { Spinner } from 'ui-kit/Spinner/Spinner' +import { CollectiveDmsTimeline } from '../CollectiveDmsTimeline/CollectiveDmsTimeline' + import styles from './CollectiveDataEdition.module.scss' import { CollectiveDataEditionReadOnly } from './CollectiveDataEditionReadOnly' import { CollectiveDataForm } from './CollectiveDataForm/CollectiveDataForm' diff --git a/pro/src/pages/VenueCreation/CollectiveDmsTimeline/CollectiveDmsTimeline.module.scss b/pro/src/pages/Offerers/Offerer/VenueV1/VenueEdition/CollectiveDmsTimeline/CollectiveDmsTimeline.module.scss similarity index 100% rename from pro/src/pages/VenueCreation/CollectiveDmsTimeline/CollectiveDmsTimeline.module.scss rename to pro/src/pages/Offerers/Offerer/VenueV1/VenueEdition/CollectiveDmsTimeline/CollectiveDmsTimeline.module.scss diff --git a/pro/src/pages/VenueCreation/CollectiveDmsTimeline/CollectiveDmsTimeline.tsx b/pro/src/pages/Offerers/Offerer/VenueV1/VenueEdition/CollectiveDmsTimeline/CollectiveDmsTimeline.tsx similarity index 100% rename from pro/src/pages/VenueCreation/CollectiveDmsTimeline/CollectiveDmsTimeline.tsx rename to pro/src/pages/Offerers/Offerer/VenueV1/VenueEdition/CollectiveDmsTimeline/CollectiveDmsTimeline.tsx diff --git a/pro/src/pages/VenueCreation/CollectiveDmsTimeline/__specs__/CollectiveDmsTimeline.spec.tsx b/pro/src/pages/Offerers/Offerer/VenueV1/VenueEdition/CollectiveDmsTimeline/__specs__/CollectiveDmsTimeline.spec.tsx similarity index 100% rename from pro/src/pages/VenueCreation/CollectiveDmsTimeline/__specs__/CollectiveDmsTimeline.spec.tsx rename to pro/src/pages/Offerers/Offerer/VenueV1/VenueEdition/CollectiveDmsTimeline/__specs__/CollectiveDmsTimeline.spec.tsx diff --git a/pro/src/pages/VenueCreation/VenueCreation.tsx b/pro/src/pages/VenueCreation/VenueCreation.tsx deleted file mode 100644 index 61d40bf3f02..00000000000 --- a/pro/src/pages/VenueCreation/VenueCreation.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import { useSelector } from 'react-redux' -import { useNavigate, useParams } from 'react-router-dom' -import useSWR from 'swr' - -import { api } from 'apiClient/api' -import { Layout } from 'app/App/layout/Layout' -import { - GET_OFFERER_QUERY_KEY, - GET_VENUE_TYPES_QUERY_KEY, -} from 'commons/config/swrQueryKeys' -import { selectCurrentOffererId } from 'commons/store/offerer/selectors' -import { DEFAULT_FORM_VALUES } from 'pages/VenueCreation/constants' -import { Spinner } from 'ui-kit/Spinner/Spinner' - -import { VenueCreationFormScreen } from './VenueCreationFormScreen' - -export const VenueCreation = (): JSX.Element | null => { - const navigate = useNavigate() - const { offererId } = useParams<{ offererId: string }>() - const selectedOffererId = useSelector(selectCurrentOffererId) - if (selectedOffererId && selectedOffererId.toString() !== offererId) { - // Prevents the following error - // Cannot update a component (`RouterProvider`) while rendering a different component (`VenueCreation`). - // As this is a temporary thing, it should be ok to keep until the beta is done - setTimeout(() => { - navigate(`/structures/${selectedOffererId}/lieux/creation`) - }) - } - - const initialValues = { ...DEFAULT_FORM_VALUES } - - const offererQuery = useSWR( - [GET_OFFERER_QUERY_KEY, offererId], - ([, offererIdParam]) => api.getOfferer(Number(offererIdParam)) - ) - const offerer = offererQuery.data - - const venueTypesQuery = useSWR([GET_VENUE_TYPES_QUERY_KEY], () => - api.getVenueTypes() - ) - const venueTypes = venueTypesQuery.data - - if ( - offererQuery.isLoading || - venueTypesQuery.isLoading || - !offerer || - !venueTypes - ) { - return ( - - - - ) - } - - return ( - - - - ) -} - -// Lazy-loaded by react-router-dom -// ts-unused-exports:disable-next-line -export const Component = VenueCreation diff --git a/pro/src/pages/VenueCreation/VenueCreationForm.module.scss b/pro/src/pages/VenueCreation/VenueCreationForm.module.scss deleted file mode 100644 index 323861c6f7c..00000000000 --- a/pro/src/pages/VenueCreation/VenueCreationForm.module.scss +++ /dev/null @@ -1,5 +0,0 @@ -@use "styles/mixins/_rem.scss" as rem; - -.eac-description-info { - margin: rem.torem(16px) 0 rem.torem(24px) 0; -} diff --git a/pro/src/pages/VenueCreation/VenueCreationForm.tsx b/pro/src/pages/VenueCreation/VenueCreationForm.tsx deleted file mode 100644 index eedb58a6312..00000000000 --- a/pro/src/pages/VenueCreation/VenueCreationForm.tsx +++ /dev/null @@ -1,198 +0,0 @@ -import { useFormikContext } from 'formik' -import { useState } from 'react' -import { useSelector } from 'react-redux' - -import { GetOffererResponseModel, VenueTypeResponseModel } from 'apiClient/v1' -import { selectCurrentOffererId } from 'commons/store/offerer/selectors' -import { ActionsBarSticky } from 'components/ActionsBarSticky/ActionsBarSticky' -import { AddressSelect } from 'components/Address/Address' -import { FormLayout } from 'components/FormLayout/FormLayout' -import { - BlockerFunction, - RouteLeavingGuard, -} from 'components/RouteLeavingGuard/RouteLeavingGuard' -import { ScrollToFirstErrorAfterSubmit } from 'components/ScrollToFirstErrorAfterSubmit/ScrollToFirstErrorAfterSubmit' -import { Button } from 'ui-kit/Button/Button' -import { ButtonLink } from 'ui-kit/Button/ButtonLink' -import { ButtonVariant } from 'ui-kit/Button/types' -import { Callout } from 'ui-kit/Callout/Callout' -import { CalloutVariant } from 'ui-kit/Callout/types' -import { Select } from 'ui-kit/form/Select/Select' -import { TextInput } from 'ui-kit/form/TextInput/TextInput' -import { InfoBox } from 'ui-kit/InfoBox/InfoBox' - -import { Accessibility } from './Accessibility/Accessibility' -import { buildVenueTypesOptions } from './buildVenueTypesOptions' -import { SiretOrCommentFields } from './SiretOrCommentFields/SiretOrCommentFields' -import { VenueCreationFormValues } from './types' -import styles from './VenueCreationForm.module.scss' - -type VenueFormProps = { - offerer: GetOffererResponseModel - updateIsSiretValued: (isSiretValued: boolean) => void - venueTypes: VenueTypeResponseModel[] - isSiretValued: boolean -} - -type ShouldBlockVenueNavigationProps = { - offererId: number - selectedOffererId: number | null -} - -type ShouldBlockVenueNavigation = ( - p: ShouldBlockVenueNavigationProps -) => BlockerFunction - -export const shouldBlockVenueNavigation: ShouldBlockVenueNavigation = - ({ - offererId, - selectedOffererId, - }: ShouldBlockVenueNavigationProps): BlockerFunction => - ({ nextLocation }) => { - const url = '/accueil?success' - const nextUrl = nextLocation.pathname + nextLocation.search - - return selectedOffererId === offererId && !nextUrl.startsWith(url) - } - -export const VenueCreationForm = ({ - offerer, - updateIsSiretValued, - venueTypes, - isSiretValued, -}: VenueFormProps) => { - const { initialValues, isSubmitting } = - useFormikContext() - const selectedOffererId = useSelector(selectCurrentOffererId) - - const [isFieldNameFrozen, setIsFieldNameFrozen] = useState(false) - const canOffererCreateCollectiveOffer = offerer.allowedOnAdage - const venueTypesOptions = buildVenueTypesOptions(venueTypes) - - return ( -
- - - - - - - - - - - - - - - À remplir si différent de la raison sociale. En le remplissant, - c’est ce dernier qui sera visible du public. - - } - > - - - - - - - - - - -