mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
Merge branch 'release-stable' of https://github.com/KieIO/grocery-vercel-commerce into feature/m4-get-blog-detail
This commit is contained in:
485
framework/vendure/schema.d.ts
vendored
485
framework/vendure/schema.d.ts
vendored
@@ -306,9 +306,52 @@ export type MutationResetPasswordArgs = {
|
|||||||
password: Scalars['String']
|
password: Scalars['String']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ActiveOrderCustomerFragment = Pick<Order, 'id'> & {
|
||||||
|
customer?: Maybe<Pick<Customer, 'id' | 'emailAddress' | 'firstName' | 'lastName'>>;
|
||||||
|
lines: Array<Pick<OrderLine, 'id'>>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SetCustomerForOrderMutationVariables = Exact<{
|
||||||
|
input: CreateCustomerInput;
|
||||||
|
}>;
|
||||||
|
|
||||||
|
export type SetCustomerForOrderMutation = { __typename?: 'Mutation' } & {
|
||||||
|
setCustomerForOrder:
|
||||||
|
| ({ __typename: 'ActiveOrderCustomerFragment' } & Pick<ActiveOrderCustomerFragment, 'customer', 'lines'>)
|
||||||
|
| ({ __typename: 'AlreadyLoggedInError' } & Pick<
|
||||||
|
AlreadyLoggedInError,
|
||||||
|
'errorCode' | 'message'
|
||||||
|
>)
|
||||||
|
| ({ __typename: 'EmailAddressConflictError' } & Pick<
|
||||||
|
EmailAddressConflictError,
|
||||||
|
'errorCode' | 'message'
|
||||||
|
>)
|
||||||
|
| ({ __typename: 'NoActiveOrderError' } & Pick<
|
||||||
|
NoActiveOrderError,
|
||||||
|
'errorCode' | 'message'
|
||||||
|
>)
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SetCustomerForOrderMutation = { __typename?: 'Mutation' } & {
|
||||||
|
setCustomerForOrder:
|
||||||
|
| ({ __typename: 'ActiveOrderCustomerFragment' } & Pick<ActiveOrderCustomerFragment, 'customer', 'lines'>)
|
||||||
|
| ({ __typename: 'AlreadyLoggedInError' } & Pick<
|
||||||
|
AlreadyLoggedInError,
|
||||||
|
'errorCode' | 'message'
|
||||||
|
>)
|
||||||
|
| ({ __typename: 'EmailAddressConflictError' } & Pick<
|
||||||
|
EmailAddressConflictError,
|
||||||
|
'errorCode' | 'message'
|
||||||
|
>)
|
||||||
|
| ({ __typename: 'NoActiveOrderError' } & Pick<
|
||||||
|
NoActiveOrderError,
|
||||||
|
'errorCode' | 'message'
|
||||||
|
>)
|
||||||
|
}
|
||||||
|
|
||||||
export type Address = Node & {
|
export type Address = Node & {
|
||||||
updateCustomerAddress:
|
updateCustomerAddress:
|
||||||
| {
|
| {
|
||||||
__typename?: 'Address'
|
__typename?: 'Address'
|
||||||
id: Scalars['ID']
|
id: Scalars['ID']
|
||||||
}
|
}
|
||||||
@@ -1471,7 +1514,7 @@ export type CustomerListOptions = {
|
|||||||
|
|
||||||
export type Customer = Node & {
|
export type Customer = Node & {
|
||||||
updateCustomer:
|
updateCustomer:
|
||||||
| {
|
| {
|
||||||
__typename?: 'Customer'
|
__typename?: 'Customer'
|
||||||
id: Scalars['ID']
|
id: Scalars['ID']
|
||||||
}
|
}
|
||||||
@@ -1482,7 +1525,7 @@ export type Customer = Node & {
|
|||||||
title?: Maybe<Scalars['String']>
|
title?: Maybe<Scalars['String']>
|
||||||
firstName: Scalars['String']
|
firstName: Scalars['String']
|
||||||
lastName: Scalars['String']
|
lastName: Scalars['String']
|
||||||
phoneNumber?: Maybe<Scalars['String']>
|
phoneNumber?: Maybe<Scalars['String']>
|
||||||
emailAddress: Scalars['String']
|
emailAddress: Scalars['String']
|
||||||
addresses?: Maybe<Array<Address>>
|
addresses?: Maybe<Array<Address>>
|
||||||
orders: OrderList
|
orders: OrderList
|
||||||
@@ -3083,56 +3126,56 @@ export type CartFragment = { __typename?: 'Order' } & Pick<
|
|||||||
| 'totalWithTax'
|
| 'totalWithTax'
|
||||||
| 'currencyCode'
|
| 'currencyCode'
|
||||||
> & {
|
> & {
|
||||||
customer?: Maybe<{ __typename?: 'Customer' } & Pick<Customer, 'id'>>
|
customer?: Maybe<{ __typename?: 'Customer' } & Pick<Customer, 'id'>>
|
||||||
lines: Array<
|
lines: Array<
|
||||||
{ __typename?: 'OrderLine' } & Pick<
|
{ __typename?: 'OrderLine' } & Pick<
|
||||||
OrderLine,
|
OrderLine,
|
||||||
|
| 'id'
|
||||||
|
| 'quantity'
|
||||||
|
| 'linePriceWithTax'
|
||||||
|
| 'discountedLinePriceWithTax'
|
||||||
|
| 'unitPriceWithTax'
|
||||||
|
| 'discountedUnitPriceWithTax'
|
||||||
|
> & {
|
||||||
|
featuredAsset?: Maybe<
|
||||||
|
{ __typename?: 'Asset' } & Pick<Asset, 'id' | 'preview'>
|
||||||
|
>
|
||||||
|
discounts: Array<
|
||||||
|
{ __typename?: 'Discount' } & Pick<
|
||||||
|
Discount,
|
||||||
|
'description' | 'amount'
|
||||||
|
>
|
||||||
|
>
|
||||||
|
productVariant: { __typename?: 'ProductVariant' } & Pick<
|
||||||
|
ProductVariant,
|
||||||
| 'id'
|
| 'id'
|
||||||
| 'quantity'
|
| 'name'
|
||||||
| 'linePriceWithTax'
|
| 'sku'
|
||||||
| 'discountedLinePriceWithTax'
|
| 'price'
|
||||||
| 'unitPriceWithTax'
|
| 'priceWithTax'
|
||||||
| 'discountedUnitPriceWithTax'
|
| 'stockLevel'
|
||||||
> & {
|
| 'productId'
|
||||||
featuredAsset?: Maybe<
|
> & { product: { __typename?: 'Product' } & Pick<Product, 'slug'> }
|
||||||
{ __typename?: 'Asset' } & Pick<Asset, 'id' | 'preview'>
|
}
|
||||||
>
|
>
|
||||||
discounts: Array<
|
}
|
||||||
{ __typename?: 'Discount' } & Pick<
|
|
||||||
Discount,
|
|
||||||
'description' | 'amount'
|
|
||||||
>
|
|
||||||
>
|
|
||||||
productVariant: { __typename?: 'ProductVariant' } & Pick<
|
|
||||||
ProductVariant,
|
|
||||||
| 'id'
|
|
||||||
| 'name'
|
|
||||||
| 'sku'
|
|
||||||
| 'price'
|
|
||||||
| 'priceWithTax'
|
|
||||||
| 'stockLevel'
|
|
||||||
| 'productId'
|
|
||||||
> & { product: { __typename?: 'Product' } & Pick<Product, 'slug'> }
|
|
||||||
}
|
|
||||||
>
|
|
||||||
}
|
|
||||||
|
|
||||||
export type SearchResultFragment = { __typename?: 'SearchResult' } & Pick<
|
export type SearchResultFragment = { __typename?: 'SearchResult' } & Pick<
|
||||||
SearchResult,
|
SearchResult,
|
||||||
'productId' | 'sku' | 'productName' | 'description' | 'slug' | 'sku' | 'currencyCode'
|
'productId' | 'sku' | 'productName' | 'description' | 'slug' | 'sku' | 'currencyCode'
|
||||||
| 'productAsset' | 'price' | 'priceWithTax' | 'currencyCode'
|
| 'productAsset' | 'price' | 'priceWithTax' | 'currencyCode'
|
||||||
| 'collectionIds' | 'productVariantId' | 'facetValueIds' | "productVariantName"
|
| 'collectionIds' | 'productVariantId' | 'facetValueIds' | "productVariantName"
|
||||||
> & {
|
> & {
|
||||||
productAsset?: Maybe<
|
productAsset?: Maybe<
|
||||||
{ __typename?: 'SearchResultAsset' } & Pick<
|
{ __typename?: 'SearchResultAsset' } & Pick<
|
||||||
SearchResultAsset,
|
SearchResultAsset,
|
||||||
'id' | 'preview'
|
'id' | 'preview'
|
||||||
>
|
|
||||||
>
|
>
|
||||||
priceWithTax:
|
>
|
||||||
| ({ __typename?: 'PriceRange' } & Pick<PriceRange, 'min' | 'max'>)
|
priceWithTax:
|
||||||
| ({ __typename?: 'SinglePrice' } & Pick<SinglePrice, 'value'>)
|
| ({ __typename?: 'PriceRange' } & Pick<PriceRange, 'min' | 'max'>)
|
||||||
}
|
| ({ __typename?: 'SinglePrice' } & Pick<SinglePrice, 'value'>)
|
||||||
|
}
|
||||||
|
|
||||||
export type AddItemToOrderMutationVariables = Exact<{
|
export type AddItemToOrderMutationVariables = Exact<{
|
||||||
variantId: Scalars['ID']
|
variantId: Scalars['ID']
|
||||||
@@ -3141,23 +3184,23 @@ export type AddItemToOrderMutationVariables = Exact<{
|
|||||||
|
|
||||||
export type AddItemToOrderMutation = { __typename?: 'Mutation' } & {
|
export type AddItemToOrderMutation = { __typename?: 'Mutation' } & {
|
||||||
addItemToOrder:
|
addItemToOrder:
|
||||||
| ({ __typename: 'Order' } & CartFragment)
|
| ({ __typename: 'Order' } & CartFragment)
|
||||||
| ({ __typename: 'OrderModificationError' } & Pick<
|
| ({ __typename: 'OrderModificationError' } & Pick<
|
||||||
OrderModificationError,
|
OrderModificationError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
| ({ __typename: 'OrderLimitError' } & Pick<
|
| ({ __typename: 'OrderLimitError' } & Pick<
|
||||||
OrderLimitError,
|
OrderLimitError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
| ({ __typename: 'NegativeQuantityError' } & Pick<
|
| ({ __typename: 'NegativeQuantityError' } & Pick<
|
||||||
NegativeQuantityError,
|
NegativeQuantityError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
| ({ __typename: 'InsufficientStockError' } & Pick<
|
| ({ __typename: 'InsufficientStockError' } & Pick<
|
||||||
InsufficientStockError,
|
InsufficientStockError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AdjustOrderLineMutationVariables = Exact<{
|
export type AdjustOrderLineMutationVariables = Exact<{
|
||||||
@@ -3167,23 +3210,23 @@ export type AdjustOrderLineMutationVariables = Exact<{
|
|||||||
|
|
||||||
export type AdjustOrderLineMutation = { __typename?: 'Mutation' } & {
|
export type AdjustOrderLineMutation = { __typename?: 'Mutation' } & {
|
||||||
adjustOrderLine:
|
adjustOrderLine:
|
||||||
| ({ __typename: 'Order' } & CartFragment)
|
| ({ __typename: 'Order' } & CartFragment)
|
||||||
| ({ __typename: 'OrderModificationError' } & Pick<
|
| ({ __typename: 'OrderModificationError' } & Pick<
|
||||||
OrderModificationError,
|
OrderModificationError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
| ({ __typename: 'OrderLimitError' } & Pick<
|
| ({ __typename: 'OrderLimitError' } & Pick<
|
||||||
OrderLimitError,
|
OrderLimitError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
| ({ __typename: 'NegativeQuantityError' } & Pick<
|
| ({ __typename: 'NegativeQuantityError' } & Pick<
|
||||||
NegativeQuantityError,
|
NegativeQuantityError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
| ({ __typename: 'InsufficientStockError' } & Pick<
|
| ({ __typename: 'InsufficientStockError' } & Pick<
|
||||||
InsufficientStockError,
|
InsufficientStockError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
}
|
}
|
||||||
|
|
||||||
export type LoginMutationVariables = Exact<{
|
export type LoginMutationVariables = Exact<{
|
||||||
@@ -3193,49 +3236,49 @@ export type LoginMutationVariables = Exact<{
|
|||||||
|
|
||||||
export type LoginMutation = { __typename?: 'Mutation' } & {
|
export type LoginMutation = { __typename?: 'Mutation' } & {
|
||||||
login:
|
login:
|
||||||
| ({ __typename: 'CurrentUser' } & Pick<CurrentUser, 'id'>)
|
| ({ __typename: 'CurrentUser' } & Pick<CurrentUser, 'id'>)
|
||||||
| ({ __typename: 'InvalidCredentialsError' } & Pick<
|
| ({ __typename: 'InvalidCredentialsError' } & Pick<
|
||||||
InvalidCredentialsError,
|
InvalidCredentialsError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
| ({ __typename: 'NotVerifiedError' } & Pick<
|
| ({ __typename: 'NotVerifiedError' } & Pick<
|
||||||
NotVerifiedError,
|
NotVerifiedError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
| ({ __typename: 'NativeAuthStrategyError' } & Pick<
|
| ({ __typename: 'NativeAuthStrategyError' } & Pick<
|
||||||
NativeAuthStrategyError,
|
NativeAuthStrategyError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ResetPasswordMutation = { __typename?: 'Mutation' } & {
|
export type ResetPasswordMutation = { __typename?: 'Mutation' } & {
|
||||||
resetPassword:
|
resetPassword:
|
||||||
| ({ __typename: 'CurrentUser' } & Pick<CurrentUser, 'id'>)
|
| ({ __typename: 'CurrentUser' } & Pick<CurrentUser, 'id'>)
|
||||||
| ({ __typename: 'PasswordResetTokenInvalidError' } & Pick<
|
| ({ __typename: 'PasswordResetTokenInvalidError' } & Pick<
|
||||||
PasswordResetTokenInvalidError,
|
PasswordResetTokenInvalidError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
| ({ __typename: 'PasswordResetTokenExpiredError' } & Pick<
|
| ({ __typename: 'PasswordResetTokenExpiredError' } & Pick<
|
||||||
PasswordResetTokenExpiredError,
|
PasswordResetTokenExpiredError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
| ({ __typename: 'NativeAuthStrategyError' } & Pick<
|
| ({ __typename: 'NativeAuthStrategyError' } & Pick<
|
||||||
NativeAuthStrategyError,
|
NativeAuthStrategyError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SignupMutation = { __typename?: 'Mutation' } & {
|
export type SignupMutation = { __typename?: 'Mutation' } & {
|
||||||
registerCustomerAccount:
|
registerCustomerAccount:
|
||||||
| ({ __typename: 'Success' } & Pick<Success, 'success'>)
|
| ({ __typename: 'Success' } & Pick<Success, 'success'>)
|
||||||
| ({ __typename: 'MissingPasswordError' } & Pick<
|
| ({ __typename: 'MissingPasswordError' } & Pick<
|
||||||
MissingPasswordError,
|
MissingPasswordError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
| ({ __typename: 'NativeAuthStrategyError' } & Pick<
|
| ({ __typename: 'NativeAuthStrategyError' } & Pick<
|
||||||
NativeAuthStrategyError,
|
NativeAuthStrategyError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
}
|
}
|
||||||
|
|
||||||
export type VerifyCustomerAccountVariables = Exact<{
|
export type VerifyCustomerAccountVariables = Exact<{
|
||||||
@@ -3245,27 +3288,27 @@ export type VerifyCustomerAccountVariables = Exact<{
|
|||||||
|
|
||||||
export type VerifyCustomerAccountMutation = { __typename?: 'Mutation' } & {
|
export type VerifyCustomerAccountMutation = { __typename?: 'Mutation' } & {
|
||||||
verifyCustomerAccount:
|
verifyCustomerAccount:
|
||||||
| ({ __typename: 'CurrentUser' } & Pick<CurrentUser, 'id'>)
|
| ({ __typename: 'CurrentUser' } & Pick<CurrentUser, 'id'>)
|
||||||
| ({ __typename: 'VerificationTokenInvalidError' } & Pick<
|
| ({ __typename: 'VerificationTokenInvalidError' } & Pick<
|
||||||
VerificationTokenInvalidError,
|
VerificationTokenInvalidError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
| ({ __typename: 'VerificationTokenExpiredError' } & Pick<
|
| ({ __typename: 'VerificationTokenExpiredError' } & Pick<
|
||||||
VerificationTokenExpiredError,
|
VerificationTokenExpiredError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
| ({ __typename: 'MissingPasswordError' } & Pick<
|
| ({ __typename: 'MissingPasswordError' } & Pick<
|
||||||
MissingPasswordError,
|
MissingPasswordError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
| ({ __typename: 'PasswordAlreadySetError' } & Pick<
|
| ({ __typename: 'PasswordAlreadySetError' } & Pick<
|
||||||
PasswordAlreadySetError,
|
PasswordAlreadySetError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
| ({ __typename: 'NativeAuthStrategyError' } & Pick<
|
| ({ __typename: 'NativeAuthStrategyError' } & Pick<
|
||||||
NativeAuthStrategyError,
|
NativeAuthStrategyError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
}
|
}
|
||||||
|
|
||||||
export type LogoutMutationVariables = Exact<{ [key: string]: never }>
|
export type LogoutMutationVariables = Exact<{ [key: string]: never }>
|
||||||
@@ -3280,11 +3323,11 @@ export type RemoveOrderLineMutationVariables = Exact<{
|
|||||||
|
|
||||||
export type RemoveOrderLineMutation = { __typename?: 'Mutation' } & {
|
export type RemoveOrderLineMutation = { __typename?: 'Mutation' } & {
|
||||||
removeOrderLine:
|
removeOrderLine:
|
||||||
| ({ __typename: 'Order' } & CartFragment)
|
| ({ __typename: 'Order' } & CartFragment)
|
||||||
| ({ __typename: 'OrderModificationError' } & Pick<
|
| ({ __typename: 'OrderModificationError' } & Pick<
|
||||||
OrderModificationError,
|
OrderModificationError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SignupMutationVariables = Exact<{
|
export type SignupMutationVariables = Exact<{
|
||||||
@@ -3294,15 +3337,15 @@ export type SignupMutationVariables = Exact<{
|
|||||||
|
|
||||||
export type RequestPasswordReset = { __typename?: 'Mutation' } & {
|
export type RequestPasswordReset = { __typename?: 'Mutation' } & {
|
||||||
requestPasswordReset:
|
requestPasswordReset:
|
||||||
| ({ __typename: 'Success' } & Pick<Success, 'success'>)
|
| ({ __typename: 'Success' } & Pick<Success, 'success'>)
|
||||||
| ({ __typename: 'MissingPasswordError' } & Pick<
|
| ({ __typename: 'MissingPasswordError' } & Pick<
|
||||||
MissingPasswordError,
|
MissingPasswordError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
| ({ __typename: 'NativeAuthStrategyError' } & Pick<
|
| ({ __typename: 'NativeAuthStrategyError' } & Pick<
|
||||||
NativeAuthStrategyError,
|
NativeAuthStrategyError,
|
||||||
'errorCode' | 'message'
|
'errorCode' | 'message'
|
||||||
>)
|
>)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3314,7 +3357,7 @@ export type ActiveCustomerQuery = { __typename?: 'Query' } & {
|
|||||||
{ __typename?: 'Customer' } & Pick<
|
{ __typename?: 'Customer' } & Pick<
|
||||||
Customer,
|
Customer,
|
||||||
Favorite,
|
Favorite,
|
||||||
'id' | 'firstName' | 'lastName' | 'emailAddress' | 'addresses' | 'phoneNumber'| 'orders'
|
'id' | 'firstName' | 'lastName' | 'emailAddress' | 'addresses' | 'phoneNumber' | 'orders'
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
}
|
}
|
||||||
@@ -3333,7 +3376,7 @@ export type FavoriteList = PaginatedList & {
|
|||||||
totalItems: Int!
|
totalItems: Int!
|
||||||
}
|
}
|
||||||
|
|
||||||
type Favorite = Node & {
|
type Favorite = Node & {
|
||||||
id: ID!
|
id: ID!
|
||||||
createdAt: DateTime!
|
createdAt: DateTime!
|
||||||
updatedAt: DateTime!
|
updatedAt: DateTime!
|
||||||
@@ -3343,7 +3386,7 @@ type Favorite = Node & {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
type FavouriteOption = Customer & {
|
type FavouriteOption = Customer & {
|
||||||
favorites(options: FavoriteListOptions): FavoriteList!
|
favorites(options: FavoriteListOptions): FavoriteList!
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3380,13 +3423,13 @@ export type GetAllFacetsQuery = { __typename?: 'Query' } & {
|
|||||||
{ __typename?: 'Facet' } & Pick<
|
{ __typename?: 'Facet' } & Pick<
|
||||||
Facet,
|
Facet,
|
||||||
'id' | 'name' | 'code' | 'values'
|
'id' | 'name' | 'code' | 'values'
|
||||||
>
|
>
|
||||||
& {
|
& {
|
||||||
parent?: Maybe<{ __typename?: 'Facet' } & Pick<Facet, 'id'>>
|
parent?: Maybe<{ __typename?: 'Facet' } & Pick<Facet, 'id'>>
|
||||||
children?: Maybe<
|
children?: Maybe<
|
||||||
Array<{ __typename?: 'Facet' } & Pick<Facet, 'id'>>
|
Array<{ __typename?: 'Facet' } & Pick<Facet, 'id'>>
|
||||||
>
|
>
|
||||||
}
|
}
|
||||||
>,
|
>,
|
||||||
'totalItems'
|
'totalItems'
|
||||||
}
|
}
|
||||||
@@ -3399,11 +3442,11 @@ export type GetAllCollectionsQuery = { __typename?: 'Query' } & {
|
|||||||
Collection,
|
Collection,
|
||||||
'id' | 'name' | 'slug'
|
'id' | 'name' | 'slug'
|
||||||
> & {
|
> & {
|
||||||
parent?: Maybe<{ __typename?: 'Collection' } & Pick<Collection, 'id'>>
|
parent?: Maybe<{ __typename?: 'Collection' } & Pick<Collection, 'id'>>
|
||||||
children?: Maybe<
|
children?: Maybe<
|
||||||
Array<{ __typename?: 'Collection' } & Pick<Collection, 'id'>>
|
Array<{ __typename?: 'Collection' } & Pick<Collection, 'id'>>
|
||||||
>
|
>
|
||||||
}
|
}
|
||||||
>,
|
>,
|
||||||
'totalItems'
|
'totalItems'
|
||||||
}
|
}
|
||||||
@@ -3424,15 +3467,15 @@ export type GetCollectionsQuery = { __typename?: 'Query' } & {
|
|||||||
Collection,
|
Collection,
|
||||||
'id' | 'name' | 'description' | 'slug'
|
'id' | 'name' | 'description' | 'slug'
|
||||||
> & {
|
> & {
|
||||||
productVariants: { __typename?: 'ProductVariantList' } & Pick<
|
productVariants: { __typename?: 'ProductVariantList' } & Pick<
|
||||||
ProductVariantList,
|
ProductVariantList,
|
||||||
'totalItems'
|
'totalItems'
|
||||||
>
|
>
|
||||||
parent?: Maybe<{ __typename?: 'Collection' } & Pick<Collection, 'id'>>
|
parent?: Maybe<{ __typename?: 'Collection' } & Pick<Collection, 'id'>>
|
||||||
children?: Maybe<
|
children?: Maybe<
|
||||||
Array<{ __typename?: 'Collection' } & Pick<Collection, 'id'>>
|
Array<{ __typename?: 'Collection' } & Pick<Collection, 'id'>>
|
||||||
>
|
>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3447,60 +3490,60 @@ export type GetProductQuery = { __typename?: 'Query' } & {
|
|||||||
Product,
|
Product,
|
||||||
'id' | 'name' | 'slug' | 'description'
|
'id' | 'name' | 'slug' | 'description'
|
||||||
> & {
|
> & {
|
||||||
assets: Array<
|
assets: Array<
|
||||||
{ __typename?: 'Asset' } & Pick<Asset, 'id' | 'preview' | 'name'>
|
{ __typename?: 'Asset' } & Pick<Asset, 'id' | 'preview' | 'name'>
|
||||||
>
|
>
|
||||||
variants: Array<
|
variants: Array<
|
||||||
{ __typename?: 'ProductVariant' } & Pick<
|
{ __typename?: 'ProductVariant' } & Pick<
|
||||||
ProductVariant,
|
ProductVariant,
|
||||||
'id' | 'priceWithTax' | 'currencyCode' | 'price' | "name"
|
'id' | 'priceWithTax' | 'currencyCode' | 'price' | "name"
|
||||||
> & {
|
> & {
|
||||||
options: Array<
|
options: Array<
|
||||||
{ __typename?: 'ProductOption' } & Pick<
|
{ __typename?: 'ProductOption' } & Pick<
|
||||||
ProductOption,
|
ProductOption,
|
||||||
'id' | 'name' | 'code' | 'groupId'
|
'id' | 'name' | 'code' | 'groupId'
|
||||||
> & {
|
> & {
|
||||||
group: { __typename?: 'ProductOptionGroup' } & Pick<
|
group: { __typename?: 'ProductOptionGroup' } & Pick<
|
||||||
ProductOptionGroup,
|
ProductOptionGroup,
|
||||||
'id'
|
'id'
|
||||||
> & {
|
> & {
|
||||||
options: Array<
|
options: Array<
|
||||||
{ __typename?: 'ProductOption' } & Pick<
|
{ __typename?: 'ProductOption' } & Pick<
|
||||||
ProductOption,
|
ProductOption,
|
||||||
'name'
|
'name'
|
||||||
>
|
>
|
||||||
>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
optionGroups: Array<
|
|
||||||
{ __typename?: 'ProductOptionGroup' } & Pick<
|
|
||||||
ProductOptionGroup,
|
|
||||||
'id' | 'code' | 'name'
|
|
||||||
> & {
|
|
||||||
options: Array<
|
|
||||||
{ __typename?: 'ProductOption' } & Pick<
|
|
||||||
ProductOption,
|
|
||||||
'id' | 'name'
|
|
||||||
>
|
>
|
||||||
>
|
}
|
||||||
}
|
}
|
||||||
>
|
|
||||||
facetValues: Array<
|
|
||||||
{ __typename?: 'FacetValue' } & Pick<
|
|
||||||
FacetValue,
|
|
||||||
'id'
|
|
||||||
>
|
>
|
||||||
>
|
}
|
||||||
collections: Array<
|
>
|
||||||
{ __typename?: 'Collection' } & Pick<
|
optionGroups: Array<
|
||||||
Collection,
|
{ __typename?: 'ProductOptionGroup' } & Pick<
|
||||||
'id'|"name"
|
ProductOptionGroup,
|
||||||
|
'id' | 'code' | 'name'
|
||||||
|
> & {
|
||||||
|
options: Array<
|
||||||
|
{ __typename?: 'ProductOption' } & Pick<
|
||||||
|
ProductOption,
|
||||||
|
'id' | 'name'
|
||||||
|
>
|
||||||
>
|
>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
facetValues: Array<
|
||||||
|
{ __typename?: 'FacetValue' } & Pick<
|
||||||
|
FacetValue,
|
||||||
|
'id'
|
||||||
>
|
>
|
||||||
}
|
>
|
||||||
|
collections: Array<
|
||||||
|
{ __typename?: 'Collection' } & Pick<
|
||||||
|
Collection,
|
||||||
|
'id' | "name"
|
||||||
|
>
|
||||||
|
>
|
||||||
|
}
|
||||||
>
|
>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,24 @@
|
|||||||
|
export const setCustomerForOrderMutation = /* GraphQL */ `
|
||||||
|
mutation setCustomerForOrder($input: CreateCustomerInput!) {
|
||||||
|
setCustomerForOrder(input: $input) {
|
||||||
|
__typename
|
||||||
|
... on Order {
|
||||||
|
id
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
code
|
||||||
|
customer {
|
||||||
|
id
|
||||||
|
firstName
|
||||||
|
lastName
|
||||||
|
emailAddress
|
||||||
|
phoneNumber
|
||||||
|
}
|
||||||
|
}
|
||||||
|
... on ErrorResult {
|
||||||
|
errorCode
|
||||||
|
message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
@@ -4,6 +4,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "set NODE_OPTIONS='--inspect' && set PORT=3005 && next dev",
|
"dev": "set NODE_OPTIONS='--inspect' && set PORT=3005 && next dev",
|
||||||
"dev-windows": "set NODE_OPTIONS='--inspect' && set PORT=3005 && next dev",
|
"dev-windows": "set NODE_OPTIONS='--inspect' && set PORT=3005 && next dev",
|
||||||
|
"dev-macos": "set NODE_OPTIONS='--inspect' && set PORT=3005 && next dev",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "PORT=3005 next start",
|
"start": "PORT=3005 next start",
|
||||||
"analyze": "BUNDLE_ANALYZE=both yarn build",
|
"analyze": "BUNDLE_ANALYZE=both yarn build",
|
||||||
|
@@ -4,7 +4,8 @@ import { CheckoutPage } from 'src/components/modules/checkout';
|
|||||||
export default function Checkout() {
|
export default function Checkout() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<CheckoutPage/>
|
<CheckoutPage />
|
||||||
|
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { FC } from 'react'
|
import { FC } from 'react'
|
||||||
import { useMessage } from 'src/components/contexts'
|
import { useMessage } from 'src/components/contexts'
|
||||||
import { useModalCommon } from 'src/components/hooks'
|
|
||||||
import { FILTER_PAGE, ROUTE } from 'src/utils/constanst.utils'
|
import { FILTER_PAGE, ROUTE } from 'src/utils/constanst.utils'
|
||||||
import { CartDrawer, Footer, MessageCommon, ScrollToTop } from '../..'
|
import { CartDrawer, Footer, MessageCommon, ScrollToTop } from '../..'
|
||||||
import Header from '../../Header/Header'
|
import Header from '../../Header/Header'
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
import { MessageProvider } from 'src/components/contexts'
|
||||||
import s from './LayoutCheckout.module.scss'
|
import s from './LayoutCheckout.module.scss'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -6,14 +7,18 @@ interface Props {
|
|||||||
|
|
||||||
const LayoutCheckout = ({ children }: Props) => {
|
const LayoutCheckout = ({ children }: Props) => {
|
||||||
return (
|
return (
|
||||||
<div className={s.layoutCheckout}>
|
<>
|
||||||
<main>{children}</main>
|
<MessageProvider>
|
||||||
<footer className={s.footer}>
|
<div className={s.layoutCheckout}>
|
||||||
<div>
|
<main>{children}</main>
|
||||||
© 2021 Online Grocery
|
<footer className={s.footer}>
|
||||||
|
<div>
|
||||||
|
© 2021 Online Grocery
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</MessageProvider>
|
||||||
</div>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import React, { memo, useEffect } from 'react'
|
import React, { memo } from 'react'
|
||||||
import s from './MessageCommon.module.scss'
|
import s from './MessageCommon.module.scss'
|
||||||
import MessageItem, { MessageItemProps } from './MessageItem/MessageItem'
|
import MessageItem, { MessageItemProps } from './MessageItem/MessageItem'
|
||||||
|
|
||||||
|
@@ -17,11 +17,11 @@ interface Props {
|
|||||||
onSwitch: () => void
|
onSwitch: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const DisplayingErrorMessagesSchema = Yup.object().shape({
|
const displayingErrorMessagesSchema = Yup.object().shape({
|
||||||
email: Yup.string().email('Your email was wrong').required('Required'),
|
email: Yup.string().email(LANGUAGE.MESSAGE.INVALID_EMAIL).required(LANGUAGE.MESSAGE.REQUIRED),
|
||||||
password: Yup.string()
|
password: Yup.string()
|
||||||
.max(30, 'Password is too long')
|
.max(30, 'Password is too long')
|
||||||
.required('Required'),
|
.required(LANGUAGE.MESSAGE.REQUIRED),
|
||||||
})
|
})
|
||||||
|
|
||||||
const FormLogin = ({ onSwitch, isHide }: Props) => {
|
const FormLogin = ({ onSwitch, isHide }: Props) => {
|
||||||
@@ -56,7 +56,7 @@ const FormLogin = ({ onSwitch, isHide }: Props) => {
|
|||||||
password: '',
|
password: '',
|
||||||
email: '',
|
email: '',
|
||||||
}}
|
}}
|
||||||
validationSchema={DisplayingErrorMessagesSchema}
|
validationSchema={displayingErrorMessagesSchema}
|
||||||
onSubmit={onLogin}
|
onSubmit={onLogin}
|
||||||
|
|
||||||
>
|
>
|
||||||
|
@@ -6,7 +6,7 @@ export type MessageContextType = {
|
|||||||
removeMessage: (id: number) => void
|
removeMessage: (id: number) => void
|
||||||
showMessageSuccess: (content: string, timeout?: number) => void
|
showMessageSuccess: (content: string, timeout?: number) => void
|
||||||
showMessageInfo: (content: string, timeout?: number) => void
|
showMessageInfo: (content: string, timeout?: number) => void
|
||||||
showMessageError: (content: string, timeout?: number) => void
|
showMessageError: (content?: string, timeout?: number) => void
|
||||||
showMessageWarning: (content: string, timeout?: number) => void
|
showMessageWarning: (content: string, timeout?: number) => void
|
||||||
}
|
}
|
||||||
export const DEFAULT_MESSAGE_CONTEXT: MessageContextType = {
|
export const DEFAULT_MESSAGE_CONTEXT: MessageContextType = {
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import { ReactNode, useCallback, useState } from 'react'
|
import { ReactNode, useState } from 'react'
|
||||||
import { MessageItemProps } from 'src/components/common/MessageCommon/MessageItem/MessageItem'
|
import { MessageItemProps } from 'src/components/common/MessageCommon/MessageItem/MessageItem'
|
||||||
|
import { LANGUAGE } from 'src/utils/language.utils'
|
||||||
import { MessageContext } from './MessageContext'
|
import { MessageContext } from './MessageContext'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -33,8 +34,8 @@ export function MessageProvider({ children }: Props) {
|
|||||||
createNewMessage(content, timeout, 'info')
|
createNewMessage(content, timeout, 'info')
|
||||||
}
|
}
|
||||||
|
|
||||||
const showMessageError = (content: string, timeout?: number) => {
|
const showMessageError = (content?: string, timeout?: number) => {
|
||||||
createNewMessage(content, timeout, 'error')
|
createNewMessage(content || LANGUAGE.MESSAGE.ERROR, timeout, 'error')
|
||||||
}
|
}
|
||||||
|
|
||||||
const showMessageWarning = (content: string, timeout?: number) => {
|
const showMessageWarning = (content: string, timeout?: number) => {
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import { Cart } from '@commerce/types/cart'
|
|
||||||
import { ActiveOrderQuery } from '@framework/schema'
|
import { ActiveOrderQuery } from '@framework/schema'
|
||||||
import { cartFragment } from '@framework/utils/fragments/cart-fragment'
|
import { cartFragment } from '@framework/utils/fragments/cart-fragment'
|
||||||
import { normalizeCart } from '@framework/utils/normalize'
|
import { normalizeCart } from '@framework/utils/normalize'
|
||||||
|
2
src/components/hooks/order/index.ts
Normal file
2
src/components/hooks/order/index.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export { default as useSetCustomerForOrder } from './useSetCustomerForOrder'
|
||||||
|
|
42
src/components/hooks/order/useSetCustomerForOrder.tsx
Normal file
42
src/components/hooks/order/useSetCustomerForOrder.tsx
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import { CreateCustomerInput, SetCustomerForOrderMutation } from '@framework/schema'
|
||||||
|
import { setCustomerForOrderMutation } from '@framework/utils/mutations/set-customer-order-mutation'
|
||||||
|
import { useState } from 'react'
|
||||||
|
import { CommonError } from 'src/domains/interfaces/CommonError'
|
||||||
|
import rawFetcher from 'src/utils/rawFetcher'
|
||||||
|
import { useGetActiveOrder } from '../cart'
|
||||||
|
|
||||||
|
|
||||||
|
const useSetCustomerForOrder = () => {
|
||||||
|
const [loading, setLoading] = useState(false)
|
||||||
|
const [error, setError] = useState<CommonError | null>(null)
|
||||||
|
const { mutate } = useGetActiveOrder()
|
||||||
|
|
||||||
|
const setCustomerForOrder = (input: CreateCustomerInput,
|
||||||
|
fCallBack: (isSuccess: boolean, message?: string) => void
|
||||||
|
) => {
|
||||||
|
setError(null)
|
||||||
|
setLoading(true)
|
||||||
|
rawFetcher<SetCustomerForOrderMutation>({
|
||||||
|
query: setCustomerForOrderMutation,
|
||||||
|
variables: { input },
|
||||||
|
})
|
||||||
|
.then(({ data }) => {
|
||||||
|
if (data.setCustomerForOrder.__typename === 'ActiveOrderCustomerFragment') {
|
||||||
|
fCallBack(true)
|
||||||
|
mutate()
|
||||||
|
} else {
|
||||||
|
fCallBack(false, data.setCustomerForOrder.message)
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
setError(error)
|
||||||
|
fCallBack(false, error.message)
|
||||||
|
})
|
||||||
|
.finally(() => setLoading(false))
|
||||||
|
}
|
||||||
|
|
||||||
|
return { loading, setCustomerForOrder, error }
|
||||||
|
}
|
||||||
|
|
||||||
|
export default useSetCustomerForOrder
|
@@ -1,6 +1,7 @@
|
|||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import { Logo } from 'src/components/common'
|
import { ButtonCommon, Logo } from 'src/components/common'
|
||||||
import CheckoutCollapse from 'src/components/common/CheckoutCollapse/CheckoutCollapse'
|
import CheckoutCollapse from 'src/components/common/CheckoutCollapse/CheckoutCollapse'
|
||||||
|
import { useAddProductToCart, useGetActiveOrder } from 'src/components/hooks/cart'
|
||||||
import { removeItem } from 'src/utils/funtion.utils'
|
import { removeItem } from 'src/utils/funtion.utils'
|
||||||
import { CheckOutForm } from 'src/utils/types.utils'
|
import { CheckOutForm } from 'src/utils/types.utils'
|
||||||
import s from './CheckoutInfo.module.scss'
|
import s from './CheckoutInfo.module.scss'
|
||||||
@@ -8,43 +9,43 @@ import CustomerInfoForm from './components/CustomerInfoForm/CustomerInfoForm'
|
|||||||
import PaymentInfoForm from './components/PaymentInfoForm/PaymentInfoForm'
|
import PaymentInfoForm from './components/PaymentInfoForm/PaymentInfoForm'
|
||||||
import ShippingInfoForm from './components/ShippingInfoForm/ShippingInfoForm'
|
import ShippingInfoForm from './components/ShippingInfoForm/ShippingInfoForm'
|
||||||
interface CheckoutInfoProps {
|
interface CheckoutInfoProps {
|
||||||
onViewCart:()=>void
|
onViewCart: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const CheckoutInfo = ({onViewCart}: CheckoutInfoProps) => {
|
const CheckoutInfo = ({ onViewCart }: CheckoutInfoProps) => {
|
||||||
const [active, setActive] = useState(1)
|
const [active, setActive] = useState(1)
|
||||||
const [done, setDone] = useState<number[]>([])
|
const [done, setDone] = useState<number[]>([])
|
||||||
const [info, setInfo] = useState<CheckOutForm>({})
|
const [info, setInfo] = useState<CheckOutForm>({})
|
||||||
|
|
||||||
const onEdit = (id:number) => {
|
const onEdit = (id: number) => {
|
||||||
setActive(id)
|
setActive(id)
|
||||||
setDone(removeItem<number>(done,id))
|
setDone(removeItem<number>(done, id))
|
||||||
}
|
}
|
||||||
|
|
||||||
const onConfirm = (id:number,formInfo:CheckOutForm) => {
|
const onConfirm = (id: number, formInfo: CheckOutForm) => {
|
||||||
if(id+1>formList.length){
|
if (id + 1 > formList.length) {
|
||||||
console.log({...info,...formInfo})
|
console.log({ ...info, ...formInfo })
|
||||||
}else{
|
} else {
|
||||||
if(done.length>0){
|
if (done.length > 0) {
|
||||||
for (let i = id+1; i <= formList.length; i++) {
|
for (let i = id + 1; i <= formList.length; i++) {
|
||||||
if(!done.includes(i)){
|
if (!done.includes(i)) {
|
||||||
setActive(i)
|
setActive(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
setActive(id+1)
|
setActive(id + 1)
|
||||||
}
|
}
|
||||||
setDone([...done,id])
|
setDone([...done, id])
|
||||||
}
|
}
|
||||||
setInfo({...info,...formInfo})
|
setInfo({ ...info, ...formInfo })
|
||||||
}
|
}
|
||||||
|
|
||||||
const getNote = (id:number) => {
|
const getNote = (id: number) => {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 1:
|
case 1:
|
||||||
return `${info.name}, ${info.email}`
|
return `${info.name}, ${info.email}`
|
||||||
case 2:
|
case 2:
|
||||||
return `${info.address}, ${info.state}, ${info.city}, ${info.code}, ${info.phone}, `
|
return `${info.address}, ${info.state}, ${info.city}, ${info.code}, ${info.phone}, `
|
||||||
default:
|
default:
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@@ -54,21 +55,37 @@ const CheckoutInfo = ({onViewCart}: CheckoutInfoProps) => {
|
|||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
title: 'Customer Information',
|
title: 'Customer Information',
|
||||||
form: <CustomerInfoForm onConfirm={onConfirm} id={1}/>,
|
form: <CustomerInfoForm onConfirm={onConfirm} id={1} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
title: 'Shipping Information',
|
title: 'Shipping Information',
|
||||||
form: <ShippingInfoForm onConfirm={onConfirm} id={2}/>,
|
form: <ShippingInfoForm onConfirm={onConfirm} id={2} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
title: 'Payment Information',
|
title: 'Payment Information',
|
||||||
form: <PaymentInfoForm onConfirm={onConfirm} id={3}/>,
|
form: <PaymentInfoForm onConfirm={onConfirm} id={3} />,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// TODO: remove
|
||||||
|
const { addProduct } = useAddProductToCart()
|
||||||
|
|
||||||
|
const createOrder = () => {
|
||||||
|
addProduct({ variantId: "63", quantity: 1 }, handleAddToCartCallback)
|
||||||
|
}
|
||||||
|
const handleAddToCartCallback = (isSuccess: boolean, message?: string) => {
|
||||||
|
// console.log("after create order: ", isSuccess, message)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const {order} = useGetActiveOrder()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={s.warpper}>
|
<div className={s.warpper}>
|
||||||
|
<ButtonCommon onClick={createOrder}>test create order</ButtonCommon>
|
||||||
|
<ButtonCommon onClick={createOrder}>test get active order</ButtonCommon>
|
||||||
<div className={s.title}>
|
<div className={s.title}>
|
||||||
<Logo />
|
<Logo />
|
||||||
<div className={s.viewCart} onClick={onViewCart}>View cart</div>
|
<div className={s.viewCart} onClick={onViewCart}>View cart</div>
|
||||||
@@ -76,7 +93,7 @@ const CheckoutInfo = ({onViewCart}: CheckoutInfoProps) => {
|
|||||||
{formList.map((item) => {
|
{formList.map((item) => {
|
||||||
let note = getNote(item.id)
|
let note = getNote(item.id)
|
||||||
return <CheckoutCollapse
|
return <CheckoutCollapse
|
||||||
key={item.title}
|
key={item.title}
|
||||||
id={item.id}
|
id={item.id}
|
||||||
visible={item.id === active}
|
visible={item.id === active}
|
||||||
title={item.title}
|
title={item.title}
|
||||||
|
@@ -0,0 +1,6 @@
|
|||||||
|
@import "../../../../../../styles/utilities";
|
||||||
|
|
||||||
|
.chekoutNotePolicy {
|
||||||
|
@apply caption;
|
||||||
|
margin-bottom: 1.6rem;
|
||||||
|
}
|
@@ -0,0 +1,31 @@
|
|||||||
|
import Link from 'next/link'
|
||||||
|
import React, { memo } from 'react'
|
||||||
|
import { ROUTE } from 'src/utils/constanst.utils'
|
||||||
|
import s from './ChekoutNotePolicy.module.scss'
|
||||||
|
|
||||||
|
const ChekoutNotePolicy = memo(() => {
|
||||||
|
return (
|
||||||
|
<div className={s.chekoutNotePolicy}>
|
||||||
|
By clicking continue you agree to Casper's{' '}
|
||||||
|
{
|
||||||
|
<Link href={ROUTE.TERM_CONDITION}>
|
||||||
|
<a>
|
||||||
|
<strong>terms and conditions</strong>
|
||||||
|
</a>
|
||||||
|
</Link>
|
||||||
|
}{' '}
|
||||||
|
and{' '}
|
||||||
|
{
|
||||||
|
<Link href={ROUTE.PRIVACY_POLICY}>
|
||||||
|
<a>
|
||||||
|
<strong>privacy policy </strong>
|
||||||
|
</a>
|
||||||
|
</Link>
|
||||||
|
}
|
||||||
|
.
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
ChekoutNotePolicy.displayName = 'ChekoutNotePolicy'
|
||||||
|
export default ChekoutNotePolicy
|
@@ -10,15 +10,8 @@
|
|||||||
.bottom{
|
.bottom{
|
||||||
margin-top: 2.4rem;
|
margin-top: 2.4rem;
|
||||||
@apply flex justify-between items-center;
|
@apply flex justify-between items-center;
|
||||||
.note{
|
|
||||||
font-size: 1.2rem;
|
|
||||||
line-height: 2rem;
|
|
||||||
}
|
|
||||||
@screen sm-only {
|
@screen sm-only {
|
||||||
@apply flex-col items-start;
|
@apply flex-col items-start;
|
||||||
.button {
|
|
||||||
padding-top: 2rem;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,55 +1,117 @@
|
|||||||
import Link from 'next/link'
|
import { Form, Formik } from 'formik'
|
||||||
import React, { useRef } from 'react'
|
import React, { useRef } from 'react'
|
||||||
import { ButtonCommon, Inputcommon } from 'src/components/common'
|
import { ButtonCommon, InputFiledInForm } from 'src/components/common'
|
||||||
import InputCommon from 'src/components/common/InputCommon/InputCommon'
|
import { useMessage } from 'src/components/contexts'
|
||||||
import { CheckOutForm } from 'src/utils/types.utils'
|
import { useSetCustomerForOrder } from 'src/components/hooks/order'
|
||||||
|
import { LANGUAGE } from 'src/utils/language.utils'
|
||||||
|
import { CustomInputCommon } from 'src/utils/type.utils'
|
||||||
|
import * as Yup from 'yup'
|
||||||
|
import ChekoutNotePolicy from '../ChekoutNotePolicy/ChekoutNotePolicy'
|
||||||
import s from './CustomerInfoForm.module.scss'
|
import s from './CustomerInfoForm.module.scss'
|
||||||
interface CustomerInfoFormProps {
|
interface Props {
|
||||||
onConfirm?: (id: number, formInfo: CheckOutForm) => void
|
isHide: boolean
|
||||||
id: number
|
onSwitch: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const CustomerInfoForm = ({ id, onConfirm }: CustomerInfoFormProps) => {
|
const displayingErrorMessagesSchema = Yup.object().shape({
|
||||||
const nameRef = useRef<React.ElementRef<typeof InputCommon>>(null)
|
firstName: Yup.string().required(LANGUAGE.MESSAGE.REQUIRED),
|
||||||
const emailRef = useRef<React.ElementRef<typeof InputCommon>>(null)
|
lastName: Yup.string().required(LANGUAGE.MESSAGE.REQUIRED),
|
||||||
|
emailAddress: Yup.string().email(LANGUAGE.MESSAGE.INVALID_EMAIL).required(LANGUAGE.MESSAGE.REQUIRED),
|
||||||
|
})
|
||||||
|
|
||||||
|
const CustomerInfoForm = ({ onSwitch, isHide }: Props) => {
|
||||||
|
const firstNameRef = useRef<CustomInputCommon>(null)
|
||||||
|
const emailRef = useRef<CustomInputCommon>(null)
|
||||||
|
const { setCustomerForOrder, loading } = useSetCustomerForOrder()
|
||||||
|
const { showMessageError } = useMessage()
|
||||||
|
|
||||||
|
const handleSubmit = (values: { firstName: string, lastName: string, emailAddress: string }) => {
|
||||||
|
console.log('on submit: ', values)
|
||||||
|
const { firstName, lastName, emailAddress } = values
|
||||||
|
setCustomerForOrder({ firstName, lastName, emailAddress }, onSubmitCalBack)
|
||||||
|
// onConfirm &&
|
||||||
|
// onConfirm(id, {
|
||||||
|
// name: nameRef?.current?.getValue().toString(),
|
||||||
|
// email: emailRef.current?.getValue().toString(),
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
const onSubmitCalBack = (isSuccess: boolean, msg?: string) => {
|
||||||
|
// TODO:
|
||||||
|
console.log("result: ", isSuccess, msg)
|
||||||
|
if (isSuccess) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
console.log("error here")
|
||||||
|
showMessageError(msg)
|
||||||
|
}
|
||||||
|
|
||||||
const handleConfirmClick = () => {
|
|
||||||
onConfirm &&
|
|
||||||
onConfirm(id, {
|
|
||||||
name: nameRef?.current?.getValue().toString(),
|
|
||||||
email: emailRef.current?.getValue().toString(),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={s.warpper}>
|
<section className={s.warpper}>
|
||||||
<div className={s.body}>
|
<div className={s.body}>
|
||||||
<Inputcommon type="text" placeholder="Full Name" ref={nameRef} />
|
<Formik
|
||||||
<Inputcommon type="text" placeholder="Email Address" ref={emailRef} />
|
initialValues={{
|
||||||
|
firstName: '',
|
||||||
|
lastName: '',
|
||||||
|
emailAddress: '',
|
||||||
|
}}
|
||||||
|
validationSchema={displayingErrorMessagesSchema}
|
||||||
|
onSubmit={handleSubmit}
|
||||||
|
|
||||||
|
>
|
||||||
|
{({ errors, touched, isValid, submitForm }) => (
|
||||||
|
<Form className="u-form">
|
||||||
|
<div className="body">
|
||||||
|
<div className="line">
|
||||||
|
<InputFiledInForm
|
||||||
|
name="firstName"
|
||||||
|
placeholder="First name"
|
||||||
|
ref={firstNameRef}
|
||||||
|
error={
|
||||||
|
touched.firstName && errors.firstName
|
||||||
|
? errors.firstName.toString()
|
||||||
|
: ''
|
||||||
|
}
|
||||||
|
isShowIconSuccess={touched.firstName && !errors.firstName}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<InputFiledInForm
|
||||||
|
name="lastName"
|
||||||
|
placeholder="Last name"
|
||||||
|
error={
|
||||||
|
touched.lastName && errors.lastName
|
||||||
|
? errors.lastName.toString()
|
||||||
|
: ''
|
||||||
|
}
|
||||||
|
isShowIconSuccess={touched.lastName && !errors.lastName}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<InputFiledInForm
|
||||||
|
name="emailAddress"
|
||||||
|
placeholder="Email Address"
|
||||||
|
ref={emailRef}
|
||||||
|
error={
|
||||||
|
touched.emailAddress && errors.emailAddress
|
||||||
|
? errors.emailAddress.toString()
|
||||||
|
: ''
|
||||||
|
}
|
||||||
|
isShowIconSuccess={touched.emailAddress && !errors.emailAddress}
|
||||||
|
onEnter={isValid ? submitForm : undefined}
|
||||||
|
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className={s.bottom}>
|
||||||
|
<ChekoutNotePolicy />
|
||||||
|
<ButtonCommon HTMLType='submit' loading={loading} size="large">
|
||||||
|
Continue to Shipping
|
||||||
|
</ButtonCommon>
|
||||||
|
</div>
|
||||||
|
</Form>
|
||||||
|
)}
|
||||||
|
</Formik>
|
||||||
</div>
|
</div>
|
||||||
<div className={s.bottom}>
|
</section>
|
||||||
<div className={s.note}>
|
|
||||||
By clicking continue you agree to Casper's{' '}
|
|
||||||
{
|
|
||||||
<Link href="#">
|
|
||||||
<strong>terms and conditions</strong>
|
|
||||||
</Link>
|
|
||||||
}{' '}
|
|
||||||
and{' '}
|
|
||||||
{
|
|
||||||
<Link href="#">
|
|
||||||
<strong>privacy policy </strong>
|
|
||||||
</Link>
|
|
||||||
}
|
|
||||||
.
|
|
||||||
</div>
|
|
||||||
<div className={s.button}>
|
|
||||||
<ButtonCommon onClick={handleConfirmClick}>
|
|
||||||
Continue to Shipping
|
|
||||||
</ButtonCommon>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,9 +14,11 @@ interface ShippingInfoFormProps {
|
|||||||
const option = [
|
const option = [
|
||||||
{
|
{
|
||||||
name: 'Hồ Chí Minh',
|
name: 'Hồ Chí Minh',
|
||||||
|
value: 'Hồ Chí Minh',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Hà Nội',
|
name: 'Hà Nội',
|
||||||
|
value: 'Hà Nội',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
import classNames from 'classnames'
|
import classNames from 'classnames'
|
||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
|
import { MessageCommon } from 'src/components/common'
|
||||||
|
import { useMessage } from 'src/components/contexts'
|
||||||
import IconHide from 'src/components/icons/IconHide'
|
import IconHide from 'src/components/icons/IconHide'
|
||||||
import { CHECKOUT_BILL_DATA } from 'src/utils/demo-data'
|
import { CHECKOUT_BILL_DATA } from 'src/utils/demo-data'
|
||||||
import { CheckoutBill, CheckoutInfo } from '..'
|
import { CheckoutBill, CheckoutInfo } from '..'
|
||||||
@@ -8,7 +10,9 @@ interface CheckoutPageProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const CheckoutPage = ({}: CheckoutPageProps) => {
|
const CheckoutPage = ({}: CheckoutPageProps) => {
|
||||||
|
const { messages, removeMessage } = useMessage()
|
||||||
const [isShow, setIsShow] = useState(false)
|
const [isShow, setIsShow] = useState(false)
|
||||||
|
|
||||||
const onClose = () => {
|
const onClose = () => {
|
||||||
setIsShow(false)
|
setIsShow(false)
|
||||||
}
|
}
|
||||||
@@ -17,6 +21,7 @@ const CheckoutPage = ({}: CheckoutPageProps) => {
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div className={s.warrper}>
|
<div className={s.warrper}>
|
||||||
|
<MessageCommon messages={messages} onRemove={removeMessage} />
|
||||||
<div className={s.left}><CheckoutInfo onViewCart = {onViewCart}/></div>
|
<div className={s.left}><CheckoutInfo onViewCart = {onViewCart}/></div>
|
||||||
<div className={s.right}><CheckoutBill data={CHECKOUT_BILL_DATA}/></div>
|
<div className={s.right}><CheckoutBill data={CHECKOUT_BILL_DATA}/></div>
|
||||||
<div className={classNames({ [s.mobile] :true,[s.isShow]: isShow})}>
|
<div className={classNames({ [s.mobile] :true,[s.isShow]: isShow})}>
|
||||||
|
@@ -201,7 +201,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.line {
|
.line {
|
||||||
@apply flex justify-between items-center;
|
@apply flex justify-between items-start;
|
||||||
> div {
|
> div {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
&:not(:last-child) {
|
&:not(:last-child) {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { request } from 'graphql-request'
|
import { GraphQLClient } from 'graphql-request'
|
||||||
import { RequestDocument, Variables } from 'graphql-request/dist/types'
|
import { RequestDocument, Variables } from 'graphql-request/dist/types'
|
||||||
import { LOCAL_STORAGE_KEY } from './constanst.utils'
|
import { LOCAL_STORAGE_KEY } from './constanst.utils'
|
||||||
|
|
||||||
@@ -12,11 +12,15 @@ interface QueryOptions {
|
|||||||
const fetcher = async <T>(options: QueryOptions): Promise<T> => {
|
const fetcher = async <T>(options: QueryOptions): Promise<T> => {
|
||||||
const { query, variables } = options
|
const { query, variables } = options
|
||||||
const token = localStorage.getItem(LOCAL_STORAGE_KEY.TOKEN)
|
const token = localStorage.getItem(LOCAL_STORAGE_KEY.TOKEN)
|
||||||
const res = await request<T>(
|
const graphQLClient = new GraphQLClient(process.env.NEXT_PUBLIC_VENDURE_SHOP_API_URL as string, {
|
||||||
process.env.NEXT_PUBLIC_VENDURE_SHOP_API_URL as string,
|
credentials: 'include',
|
||||||
|
mode: 'cors',
|
||||||
|
headers: token ? { Authorization: 'Bearer ' + token } : {},
|
||||||
|
})
|
||||||
|
|
||||||
|
const res = await graphQLClient.request<T>(
|
||||||
query,
|
query,
|
||||||
variables,
|
variables,
|
||||||
token ? { Authorization: 'Bearer ' + token } : {}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
@@ -11,6 +11,9 @@ export const LANGUAGE = {
|
|||||||
SEARCH: 'Search',
|
SEARCH: 'Search',
|
||||||
},
|
},
|
||||||
MESSAGE: {
|
MESSAGE: {
|
||||||
ERROR: 'Something went wrong! Please try again!'
|
ERROR: 'Something went wrong! Please try again!',
|
||||||
|
INVALID_EMAIL: 'Your email was wrong',
|
||||||
|
REQUIRED: 'Required',
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,7 +1,6 @@
|
|||||||
import { rawRequest } from 'graphql-request'
|
import { GraphQLClient } from 'graphql-request'
|
||||||
import { RequestDocument, Variables } from 'graphql-request/dist/types'
|
import { RequestDocument, Variables } from 'graphql-request/dist/types'
|
||||||
import { LOCAL_STORAGE_KEY } from './constanst.utils'
|
import { LOCAL_STORAGE_KEY } from './constanst.utils'
|
||||||
|
|
||||||
interface QueryOptions {
|
interface QueryOptions {
|
||||||
query: RequestDocument
|
query: RequestDocument
|
||||||
variables?: Variables
|
variables?: Variables
|
||||||
@@ -16,15 +15,20 @@ const rawFetcher = <T>({
|
|||||||
}: QueryOptions): Promise<{ data: T; headers: any }> => {
|
}: QueryOptions): Promise<{ data: T; headers: any }> => {
|
||||||
onLoad(true)
|
onLoad(true)
|
||||||
const token = localStorage.getItem(LOCAL_STORAGE_KEY.TOKEN)
|
const token = localStorage.getItem(LOCAL_STORAGE_KEY.TOKEN)
|
||||||
return rawRequest<T>(
|
|
||||||
process.env.NEXT_PUBLIC_VENDURE_SHOP_API_URL as string,
|
const graphQLClient = new GraphQLClient(process.env.NEXT_PUBLIC_VENDURE_SHOP_API_URL as string, {
|
||||||
|
credentials: 'include',
|
||||||
|
mode: 'cors',
|
||||||
|
headers: token ? { Authorization: 'Bearer ' + token } : {},
|
||||||
|
})
|
||||||
|
|
||||||
|
return graphQLClient.rawRequest<T>(
|
||||||
query as string,
|
query as string,
|
||||||
variables,
|
variables,
|
||||||
token ? { Authorization: 'Bearer ' + token } : {}
|
)
|
||||||
)
|
.then(({ data, headers }) => {
|
||||||
.then(({ data, headers }) => {
|
return { data, headers }
|
||||||
return { data, headers }
|
})
|
||||||
})
|
|
||||||
.finally(() => onLoad(false))
|
.finally(() => onLoad(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -72,4 +72,18 @@ export type PromiseWithKey = {
|
|||||||
keyResult?: string,
|
keyResult?: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SelectedOptions = Record<string, string | null>
|
// ref https://www.vendure.io/docs/typescript-api/orders/order-state/
|
||||||
|
export type OrderState = | 'Created'
|
||||||
|
| 'AddingItems'
|
||||||
|
| 'ArrangingPayment'
|
||||||
|
| 'PaymentAuthorized'
|
||||||
|
| 'PaymentSettled'
|
||||||
|
| 'PartiallyShipped'
|
||||||
|
| 'Shipped'
|
||||||
|
| 'PartiallyDelivered'
|
||||||
|
| 'Delivered'
|
||||||
|
| 'Modifying'
|
||||||
|
| 'ArrangingAdditionalPayment'
|
||||||
|
| 'Cancelled'
|
||||||
|
|
||||||
|
export type SelectedOptions = Record<string, string | null>
|
||||||
|
Reference in New Issue
Block a user