Skip to content

Commit

Permalink
Merge pull request #689 from mirumee/fix/availability-date
Browse files Browse the repository at this point in the history
fix availability date
  • Loading branch information
dominik-zeglen authored Sep 3, 2020
2 parents eba4ba2 + 7d5d369 commit abda7f5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
8 changes: 4 additions & 4 deletions locale/defaultMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1437,10 +1437,6 @@
"context": "product availability",
"string": "Available for purchase"
},
"src_dot_components_dot_AvailabilityCard_dot_2936097346": {
"context": "product unavailability",
"string": "Unvailable for purchase"
},
"src_dot_components_dot_AvailabilityCard_dot_2938074852": {
"context": "product available for purchase date",
"string": "will become available on {date}"
Expand All @@ -1449,6 +1445,10 @@
"context": "product availability date label",
"string": "Set availability date"
},
"src_dot_components_dot_AvailabilityCard_dot_825317195": {
"context": "product unavailability",
"string": "Unavailable for purchase"
},
"src_dot_components_dot_ColumnPicker_dot_1483881697": {
"context": "button",
"string": "Reset"
Expand Down
2 changes: 1 addition & 1 deletion src/components/AvailabilityCard/AvailabilityCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const AvailabilityCard: React.FC<AvailabilityCardProps> = props => {
description: "product availability date label"
}),
unavailableLabel: intl.formatMessage({
defaultMessage: "Unvailable for purchase",
defaultMessage: "Unavailable for purchase",
description: "product unavailability"
})
}}
Expand Down
13 changes: 11 additions & 2 deletions src/components/VisibilityCard/VisibilityCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ControlledCheckbox from "@saleor/components/ControlledCheckbox";
import Hr from "@saleor/components/Hr";
import RadioSwitchField from "@saleor/components/RadioSwitchField";
import useDateLocalize from "@saleor/hooks/useDateLocalize";
import { ChangeEvent } from "@saleor/hooks/useForm";
import { UserError } from "@saleor/types";
import { getFieldError } from "@saleor/utils/errors";
import classNames from "classnames";
Expand Down Expand Up @@ -82,7 +83,7 @@ export interface VisibilityCardProps {
errors: UserError[];
disabled?: boolean;
messages: Message;
onChange: (event: React.ChangeEvent<any>) => void;
onChange: (event: ChangeEvent) => void;
}

export const VisibilityCard: React.FC<VisibilityCardProps> = props => {
Expand Down Expand Up @@ -236,7 +237,15 @@ export const VisibilityCard: React.FC<VisibilityCardProps> = props => {
</>
}
value={isAvailable}
onChange={onChange}
onChange={e => {
const { value } = e.target;
if (!value) {
onChange({
target: { name: "availableForPurchase", value: null }
});
}
return onChange(e);
}}
/>
{!isAvailable && (
<>
Expand Down
22 changes: 11 additions & 11 deletions src/storybook/__snapshots__/Stories.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,7 @@ exports[`Storyshots Generics / AvailabilityCard default 1`] = `
<p
class="VisibilityCard-label-id"
>
Unvailable for purchase
Unavailable for purchase
</p>
</span>
</label>
Expand Down Expand Up @@ -133844,7 +133844,7 @@ Ctrl + K"
<p
class="VisibilityCard-label-id"
>
Unvailable for purchase
Unavailable for purchase
</p>
</span>
</label>
Expand Down Expand Up @@ -135003,7 +135003,7 @@ Ctrl + K"
<p
class="VisibilityCard-label-id"
>
Unvailable for purchase
Unavailable for purchase
</p>
</span>
</label>
Expand Down Expand Up @@ -136175,7 +136175,7 @@ Ctrl + K"
<p
class="VisibilityCard-label-id"
>
Unvailable for purchase
Unavailable for purchase
</p>
</span>
</label>
Expand Down Expand Up @@ -141594,7 +141594,7 @@ Ctrl + K"
<p
class="VisibilityCard-label-id"
>
Unvailable for purchase
Unavailable for purchase
</p>
</span>
</label>
Expand Down Expand Up @@ -143596,7 +143596,7 @@ Ctrl + K"
<p
class="VisibilityCard-label-id"
>
Unvailable for purchase
Unavailable for purchase
</p>
</span>
</label>
Expand Down Expand Up @@ -146016,7 +146016,7 @@ Ctrl + K"
<p
class="VisibilityCard-label-id"
>
Unvailable for purchase
Unavailable for purchase
</p>
</span>
</label>
Expand Down Expand Up @@ -148570,7 +148570,7 @@ Ctrl + K"
<p
class="VisibilityCard-label-id"
>
Unvailable for purchase
Unavailable for purchase
</p>
</span>
</label>
Expand Down Expand Up @@ -150831,7 +150831,7 @@ Ctrl + K"
<p
class="VisibilityCard-label-id"
>
Unvailable for purchase
Unavailable for purchase
</p>
</span>
</label>
Expand Down Expand Up @@ -154305,7 +154305,7 @@ Ctrl + K"
<p
class="VisibilityCard-label-id"
>
Unvailable for purchase
Unavailable for purchase
</p>
</span>
</label>
Expand Down Expand Up @@ -156859,7 +156859,7 @@ Ctrl + K"
<p
class="VisibilityCard-label-id"
>
Unvailable for purchase
Unavailable for purchase
</p>
</span>
</label>
Expand Down

0 comments on commit abda7f5

Please sign in to comment.