Back cart with GraphQL storage

This commit is contained in:
Ruslan Bakiev
2026-04-04 09:08:51 +07:00
parent f1ee0850c9
commit 264b88bcee
10 changed files with 644 additions and 68 deletions

View File

@@ -62,6 +62,30 @@ export type BonusTransaction = {
userId: Scalars['ID']['output'];
};
export type Cart = {
__typename?: 'Cart';
createdAt: Scalars['DateTime']['output'];
deliveryAddress?: Maybe<DeliveryAddress>;
deliveryAddressId?: Maybe<Scalars['ID']['output']>;
id: Scalars['ID']['output'];
items: Array<CartItem>;
updatedAt: Scalars['DateTime']['output'];
userId: Scalars['ID']['output'];
};
export type CartItem = {
__typename?: 'CartItem';
createdAt: Scalars['DateTime']['output'];
id: Scalars['ID']['output'];
isCustomizable: Scalars['Boolean']['output'];
parameters: Scalars['JSON']['output'];
productId: Scalars['ID']['output'];
productName: Scalars['String']['output'];
quantity: Scalars['Float']['output'];
sku: Scalars['String']['output'];
updatedAt: Scalars['DateTime']['output'];
};
export type Company = {
__typename?: 'Company';
id: Scalars['ID']['output'];
@@ -180,7 +204,9 @@ export type Mutation = {
__typename?: 'Mutation';
acceptInvitation: User;
addBonusTransaction: BonusTransaction;
addProductToCart: Cart;
blockOrder: Order;
clearCart: Cart;
clientReviewOrder: Order;
completeOrder: Order;
connectMessenger: MessengerConnection;
@@ -192,15 +218,18 @@ export type Mutation = {
managerFinalizeOrder: Order;
managerSetOrderOffer: Order;
registerSelf: RegistrationRequest;
removeCartItem: Cart;
requestLoginCode: AuthCodeRequestResult;
requestRewardWithdrawal: RewardWithdrawalRequest;
reviewRegistrationRequest: RegistrationRequest;
reviewRewardWithdrawal: RewardWithdrawalRequest;
sendTestMessengerMessage: MessengerDispatchResult;
setCartDeliveryAddress: Cart;
setMyDefaultDeliveryAddress: DeliveryAddress;
startOrderWork: Order;
submitCalculationOrder: Order;
submitReadyOrder: Order;
updateCartItemQuantity: Cart;
upsertMyCounterpartyProfile: CounterpartyProfile;
verifyLoginCode: AuthSession;
};
@@ -216,6 +245,11 @@ export type MutationAddBonusTransactionArgs = {
};
export type MutationAddProductToCartArgs = {
productId: Scalars['ID']['input'];
};
export type MutationBlockOrderArgs = {
input: BlockOrderInput;
};
@@ -278,6 +312,11 @@ export type MutationRegisterSelfArgs = {
};
export type MutationRemoveCartItemArgs = {
productId: Scalars['ID']['input'];
};
export type MutationRequestLoginCodeArgs = {
input: RequestLoginCodeInput;
};
@@ -305,6 +344,11 @@ export type MutationSendTestMessengerMessageArgs = {
};
export type MutationSetCartDeliveryAddressArgs = {
addressId?: InputMaybe<Scalars['ID']['input']>;
};
export type MutationSetMyDefaultDeliveryAddressArgs = {
addressId: Scalars['ID']['input'];
};
@@ -325,6 +369,11 @@ export type MutationSubmitReadyOrderArgs = {
};
export type MutationUpdateCartItemQuantityArgs = {
input: UpdateCartItemQuantityInput;
};
export type MutationUpsertMyCounterpartyProfileArgs = {
input: UpsertMyCounterpartyProfileInput;
};
@@ -430,6 +479,7 @@ export type Query = {
managerNotificationHistory: Array<NotificationHistoryItem>;
managerOrders: Array<Order>;
me?: Maybe<User>;
myCart: Cart;
myCounterpartyProfile?: Maybe<CounterpartyProfile>;
myCurrentOrders: Array<Order>;
myDeliveryAddresses: Array<DeliveryAddress>;
@@ -564,6 +614,11 @@ export type SubmitReadyOrderInput = {
items: Array<ReadyOrderItemInput>;
};
export type UpdateCartItemQuantityInput = {
productId: Scalars['ID']['input'];
quantity: Scalars['Float']['input'];
};
export type UpsertMyCounterpartyProfileInput = {
bankName: Scalars['String']['input'];
bik: Scalars['String']['input'];
@@ -645,6 +700,44 @@ export type VerifyLoginCodeMutationVariables = Exact<{
export type VerifyLoginCodeMutation = { __typename?: 'Mutation', verifyLoginCode: { __typename?: 'AuthSession', accessToken: string, expiresAt: any, user: { __typename?: 'User', id: string, email: string, fullName: string, role: UserRole, company?: { __typename?: 'Company', id: string } | null } } };
export type AddProductToCartMutationVariables = Exact<{
productId: Scalars['ID']['input'];
}>;
export type AddProductToCartMutation = { __typename?: 'Mutation', addProductToCart: { __typename?: 'Cart', id: string, userId: string, deliveryAddressId?: string | null, updatedAt: any, items: Array<{ __typename?: 'CartItem', id: string, productId: string, productName: string, sku: string, isCustomizable: boolean, quantity: number, parameters: any, updatedAt: any }> } };
export type ClearCartMutationVariables = Exact<{ [key: string]: never; }>;
export type ClearCartMutation = { __typename?: 'Mutation', clearCart: { __typename?: 'Cart', id: string, userId: string, deliveryAddressId?: string | null, updatedAt: any, items: Array<{ __typename?: 'CartItem', id: string, productId: string, productName: string, sku: string, isCustomizable: boolean, quantity: number, parameters: any, updatedAt: any }> } };
export type MyCartQueryVariables = Exact<{ [key: string]: never; }>;
export type MyCartQuery = { __typename?: 'Query', myCart: { __typename?: 'Cart', id: string, userId: string, deliveryAddressId?: string | null, updatedAt: any, items: Array<{ __typename?: 'CartItem', id: string, productId: string, productName: string, sku: string, isCustomizable: boolean, quantity: number, parameters: any, updatedAt: any }> } };
export type RemoveCartItemMutationVariables = Exact<{
productId: Scalars['ID']['input'];
}>;
export type RemoveCartItemMutation = { __typename?: 'Mutation', removeCartItem: { __typename?: 'Cart', id: string, userId: string, deliveryAddressId?: string | null, updatedAt: any, items: Array<{ __typename?: 'CartItem', id: string, productId: string, productName: string, sku: string, isCustomizable: boolean, quantity: number, parameters: any, updatedAt: any }> } };
export type SetCartDeliveryAddressMutationVariables = Exact<{
addressId?: InputMaybe<Scalars['ID']['input']>;
}>;
export type SetCartDeliveryAddressMutation = { __typename?: 'Mutation', setCartDeliveryAddress: { __typename?: 'Cart', id: string, userId: string, deliveryAddressId?: string | null, updatedAt: any, items: Array<{ __typename?: 'CartItem', id: string, productId: string, productName: string, sku: string, isCustomizable: boolean, quantity: number, parameters: any, updatedAt: any }> } };
export type UpdateCartItemQuantityMutationVariables = Exact<{
input: UpdateCartItemQuantityInput;
}>;
export type UpdateCartItemQuantityMutation = { __typename?: 'Mutation', updateCartItemQuantity: { __typename?: 'Cart', id: string, userId: string, deliveryAddressId?: string | null, updatedAt: any, items: Array<{ __typename?: 'CartItem', id: string, productId: string, productName: string, sku: string, isCustomizable: boolean, quantity: number, parameters: any, updatedAt: any }> } };
export type ClientProductsQueryVariables = Exact<{ [key: string]: never; }>;
@@ -1015,6 +1108,252 @@ export function useVerifyLoginCodeMutation(options: VueApolloComposable.UseMutat
return VueApolloComposable.useMutation<VerifyLoginCodeMutation, VerifyLoginCodeMutationVariables>(VerifyLoginCodeDocument, options);
}
export type VerifyLoginCodeMutationCompositionFunctionResult = VueApolloComposable.UseMutationReturn<VerifyLoginCodeMutation, VerifyLoginCodeMutationVariables>;
export const AddProductToCartDocument = gql`
mutation AddProductToCart($productId: ID!) {
addProductToCart(productId: $productId) {
id
userId
deliveryAddressId
items {
id
productId
productName
sku
isCustomizable
quantity
parameters
updatedAt
}
updatedAt
}
}
`;
/**
* __useAddProductToCartMutation__
*
* To run a mutation, you first call `useAddProductToCartMutation` within a Vue component and pass it any options that fit your needs.
* When your component renders, `useAddProductToCartMutation` returns an object that includes:
* - A mutate function that you can call at any time to execute the mutation
* - Several other properties: https://v4.apollo.vuejs.org/api/use-mutation.html#return
*
* @param options that will be passed into the mutation, supported options are listed on: https://v4.apollo.vuejs.org/guide-composable/mutation.html#options;
*
* @example
* const { mutate, loading, error, onDone } = useAddProductToCartMutation({
* variables: {
* productId: // value for 'productId'
* },
* });
*/
export function useAddProductToCartMutation(options: VueApolloComposable.UseMutationOptions<AddProductToCartMutation, AddProductToCartMutationVariables> | ReactiveFunction<VueApolloComposable.UseMutationOptions<AddProductToCartMutation, AddProductToCartMutationVariables>> = {}) {
return VueApolloComposable.useMutation<AddProductToCartMutation, AddProductToCartMutationVariables>(AddProductToCartDocument, options);
}
export type AddProductToCartMutationCompositionFunctionResult = VueApolloComposable.UseMutationReturn<AddProductToCartMutation, AddProductToCartMutationVariables>;
export const ClearCartDocument = gql`
mutation ClearCart {
clearCart {
id
userId
deliveryAddressId
items {
id
productId
productName
sku
isCustomizable
quantity
parameters
updatedAt
}
updatedAt
}
}
`;
/**
* __useClearCartMutation__
*
* To run a mutation, you first call `useClearCartMutation` within a Vue component and pass it any options that fit your needs.
* When your component renders, `useClearCartMutation` returns an object that includes:
* - A mutate function that you can call at any time to execute the mutation
* - Several other properties: https://v4.apollo.vuejs.org/api/use-mutation.html#return
*
* @param options that will be passed into the mutation, supported options are listed on: https://v4.apollo.vuejs.org/guide-composable/mutation.html#options;
*
* @example
* const { mutate, loading, error, onDone } = useClearCartMutation();
*/
export function useClearCartMutation(options: VueApolloComposable.UseMutationOptions<ClearCartMutation, ClearCartMutationVariables> | ReactiveFunction<VueApolloComposable.UseMutationOptions<ClearCartMutation, ClearCartMutationVariables>> = {}) {
return VueApolloComposable.useMutation<ClearCartMutation, ClearCartMutationVariables>(ClearCartDocument, options);
}
export type ClearCartMutationCompositionFunctionResult = VueApolloComposable.UseMutationReturn<ClearCartMutation, ClearCartMutationVariables>;
export const MyCartDocument = gql`
query MyCart {
myCart {
id
userId
deliveryAddressId
items {
id
productId
productName
sku
isCustomizable
quantity
parameters
updatedAt
}
updatedAt
}
}
`;
/**
* __useMyCartQuery__
*
* To run a query within a Vue component, call `useMyCartQuery` and pass it any options that fit your needs.
* When your component renders, `useMyCartQuery` returns an object from Apollo Client that contains result, loading and error properties
* you can use to render your UI.
*
* @param options that will be passed into the query, supported options are listed on: https://v4.apollo.vuejs.org/guide-composable/query.html#options;
*
* @example
* const { result, loading, error } = useMyCartQuery();
*/
export function useMyCartQuery(options: VueApolloComposable.UseQueryOptions<MyCartQuery, MyCartQueryVariables> | VueCompositionApi.Ref<VueApolloComposable.UseQueryOptions<MyCartQuery, MyCartQueryVariables>> | ReactiveFunction<VueApolloComposable.UseQueryOptions<MyCartQuery, MyCartQueryVariables>> = {}) {
return VueApolloComposable.useQuery<MyCartQuery, MyCartQueryVariables>(MyCartDocument, {}, options);
}
export function useMyCartLazyQuery(options: VueApolloComposable.UseQueryOptions<MyCartQuery, MyCartQueryVariables> | VueCompositionApi.Ref<VueApolloComposable.UseQueryOptions<MyCartQuery, MyCartQueryVariables>> | ReactiveFunction<VueApolloComposable.UseQueryOptions<MyCartQuery, MyCartQueryVariables>> = {}) {
return VueApolloComposable.useLazyQuery<MyCartQuery, MyCartQueryVariables>(MyCartDocument, {}, options);
}
export type MyCartQueryCompositionFunctionResult = VueApolloComposable.UseQueryReturn<MyCartQuery, MyCartQueryVariables>;
export const RemoveCartItemDocument = gql`
mutation RemoveCartItem($productId: ID!) {
removeCartItem(productId: $productId) {
id
userId
deliveryAddressId
items {
id
productId
productName
sku
isCustomizable
quantity
parameters
updatedAt
}
updatedAt
}
}
`;
/**
* __useRemoveCartItemMutation__
*
* To run a mutation, you first call `useRemoveCartItemMutation` within a Vue component and pass it any options that fit your needs.
* When your component renders, `useRemoveCartItemMutation` returns an object that includes:
* - A mutate function that you can call at any time to execute the mutation
* - Several other properties: https://v4.apollo.vuejs.org/api/use-mutation.html#return
*
* @param options that will be passed into the mutation, supported options are listed on: https://v4.apollo.vuejs.org/guide-composable/mutation.html#options;
*
* @example
* const { mutate, loading, error, onDone } = useRemoveCartItemMutation({
* variables: {
* productId: // value for 'productId'
* },
* });
*/
export function useRemoveCartItemMutation(options: VueApolloComposable.UseMutationOptions<RemoveCartItemMutation, RemoveCartItemMutationVariables> | ReactiveFunction<VueApolloComposable.UseMutationOptions<RemoveCartItemMutation, RemoveCartItemMutationVariables>> = {}) {
return VueApolloComposable.useMutation<RemoveCartItemMutation, RemoveCartItemMutationVariables>(RemoveCartItemDocument, options);
}
export type RemoveCartItemMutationCompositionFunctionResult = VueApolloComposable.UseMutationReturn<RemoveCartItemMutation, RemoveCartItemMutationVariables>;
export const SetCartDeliveryAddressDocument = gql`
mutation SetCartDeliveryAddress($addressId: ID) {
setCartDeliveryAddress(addressId: $addressId) {
id
userId
deliveryAddressId
items {
id
productId
productName
sku
isCustomizable
quantity
parameters
updatedAt
}
updatedAt
}
}
`;
/**
* __useSetCartDeliveryAddressMutation__
*
* To run a mutation, you first call `useSetCartDeliveryAddressMutation` within a Vue component and pass it any options that fit your needs.
* When your component renders, `useSetCartDeliveryAddressMutation` returns an object that includes:
* - A mutate function that you can call at any time to execute the mutation
* - Several other properties: https://v4.apollo.vuejs.org/api/use-mutation.html#return
*
* @param options that will be passed into the mutation, supported options are listed on: https://v4.apollo.vuejs.org/guide-composable/mutation.html#options;
*
* @example
* const { mutate, loading, error, onDone } = useSetCartDeliveryAddressMutation({
* variables: {
* addressId: // value for 'addressId'
* },
* });
*/
export function useSetCartDeliveryAddressMutation(options: VueApolloComposable.UseMutationOptions<SetCartDeliveryAddressMutation, SetCartDeliveryAddressMutationVariables> | ReactiveFunction<VueApolloComposable.UseMutationOptions<SetCartDeliveryAddressMutation, SetCartDeliveryAddressMutationVariables>> = {}) {
return VueApolloComposable.useMutation<SetCartDeliveryAddressMutation, SetCartDeliveryAddressMutationVariables>(SetCartDeliveryAddressDocument, options);
}
export type SetCartDeliveryAddressMutationCompositionFunctionResult = VueApolloComposable.UseMutationReturn<SetCartDeliveryAddressMutation, SetCartDeliveryAddressMutationVariables>;
export const UpdateCartItemQuantityDocument = gql`
mutation UpdateCartItemQuantity($input: UpdateCartItemQuantityInput!) {
updateCartItemQuantity(input: $input) {
id
userId
deliveryAddressId
items {
id
productId
productName
sku
isCustomizable
quantity
parameters
updatedAt
}
updatedAt
}
}
`;
/**
* __useUpdateCartItemQuantityMutation__
*
* To run a mutation, you first call `useUpdateCartItemQuantityMutation` within a Vue component and pass it any options that fit your needs.
* When your component renders, `useUpdateCartItemQuantityMutation` returns an object that includes:
* - A mutate function that you can call at any time to execute the mutation
* - Several other properties: https://v4.apollo.vuejs.org/api/use-mutation.html#return
*
* @param options that will be passed into the mutation, supported options are listed on: https://v4.apollo.vuejs.org/guide-composable/mutation.html#options;
*
* @example
* const { mutate, loading, error, onDone } = useUpdateCartItemQuantityMutation({
* variables: {
* input: // value for 'input'
* },
* });
*/
export function useUpdateCartItemQuantityMutation(options: VueApolloComposable.UseMutationOptions<UpdateCartItemQuantityMutation, UpdateCartItemQuantityMutationVariables> | ReactiveFunction<VueApolloComposable.UseMutationOptions<UpdateCartItemQuantityMutation, UpdateCartItemQuantityMutationVariables>> = {}) {
return VueApolloComposable.useMutation<UpdateCartItemQuantityMutation, UpdateCartItemQuantityMutationVariables>(UpdateCartItemQuantityDocument, options);
}
export type UpdateCartItemQuantityMutationCompositionFunctionResult = VueApolloComposable.UseMutationReturn<UpdateCartItemQuantityMutation, UpdateCartItemQuantityMutationVariables>;
export const ClientProductsDocument = gql`
query ClientProducts {
clientProducts {