Добавлены модели товаров и корзины для оптовиков, реализованы соответствующие мутации и запросы в GraphQL. Обновлен API для загрузки файлов с учетом новых типов данных. Улучшена обработка ошибок и добавлены новые функции для работы с категориями товаров.
This commit is contained in:
@ -634,4 +634,187 @@ export const DELETE_SUPPLY = gql`
|
||||
mutation DeleteSupply($id: ID!) {
|
||||
deleteSupply(id: $id)
|
||||
}
|
||||
`
|
||||
`
|
||||
|
||||
// Мутации для товаров оптовика
|
||||
export const CREATE_PRODUCT = gql`
|
||||
mutation CreateProduct($input: ProductInput!) {
|
||||
createProduct(input: $input) {
|
||||
success
|
||||
message
|
||||
product {
|
||||
id
|
||||
name
|
||||
article
|
||||
description
|
||||
price
|
||||
quantity
|
||||
category {
|
||||
id
|
||||
name
|
||||
}
|
||||
brand
|
||||
color
|
||||
size
|
||||
weight
|
||||
dimensions
|
||||
material
|
||||
images
|
||||
mainImage
|
||||
isActive
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const UPDATE_PRODUCT = gql`
|
||||
mutation UpdateProduct($id: ID!, $input: ProductInput!) {
|
||||
updateProduct(id: $id, input: $input) {
|
||||
success
|
||||
message
|
||||
product {
|
||||
id
|
||||
name
|
||||
article
|
||||
description
|
||||
price
|
||||
quantity
|
||||
category {
|
||||
id
|
||||
name
|
||||
}
|
||||
brand
|
||||
color
|
||||
size
|
||||
weight
|
||||
dimensions
|
||||
material
|
||||
images
|
||||
mainImage
|
||||
isActive
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const DELETE_PRODUCT = gql`
|
||||
mutation DeleteProduct($id: ID!) {
|
||||
deleteProduct(id: $id)
|
||||
}
|
||||
`
|
||||
|
||||
// Мутации для корзины
|
||||
export const ADD_TO_CART = gql`
|
||||
mutation AddToCart($productId: ID!, $quantity: Int = 1) {
|
||||
addToCart(productId: $productId, quantity: $quantity) {
|
||||
success
|
||||
message
|
||||
cart {
|
||||
id
|
||||
totalPrice
|
||||
totalItems
|
||||
items {
|
||||
id
|
||||
quantity
|
||||
totalPrice
|
||||
isAvailable
|
||||
availableQuantity
|
||||
product {
|
||||
id
|
||||
name
|
||||
article
|
||||
price
|
||||
quantity
|
||||
images
|
||||
mainImage
|
||||
organization {
|
||||
id
|
||||
name
|
||||
fullName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const UPDATE_CART_ITEM = gql`
|
||||
mutation UpdateCartItem($productId: ID!, $quantity: Int!) {
|
||||
updateCartItem(productId: $productId, quantity: $quantity) {
|
||||
success
|
||||
message
|
||||
cart {
|
||||
id
|
||||
totalPrice
|
||||
totalItems
|
||||
items {
|
||||
id
|
||||
quantity
|
||||
totalPrice
|
||||
isAvailable
|
||||
availableQuantity
|
||||
product {
|
||||
id
|
||||
name
|
||||
article
|
||||
price
|
||||
quantity
|
||||
images
|
||||
mainImage
|
||||
organization {
|
||||
id
|
||||
name
|
||||
fullName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const REMOVE_FROM_CART = gql`
|
||||
mutation RemoveFromCart($productId: ID!) {
|
||||
removeFromCart(productId: $productId) {
|
||||
success
|
||||
message
|
||||
cart {
|
||||
id
|
||||
totalPrice
|
||||
totalItems
|
||||
items {
|
||||
id
|
||||
quantity
|
||||
totalPrice
|
||||
isAvailable
|
||||
availableQuantity
|
||||
product {
|
||||
id
|
||||
name
|
||||
article
|
||||
price
|
||||
quantity
|
||||
images
|
||||
mainImage
|
||||
organization {
|
||||
id
|
||||
name
|
||||
fullName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const CLEAR_CART = gql`
|
||||
mutation ClearCart {
|
||||
clearCart
|
||||
}
|
||||
`
|
Reference in New Issue
Block a user