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

Pwa 3122 #4104

Merged
merged 8 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ exports[`it renders correctly when it has cards 1`] = `
className="root"
/>
</div>
<span
aria-live="polite"
>
<div
className="balance"
>
<span
className="invalid_card_error"
/>
</div>
</span>
</div>
<div
className="root"
Expand Down Expand Up @@ -303,6 +314,17 @@ exports[`it renders correctly with no cards 1`] = `
className="root"
/>
</div>
<span
aria-live="polite"
>
<div
className="balance"
>
<span
className="invalid_card_error"
/>
</div>
</span>
</div>
<div
className="root"
Expand Down
40 changes: 23 additions & 17 deletions packages/venia-ui/lib/components/CartPage/GiftCards/giftCards.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,25 +133,31 @@ const GiftCards = props => {
);
}

const cardBalance = shouldDisplayCardBalance && (
<div className={classes.balance}>
<span className={classes.price}>
<FormattedMessage
id={'giftCards.balance'}
defaultMessage={'Balance: '}
/>
<Price
value={checkBalanceData.balance.value}
currencyCode={checkBalanceData.balance.currency}
/>
</span>
</div>
);

const containerClass = shouldDisplayCardError
? classes.card_input_container_error
: classes.card_input_container;

const cardBalance = (
<div className={classes.balance}>
{checkBalanceData && shouldDisplayCardBalance ? (
<div className={classes.price}>
<FormattedMessage
id={'giftCards.balance'}
defaultMessage={'Balance: '}
/>
<Price
value={checkBalanceData.balance.value}
currencyCode={checkBalanceData.balance.currency}
/>
</div>
) : (
<span className={classes.invalid_card_error}>
{cardEntryErrorMessage}
</span>
)}
</div>
);

const cardEntryContents = (
<div className={classes.card}>
<Field
Expand All @@ -172,15 +178,15 @@ const GiftCards = props => {
field="card"
mask={value => value && value.trim()}
maskOnBlur={true}
message={cardEntryErrorMessage}
// message={cardEntryErrorMessage}
placeholder={formatMessage({
id: 'giftCards.cardEntry',
defaultMessage: 'Enter card number'
})}
validate={isRequired}
/>
</div>
{cardBalance}
<span aria-live="polite">{cardBalance}</span>
</Field>
<Field
classes={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
.card_input_container {
}

.invalid_card_error {
color: red;
}

/* TODO @TW: cannot compose */
.card_input_container_error input {
/* composes: border-error from global; */
Expand Down