Fix types
This commit is contained in:
parent
f4dfbe7e90
commit
7c90ec1c72
9 changed files with 15 additions and 23 deletions
|
@ -13,7 +13,7 @@ import React from "react";
|
||||||
import { FormattedMessage, useIntl } from "react-intl";
|
import { FormattedMessage, useIntl } from "react-intl";
|
||||||
|
|
||||||
import { CategoryDetails_category_backgroundImage } from "../../types/CategoryDetails";
|
import { CategoryDetails_category_backgroundImage } from "../../types/CategoryDetails";
|
||||||
import { FormData } from "../CategoryUpdatePage";
|
import { CategoryUpdateData } from "../CategoryUpdatePage/form";
|
||||||
|
|
||||||
const useStyles = makeStyles(
|
const useStyles = makeStyles(
|
||||||
theme => ({
|
theme => ({
|
||||||
|
@ -42,7 +42,7 @@ const useStyles = makeStyles(
|
||||||
);
|
);
|
||||||
|
|
||||||
export interface CategoryBackgroundProps {
|
export interface CategoryBackgroundProps {
|
||||||
data: FormData;
|
data: CategoryUpdateData;
|
||||||
image: CategoryDetails_category_backgroundImage;
|
image: CategoryDetails_category_backgroundImage;
|
||||||
onChange: (event: React.ChangeEvent<any>) => void;
|
onChange: (event: React.ChangeEvent<any>) => void;
|
||||||
onImageDelete: () => void;
|
onImageDelete: () => void;
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { MetadataFormData } from "@saleor/components/Metadata";
|
||||||
import { RichTextEditorChange } from "@saleor/components/RichTextEditor";
|
import { RichTextEditorChange } from "@saleor/components/RichTextEditor";
|
||||||
import useForm, { FormChange } from "@saleor/hooks/useForm";
|
import useForm, { FormChange } from "@saleor/hooks/useForm";
|
||||||
import handleFormSubmit from "@saleor/utils/handlers/handleFormSubmit";
|
import handleFormSubmit from "@saleor/utils/handlers/handleFormSubmit";
|
||||||
import getMetadata from "@saleor/utils/metadata/getMetadata";
|
|
||||||
import useMetadataChangeTrigger from "@saleor/utils/metadata/useMetadataChangeTrigger";
|
import useMetadataChangeTrigger from "@saleor/utils/metadata/useMetadataChangeTrigger";
|
||||||
import useRichText from "@saleor/utils/richText/useRichText";
|
import useRichText from "@saleor/utils/richText/useRichText";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
|
@ -9,7 +9,8 @@ import {
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useIntl } from "react-intl";
|
import { useIntl } from "react-intl";
|
||||||
|
|
||||||
import CategoryCreatePage, { FormData } from "../components/CategoryCreatePage";
|
import CategoryCreatePage from "../components/CategoryCreatePage";
|
||||||
|
import { CategoryCreateData } from "../components/CategoryCreatePage/form";
|
||||||
import { useCategoryCreateMutation } from "../mutations";
|
import { useCategoryCreateMutation } from "../mutations";
|
||||||
import { CategoryCreate } from "../types/CategoryCreate";
|
import { CategoryCreate } from "../types/CategoryCreate";
|
||||||
import { categoryListUrl, categoryUrl } from "../urls";
|
import { categoryListUrl, categoryUrl } from "../urls";
|
||||||
|
@ -43,7 +44,7 @@ export const CategoryCreateView: React.FC<CategoryCreateViewProps> = ({
|
||||||
onCompleted: handleSuccess
|
onCompleted: handleSuccess
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleCreate = async (formData: FormData) => {
|
const handleCreate = async (formData: CategoryCreateData) => {
|
||||||
const result = await createCategory({
|
const result = await createCategory({
|
||||||
variables: {
|
variables: {
|
||||||
input: {
|
input: {
|
||||||
|
|
|
@ -27,9 +27,9 @@ import { productAddUrl, productUrl } from "../../products/urls";
|
||||||
import { CategoryInput } from "../../types/globalTypes";
|
import { CategoryInput } from "../../types/globalTypes";
|
||||||
import {
|
import {
|
||||||
CategoryPageTab,
|
CategoryPageTab,
|
||||||
CategoryUpdatePage,
|
CategoryUpdatePage
|
||||||
FormData
|
|
||||||
} from "../components/CategoryUpdatePage/CategoryUpdatePage";
|
} from "../components/CategoryUpdatePage/CategoryUpdatePage";
|
||||||
|
import { CategoryUpdateData } from "../components/CategoryUpdatePage/form";
|
||||||
import {
|
import {
|
||||||
useCategoryBulkDeleteMutation,
|
useCategoryBulkDeleteMutation,
|
||||||
useCategoryDeleteMutation,
|
useCategoryDeleteMutation,
|
||||||
|
@ -175,7 +175,7 @@ export const CategoryDetails: React.FC<CategoryDetailsProps> = ({
|
||||||
params
|
params
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleUpdate = async (formData: FormData) => {
|
const handleUpdate = async (formData: CategoryUpdateData) => {
|
||||||
const result = await updateCategory({
|
const result = await updateCategory({
|
||||||
variables: {
|
variables: {
|
||||||
id,
|
id,
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { MetadataFormData } from "@saleor/components/Metadata";
|
||||||
import { RichTextEditorChange } from "@saleor/components/RichTextEditor";
|
import { RichTextEditorChange } from "@saleor/components/RichTextEditor";
|
||||||
import useForm, { FormChange } from "@saleor/hooks/useForm";
|
import useForm, { FormChange } from "@saleor/hooks/useForm";
|
||||||
import handleFormSubmit from "@saleor/utils/handlers/handleFormSubmit";
|
import handleFormSubmit from "@saleor/utils/handlers/handleFormSubmit";
|
||||||
import getMetadata from "@saleor/utils/metadata/getMetadata";
|
|
||||||
import useMetadataChangeTrigger from "@saleor/utils/metadata/useMetadataChangeTrigger";
|
import useMetadataChangeTrigger from "@saleor/utils/metadata/useMetadataChangeTrigger";
|
||||||
import useRichText from "@saleor/utils/richText/useRichText";
|
import useRichText from "@saleor/utils/richText/useRichText";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
|
@ -25,9 +25,8 @@ import { FormattedMessage, useIntl } from "react-intl";
|
||||||
import { getMutationState, maybe } from "../../misc";
|
import { getMutationState, maybe } from "../../misc";
|
||||||
import { productUrl } from "../../products/urls";
|
import { productUrl } from "../../products/urls";
|
||||||
import { CollectionInput } from "../../types/globalTypes";
|
import { CollectionInput } from "../../types/globalTypes";
|
||||||
import CollectionDetailsPage, {
|
import CollectionDetailsPage from "../components/CollectionDetailsPage/CollectionDetailsPage";
|
||||||
CollectionDetailsPageFormData
|
import { CollectionUpdateData } from "../components/CollectionDetailsPage/form";
|
||||||
} from "../components/CollectionDetailsPage/CollectionDetailsPage";
|
|
||||||
import {
|
import {
|
||||||
useCollectionAssignProductMutation,
|
useCollectionAssignProductMutation,
|
||||||
useCollectionRemoveMutation,
|
useCollectionRemoveMutation,
|
||||||
|
@ -168,9 +167,7 @@ export const CollectionDetails: React.FC<CollectionDetailsProps> = ({
|
||||||
return <NotFoundPage onBack={handleBack} />;
|
return <NotFoundPage onBack={handleBack} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleUpdate = async (
|
const handleUpdate = async (formData: CollectionUpdateData) => {
|
||||||
formData: CollectionDetailsPageFormData
|
|
||||||
) => {
|
|
||||||
const input: CollectionInput = {
|
const input: CollectionInput = {
|
||||||
backgroundImageAlt: formData.backgroundImageAlt,
|
backgroundImageAlt: formData.backgroundImageAlt,
|
||||||
descriptionJson: JSON.stringify(formData.description),
|
descriptionJson: JSON.stringify(formData.description),
|
||||||
|
|
|
@ -14,9 +14,8 @@ import { FormattedMessage, useIntl } from "react-intl";
|
||||||
|
|
||||||
import { getStringOrPlaceholder, maybe } from "../../misc";
|
import { getStringOrPlaceholder, maybe } from "../../misc";
|
||||||
import { PageInput } from "../../types/globalTypes";
|
import { PageInput } from "../../types/globalTypes";
|
||||||
import PageDetailsPage, {
|
import PageDetailsPage from "../components/PageDetailsPage";
|
||||||
PageDetailsPageFormData
|
import { PageData } from "../components/PageDetailsPage/form";
|
||||||
} from "../components/PageDetailsPage";
|
|
||||||
import { TypedPageRemove, TypedPageUpdate } from "../mutations";
|
import { TypedPageRemove, TypedPageUpdate } from "../mutations";
|
||||||
import { TypedPageDetailsQuery } from "../queries";
|
import { TypedPageDetailsQuery } from "../queries";
|
||||||
import { PageRemove } from "../types/PageRemove";
|
import { PageRemove } from "../types/PageRemove";
|
||||||
|
@ -27,7 +26,7 @@ export interface PageDetailsProps {
|
||||||
params: PageUrlQueryParams;
|
params: PageUrlQueryParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
const createPageInput = (data: PageDetailsPageFormData): PageInput => ({
|
const createPageInput = (data: PageData): PageInput => ({
|
||||||
contentJson: JSON.stringify(data.content),
|
contentJson: JSON.stringify(data.content),
|
||||||
isPublished: data.isPublished,
|
isPublished: data.isPublished,
|
||||||
publicationDate: data.publicationDate,
|
publicationDate: data.publicationDate,
|
||||||
|
@ -63,7 +62,7 @@ export const PageDetails: React.FC<PageDetailsProps> = ({ id, params }) => {
|
||||||
{(pageUpdate, pageUpdateOpts) => (
|
{(pageUpdate, pageUpdateOpts) => (
|
||||||
<TypedPageDetailsQuery variables={{ id }}>
|
<TypedPageDetailsQuery variables={{ id }}>
|
||||||
{pageDetails => {
|
{pageDetails => {
|
||||||
const handleUpdate = async (data: PageDetailsPageFormData) => {
|
const handleUpdate = async (data: PageData) => {
|
||||||
const result = await pageUpdate({
|
const result = await pageUpdate({
|
||||||
variables: {
|
variables: {
|
||||||
id,
|
id,
|
||||||
|
|
|
@ -19,7 +19,6 @@ import { SearchCategories_search_edges_node } from "@saleor/searches/types/Searc
|
||||||
import { SearchCollections_search_edges_node } from "@saleor/searches/types/SearchCollections";
|
import { SearchCollections_search_edges_node } from "@saleor/searches/types/SearchCollections";
|
||||||
import { SearchProductTypes_search_edges_node } from "@saleor/searches/types/SearchProductTypes";
|
import { SearchProductTypes_search_edges_node } from "@saleor/searches/types/SearchProductTypes";
|
||||||
import { SearchWarehouses_search_edges_node } from "@saleor/searches/types/SearchWarehouses";
|
import { SearchWarehouses_search_edges_node } from "@saleor/searches/types/SearchWarehouses";
|
||||||
import { ContentState, convertToRaw } from "draft-js";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useIntl } from "react-intl";
|
import { useIntl } from "react-intl";
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { OutputData } from "@editorjs/editorjs";
|
|
||||||
import { MetadataFormData } from "@saleor/components/Metadata/types";
|
import { MetadataFormData } from "@saleor/components/Metadata/types";
|
||||||
import { MultiAutocompleteChoiceType } from "@saleor/components/MultiAutocompleteSelectField";
|
import { MultiAutocompleteChoiceType } from "@saleor/components/MultiAutocompleteSelectField";
|
||||||
import { SingleAutocompleteChoiceType } from "@saleor/components/SingleAutocompleteSelectField";
|
import { SingleAutocompleteChoiceType } from "@saleor/components/SingleAutocompleteSelectField";
|
||||||
|
@ -13,7 +12,6 @@ import {
|
||||||
import { SearchProductTypes_search_edges_node_productAttributes } from "@saleor/searches/types/SearchProductTypes";
|
import { SearchProductTypes_search_edges_node_productAttributes } from "@saleor/searches/types/SearchProductTypes";
|
||||||
import { StockInput } from "@saleor/types/globalTypes";
|
import { StockInput } from "@saleor/types/globalTypes";
|
||||||
import { mapMetadataItemToInput } from "@saleor/utils/maps";
|
import { mapMetadataItemToInput } from "@saleor/utils/maps";
|
||||||
import { RawDraftContentState } from "draft-js";
|
|
||||||
|
|
||||||
import { ProductAttributeInput } from "../components/ProductAttributes";
|
import { ProductAttributeInput } from "../components/ProductAttributes";
|
||||||
import { ProductStockInput } from "../components/ProductStocks";
|
import { ProductStockInput } from "../components/ProductStocks";
|
||||||
|
|
Loading…
Reference in a new issue