Check shop errors too

This commit is contained in:
dominik-zeglen 2020-03-05 18:48:54 +01:00
parent a95054ecb3
commit 490c4c3023
2 changed files with 14 additions and 1 deletions

View file

@ -54,6 +54,7 @@ interface CollectionUpdateOperationsProps {
>; >;
}) => React.ReactNode; }) => React.ReactNode;
onUpdate: (data: CollectionUpdate) => void; onUpdate: (data: CollectionUpdate) => void;
onUpdateWithCollection: (data: CollectionUpdateWithHomepage) => void;
onProductAssign: (data: CollectionAssignProduct) => void; onProductAssign: (data: CollectionAssignProduct) => void;
onProductUnassign: (data: UnassignCollectionProduct) => void; onProductUnassign: (data: UnassignCollectionProduct) => void;
onRemove: (data: RemoveCollection) => void; onRemove: (data: RemoveCollection) => void;
@ -62,6 +63,7 @@ interface CollectionUpdateOperationsProps {
const CollectionOperations: React.FC<CollectionUpdateOperationsProps> = ({ const CollectionOperations: React.FC<CollectionUpdateOperationsProps> = ({
children, children,
onUpdate, onUpdate,
onUpdateWithCollection,
onProductAssign, onProductAssign,
onProductUnassign, onProductUnassign,
onRemove onRemove
@ -72,7 +74,9 @@ const CollectionOperations: React.FC<CollectionUpdateOperationsProps> = ({
{(...removeCollection) => ( {(...removeCollection) => (
<TypedCollectionAssignProductMutation onCompleted={onProductAssign}> <TypedCollectionAssignProductMutation onCompleted={onProductAssign}>
{(...assignProduct) => ( {(...assignProduct) => (
<TypedCollectionUpdateWithHomepageMutation onCompleted={onUpdate}> <TypedCollectionUpdateWithHomepageMutation
onCompleted={onUpdateWithCollection}
>
{(...updateWithHomepage) => ( {(...updateWithHomepage) => (
<TypedUnassignCollectionProductMutation <TypedUnassignCollectionProductMutation
onCompleted={onProductUnassign} onCompleted={onProductUnassign}

View file

@ -35,6 +35,7 @@ import {
CollectionUrlQueryParams, CollectionUrlQueryParams,
CollectionUrlDialog CollectionUrlDialog
} from "../urls"; } from "../urls";
import { CollectionUpdateWithHomepage } from "../types/CollectionUpdateWithHomepage";
interface CollectionDetailsProps { interface CollectionDetailsProps {
id: string; id: string;
@ -93,6 +94,13 @@ export const CollectionDetails: React.FC<CollectionDetailsProps> = ({
} }
} }
}; };
const handleCollectioUpdateWithHomepage = (
data: CollectionUpdateWithHomepage
) => {
if (data.homepageCollectionUpdate.errors.length === 0) {
handleCollectionUpdate(data);
}
};
const handleProductAssign = (data: CollectionAssignProduct) => { const handleProductAssign = (data: CollectionAssignProduct) => {
if (data.collectionAddProducts.errors.length === 0) { if (data.collectionAddProducts.errors.length === 0) {
@ -130,6 +138,7 @@ export const CollectionDetails: React.FC<CollectionDetailsProps> = ({
return ( return (
<CollectionOperations <CollectionOperations
onUpdate={handleCollectionUpdate} onUpdate={handleCollectionUpdate}
onUpdateWithCollection={handleCollectioUpdateWithHomepage}
onProductAssign={handleProductAssign} onProductAssign={handleProductAssign}
onProductUnassign={handleProductUnassign} onProductUnassign={handleProductUnassign}
onRemove={handleCollectionRemove} onRemove={handleCollectionRemove}