Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Update types

dominik-zeglen79293e272326
diff --git a/saleor/static/dashboard-next/components/ImageTile/ImageTile.tsx b/saleor/static/dashboard-next/components/ImageTile/ImageTile.tsx
index 05c111f147..a85c7c60d2 100644
--- a/saleor/static/dashboard-next/components/ImageTile/ImageTile.tsx
+++ b/saleor/static/dashboard-next/components/ImageTile/ImageTile.tsx
@@ -4,6 +4,7 @@ import * as React from "react";
import IconButton from "@material-ui/core/IconButton";
import DeleteIcon from "@material-ui/icons/Delete";
import EditIcon from "@material-ui/icons/Edit";
+import { ProductDetails_product_images_edges_node } from "../../products/types/ProductDetails";
const decorate = withStyles(theme => ({
image: {
@@ -44,21 +45,15 @@ const decorate = withStyles(theme => ({
}));
interface ImageTileProps {
- tile?: {
- id?: string;
- alt?: string;
- sortOrder?: number;
- url?: string;
- };
+ image: ProductDetails_product_images_edges_node;
deleteIcon: boolean;
editIcon: boolean;
onImageDelete?: () => void;
- onImageEdit?: (event: React.ChangeEvent<any>) => void;
- index?: string;
+ onImageEdit: (event: React.ChangeEvent<any>) => void;
}
const ImageTile = decorate<ImageTileProps>(
- ({ classes, onImageDelete, onImageEdit, tile, editIcon, deleteIcon }) => (
+ ({ classes, onImageDelete, onImageEdit, image, editIcon, deleteIcon }) => (
<div className={classes.imageContainer}>
<div className={classes.imageOverlay}>
<div className={classes.imageOverlayToolbar}>
@@ -74,7 +69,7 @@ const ImageTile = decorate<ImageTileProps>(
)}
</div>
</div>
- <img className={classes.image} src={tile.url} alt={tile.alt} />
+ <img className={classes.image} src={image.url} alt={image.alt} />
</div>
)
);
diff --git a/saleor/static/dashboard-next/products/components/ProductImages/ProductImages.tsx b/saleor/static/dashboard-next/products/components/ProductImages/ProductImages.tsx
index 7b2574ddb9..68bf597ab4 100644
--- a/saleor/static/dashboard-next/products/components/ProductImages/ProductImages.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductImages/ProductImages.tsx
@@ -13,15 +13,11 @@ import CardTitle from "../../../components/CardTitle";
import ImageTile from "../../../components/ImageTile";
import Toggle from "../../../components/Toggle";
import i18n from "../../../i18n";
+import { ProductDetails_product_images_edges_node } from "../../types/ProductDetails";
interface ProductImagesProps {
placeholderImage?: string;
- images?: Array<{
- id: string;
- alt?: string;
- sortOrder: number;
- url: string;
- }>;
+ images: ProductDetails_product_images_edges_node[];
loading?: boolean;
onImageDelete: (id: string) => () => void;
onImageEdit: (id: string) => () => void;
@@ -116,17 +112,15 @@ const decorate = withStyles(theme => ({
}
}));
-const SortableImage = SortableElement(
- ({ image, onImageEdit, toggle, tile }) => (
- <ImageTile
- tile={tile}
- deleteIcon={true}
- editIcon={true}
- onImageEdit={onImageEdit ? onImageEdit(image.id) : null}
- onImageDelete={toggle}
- />
- )
-);
+const SortableImage = SortableElement(({ image, onImageEdit, toggle }) => (
+ <ImageTile
+ image={image}
+ deleteIcon={true}
+ editIcon={true}
+ onImageEdit={onImageEdit ? () => onImageEdit(image.id) : undefined}
+ onImageDelete={toggle}
+ />
+));
const ImageListContainer = SortableContainer(
decorate<ImageListContainerProps>(
@@ -140,7 +134,7 @@ const ImageListContainer = SortableContainer(
<SortableImage
key={`item-${index}`}
index={index}
- tile={image}
+ image={image}
onImageEdit={onImageEdit ? onImageEdit(image.id) : null}
onImageDelete={toggle}
/>
diff --git a/saleor/static/dashboard-next/products/queries.ts b/saleor/static/dashboard-next/products/queries.ts
index a0e79044da..c2a5a56a27 100644
--- a/saleor/static/dashboard-next/products/queries.ts
+++ b/saleor/static/dashboard-next/products/queries.ts
@@ -28,7 +28,7 @@ export const fragmentMoney = gql`
`;
export const fragmentProductImage = gql`
- fragment ProductImage on ProductImage {
+ fragment ProductImageFragment on ProductImage {
id
alt
sortOrder
@@ -109,7 +109,7 @@ export const fragmentProduct = gql`
images {
edges {
node {
- ...ProductImage
+ ...ProductImageFragment
}
}
}
@@ -177,7 +177,7 @@ export const fragmentVariant = gql`
images {
edges {
node {
- ...ProductImage
+ ...ProductImageFragment
}
}
}
diff --git a/saleor/static/dashboard-next/products/types/ProductImageFragment.ts b/saleor/static/dashboard-next/products/types/ProductImageFragment.ts
new file mode 100644
index 0000000000..7a1c314b57
--- /dev/null
+++ b/saleor/static/dashboard-next/products/types/ProductImageFragment.ts
@@ -0,0 +1,14 @@
+/* tslint:disable */
+// This file was automatically generated and should not be edited.
+
+// ====================================================
+// GraphQL fragment: ProductImageFragment
+// ====================================================
+
+export interface ProductImageFragment {
+ __typename: "ProductImage";
+ id: string;
+ alt: string;
+ sortOrder: number;
+ url: string;
+}