Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PC-31965)[API]fix: Le patch n'est pas fait sur la 1ère étape du formulaire de mise à jour d'offre si produit #14254

Open
wants to merge 1 commit into
base: pcharlet/pc-31878-patch-offer-extra-data
Choose a base branch
from

Conversation

pcharlet-pass
Copy link
Contributor

But de la pull request

Ticket Jira (ou description si BSR) : https://passculture.atlassian.net/browse/PC-31965

Vérifications

  • J'ai écrit les tests nécessaires
  • J'ai mis à jour le fichier des plans de tests du portail pro si nécessaire
  • J'ai mis à jour la liste des routes et des titres de pages du portail pro si j'en ai rajouté/modifié ou supprimé une.
  • J'ai relu attentivement les migrations, en particulier pour éviter les locks, et je préviens les équipes Shérif et Data
  • J'ai ajouté des screenshots pour d'éventuels changements graphiques

Copy link
Contributor

github-actions bot commented Sep 20, 2024

Visit the preview URL for this PR (updated for commit c8cb606):

https://pc-pro-testing--pr14254-pcharlet-pc-31965-no-763dpz8l.web.app

(expires Sun, 22 Sep 2024 13:57:52 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 032d233ee67e1c50d6af12e29c936c7076770eb1

@pcharlet-pass pcharlet-pass force-pushed the pcharlet/pc-31965-no-extra-data-if-offer-with-product branch from f4cbedc to f54d9bb Compare September 20, 2024 10:17
@@ -79,9 +79,9 @@ export const buildShowSubTypeOptions = (showType: string): SelectOption[] => {
export const completeSubcategoryConditionalFields = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attention pas mal de soucis d'indentation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oui, faut faire tourner le lint/prettier et repousser.

@@ -111,6 +113,8 @@ export const InformationsScreen = ({
isPhysicalEvent
)

console.log('initialValues', initialValues)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

à enlever

@@ -141,6 +145,7 @@ export const InformationsScreen = ({

// Submit
try {
const shouldNotSendExtraData = isSearchByEanEnabled && !!offer?.productId
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peut être que le test pour savoir si c'est un produit n'est pas complet.
J'ai vu passer ce bout de code dans ./pro/src/screens/IndividualOffer/DetailsScreen/DetailsScreen.tsx

/ (Draft) offers are created via POST request.
  // On Details screen, the form might be pre-filled with a product,
  // until the form is submitted, the draft offer is not created yet.
  const isOfferProductBased = !!offer?.productId
  const isNotAnOfferYetButProductBased = !offer && !!formik.values.productId
  const isProductBased = isOfferProductBased || isNotAnOfferYetButProductBased

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ces modifications ne concernent que le patch, donc que lorsque offer est défini : c'est véritablement isOfferProductBased qui nous intéresse.
Par contre ce qui peut être challengé c'est d'avoir une fonction dans utils pour partager ces définitions isOfferProductBased/isNotAnOfferYetButProductBased.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il me semble que le cas décrit dans ./pro/src/screens/IndividualOffer/DetailsScreen/DetailsScreen.tsx est spécifique à cette étape. Dans les autres, aucun champ front ne permet de spécifier le produit. L'offre ne peut donc avoir l'attribut productId différent de null que si c'est réellement le cas en DB. Je pense que le test est suffisant. @asaez-pass ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est qu'en contexte de création d'offre - étape 1 et avant le POST que la condition isNotAnOfferYetButProductBased a du sens. Arrivé à l'étape 2, on se base sur l'offre (en draft) enregistré en base. Par contre j'ai un doute sur le distingo UsefulInformationScreen (nouveau parcours avec SPLIT) / InformationsScreen (ancien parcours). Il faudrait tester que tout soit ok sans le flag FF_SPLIT_OFFER.

@ogeber ogeber changed the base branch from master to pcharlet/pc-31878-patch-offer-extra-data September 20, 2024 12:29
@pcharlet-pass pcharlet-pass force-pushed the pcharlet/pc-31878-patch-offer-extra-data branch from f998e1e to 3446bdd Compare September 20, 2024 12:49
@pcharlet-pass pcharlet-pass force-pushed the pcharlet/pc-31965-no-extra-data-if-offer-with-product branch from f54d9bb to 069011e Compare September 20, 2024 13:31
let response
if (!offer) {
response = await api.postDraftOffer(serializeDetailsPostData(formValues))
} else if (shouldPatchData && !!offer.lastProvider) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je pense qu'on peut réécrire :

const shouldNotPatchData = isProviderOffer || (!isSearchByEnabled && !!offer?.productId)
Et ici : (!shouldNotPatchData), pour plus de clarté.

Sinon
const shouldPatchData = !isProviderOffer && (isSearchByEnabled || !offer?.productId)
Et ici : (shouldPatchData)

Si const isProviderOffer = !!offer.lastProvider, et dans la mesure où offer.lastProvider n'est jamais un objet vide.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also je pense qu'un commentaire type : / / Draft offer PATCH requests are useless for product-based offers and synchronized / provider offers since neither of the inputs displayed in DetailsScreen can be edited at all.

@@ -120,13 +121,17 @@ export const UsefulInformationScreen = ({
}
}

console.log('formValues', formValues)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log oublié ici.

@@ -79,9 +79,9 @@ export const buildShowSubTypeOptions = (showType: string): SelectOption[] => {
export const completeSubcategoryConditionalFields = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oui, faut faire tourner le lint/prettier et repousser.

@@ -141,6 +145,7 @@ export const InformationsScreen = ({

// Submit
try {
const shouldNotSendExtraData = isSearchByEanEnabled && !!offer?.productId
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ces modifications ne concernent que le patch, donc que lorsque offer est défini : c'est véritablement isOfferProductBased qui nous intéresse.
Par contre ce qui peut être challengé c'est d'avoir une fonction dans utils pour partager ces définitions isOfferProductBased/isNotAnOfferYetButProductBased.

…not product base and FF WIP_EAN_CREATION id disabled
@pcharlet-pass pcharlet-pass force-pushed the pcharlet/pc-31965-no-extra-data-if-offer-with-product branch from 069011e to c8cb606 Compare September 20, 2024 13:45
Copy link
Contributor

@ogeber ogeber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok pour le back

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants