saleor-dashboard/src/attributes/mutations.ts
Dawid Tarasiuk fc02fce701
Page types (#807)
* Create attribute class selector

* Use ProductAttributeType to check if product is simple or with variants

* Allow attribute class selection only during its creation

* Update attribute type selection translations

* Show only product attributes in columns picker on product list view

* Cleanups in Attribute Organization component

* Create Page Types list page

* Create content management section in settings

* Implement page types list view

* Remove unused imports from page type list

* Updatte page type list style

* Remove legacy code from page type list component

* Update PageTypeListPage component

* Create Page Types details page

* Fix page type attribute reordering

* Implement PageType create view

* Implement PageType update view

* gUpdate page type details components

* Fix page type update component

* Update page type components stories

* Update page type errors handling

* Update page type details view

* Create Page Types details page

* Implement PageType create view

* Update product attribute assignment mutations

* Add page types attribute assignment mutations

* Add page types attribute assignment handling

* Temporarily fix page create mutation

* Update page type error messages

* Remove legacy storybook page type stories

* Update attribute assignment dialogs stories

* Update page type details error handling

* Update props for page type components

* Create attribute class selector

* Implement page types list view

* Add page type selector on page create and details views

* Add attributes list to page details views

* Update page types list

* Use attribute errors for attributes muatations

* Save attribute values on page create and update

* Update messages for page view

* Update page attributes fragment

* Use AttributeError in AttributeBulkDelete

* Update page type and its attribute selection

* Handle page types deleting

* Update page types deleting messages

* Handle page types attribute reorder

* Fix PageOrganizeContent component types

* Update graphqql types

* Fix page fixture

* Update messages

* Update test snapshots

* Pass pageTypes to PageForm

* Update changelog with page type addition note

* Update package-lock

* Update test snapshots

* Fix malformed generated type

* Update messages after rebase
2020-11-19 15:42:14 +01:00

183 lines
4.7 KiB
TypeScript

import { attributeDetailsFragment } from "@saleor/fragments/attributes";
import { attributeErrorFragment } from "@saleor/fragments/errors";
import makeMutation from "@saleor/hooks/makeMutation";
import gql from "graphql-tag";
import {
AttributeBulkDelete,
AttributeBulkDeleteVariables
} from "./types/AttributeBulkDelete";
import {
AttributeCreate,
AttributeCreateVariables
} from "./types/AttributeCreate";
import {
AttributeDelete,
AttributeDeleteVariables
} from "./types/AttributeDelete";
import {
AttributeUpdate,
AttributeUpdateVariables
} from "./types/AttributeUpdate";
import {
AttributeValueCreate,
AttributeValueCreateVariables
} from "./types/AttributeValueCreate";
import {
AttributeValueDelete,
AttributeValueDeleteVariables
} from "./types/AttributeValueDelete";
import {
AttributeValueReorder,
AttributeValueReorderVariables
} from "./types/AttributeValueReorder";
import {
AttributeValueUpdate,
AttributeValueUpdateVariables
} from "./types/AttributeValueUpdate";
const attributeBulkDelete = gql`
${attributeErrorFragment}
mutation AttributeBulkDelete($ids: [ID!]!) {
attributeBulkDelete(ids: $ids) {
errors: attributeErrors {
...AttributeErrorFragment
}
}
}
`;
export const useAttributeBulkDeleteMutation = makeMutation<
AttributeBulkDelete,
AttributeBulkDeleteVariables
>(attributeBulkDelete);
const attributeDelete = gql`
${attributeErrorFragment}
mutation AttributeDelete($id: ID!) {
attributeDelete(id: $id) {
errors: attributeErrors {
...AttributeErrorFragment
}
}
}
`;
export const useAttributeDeleteMutation = makeMutation<
AttributeDelete,
AttributeDeleteVariables
>(attributeDelete);
export const attributeUpdateMutation = gql`
${attributeDetailsFragment}
${attributeErrorFragment}
mutation AttributeUpdate($id: ID!, $input: AttributeUpdateInput!) {
attributeUpdate(id: $id, input: $input) {
attribute {
...AttributeDetailsFragment
}
errors: attributeErrors {
...AttributeErrorFragment
}
}
}
`;
export const useAttributeUpdateMutation = makeMutation<
AttributeUpdate,
AttributeUpdateVariables
>(attributeUpdateMutation);
const attributeValueDelete = gql`
${attributeDetailsFragment}
${attributeErrorFragment}
mutation AttributeValueDelete($id: ID!) {
attributeValueDelete(id: $id) {
attribute {
...AttributeDetailsFragment
}
errors: attributeErrors {
...AttributeErrorFragment
}
}
}
`;
export const useAttributeValueDeleteMutation = makeMutation<
AttributeValueDelete,
AttributeValueDeleteVariables
>(attributeValueDelete);
export const attributeValueUpdateMutation = gql`
${attributeDetailsFragment}
${attributeErrorFragment}
mutation AttributeValueUpdate($id: ID!, $input: AttributeValueCreateInput!) {
attributeValueUpdate(id: $id, input: $input) {
attribute {
...AttributeDetailsFragment
}
errors: attributeErrors {
...AttributeErrorFragment
}
}
}
`;
export const useAttributeValueUpdateMutation = makeMutation<
AttributeValueUpdate,
AttributeValueUpdateVariables
>(attributeValueUpdateMutation);
export const attributeValueCreateMutation = gql`
${attributeDetailsFragment}
${attributeErrorFragment}
mutation AttributeValueCreate($id: ID!, $input: AttributeValueCreateInput!) {
attributeValueCreate(attribute: $id, input: $input) {
attribute {
...AttributeDetailsFragment
}
errors: attributeErrors {
...AttributeErrorFragment
}
}
}
`;
export const useAttributeValueCreateMutation = makeMutation<
AttributeValueCreate,
AttributeValueCreateVariables
>(attributeValueCreateMutation);
export const attributeCreateMutation = gql`
${attributeDetailsFragment}
${attributeErrorFragment}
mutation AttributeCreate($input: AttributeCreateInput!) {
attributeCreate(input: $input) {
attribute {
...AttributeDetailsFragment
}
errors: attributeErrors {
...AttributeErrorFragment
}
}
}
`;
export const useAttributeCreateMutation = makeMutation<
AttributeCreate,
AttributeCreateVariables
>(attributeCreateMutation);
const attributeValueReorderMutation = gql`
${attributeErrorFragment}
mutation AttributeValueReorder($id: ID!, $move: ReorderInput!) {
attributeReorderValues(attributeId: $id, moves: [$move]) {
attribute {
id
values {
id
}
}
errors: attributeErrors {
...AttributeErrorFragment
}
}
}
`;
export const useAttributeValueReorderMutation = makeMutation<
AttributeValueReorder,
AttributeValueReorderVariables
>(attributeValueReorderMutation);