From c5973620241a97ad4ea95a75d4bd6efb288d5500 Mon Sep 17 00:00:00 2001 From: Magdalena Markusik Date: Thu, 22 Oct 2020 13:03:02 +0200 Subject: [PATCH] Fix product create publication date --- src/collections/views/CollectionCreate.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/collections/views/CollectionCreate.tsx b/src/collections/views/CollectionCreate.tsx index ab2c29615..549a93efc 100644 --- a/src/collections/views/CollectionCreate.tsx +++ b/src/collections/views/CollectionCreate.tsx @@ -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 result = await createCollection({ variables: { @@ -54,18 +62,19 @@ export const CollectionCreate: React.FC = () => { backgroundImage: formData.backgroundImage.value, backgroundImageAlt: formData.backgroundImageAlt, descriptionJson: JSON.stringify(formData.description), - isPublished: formData.isPublished, name: formData.name, seo: { description: formData.seoDescription, title: formData.seoTitle - } + }, + ...getPublicationData(formData) } } }); return result.data?.collectionCreate.collection?.id || null; }; + const handleSubmit = createMetadataCreateHandler( handleCreate, updateMetadata,