-
Notifications
You must be signed in to change notification settings - Fork 38
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
base: pcharlet/pc-31878-patch-offer-extra-data
Are you sure you want to change the base?
Conversation
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 |
f4cbedc
to
f54d9bb
Compare
@@ -79,9 +79,9 @@ export const buildShowSubTypeOptions = (showType: string): SelectOption[] => { | |||
export const completeSubcategoryConditionalFields = ( |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
f998e1e
to
3446bdd
Compare
f54d9bb
to
069011e
Compare
let response | ||
if (!offer) { | ||
response = await api.postDraftOffer(serializeDetailsPostData(formValues)) | ||
} else if (shouldPatchData && !!offer.lastProvider) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 = ( |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
069011e
to
c8cb606
Compare
There was a problem hiding this 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
But de la pull request
Ticket Jira (ou description si BSR) : https://passculture.atlassian.net/browse/PC-31965
Vérifications