Merge pull request #789 from mirumee/fix-collection-published-date
Fix product create isPublished
This commit is contained in:
commit
09a19c1b6b
1 changed files with 11 additions and 2 deletions
|
@ -47,6 +47,14 @@ export const CollectionCreate: React.FC = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const getPublicationData = ({
|
||||||
|
publicationDate,
|
||||||
|
isPublished
|
||||||
|
}: CollectionCreatePageFormData) => ({
|
||||||
|
isPublished: !!publicationDate || isPublished,
|
||||||
|
publicationDate: publicationDate || null
|
||||||
|
});
|
||||||
|
|
||||||
const handleCreate = async (formData: CollectionCreatePageFormData) => {
|
const handleCreate = async (formData: CollectionCreatePageFormData) => {
|
||||||
const result = await createCollection({
|
const result = await createCollection({
|
||||||
variables: {
|
variables: {
|
||||||
|
@ -54,18 +62,19 @@ export const CollectionCreate: React.FC = () => {
|
||||||
backgroundImage: formData.backgroundImage.value,
|
backgroundImage: formData.backgroundImage.value,
|
||||||
backgroundImageAlt: formData.backgroundImageAlt,
|
backgroundImageAlt: formData.backgroundImageAlt,
|
||||||
descriptionJson: JSON.stringify(formData.description),
|
descriptionJson: JSON.stringify(formData.description),
|
||||||
isPublished: formData.isPublished,
|
|
||||||
name: formData.name,
|
name: formData.name,
|
||||||
seo: {
|
seo: {
|
||||||
description: formData.seoDescription,
|
description: formData.seoDescription,
|
||||||
title: formData.seoTitle
|
title: formData.seoTitle
|
||||||
}
|
},
|
||||||
|
...getPublicationData(formData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return result.data?.collectionCreate.collection?.id || null;
|
return result.data?.collectionCreate.collection?.id || null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = createMetadataCreateHandler(
|
const handleSubmit = createMetadataCreateHandler(
|
||||||
handleCreate,
|
handleCreate,
|
||||||
updateMetadata,
|
updateMetadata,
|
||||||
|
|
Loading…
Reference in a new issue