Skip to content
This repository has been archived by the owner on Mar 10, 2022. It is now read-only.

Commit

Permalink
[PC-11478] VenueEdition: add virtual venue page
Browse files Browse the repository at this point in the history
  This page is accessible with the feature flag: "ENFORCE_BANK_INFORMATION_WITH_SIRET"
  • Loading branch information
rlecellier committed Nov 9, 2021
1 parent 081d05d commit 36500a3
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 100 deletions.
7 changes: 4 additions & 3 deletions src/components/pages/Home/Venues/Venue.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* @debt directory "Gaël: this file should be migrated within the new directory structure"
*/
* @debt directory "Gaël: this file should be migrated within the new directory structure"
*/

import * as PropTypes from 'prop-types'
import React, { Fragment } from 'react'
Expand Down Expand Up @@ -55,6 +55,7 @@ const Venue = ({ id, isVirtual, name, offererId, publicName, venueStats }) => {
]

const isVenueV2Enabled = useActiveFeature('ENABLE_NEW_VENUE_PAGES')
const isBankInformationWithSiretActive = useActiveFeature('ENFORCE_BANK_INFORMATION_WITH_SIRET')

const showVenueLink = `/structures/${offererId}/lieux/${id}`
let editVenueLink = `/structures/${offererId}/lieux/${id}`
Expand Down Expand Up @@ -85,7 +86,7 @@ const Venue = ({ id, isVirtual, name, offererId, publicName, venueStats }) => {
</span>
</Link>
</h3>
{!isVirtual && (
{(!isVirtual || isBankInformationWithSiretActive) && (
<Link
className="tertiary-link"
to={editVenueLink}
Expand Down
9 changes: 5 additions & 4 deletions src/components/pages/Home/Venues/VenueLegacy.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* @debt directory "Gaël: this file should be migrated within the new directory structure"
*/
* @debt directory "Gaël: this file should be migrated within the new directory structure"
*/

import * as PropTypes from 'prop-types'
import React, { Fragment, useEffect, useState } from 'react'
Expand Down Expand Up @@ -68,6 +68,7 @@ const Venue = ({ id, isVirtual, name, offererId, publicName }) => {
]

const isVenueV2Enabled = useActiveFeature('ENABLE_NEW_VENUE_PAGES')
const isBankInformationWithSiretActive = useActiveFeature('ENFORCE_BANK_INFORMATION_WITH_SIRET')

useEffect(() => {
if (isStatOpen && !isStatLoaded) {
Expand Down Expand Up @@ -96,7 +97,7 @@ const Venue = ({ id, isVirtual, name, offererId, publicName }) => {
}, [offererId])

let editVenueLink = `/structures/${offererId}/lieux/${id}`

if (!isVenueV2Enabled) {
editVenueLink += '?modification'
}
Expand Down Expand Up @@ -141,7 +142,7 @@ const Venue = ({ id, isVirtual, name, offererId, publicName }) => {
</>
)}
</button>
{!isVirtual && (
{(!isVirtual || isBankInformationWithSiretActive) && (
<>
<span className="button-group-separator" />
<Link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Form } from 'react-final-form'
import { getCanSubmit, parseSubmitErrors } from 'react-final-form-utils'
import { Link, NavLink } from 'react-router-dom'

import useActiveFeature from 'components/hooks/useActiveFeature'
import Icon from 'components/layout/Icon'
import PageTitle from 'components/layout/PageTitle/PageTitle'
import Titles from 'components/layout/Titles/Titles'
Expand Down Expand Up @@ -54,9 +55,13 @@ const VenueEdition = ({
}) => {
const [isRequestPending, setIsRequestPending] = useState(false)

const isBankInformationWithSiretActive = useActiveFeature('ENFORCE_BANK_INFORMATION_WITH_SIRET')

// TODO check that it's execute only once when initialize
useEffect(() => handleInitialRequest(), [handleInitialRequest])

const pageNotFoundRedirect = () => history.push('/404')

const handleFormFail = formResolver => (_state, action) => {
const { payload } = action
const errors = parseSubmitErrors(payload.errors)
Expand Down Expand Up @@ -96,7 +101,7 @@ const VenueEdition = ({
const { readOnly } = query.context({
id: venueId,
})
const { siret: initialSiret, withdrawalDetails: initialWithdrawalDetails } = venue || {}
const { siret: initialSiret, isVirtual: initialIsVirtual, withdrawalDetails: initialWithdrawalDetails } = venue || {}
const canSubmit = getCanSubmit(formProps)
const { form, handleSubmit, values } = formProps
const {
Expand Down Expand Up @@ -124,13 +129,14 @@ const VenueEdition = ({
formSiret={formSiret}
initialSiret={initialSiret}
isDirtyFieldBookingEmail={isDirtyFieldBookingEmail}
readOnly={readOnly}
readOnly={readOnly || initialIsVirtual}
venueIsVirtual={initialIsVirtual}
venueLabelId={venueLabelId}
venueLabels={venueLabels}
venueTypeId={venueTypeId}
venueTypes={venueTypes}
/>
{withdrawalDetailActive && (
{withdrawalDetailActive && !initialIsVirtual && (
<WithdrawalDetailsFields
initialWithdrawalDetails={initialWithdrawalDetails}
readOnly={readOnly}
Expand All @@ -139,21 +145,25 @@ const VenueEdition = ({
<BankInformation
offerer={offerer}
venue={venue}
/>
<LocationFields
fieldReadOnlyBecauseFrozenFormSiret={fieldReadOnlyBecauseFrozenFormSiret}
form={form}
formIsLocationFrozen={formIsLocationFrozen}
formLatitude={formLatitude === '' ? FRANCE_POSITION.latitude : formLatitude}
formLongitude={formLongitude === '' ? FRANCE_POSITION.longitude : formLongitude}
readOnly={readOnly}
/>
<AccessibilityFields
formValues={values}
readOnly={readOnly}
venue={venue}
/>
<ContactInfosFields readOnly={readOnly} />
/>
{!initialIsVirtual && (
<>
<LocationFields
fieldReadOnlyBecauseFrozenFormSiret={fieldReadOnlyBecauseFrozenFormSiret}
form={form}
formIsLocationFrozen={formIsLocationFrozen}
formLatitude={formLatitude === '' ? FRANCE_POSITION.latitude : formLatitude}
formLongitude={formLongitude === '' ? FRANCE_POSITION.longitude : formLongitude}
readOnly={readOnly}
/>
<AccessibilityFields
formValues={values}
readOnly={readOnly}
venue={venue}
/>
<ContactInfosFields readOnly={readOnly} />
</>
)}
<hr />
<div
className="field is-grouped is-grouped-centered"
Expand Down Expand Up @@ -232,6 +242,11 @@ const VenueEdition = ({
</Link>
)

if (initialIsVirtual && !isBankInformationWithSiretActive) {
pageNotFoundRedirect()
return null
}

return (
<div className="venue-page">
<NavLink
Expand All @@ -247,12 +262,8 @@ const VenueEdition = ({
subtitle={initialName}
title="Lieu"
/>
{!initialIsVirtual && (
<>
{venue && <VenueProvidersManager venue={venue} />}
{venue && offerer && renderForm()}
</>
)}
{venue && !initialIsVirtual && <VenueProvidersManager venue={venue} />}
{venue && offerer && renderForm()}
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class IdentifierFields extends PureComponent {
isCreatedEntity,
isDirtyFieldBookingEmail,
readOnly,
venueIsVirtual,
venueLabels,
venueLabelId,
venueTypes,
Expand Down Expand Up @@ -139,27 +140,31 @@ class IdentifierFields extends PureComponent {
</h2>
<div className="field-group">
{isCreatedEntity && <HiddenField name="managingOffererId" />}
<TextField
format={formatSiret}
label={siretLabel}
name="siret"
parse={parseSiret}
readOnly={readOnly || initialSiret !== null}
renderValue={this.handleRenderValue(fieldReadOnlyBecauseFrozenFormSiret, readOnly)}
type="siret"
validate={initialSiret ? undefined : siretValidate}
/>
{!venueIsVirtual &&
<TextField
format={formatSiret}
label={siretLabel}
name="siret"
parse={parseSiret}
readOnly={readOnly || initialSiret !== null}
renderValue={this.handleRenderValue(fieldReadOnlyBecauseFrozenFormSiret, readOnly)}
type="siret"
validate={initialSiret ? undefined : siretValidate}
/>
}
<TextField
label="Nom du lieu : "
name="name"
readOnly={readOnly || fieldReadOnlyBecauseFrozenFormSiret}
required
/>
<TextField
label="Nom d’usage du lieu : "
name="publicName"
readOnly={readOnly}
/>
{!venueIsVirtual &&
<TextField
label="Nom d’usage du lieu : "
name="publicName"
readOnly={readOnly}
/>
}
<TextField
label="E-mail : "
name="bookingEmail"
Expand All @@ -178,13 +183,15 @@ class IdentifierFields extends PureComponent {
/>
)}

<TextareaField
label="Commentaire (si pas de SIRET) : "
name="comment"
readOnly={readOnly}
rows={1}
validate={this.commentValidate}
/>
{!venueIsVirtual &&
<TextareaField
label="Commentaire (si pas de SIRET) : "
name="comment"
readOnly={readOnly}
rows={1}
validate={this.commentValidate}
/>
}
<div
className={classnames('field field-select is-label-aligned', {
readonly: readOnly,
Expand All @@ -207,7 +214,7 @@ class IdentifierFields extends PureComponent {
id="venue-type"
>
<span>
{venueTypeLabel}
{venueIsVirtual ? 'Offre numérique' : venueTypeLabel}
</span>
</div>
) : (
Expand Down Expand Up @@ -239,59 +246,63 @@ class IdentifierFields extends PureComponent {
)}
</div>
</div>
<div
className={classnames('field field-select is-label-aligned', {
readonly: readOnly,
})}
>
<div className="field-label">
<label htmlFor="venue-label">
Label du Ministère de la Culture ou du CNC
</label>
</div>
{!venueIsVirtual && (
<div
className={classnames('field field-select is-label-aligned', {
readonly: readOnly,
})}
>
<div className="field-label">
<label htmlFor="venue-label">
Label du Ministère de la Culture ou du CNC
</label>
</div>

<div className="field-control">
{readOnly ? (
<div
className="venue-label-label"
id="venue-label"
>
<span>
{venueLabelText}
</span>
</div>
) : (
<div className="control control-select">
<div className="field-control">
{readOnly ? (
<div
className="select"
className="venue-label-label"
id="venue-label"
>
<Field
component="select"
id="venue-label"
name="venueLabelId"
<span>
{venueLabelText}
</span>
</div>
) : (
<div className="control control-select">
<div
className="select"
>
<option value="">
Si votre lieu est labellisé précisez-le en le sélectionnant dans la liste
</option>
{venueLabels.map(venueLabel => (
<option
key={`venue-label-${venueLabel.id}`}
value={venueLabel.id}
>
{venueLabel.label}
<Field
component="select"
id="venue-label"
name="venueLabelId"
>
<option value="">
Si votre lieu est labellisé précisez-le en le sélectionnant dans la liste
</option>
))}
</Field>
{venueLabels.map(venueLabel => (
<option
key={`venue-label-${venueLabel.id}`}
value={venueLabel.id}
>
{venueLabel.label}
</option>
))}
</Field>
</div>
</div>
</div>
)}
)}
</div>
</div>
</div>
<TextareaField
label="Description : "
name="description"
readOnly={readOnly}
/>
)}
{!venueIsVirtual &&
<TextareaField
label="Description : "
name="description"
readOnly={readOnly}
/>
}
</div>
</div>
)
Expand All @@ -305,6 +316,7 @@ IdentifierFields.defaultProps = {
isCreatedEntity: false,
isDirtyFieldBookingEmail: false,
readOnly: true,
venueIsVirtual: false,
venueLabelId: null,
venueTypeId: null,
}
Expand All @@ -316,6 +328,7 @@ IdentifierFields.propTypes = {
isCreatedEntity: PropTypes.bool,
isDirtyFieldBookingEmail: PropTypes.bool,
readOnly: PropTypes.bool,
venueIsVirtual: PropTypes.bool,
venueLabelId: PropTypes.string,
venueLabels: PropTypes.arrayOf(PropTypes.instanceOf(VenueLabel)).isRequired,
venueTypeId: PropTypes.string,
Expand Down

0 comments on commit 36500a3

Please sign in to comment.