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

allow backorder #4051

Merged
merged 8 commits into from
May 16, 2023
Merged

allow backorder #4051

merged 8 commits into from
May 16, 2023

Conversation

pKorsholm
Copy link
Contributor

What

  • Fix allow_backorder issue

How

  • add property outside removeNullish

@pKorsholm pKorsholm requested a review from a team as a code owner May 9, 2023 11:05
@vercel
Copy link

vercel bot commented May 9, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
medusa-docs ⬜️ Ignored (Inspect) Visit Preview May 16, 2023 1:36pm

@changeset-bot
Copy link

changeset-bot bot commented May 9, 2023

🦋 Changeset detected

Latest commit: eb8622d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@medusajs/admin-ui Patch
@medusajs/admin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

allow_backorder,
}),
{
...removeNullish({
Copy link
Member

Choose a reason for hiding this comment

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

todo: Should we update removeNullish instead to check != null or != '' intead in order to prevent stripping false values? wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renaming existing utility to falsy and updating remove nullish to be == null since that evaluates to true for null and undefined (source: https://dorey.github.io/JavaScript-Equality-Table/)

@pKorsholm pKorsholm requested a review from adrien2p May 16, 2023 12:17
Copy link
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

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

LGTM - @adrien2p will you give this another look :)

…-section/edit-variant-inventory-modal.tsx

Co-authored-by: Oliver Windall Juhl <[email protected]>
Copy link
Member

@adrien2p adrien2p left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

@olivermrbl olivermrbl merged commit 2945769 into develop May 16, 2023
@olivermrbl olivermrbl deleted the feat/include-allow-backorder branch May 16, 2023 15:28
@github-actions github-actions bot mentioned this pull request May 16, 2023
@@ -74,8 +74,9 @@ const useEditProductActions = (productId: string) => {
updateVariant.mutate(
{
variant_id: id,
...removeNullish(payload),
...removeFalsy(payload),
Copy link
Contributor

Choose a reason for hiding this comment

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

question: @adrien2p @pKorsholm I am currently fiddling around with a reported bug around updating inventory quantities. Can you remember the reason for us using removeFalsy here? It will remove all number properties (e.g. inventory_quantity) that are attempted to be set to 0.

I have a PR ready, but I just want to make sure I don't introduce unexpected issues.

Copy link
Contributor

@olivermrbl olivermrbl Sep 21, 2023

Choose a reason for hiding this comment

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

Currently, you can't update any number properties to 0, including all measurements + inventory, because they are stripped from the payload.

Copy link
Member

Choose a reason for hiding this comment

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

I dont recall but indeed it strips every falsy values, 0 being considered as false as well.

Copy link
Member

@adrien2p adrien2p Sep 21, 2023

Choose a reason for hiding this comment

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

RemoveNullish will strip all null or undefined which seems better no? Unless we want to erase if undefined in that case we need to check !== null

Copy link
Contributor

Choose a reason for hiding this comment

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

I want to revert this to removeNullish.

Copy link
Member

Choose a reason for hiding this comment

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

In that case null or undefined will not be assigned, is it what we want? Looks alright to me, but what are we really trying to achieve here? Undefined is stripped by the api i think and null could allow to reset a field that is nullable right?

Copy link
Contributor

@olivermrbl olivermrbl Sep 21, 2023

Choose a reason for hiding this comment

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

I can't immediately think of any properties that we would like to remove with undefined on variants. If the API strips undefined values, I would also argue we could just pass the entire payload through without stripping anything.

Maybe we'll have to go a PR further back, and check why we added removeNullish 😅

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.

3 participants