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

feat(react-notifications): add OverlappingPriceValidity and OverlappingStandalonePriceValidity error codes #3517

Merged
merged 4 commits into from
May 13, 2024
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
6 changes: 6 additions & 0 deletions .changeset/ten-buses-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@commercetools-frontend/react-notifications': minor
'@commercetools-frontend/i18n': minor
---

Add messages for `OverlappingPriceValidity` and `OverlappingStandalonePriceValidity` error code
8 changes: 8 additions & 0 deletions packages/i18n/data/core.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,18 @@
"developer_comment": "User attempts to create a resource while having already reached the limit",
"string": "The project reached the limit for the resource. To add more resources delete existing ones or reach out to the administrator or contact customer support."
},
"ApiError.OverlappingPriceValidity": {
"developer_comment": "Returned when a given price validity period conflicts with an existing one",
"string": "Two prices have overlapping validity periods."
},
"ApiError.OverlappingPrices": {
"developer_comment": "",
"string": "Sorry, but a price with these details already exists. Please amend the price details so that they do not overlap with another price before saving."
},
"ApiError.OverlappingStandalonePriceValidity": {
"developer_comment": "Returned when a given standalone price validity period conflicts with an existing one",
"string": "Two standalone prices have overlapping validity periods."
},
"ApiError.PendingOperation": {
"developer_comment": "User tries to start a new process when one is already underway",
"string": "Sorry, but we are still processing the previous request. Please try again once it is complete."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,50 @@ describe('render', () => {
)
).toBeInTheDocument();
});
it('should show message for DuplicatePriceScope', () => {
const error = {
extensions: { code: 'DuplicatePriceScope' },
message: 'message-content',
};
renderMessage(<ApiErrorMessage error={error} />);
expect(
screen.getByText(
'A price with the same scope already exists for this product variant. Make sure that the combination of currency, country, customer group, channel and valid dates is unique per price.'
)
).toBeInTheDocument();
});
it('should show message for DuplicateStandalonePriceScope', () => {
const error = {
extensions: { code: 'DuplicateStandalonePriceScope' },
message: 'message-content',
};
renderMessage(<ApiErrorMessage error={error} />);
expect(
screen.getByText(
'A price with the same scope already exists for this product variant. The combination of currency, country, customer group, channel and validity date must be unique for each price per SKU.'
)
).toBeInTheDocument();
});
it('should show message for OverlappingPriceValidity', () => {
const error = {
extensions: { code: 'OverlappingPriceValidity' },
message: 'message-content',
};
renderMessage(<ApiErrorMessage error={error} />);
expect(
screen.getByText('Two prices have overlapping validity periods.')
).toBeInTheDocument();
});
it('should show message for OverlappingStandalonePriceValidity', () => {
const error = {
extensions: { code: 'OverlappingStandalonePriceValidity' },
message: 'message-content',
};
renderMessage(<ApiErrorMessage error={error} />);
expect(
screen.getByText(
'Two standalone prices have overlapping validity periods.'
)
).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ export default defineMessages({
defaultMessage:
'Slugs may only contain alphanumeric (0-9A-Z) characters, underscores and hyphens and must have a length between 2 and 256 characters.',
},
OverlappingPriceValidity: {
id: 'ApiError.OverlappingPriceValidity',
description:
'Returned when a given price validity period conflicts with an existing one',
defaultMessage: 'Two prices have overlapping validity periods.',
},
OverlappingStandalonePriceValidity: {
id: 'ApiError.OverlappingStandalonePriceValidity',
description:
'Returned when a given standalone price validity period conflicts with an existing one',
defaultMessage: 'Two standalone prices have overlapping validity periods.',
},
PendingOperation: {
id: 'ApiError.PendingOperation',
description:
Expand Down
Loading