Check shop errors too
This commit is contained in:
parent
a95054ecb3
commit
490c4c3023
2 changed files with 14 additions and 1 deletions
|
@ -54,6 +54,7 @@ interface CollectionUpdateOperationsProps {
|
|||
>;
|
||||
}) => React.ReactNode;
|
||||
onUpdate: (data: CollectionUpdate) => void;
|
||||
onUpdateWithCollection: (data: CollectionUpdateWithHomepage) => void;
|
||||
onProductAssign: (data: CollectionAssignProduct) => void;
|
||||
onProductUnassign: (data: UnassignCollectionProduct) => void;
|
||||
onRemove: (data: RemoveCollection) => void;
|
||||
|
@ -62,6 +63,7 @@ interface CollectionUpdateOperationsProps {
|
|||
const CollectionOperations: React.FC<CollectionUpdateOperationsProps> = ({
|
||||
children,
|
||||
onUpdate,
|
||||
onUpdateWithCollection,
|
||||
onProductAssign,
|
||||
onProductUnassign,
|
||||
onRemove
|
||||
|
@ -72,7 +74,9 @@ const CollectionOperations: React.FC<CollectionUpdateOperationsProps> = ({
|
|||
{(...removeCollection) => (
|
||||
<TypedCollectionAssignProductMutation onCompleted={onProductAssign}>
|
||||
{(...assignProduct) => (
|
||||
<TypedCollectionUpdateWithHomepageMutation onCompleted={onUpdate}>
|
||||
<TypedCollectionUpdateWithHomepageMutation
|
||||
onCompleted={onUpdateWithCollection}
|
||||
>
|
||||
{(...updateWithHomepage) => (
|
||||
<TypedUnassignCollectionProductMutation
|
||||
onCompleted={onProductUnassign}
|
||||
|
|
|
@ -35,6 +35,7 @@ import {
|
|||
CollectionUrlQueryParams,
|
||||
CollectionUrlDialog
|
||||
} from "../urls";
|
||||
import { CollectionUpdateWithHomepage } from "../types/CollectionUpdateWithHomepage";
|
||||
|
||||
interface CollectionDetailsProps {
|
||||
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) => {
|
||||
if (data.collectionAddProducts.errors.length === 0) {
|
||||
|
@ -130,6 +138,7 @@ export const CollectionDetails: React.FC<CollectionDetailsProps> = ({
|
|||
return (
|
||||
<CollectionOperations
|
||||
onUpdate={handleCollectionUpdate}
|
||||
onUpdateWithCollection={handleCollectioUpdateWithHomepage}
|
||||
onProductAssign={handleProductAssign}
|
||||
onProductUnassign={handleProductUnassign}
|
||||
onRemove={handleCollectionRemove}
|
||||
|
|
Loading…
Reference in a new issue