diff --git a/.changeset/selfish-swans-turn.md b/.changeset/selfish-swans-turn.md new file mode 100644 index 00000000000..b2c0f2027ec --- /dev/null +++ b/.changeset/selfish-swans-turn.md @@ -0,0 +1,5 @@ +--- +"saleor-dashboard": patch +--- + +After creating a new collection, you should see a list of assigned channels diff --git a/src/collections/views/CollectionCreate.tsx b/src/collections/views/CollectionCreate.tsx index 4cc8fc4dfe3..a79db066b10 100644 --- a/src/collections/views/CollectionCreate.tsx +++ b/src/collections/views/CollectionCreate.tsx @@ -63,28 +63,7 @@ export const CollectionCreate: React.FC = ({ params }) => { closeModal, openModal }, { formId: COLLECTION_CREATE_FORM_ID }, ); - const [createCollection, createCollectionOpts] = useCreateCollectionMutation({ - onCompleted: data => { - if (data.collectionCreate.errors.length === 0) { - notify({ - status: "success", - text: intl.formatMessage(commonMessages.savedChanges), - }); - navigate(collectionUrl(data.collectionCreate.collection.id)); - } else { - const backgroundImageError = data.collectionCreate.errors.find( - error => error.field === ("backgroundImage" as keyof CollectionCreateInput), - ); - - if (backgroundImageError) { - notify({ - status: "error", - text: intl.formatMessage(commonMessages.somethingWentWrong), - }); - } - } - }, - }); + const [createCollection, createCollectionOpts] = useCreateCollectionMutation({}); const handleCreate = async (formData: CollectionCreateData) => { const result = await createCollection({ variables: { @@ -103,7 +82,7 @@ export const CollectionCreate: React.FC = ({ params }) => const id = result.data?.collectionCreate.collection?.id || null; if (id) { - updateChannels({ + await updateChannels({ variables: { id, input: { @@ -118,6 +97,25 @@ export const CollectionCreate: React.FC = ({ params }) => }); } + if (result.data.collectionCreate.errors.length === 0) { + notify({ + status: "success", + text: intl.formatMessage(commonMessages.savedChanges), + }); + navigate(collectionUrl(id)); + } else { + const backgroundImageError = result.data.collectionCreate.errors.find( + error => error.field === ("backgroundImage" as keyof CollectionCreateInput), + ); + + if (backgroundImageError) { + notify({ + status: "error", + text: intl.formatMessage(commonMessages.somethingWentWrong), + }); + } + } + return { id, errors: getMutationErrors(result) }; }; const handleSubmit = createMetadataCreateHandler(