Skip to content

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

Refactor code a bit

dominik-zeglen6f422c9b6f1d
diff --git a/saleor/static/dashboard-next/index.tsx b/saleor/static/dashboard-next/index.tsx
index db98a73fc1..a8a2457d08 100644
--- a/saleor/static/dashboard-next/index.tsx
+++ b/saleor/static/dashboard-next/index.tsx
@@ -73,6 +73,9 @@ export interface UserError {
field: string;
message: string;
}
+
+// These interfaces are used in atomic mutation providers, which then are
+// combined into one compound mutation provider
export interface PartialMutationProviderProps<T extends {}> {
onSuccess?: (data: T) => void;
onError?: (error: ApolloError) => void;
@@ -85,7 +88,6 @@ export interface PartialMutationProviderOutput<
loading: boolean;
mutate: (variables: TVariables) => void;
}
-
export interface PartialMutationProviderRenderProps<
TData extends {} = {},
TVariables extends {} = {}
@@ -96,6 +98,6 @@ export interface PartialMutationProviderRenderProps<
mutate: MutationFn<TData, TVariables>;
}
-export type MutationProviderRenderProps<T> = T & {
- errors: UserError[];
-};
+export type MutationProviderRenderProps<T> = (
+ props: T & { errors: UserError[] }
+) => React.ReactElement<any>;
diff --git a/saleor/static/dashboard-next/products/containers/ProductUpdateOperations.tsx b/saleor/static/dashboard-next/products/containers/ProductUpdateOperations.tsx
index 10b0f88ba4..d64572b7fb 100644
--- a/saleor/static/dashboard-next/products/containers/ProductUpdateOperations.tsx
+++ b/saleor/static/dashboard-next/products/containers/ProductUpdateOperations.tsx
@@ -104,23 +104,21 @@ const ProductImageCreateProvider: React.StatelessComponent<
interface ProductUpdateOperationsProps
extends PartialMutationProviderProps<ProductImageCreateMutation> {
product?: ProductDetailsQuery["product"];
- children: (
- props: MutationProviderRenderProps<{
- createProductImage: PartialMutationProviderOutput<
- ProductImageCreateMutation,
- ProductImageCreateMutationVariables
- >;
- deleteProduct: PartialMutationProviderOutput;
- reorderProductImages: PartialMutationProviderOutput<
- ProductImageReorderMutation,
- ProductImageReorderMutationVariables
- >;
- updateProduct: PartialMutationProviderOutput<
- ProductUpdateMutation,
- ProductUpdateMutationVariables
- >;
- }>
- ) => React.ReactElement<any>;
+ children: MutationProviderRenderProps<{
+ createProductImage: PartialMutationProviderOutput<
+ ProductImageCreateMutation,
+ ProductImageCreateMutationVariables
+ >;
+ deleteProduct: PartialMutationProviderOutput;
+ reorderProductImages: PartialMutationProviderOutput<
+ ProductImageReorderMutation,
+ ProductImageReorderMutationVariables
+ >;
+ updateProduct: PartialMutationProviderOutput<
+ ProductUpdateMutation,
+ ProductUpdateMutationVariables
+ >;
+ }>;
onDelete?: (data: ProductDeleteMutation) => void;
onError?: (error: ApolloError) => void;
onImageCreate?: (data: ProductImageCreateMutation) => void;