[598-33][@ant] feat: SDK-обёртки корзины и checkout (селекторы, queries, mutations) — дать desktop типизированный клиент для работы с корзиной и оформлением заказа
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { marketplaceCartSelector } from '../../selectors/marketplace/cartSelector'
|
||||
import { $, type GraphQLTypes, type InputType, type ModelTypes, Selector } from '../../zeus/index'
|
||||
|
||||
export const name = 'marketplaceAddToCart'
|
||||
|
||||
export const mutation = Selector('Mutation')({
|
||||
[name]: [{ input: $('input', 'MarketplaceAddToCartInput!') }, marketplaceCartSelector],
|
||||
})
|
||||
|
||||
export interface IInput {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
[key: string]: unknown
|
||||
|
||||
input: ModelTypes['MarketplaceAddToCartInput']
|
||||
}
|
||||
|
||||
export type IOutput = InputType<GraphQLTypes['Mutation'], typeof mutation>
|
||||
@@ -0,0 +1,19 @@
|
||||
import { marketplaceCheckoutResultSelector } from '../../selectors/marketplace/cartSelector'
|
||||
import { $, type GraphQLTypes, type InputType, type ModelTypes, Selector } from '../../zeus/index'
|
||||
|
||||
export const name = 'marketplaceCheckoutCart'
|
||||
|
||||
export const mutation = Selector('Mutation')({
|
||||
[name]: [{ input: $('input', 'MarketplaceCheckoutCartInput') }, marketplaceCheckoutResultSelector],
|
||||
})
|
||||
|
||||
export interface IInput {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
[key: string]: unknown
|
||||
|
||||
input?: ModelTypes['MarketplaceCheckoutCartInput']
|
||||
}
|
||||
|
||||
export type IOutput = InputType<GraphQLTypes['Mutation'], typeof mutation>
|
||||
@@ -0,0 +1,8 @@
|
||||
import { marketplaceCartSelector } from '../../selectors/marketplace/cartSelector'
|
||||
import { type GraphQLTypes, type InputType, Selector } from '../../zeus/index'
|
||||
|
||||
export const name = 'marketplaceClearCart'
|
||||
|
||||
export const mutation = Selector('Mutation')({ [name]: marketplaceCartSelector })
|
||||
|
||||
export type IOutput = InputType<GraphQLTypes['Mutation'], typeof mutation>
|
||||
@@ -72,3 +72,15 @@ export * as UpdateOffer from './updateOffer'
|
||||
export * as WithdrawOffer from './withdrawOffer'
|
||||
/** Поставщик возвращает снятый offer на публикацию (WITHDRAWN → PENDING_MODERATION) */
|
||||
export * as RepublishOffer from './republishOffer'
|
||||
/** Эпик 16: добавить товар в корзину (привязка корзины к пункту выдачи) */
|
||||
export * as AddToCart from './addToCart'
|
||||
/** Эпик 16: изменить количество позиции в корзине */
|
||||
export * as UpdateCartItem from './updateCartItem'
|
||||
/** Эпик 16: убрать позицию из корзины */
|
||||
export * as RemoveFromCart from './removeFromCart'
|
||||
/** Эпик 16: очистить корзину */
|
||||
export * as ClearCart from './clearCart'
|
||||
/** Эпик 16: сменить пункт выдачи (КУ) корзины */
|
||||
export * as SetCartDeliveryPoint from './setCartDeliveryPoint'
|
||||
/** Эпик 16: оформить заказ из корзины (per-line, общий checkout_id) */
|
||||
export * as CheckoutCart from './checkoutCart'
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { marketplaceCartSelector } from '../../selectors/marketplace/cartSelector'
|
||||
import { $, type GraphQLTypes, type InputType, type ModelTypes, Selector } from '../../zeus/index'
|
||||
|
||||
export const name = 'marketplaceRemoveFromCart'
|
||||
|
||||
export const mutation = Selector('Mutation')({
|
||||
[name]: [{ input: $('input', 'MarketplaceRemoveFromCartInput!') }, marketplaceCartSelector],
|
||||
})
|
||||
|
||||
export interface IInput {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
[key: string]: unknown
|
||||
|
||||
input: ModelTypes['MarketplaceRemoveFromCartInput']
|
||||
}
|
||||
|
||||
export type IOutput = InputType<GraphQLTypes['Mutation'], typeof mutation>
|
||||
@@ -0,0 +1,19 @@
|
||||
import { marketplaceCartSelector } from '../../selectors/marketplace/cartSelector'
|
||||
import { $, type GraphQLTypes, type InputType, type ModelTypes, Selector } from '../../zeus/index'
|
||||
|
||||
export const name = 'marketplaceSetCartDeliveryPoint'
|
||||
|
||||
export const mutation = Selector('Mutation')({
|
||||
[name]: [{ input: $('input', 'MarketplaceSetCartDeliveryPointInput!') }, marketplaceCartSelector],
|
||||
})
|
||||
|
||||
export interface IInput {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
[key: string]: unknown
|
||||
|
||||
input: ModelTypes['MarketplaceSetCartDeliveryPointInput']
|
||||
}
|
||||
|
||||
export type IOutput = InputType<GraphQLTypes['Mutation'], typeof mutation>
|
||||
@@ -0,0 +1,19 @@
|
||||
import { marketplaceCartSelector } from '../../selectors/marketplace/cartSelector'
|
||||
import { $, type GraphQLTypes, type InputType, type ModelTypes, Selector } from '../../zeus/index'
|
||||
|
||||
export const name = 'marketplaceUpdateCartItem'
|
||||
|
||||
export const mutation = Selector('Mutation')({
|
||||
[name]: [{ input: $('input', 'MarketplaceUpdateCartItemInput!') }, marketplaceCartSelector],
|
||||
})
|
||||
|
||||
export interface IInput {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
[key: string]: unknown
|
||||
|
||||
input: ModelTypes['MarketplaceUpdateCartItemInput']
|
||||
}
|
||||
|
||||
export type IOutput = InputType<GraphQLTypes['Mutation'], typeof mutation>
|
||||
@@ -0,0 +1,8 @@
|
||||
import { marketplaceCartSelector } from '../../selectors/marketplace/cartSelector'
|
||||
import { type GraphQLTypes, type InputType, Selector } from '../../zeus/index'
|
||||
|
||||
export const name = 'marketplaceGetCart'
|
||||
|
||||
export const query = Selector('Query')({ [name]: marketplaceCartSelector })
|
||||
|
||||
export type IOutput = InputType<GraphQLTypes['Query'], typeof query>
|
||||
@@ -76,3 +76,5 @@ export * as GetAvailableCategories from './getAvailableCategories'
|
||||
export * as GetAvailabilityStats from './getAvailabilityStats'
|
||||
/** Эпик 1 / Story 1.4: состояние L3 онбординга пайщика в Marketplace */
|
||||
export * as MarketplaceOnboardingState from './marketplaceOnboardingState'
|
||||
/** Эпик 16: корзина текущего заказчика */
|
||||
export * as GetCart from './getCart'
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
import { Selector, type ValueTypes } from '../../zeus/index'
|
||||
import type { MakeAllFieldsRequired } from '../../utils/MakeAllFieldsRequired'
|
||||
import { rawOrderSelector } from './orderSelector'
|
||||
|
||||
/** Эпик 16: позиция корзины (оффер + кол-во + обогащение для UI). */
|
||||
const rawCartItemSelector = {
|
||||
id: true,
|
||||
offer_id: true,
|
||||
quantity: true,
|
||||
product_name: true,
|
||||
unit_of_measure: true,
|
||||
price_per_unit: true,
|
||||
line_total: true,
|
||||
image_url: true,
|
||||
available_on_current_ku: true,
|
||||
}
|
||||
|
||||
const _validateCartItem: MakeAllFieldsRequired<ValueTypes['MarketplaceCartItem']> = rawCartItemSelector
|
||||
|
||||
/** Эпик 16: корзина заказчика с позициями. */
|
||||
const rawCartSelector = {
|
||||
id: true,
|
||||
delivery_braname: true,
|
||||
delivery_point_name: true,
|
||||
items: rawCartItemSelector,
|
||||
positions_count: true,
|
||||
total_quantity: true,
|
||||
total_cost: true,
|
||||
}
|
||||
|
||||
const _validateCart: MakeAllFieldsRequired<ValueTypes['MarketplaceCart']> = rawCartSelector
|
||||
|
||||
export const marketplaceCartSelector = Selector('MarketplaceCart')(rawCartSelector)
|
||||
|
||||
/** Эпик 16: непрошедшая позиция оформления. */
|
||||
const rawCheckoutFailedLineSelector = {
|
||||
offer_id: true,
|
||||
product_name: true,
|
||||
quantity: true,
|
||||
reason: true,
|
||||
}
|
||||
|
||||
const _validateFailedLine: MakeAllFieldsRequired<ValueTypes['MarketplaceCheckoutFailedLine']> =
|
||||
rawCheckoutFailedLineSelector
|
||||
|
||||
/** Эпик 16: результат оформления заказа из корзины. */
|
||||
const rawCheckoutResultSelector = {
|
||||
checkout_id: true,
|
||||
delivery_braname: true,
|
||||
created_orders: rawOrderSelector,
|
||||
failed_lines: rawCheckoutFailedLineSelector,
|
||||
fully_completed: true,
|
||||
cart: rawCartSelector,
|
||||
}
|
||||
|
||||
const _validateCheckoutResult: MakeAllFieldsRequired<ValueTypes['MarketplaceCheckoutResult']> =
|
||||
rawCheckoutResultSelector
|
||||
|
||||
export const marketplaceCheckoutResultSelector = Selector('MarketplaceCheckoutResult')(
|
||||
rawCheckoutResultSelector
|
||||
)
|
||||
@@ -5,3 +5,4 @@ export * from './offerSelector'
|
||||
export * from './categoryOfferCountSelector'
|
||||
export * from './marketplaceOfferPaginationSelector'
|
||||
export * from './moderationLogEntrySelector'
|
||||
export * from './cartSelector'
|
||||
|
||||
@@ -30,7 +30,7 @@ export const marketplaceOrderIssuanceFactSnapshotSelector = Selector(
|
||||
'MarketplaceOrderIssuanceFactSnapshot',
|
||||
)(rawOrderIssuanceFactSnapshotSelector)
|
||||
|
||||
const rawOrderSelector = {
|
||||
export const rawOrderSelector = {
|
||||
id: true,
|
||||
coopname: true,
|
||||
order_hash: true,
|
||||
|
||||
Reference in New Issue
Block a user