import { gql } from 'graphql-tag' export const SEND_SMS_CODE = gql` mutation SendSmsCode($phone: String!) { sendSmsCode(phone: $phone) { success message } } ` export const VERIFY_SMS_CODE = gql` mutation VerifySmsCode($phone: String!, $code: String!) { verifySmsCode(phone: $phone, code: $code) { success message token user { id phone organization { id inn kpp name fullName address addressFull ogrn ogrnDate type status actualityDate registrationDate liquidationDate managementName managementPost opfCode opfFull opfShort okato oktmo okpo okved employeeCount revenue taxSystem phones emails apiKeys { id marketplace isActive } } } } } ` export const VERIFY_INN = gql` mutation VerifyInn($inn: String!) { verifyInn(inn: $inn) { success message organization { name fullName address isActive } } } ` export const REGISTER_FULFILLMENT_ORGANIZATION = gql` mutation RegisterFulfillmentOrganization($input: FulfillmentRegistrationInput!) { registerFulfillmentOrganization(input: $input) { success message user { id phone organization { id inn kpp name fullName address addressFull ogrn ogrnDate type status actualityDate registrationDate liquidationDate managementName managementPost opfCode opfFull opfShort okato oktmo okpo okved employeeCount revenue taxSystem phones emails apiKeys { id marketplace isActive } referralPoints } } } } ` export const REGISTER_SELLER_ORGANIZATION = gql` mutation RegisterSellerOrganization($input: SellerRegistrationInput!) { registerSellerOrganization(input: $input) { success message user { id phone organization { id inn kpp name fullName address addressFull ogrn ogrnDate type status actualityDate registrationDate liquidationDate managementName managementPost opfCode opfFull opfShort okato oktmo okpo okved employeeCount revenue taxSystem phones emails apiKeys { id marketplace isActive } referralPoints } } } } ` export const ADD_MARKETPLACE_API_KEY = gql` mutation AddMarketplaceApiKey($input: MarketplaceApiKeyInput!) { addMarketplaceApiKey(input: $input) { success message apiKey { id marketplace apiKey isActive validationData } } } ` export const REMOVE_MARKETPLACE_API_KEY = gql` mutation RemoveMarketplaceApiKey($marketplace: MarketplaceType!) { removeMarketplaceApiKey(marketplace: $marketplace) } ` export const UPDATE_USER_PROFILE = gql` mutation UpdateUserProfile($input: UpdateUserProfileInput!) { updateUserProfile(input: $input) { success message user { id phone avatar managerName organization { id inn kpp name fullName address addressFull ogrn ogrnDate type market status actualityDate registrationDate liquidationDate managementName managementPost opfCode opfFull opfShort okato oktmo okpo okved employeeCount revenue taxSystem phones emails apiKeys { id marketplace isActive } } } } } ` export const UPDATE_ORGANIZATION_BY_INN = gql` mutation UpdateOrganizationByInn($inn: String!) { updateOrganizationByInn(inn: $inn) { success message user { id phone organization { id inn kpp name fullName address addressFull ogrn ogrnDate type status actualityDate registrationDate liquidationDate managementName managementPost opfCode opfFull opfShort okato oktmo okpo okved employeeCount revenue taxSystem phones emails apiKeys { id marketplace isActive } } } } } ` // Мутации для контрагентов export const SEND_COUNTERPARTY_REQUEST = gql` mutation SendCounterpartyRequest($organizationId: ID!, $message: String) { sendCounterpartyRequest(organizationId: $organizationId, message: $message) { success message request { id status message createdAt sender { id inn name fullName type } receiver { id inn name fullName type } } } } ` export const RESPOND_TO_COUNTERPARTY_REQUEST = gql` mutation RespondToCounterpartyRequest($requestId: ID!, $accept: Boolean!) { respondToCounterpartyRequest(requestId: $requestId, accept: $accept) { success message request { id status message createdAt sender { id inn name fullName type } receiver { id inn name fullName type } } } } ` export const CANCEL_COUNTERPARTY_REQUEST = gql` mutation CancelCounterpartyRequest($requestId: ID!) { cancelCounterpartyRequest(requestId: $requestId) } ` export const REMOVE_COUNTERPARTY = gql` mutation RemoveCounterparty($organizationId: ID!) { removeCounterparty(organizationId: $organizationId) } ` // Автоматическое создание записи в таблице склада при новом партнерстве export const AUTO_CREATE_WAREHOUSE_ENTRY = gql` mutation AutoCreateWarehouseEntry($partnerId: ID!) { autoCreateWarehouseEntry(partnerId: $partnerId) { success message warehouseEntry { id storeName storeOwner storeImage storeQuantity partnershipDate } } } ` // Мутации для сообщений export const SEND_MESSAGE = gql` mutation SendMessage($receiverOrganizationId: ID!, $content: String!, $type: MessageType = TEXT) { sendMessage(receiverOrganizationId: $receiverOrganizationId, content: $content, type: $type) { success message messageData { id content type voiceUrl voiceDuration fileUrl fileName fileSize fileType senderId senderOrganization { id name fullName type users { id avatar managerName } } receiverOrganization { id name fullName type users { id avatar managerName } } isRead createdAt updatedAt } } } ` export const SEND_VOICE_MESSAGE = gql` mutation SendVoiceMessage($receiverOrganizationId: ID!, $voiceUrl: String!, $voiceDuration: Int!) { sendVoiceMessage( receiverOrganizationId: $receiverOrganizationId voiceUrl: $voiceUrl voiceDuration: $voiceDuration ) { success message messageData { id content type voiceUrl voiceDuration fileUrl fileName fileSize fileType senderId senderOrganization { id name fullName type users { id avatar managerName } } receiverOrganization { id name fullName type users { id avatar managerName } } isRead createdAt updatedAt } } } ` export const SEND_IMAGE_MESSAGE = gql` mutation SendImageMessage( $receiverOrganizationId: ID! $fileUrl: String! $fileName: String! $fileSize: Int! $fileType: String! ) { sendImageMessage( receiverOrganizationId: $receiverOrganizationId fileUrl: $fileUrl fileName: $fileName fileSize: $fileSize fileType: $fileType ) { success message messageData { id content type voiceUrl voiceDuration fileUrl fileName fileSize fileType senderId senderOrganization { id name fullName type users { id avatar managerName } } receiverOrganization { id name fullName type users { id avatar managerName } } isRead createdAt updatedAt } } } ` export const SEND_FILE_MESSAGE = gql` mutation SendFileMessage( $receiverOrganizationId: ID! $fileUrl: String! $fileName: String! $fileSize: Int! $fileType: String! ) { sendFileMessage( receiverOrganizationId: $receiverOrganizationId fileUrl: $fileUrl fileName: $fileName fileSize: $fileSize fileType: $fileType ) { success message messageData { id content type voiceUrl voiceDuration fileUrl fileName fileSize fileType senderId senderOrganization { id name fullName type users { id avatar managerName } } receiverOrganization { id name fullName type users { id avatar managerName } } isRead createdAt updatedAt } } } ` export const MARK_MESSAGES_AS_READ = gql` mutation MarkMessagesAsRead($conversationId: ID!) { markMessagesAsRead(conversationId: $conversationId) } ` // Мутации для услуг export const CREATE_SERVICE = gql` mutation CreateService($input: ServiceInput!) { createService(input: $input) { success message service { id name description price imageUrl createdAt updatedAt } } } ` export const UPDATE_SERVICE = gql` mutation UpdateService($id: ID!, $input: ServiceInput!) { updateService(id: $id, input: $input) { success message service { id name description price imageUrl createdAt updatedAt } } } ` export const DELETE_SERVICE = gql` mutation DeleteService($id: ID!) { deleteService(id: $id) } ` // Мутации для расходников - только обновление цены разрешено export const UPDATE_SUPPLY_PRICE = gql` mutation UpdateSupplyPrice($id: ID!, $input: UpdateSupplyPriceInput!) { updateSupplyPrice(id: $id, input: $input) { success message supply { id name article description pricePerUnit unit imageUrl warehouseStock isAvailable warehouseConsumableId createdAt updatedAt organization { id name } } } } ` // Мутация для заказа поставки товаров с поддержкой многоуровневой системы export const CREATE_SUPPLY_ORDER = gql` mutation CreateSupplyOrder($input: SupplyOrderInput!) { createSupplyOrder(input: $input) { success message order { id partnerId deliveryDate status totalAmount totalItems fulfillmentCenterId logisticsPartnerId # Новые поля для многоуровневой системы packagesCount volume responsibleEmployee notes createdAt updatedAt partner { id inn name fullName address market } fulfillmentCenter { id name fullName address } logisticsPartner { id name fullName } employee { id firstName lastName position department } # Маршруты поставки routes { id logisticsId fromLocation toLocation fromAddress toAddress distance estimatedTime price status createdDate logistics { id fromLocation toLocation priceUnder1m3 priceOver1m3 description } } items { id quantity price totalPrice recipe { services { id name description price } fulfillmentConsumables { id name description pricePerUnit unit imageUrl organization { id name } } sellerConsumables { id name description price unit } marketplaceCardId } product { id name article description price quantity images mainImage category { id name } } } } } } ` // Мутация для назначения логистики на поставку фулфилментом export const ASSIGN_LOGISTICS_TO_SUPPLY = gql` mutation AssignLogisticsToSupply($supplyOrderId: ID!, $logisticsPartnerId: ID!, $responsibleId: ID) { assignLogisticsToSupply( supplyOrderId: $supplyOrderId logisticsPartnerId: $logisticsPartnerId responsibleId: $responsibleId ) { success message order { id status logisticsPartnerId responsibleId logisticsPartner { id name fullName type } responsible { id firstName lastName email } } } } ` // Мутации для логистики export const CREATE_LOGISTICS = gql` mutation CreateLogistics($input: LogisticsInput!) { createLogistics(input: $input) { success message logistics { id fromLocation toLocation priceUnder1m3 priceOver1m3 description createdAt updatedAt organization { id name fullName } } } } ` export const UPDATE_LOGISTICS = gql` mutation UpdateLogistics($id: ID!, $input: LogisticsInput!) { updateLogistics(id: $id, input: $input) { success message logistics { id fromLocation toLocation priceUnder1m3 priceOver1m3 description createdAt updatedAt organization { id name fullName } } } } ` export const DELETE_LOGISTICS = gql` mutation DeleteLogistics($id: ID!) { deleteLogistics(id: $id) } ` // Мутации для товаров поставщика export const CREATE_PRODUCT = gql` mutation CreateProduct($input: ProductInput!) { createProduct(input: $input) { success message product { id name article description price pricePerSet quantity setQuantity ordered inTransit stock sold type category { id name } brand color size weight dimensions material images mainImage isActive createdAt updatedAt organization { id market } } } } ` export const UPDATE_PRODUCT = gql` mutation UpdateProduct($id: ID!, $input: ProductInput!) { updateProduct(id: $id, input: $input) { success message product { id name article description price pricePerSet quantity setQuantity ordered inTransit stock sold type category { id name } brand color size weight dimensions material images mainImage isActive createdAt updatedAt organization { id market } } } } ` export const DELETE_PRODUCT = gql` mutation DeleteProduct($id: ID!) { deleteProduct(id: $id) } ` // Мутация для проверки уникальности артикула export const CHECK_ARTICLE_UNIQUENESS = gql` mutation CheckArticleUniqueness($article: String!, $excludeId: ID) { checkArticleUniqueness(article: $article, excludeId: $excludeId) { isUnique existingProduct { id name article } } } ` // Мутация для резервирования товара (при заказе) export const RESERVE_PRODUCT_STOCK = gql` mutation ReserveProductStock($productId: ID!, $quantity: Int!) { reserveProductStock(productId: $productId, quantity: $quantity) { success message product { id quantity ordered stock } } } ` // Мутация для освобождения резерва (при отмене заказа) export const RELEASE_PRODUCT_RESERVE = gql` mutation ReleaseProductReserve($productId: ID!, $quantity: Int!) { releaseProductReserve(productId: $productId, quantity: $quantity) { success message product { id quantity ordered stock } } } ` // Мутация для обновления статуса "в пути" export const UPDATE_PRODUCT_IN_TRANSIT = gql` mutation UpdateProductInTransit($productId: ID!, $quantity: Int!, $operation: String!) { updateProductInTransit(productId: $productId, quantity: $quantity, operation: $operation) { success message product { id quantity ordered inTransit stock } } } ` // Мутации для корзины 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 } ` // Мутации для избранного export const ADD_TO_FAVORITES = gql` mutation AddToFavorites($productId: ID!) { addToFavorites(productId: $productId) { success message favorites { id name article price quantity images mainImage category { id name } organization { id name fullName inn } } } } ` export const REMOVE_FROM_FAVORITES = gql` mutation RemoveFromFavorites($productId: ID!) { removeFromFavorites(productId: $productId) { success message favorites { id name article price quantity images mainImage category { id name } organization { id name fullName inn } } } } ` // Мутации для внешней рекламы export const CREATE_EXTERNAL_AD = gql` mutation CreateExternalAd($input: ExternalAdInput!) { createExternalAd(input: $input) { success message externalAd { id name url cost date nmId clicks organizationId createdAt updatedAt } } } ` export const UPDATE_EXTERNAL_AD = gql` mutation UpdateExternalAd($id: ID!, $input: ExternalAdInput!) { updateExternalAd(id: $id, input: $input) { success message externalAd { id name url cost date nmId clicks organizationId createdAt updatedAt } } } ` export const DELETE_EXTERNAL_AD = gql` mutation DeleteExternalAd($id: ID!) { deleteExternalAd(id: $id) { success message externalAd { id } } } ` export const UPDATE_EXTERNAL_AD_CLICKS = gql` mutation UpdateExternalAdClicks($id: ID!, $clicks: Int!) { updateExternalAdClicks(id: $id, clicks: $clicks) { success message } } ` // Мутации для категорий export const CREATE_CATEGORY = gql` mutation CreateCategory($input: CategoryInput!) { createCategory(input: $input) { success message category { id name createdAt updatedAt } } } ` export const UPDATE_CATEGORY = gql` mutation UpdateCategory($id: ID!, $input: CategoryInput!) { updateCategory(id: $id, input: $input) { success message category { id name createdAt updatedAt } } } ` export const DELETE_CATEGORY = gql` mutation DeleteCategory($id: ID!) { deleteCategory(id: $id) } ` // Мутации для сотрудников export const CREATE_EMPLOYEE = gql` mutation CreateEmployee($input: CreateEmployeeInput!) { createEmployee(input: $input) { success message employee { id firstName lastName middleName birthDate avatar position department hireDate salary status phone email emergencyContact emergencyPhone createdAt updatedAt } } } ` export const UPDATE_EMPLOYEE = gql` mutation UpdateEmployee($id: ID!, $input: UpdateEmployeeInput!) { updateEmployee(id: $id, input: $input) { success message employee { id firstName lastName middleName birthDate avatar passportSeries passportNumber passportIssued passportDate address position department hireDate salary status phone email emergencyContact emergencyPhone createdAt updatedAt } } } ` export const DELETE_EMPLOYEE = gql` mutation DeleteEmployee($id: ID!) { deleteEmployee(id: $id) } ` export const UPDATE_EMPLOYEE_SCHEDULE = gql` mutation UpdateEmployeeSchedule($input: UpdateScheduleInput!) { updateEmployeeSchedule(input: $input) } ` export const CREATE_WILDBERRIES_SUPPLY = gql` mutation CreateWildberriesSupply($input: CreateWildberriesSupplyInput!) { createWildberriesSupply(input: $input) { success message supply { id deliveryDate status totalAmount totalItems createdAt } } } ` // Админ мутации export const ADMIN_LOGIN = gql` mutation AdminLogin($username: String!, $password: String!) { adminLogin(username: $username, password: $password) { success message token admin { id username email isActive lastLogin createdAt updatedAt } } } ` export const ADMIN_LOGOUT = gql` mutation AdminLogout { adminLogout } ` export const CREATE_SUPPLY_SUPPLIER = gql` mutation CreateSupplySupplier($input: CreateSupplySupplierInput!) { createSupplySupplier(input: $input) { success message supplier { id name contactName phone market address place telegram createdAt } } } ` // Мутация для обновления статуса заказа поставки export const UPDATE_SUPPLY_ORDER_STATUS = gql` mutation UpdateSupplyOrderStatus($id: ID!, $status: SupplyOrderStatus!) { updateSupplyOrderStatus(id: $id, status: $status) { success message order { id status deliveryDate totalAmount totalItems partner { id name fullName } items { id quantity price totalPrice product { id name article description price quantity images mainImage category { id name } } } } } } ` // Мутации для кеша склада WB export const SAVE_WB_WAREHOUSE_CACHE = gql` mutation SaveWBWarehouseCache($input: WBWarehouseCacheInput!) { saveWBWarehouseCache(input: $input) { success message fromCache cache { id organizationId cacheDate data totalProducts totalStocks totalReserved createdAt updatedAt } } } ` // Мутации для кеша статистики продаж export const SAVE_SELLER_STATS_CACHE = gql` mutation SaveSellerStatsCache($input: SellerStatsCacheInput!) { saveSellerStatsCache(input: $input) { success message cache { id organizationId cacheDate period dateFrom dateTo productsData productsTotalSales productsTotalOrders productsCount advertisingData advertisingTotalCost advertisingTotalViews advertisingTotalClicks expiresAt createdAt updatedAt } } } ` // Новые мутации для управления заказами поставок export const SUPPLIER_APPROVE_ORDER = gql` mutation SupplierApproveOrder($id: ID!) { supplierApproveOrder(id: $id) { success message order { id status deliveryDate totalAmount totalItems partner { id name fullName } logisticsPartner { id name fullName } } } } ` export const SUPPLIER_REJECT_ORDER = gql` mutation SupplierRejectOrder($id: ID!, $reason: String) { supplierRejectOrder(id: $id, reason: $reason) { success message order { id status } } } ` export const SUPPLIER_SHIP_ORDER = gql` mutation SupplierShipOrder($id: ID!) { supplierShipOrder(id: $id) { success message order { id status deliveryDate partner { id name fullName } logisticsPartner { id name fullName } } } } ` export const LOGISTICS_CONFIRM_ORDER = gql` mutation LogisticsConfirmOrder($id: ID!) { logisticsConfirmOrder(id: $id) { success message order { id status deliveryDate partner { id name fullName } logisticsPartner { id name fullName } } } } ` export const LOGISTICS_REJECT_ORDER = gql` mutation LogisticsRejectOrder($id: ID!, $reason: String) { logisticsRejectOrder(id: $id, reason: $reason) { success message order { id status } } } ` export const FULFILLMENT_RECEIVE_ORDER = gql` mutation FulfillmentReceiveOrder($id: ID!) { fulfillmentReceiveOrder(id: $id) { success message order { id status deliveryDate totalAmount totalItems partner { id name fullName } logisticsPartner { id name fullName } } } } `