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

Migrate old notifications to the new ones #587

Merged
merged 2 commits into from
Jul 6, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable, unreleased changes to this project will be documented in this file.

- Add sku column to fulfillment cards - #538 by @dominik-zeglen
- Migrate product base price to variant prices - #555 by @orzechdev
- Migrate old notifications to the new ones - #587 by @AlicjaSzu

## 2.10.0

Expand Down
1 change: 1 addition & 0 deletions src/attributes/views/AttributeCreate/AttributeCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const AttributeDetails: React.FC<AttributeDetailsProps> = ({ params }) => {
const handleCreate = (data: AttributeCreate) => {
if (data.attributeCreate.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage({
defaultMessage: "Successfully created attribute"
})
Expand Down
14 changes: 12 additions & 2 deletions src/attributes/views/AttributeDetails/AttributeDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const AttributeDetails: React.FC<AttributeDetailsProps> = ({ id, params }) => {
const handleDelete = (data: AttributeDelete) => {
if (data.attributeDelete.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage({
defaultMessage: "Attribute deleted"
})
Expand All @@ -63,6 +64,7 @@ const AttributeDetails: React.FC<AttributeDetailsProps> = ({ id, params }) => {
const handleValueDelete = (data: AttributeValueDelete) => {
if (data.attributeValueDelete.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage({
defaultMessage: "Value deleted",
description: "attribute value deleted"
Expand All @@ -73,18 +75,25 @@ const AttributeDetails: React.FC<AttributeDetailsProps> = ({ id, params }) => {
};
const handleUpdate = (data: AttributeUpdate) => {
if (data.attributeUpdate.errors.length === 0) {
notify({ text: intl.formatMessage(commonMessages.savedChanges) });
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
}
};
const handleValueUpdate = (data: AttributeValueUpdate) => {
if (data.attributeValueUpdate.errors.length === 0) {
notify({ text: intl.formatMessage(commonMessages.savedChanges) });
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
closeModal();
}
};
const handleValueCreate = (data: AttributeValueCreate) => {
if (data.attributeValueCreate.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage({
defaultMessage: "Added new value",
description: "added new attribute value"
Expand All @@ -96,6 +105,7 @@ const AttributeDetails: React.FC<AttributeDetailsProps> = ({ id, params }) => {
const handleValueReorderMutation = (data: AttributeValueReorder) => {
if (data.attributeReorderValues.errors.length !== 0) {
notify({
status: "error",
text: getProductErrorMessage(
data.attributeReorderValues.errors[0],
intl
Expand Down
1 change: 1 addition & 0 deletions src/attributes/views/AttributeList/AttributeList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ const AttributeList: React.FC<AttributeListProps> = ({ params }) => {
if (data.attributeBulkDelete.errors.length === 0) {
closeModal();
notify({
status: "success",
text: intl.formatMessage({
defaultMessage: "Attributes successfully delete",
description: "deleted multiple attributes"
Expand Down
1 change: 1 addition & 0 deletions src/categories/views/CategoryCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const CategoryCreateView: React.FC<CategoryCreateViewProps> = ({
const handleSuccess = (data: CategoryCreate) => {
if (data.categoryCreate.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage({
defaultMessage: "Category created"
})
Expand Down
4 changes: 4 additions & 0 deletions src/categories/views/CategoryDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const CategoryDetails: React.FC<CategoryDetailsProps> = ({
const handleCategoryDelete = (data: CategoryDelete) => {
if (data.categoryDelete.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage({
defaultMessage: "Category deleted"
})
Expand All @@ -99,6 +100,7 @@ export const CategoryDetails: React.FC<CategoryDetailsProps> = ({
);
if (backgroundImageError) {
notify({
status: "error",
text: intl.formatMessage(commonMessages.somethingWentWrong)
});
}
Expand All @@ -113,6 +115,7 @@ export const CategoryDetails: React.FC<CategoryDetailsProps> = ({
if (data.categoryBulkDelete.errors.length === 0) {
closeModal();
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
reset();
Expand Down Expand Up @@ -144,6 +147,7 @@ export const CategoryDetails: React.FC<CategoryDetailsProps> = ({
if (data.productBulkDelete.errors.length === 0) {
closeModal();
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
refetch();
Expand Down
2 changes: 2 additions & 0 deletions src/collections/views/CollectionCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const CollectionCreate: React.FC = () => {
const handleCollectionCreateSuccess = (data: CreateCollection) => {
if (data.collectionCreate.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
navigate(collectionUrl(data.collectionCreate.collection.id));
Expand All @@ -29,6 +30,7 @@ export const CollectionCreate: React.FC = () => {
);
if (backgroundImageError) {
notify({
status: "error",
text: intl.formatMessage(commonMessages.somethingWentWrong)
});
}
Expand Down
5 changes: 5 additions & 0 deletions src/collections/views/CollectionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const CollectionDetails: React.FC<CollectionDetailsProps> = ({
const handleCollectionUpdate = (data: CollectionUpdate) => {
if (data.collectionUpdate.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
navigate(collectionUrl(id));
Expand All @@ -89,6 +90,7 @@ export const CollectionDetails: React.FC<CollectionDetailsProps> = ({
);
if (backgroundImageError) {
notify({
status: "error",
text: intl.formatMessage(commonMessages.somethingWentWrong)
});
}
Expand All @@ -105,6 +107,7 @@ export const CollectionDetails: React.FC<CollectionDetailsProps> = ({
const handleProductAssign = (data: CollectionAssignProduct) => {
if (data.collectionAddProducts.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage({
defaultMessage: "Added product to collection"
})
Expand All @@ -116,6 +119,7 @@ export const CollectionDetails: React.FC<CollectionDetailsProps> = ({
const handleProductUnassign = (data: UnassignCollectionProduct) => {
if (data.collectionRemoveProducts.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage({
defaultMessage: "Deleted product from collection"
})
Expand All @@ -128,6 +132,7 @@ export const CollectionDetails: React.FC<CollectionDetailsProps> = ({
const handleCollectionRemove = (data: RemoveCollection) => {
if (data.collectionDelete.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage({
defaultMessage: "Deleted collection"
})
Expand Down
2 changes: 2 additions & 0 deletions src/collections/views/CollectionList/CollectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export const CollectionList: React.FC<CollectionListProps> = ({ params }) => {
const handleCollectionBulkDelete = (data: CollectionBulkDelete) => {
if (data.collectionBulkDelete.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
refetch();
Expand All @@ -150,6 +151,7 @@ export const CollectionList: React.FC<CollectionListProps> = ({ params }) => {
const handleCollectionBulkPublish = (data: CollectionBulkPublish) => {
if (data.collectionBulkPublish.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
refetch();
Expand Down
3 changes: 3 additions & 0 deletions src/customers/views/CustomerAddresses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const CustomerAddresses: React.FC<CustomerAddressesProps> = ({
if (data.addressSetDefault.errors.length === 0) {
closeModal();
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
}
Expand All @@ -68,6 +69,7 @@ const CustomerAddresses: React.FC<CustomerAddressesProps> = ({
if (data.addressUpdate.errors.length === 0) {
closeModal();
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
}
Expand All @@ -77,6 +79,7 @@ const CustomerAddresses: React.FC<CustomerAddressesProps> = ({
if (data.addressDelete.errors.length === 0) {
closeModal();
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
}
Expand Down
1 change: 1 addition & 0 deletions src/customers/views/CustomerCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const CustomerCreate: React.FC<{}> = () => {
const handleCreateCustomerSuccess = (data: CreateCustomer) => {
if (data.customerCreate.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage({
defaultMessage: "Customer created"
})
Expand Down
2 changes: 2 additions & 0 deletions src/customers/views/CustomerDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ export const CustomerDetailsView: React.FC<CustomerDetailsViewProps> = ({
const handleCustomerUpdateSuccess = (data: UpdateCustomer) => {
if (data.customerUpdate.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
}
};
const handleCustomerRemoveSuccess = (data: RemoveCustomer) => {
if (data.customerDelete.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage({
defaultMessage: "Customer Removed"
})
Expand Down
1 change: 1 addition & 0 deletions src/customers/views/CustomerList/CustomerList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export const CustomerList: React.FC<CustomerListProps> = ({ params }) => {
const handleBulkCustomerDelete = (data: BulkRemoveCustomers) => {
if (data.customerBulkDelete.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
reset();
Expand Down
2 changes: 2 additions & 0 deletions src/discounts/views/SaleDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const SaleDetails: React.FC<SaleDetailsProps> = ({ id, params }) => {
const handleSaleDelete = (data: SaleDelete) => {
if (data.saleDelete.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage({
defaultMessage: "Removed sale"
})
Expand All @@ -110,6 +111,7 @@ export const SaleDetails: React.FC<SaleDetailsProps> = ({ id, params }) => {
const handleSaleUpdate = (data: SaleUpdate) => {
if (data.saleUpdate.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
}
Expand Down
1 change: 1 addition & 0 deletions src/discounts/views/SaleList/SaleList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export const SaleList: React.FC<SaleListProps> = ({ params }) => {
const handleSaleBulkDelete = (data: SaleBulkDelete) => {
if (data.saleBulkDelete.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
reset();
Expand Down
1 change: 1 addition & 0 deletions src/discounts/views/VoucherCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const VoucherDetails: React.FC = () => {
const handleVoucherCreate = (data: VoucherCreate) => {
if (data.voucherCreate.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage({
defaultMessage: "Successfully created voucher"
})
Expand Down
2 changes: 2 additions & 0 deletions src/discounts/views/VoucherDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export const VoucherDetails: React.FC<VoucherDetailsProps> = ({
const handleVoucherDelete = (data: VoucherDelete) => {
if (data.voucherDelete.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage({
defaultMessage: "Deleted voucher"
})
Expand All @@ -113,6 +114,7 @@ export const VoucherDetails: React.FC<VoucherDetailsProps> = ({
if (data.voucherUpdate.errors.length === 0) {
closeModal();
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
}
Expand Down
1 change: 1 addition & 0 deletions src/discounts/views/VoucherList/VoucherList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export const VoucherList: React.FC<VoucherListProps> = ({ params }) => {
const handleVoucherBulkDelete = (data: VoucherBulkDelete) => {
if (data.voucherBulkDelete.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
reset();
Expand Down
3 changes: 3 additions & 0 deletions src/hooks/makeMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,18 @@ function makeMutation<TData, TVariables>(
)
) {
notify({
status: "error",
text: intl.formatMessage(commonMessages.readOnly)
});
} else if (err.graphQLErrors.some(isJwtError)) {
user.logout();
notify({
status: "error",
text: intl.formatMessage(commonMessages.sessionExpired)
});
} else {
notify({
status: "error",
text: intl.formatMessage(commonMessages.somethingWentWrong)
});
}
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/makeQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function makeQuery<TData, TVariables>(
if (queryData.error.graphQLErrors.some(isJwtError)) {
user.logout();
notify({
status: "error",
text: intl.formatMessage(commonMessages.sessionExpired)
});
} else if (
Expand All @@ -76,6 +77,7 @@ function makeQuery<TData, TVariables>(
)
) {
notify({
status: "error",
text: intl.formatMessage(commonMessages.somethingWentWrong)
});
}
Expand Down
4 changes: 4 additions & 0 deletions src/mutations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function TypedMutation<TData, TVariables>(
onError={(err: ApolloError) => {
if (err.networkError) {
notify({
status: "error",
text: intl.formatMessage(commonMessages.somethingWentWrong)
});
}
Expand All @@ -47,15 +48,18 @@ export function TypedMutation<TData, TVariables>(
"ReadOnlyException"
) {
notify({
status: "error",
text: intl.formatMessage(commonMessages.readOnly)
});
} else if (err.graphQLErrors.some(isJwtError)) {
user.logout();
notify({
status: "error",
text: intl.formatMessage(commonMessages.sessionExpired)
});
} else {
notify({
status: "error",
text: intl.formatMessage(commonMessages.somethingWentWrong)
});
}
Expand Down
4 changes: 4 additions & 0 deletions src/navigation/views/MenuDetails/successHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export function handleItemCreate(
if (data.menuItemCreate.errors.length === 0) {
closeModal();
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
}
Expand All @@ -32,6 +33,7 @@ export function handleItemUpdate(
) {
if (data.menuItemUpdate.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
navigate(
Expand All @@ -51,6 +53,7 @@ export function handleDelete(
) {
if (data.menuDelete.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
navigate(menuListUrl(), true);
Expand All @@ -69,6 +72,7 @@ export function handleUpdate(
data.menuUpdate.errors.length === 0
) {
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
refetch();
Expand Down
Loading