feat: get blog list

This commit is contained in:
Quangnhankie
2021-10-19 10:32:09 +07:00
88 changed files with 2019 additions and 356 deletions

View File

@@ -7,6 +7,8 @@ export const searchResultFragment = /* GraphQL */ `
slug
sku
currencyCode
productVariantId
productVariantName
productAsset {
id
preview

View File

@@ -0,0 +1,14 @@
export const requestPasswordReset = /* GraphQL */ `
mutation RequestPasswordReset($emailAddress: String!) {
requestPasswordReset(emailAddress: $emailAddress) {
__typename
...on Success{
success
}
...on ErrorResult{
errorCode
message
}
}
}
`

View File

@@ -0,0 +1,15 @@
export const resetPasswordMutation = /* GraphQL */ `
mutation resetPassword($token: String!,$password: String!){
resetPassword(token: $token,password: $password){
__typename
...on CurrentUser{
id
identifier
}
...on ErrorResult{
errorCode
message
}
}
}
`

View File

@@ -0,0 +1,9 @@
export const toggleWishlistMutation = /* GraphQL */ `
mutation toggleFavorite($productId:ID!){
toggleFavorite(productId:$productId){
items{
id
}
}
}
`

View File

@@ -0,0 +1,14 @@
export const updateCustomerAddress = /* GraphQL */ `
mutation updateCustomerAddress($input: UpdateAddressInput!){
updateCustomerAddress(input: $input){
__typename
...on Address{
id
streetLine1
city
postalCode
province
}
}
}
`

View File

@@ -0,0 +1,13 @@
export const updateCustomer = /* GraphQL */ `
mutation updateCustomer($input: UpdateCustomerInput!){
updateCustomer(input:$input){
__typename
...on Customer{
id
firstName
lastName
phoneNumber
}
}
}
`

View File

@@ -1,6 +1,6 @@
import { Cart } from '@commerce/types/cart'
import { ProductCard } from '@commerce/types/product'
import { CartFragment, SearchResultFragment } from '../schema'
import { ProductCard, Product } from '@commerce/types/product'
import { CartFragment, SearchResultFragment,Favorite } from '../schema'
export function normalizeSearchResult(item: SearchResultFragment): ProductCard {
return {
@@ -10,6 +10,8 @@ export function normalizeSearchResult(item: SearchResultFragment): ProductCard {
imageSrc: item.productAsset?.preview ? item.productAsset?.preview + '?w=800&mode=crop' : '',
price: (item.priceWithTax as any).min / 100,
currencyCode: item.currencyCode,
productVariantId: item.productVariantId,
productVariantName:item.productVariantName,
facetValueIds: item.facetValueIds,
collectionIds: item.collectionIds,
@@ -21,6 +23,18 @@ export function normalizeSearchResult(item: SearchResultFragment): ProductCard {
}
}
export function normalizeFavoriteProductResult(item: Favorite) {
return {
id: item.product.id,
name: item.product.name,
slug: item.product.slug,
imageSrc: item.product.assets[0].preview ? item.product.assets[0].preview + '?w=800&mode=crop' : '',
price: item.product.variants[0].priceWithTax as number / 100,
currencyCode: item.product.variants[0].currencyCode,
}
}
export function normalizeCart(order: CartFragment): Cart {
return {
id: order.id.toString(),
@@ -35,7 +49,7 @@ export function normalizeCart(order: CartFragment): Cart {
id: l.id,
name: l.productVariant.name,
quantity: l.quantity,
url: l.productVariant.product.slug,
slug: l.productVariant.product.slug,
variantId: l.productVariant.id,
productId: l.productVariant.productId,
images: [{ url: l.featuredAsset?.preview + '?preset=thumb' || '' }],
@@ -55,3 +69,18 @@ export function normalizeCart(order: CartFragment): Cart {
})),
}
}
export function normalizeProductCard(product: Product): ProductCard {
return {
id: product.id,
name: product.name,
slug: product.slug,
imageSrc: product.images[0].url,
price: product.price,
currencyCode: product.currencyCode,
productVariantId: product.variants?.[0].id.toString(),
productVariantName:product.variants?.[0].name,
facetValueIds: product.facetValueIds,
collectionIds: product.collectionIds,
}
}

View File

@@ -1,10 +1,24 @@
export const activeCustomerQuery = /* GraphQL */ `
query activeCustomer {
activeCustomer {
id
firstName
lastName
emailAddress
query activeCustomer {
activeCustomer {
id
firstName
lastName
emailAddress
favorites{
items{
product{
id
}
}
}
phoneNumber
addresses{
streetLine1
city
province
postalCode
}
}
}
`

View File

@@ -0,0 +1,28 @@
export const getFavoriteProductQuery = /* GraphQL */ `
query activeCustomer($options: FavoriteListOptions) {
activeCustomer {
id
firstName
lastName
emailAddress
favorites(options: $options){
items{
product{
id
name
slug
assets{
source
preview
}
variants{
priceWithTax
currencyCode
}
}
}
totalItems
}
}
}
`

View File

@@ -12,6 +12,7 @@ export const getProductQuery = /* GraphQL */ `
}
variants {
id
name
priceWithTax
currencyCode
options {
@@ -41,6 +42,7 @@ export const getProductQuery = /* GraphQL */ `
}
collections {
id
name
}
}
}

View File

@@ -0,0 +1,19 @@
export const getUserOrderQuery = /* GraphQL */ `
query activeCustomer {
activeCustomer {
orders{
items{
lines{
productVariant{
name
}
quantity
}
total
state
code
}
}
}
}
`

View File

@@ -0,0 +1,16 @@
export const userInfoQuery = /* GraphQL */ `
query activeCustomer{
activeCustomer{
lastName
firstName
emailAddress
phoneNumber
addresses{
streetLine1
city
province
postalCode
}
}
}
`