Загрузка данных


export const userWishListQuery = ({
    page = 1,
    perPage = 15,
    currencyCode = 'GBP',
    countryId = 37,
}) => {
    return JSON.stringify({
        variables: { page, perPage, currencyCode, countryId },
        query: `
            query userWishList(
                $page: PositiveInt! = 1,
                $perPage: PositiveInt! = 15,
                $localeId: Int! = 1,
                $currencyCode: String,
                $countryId: Int,
            ) {
                me {
                    wishList(page: $page, perPage: $perPage) {
                        pageInfo {
                            hasNextPage
                        }
                        items {
                            id
                            basePrice {
                                price (currencyCode: $currencyCode)
                                currency { code }
                            }
                            customPrice {
                                price (currencyCode: $currencyCode)
                                currency { code }
                            }
                            recognition {
                                id
                                images {
                                    imageUrl(
                                        transformations: {width: 192, height: 192, resize: fit}
                                    )
                                }
                                createdAt
                                product {
                                    slug
                                    bottleSize { volumeML }
                                    packageType { shortName }
                                    tradeOfferLotCount(filter: { countryId: $countryId })
                                    maximumTradeOfferLot(filter: { countryId: $countryId }) {
                                        pricePerBottle: price(wineLotId: 1, currencyCode: $currencyCode)
                                    }
                                    minimalTradeOfferLot(filter: { countryId: $countryId }) {
                                        pricePerBottle: price(wineLotId: 1, currencyCode: $currencyCode)
                                    }
                                    wine {
                                        ...WineInfo
                                    }
                                }
                                productDraft {
                                    bottleSize { volumeML }
                                    packageType { shortName }
                                    wine {
                                        ...WineInfo
                                        ...WineDraftInfo
                                    }
                                }
                            }
                        }
                    }
                }
            }

            fragment WineInfo on Wine {
                keyWords
                tradeName { tradeName }
                brand { name }
                wineType { localizedName(localeId: $localeId) }
                wineColor { localizedName(localeId: $localeId) }
                sweetnessLevel { localizedName(localeId: $localeId) }
                country {
                    codeISO
                    localizedName(localeId: $localeId)
                }
                nationalGIType { localizedShortName(localeId: $localeId) }
                geoIndications { localizedName(localeId: $localeId) }
                specialClassifications { name }
                vintageText
                vintageList {
                    vintageText
                    products {
                        bottleSize { volumeML }
                        packageType { shortName }
                        tradeOfferLots {
                            tradeOffer {
                                merchant {
                                    country { codeISO }
                                }
                            }
                        }
                    }
                }
            }

            fragment WineDraftInfo on WineDraft {
                keyWords
                tradeName { tradeName }
                brand { name }
                wineType { localizedName(localeId: $localeId) }
                wineColor { localizedName(localeId: $localeId) }
                sweetnessLevel { localizedName(localeId: $localeId) }
                country {
                    codeISO
                    localizedName(localeId: $localeId)
                }
                nationalGIType { localizedShortName(localeId: $localeId) }
                geoIndications { localizedName(localeId: $localeId) }
                specialClassifications { name }
                vintageTextDraft: vintageText
                isVintageUnknown
            }
        `,
    });
};

export const wishListSetCustomPriceMutation = ({
    id,
    price,
    currencyId,
}: {
    id: string;
    price: number | null;
    currencyId: number | null;
}) => {
    return JSON.stringify({
        variables: { id, price, currencyId },
        query: `
            mutation userWishListSetCustomPrice(
                $id: ID!
                $price: NonNegativeFloat
                $currencyId: Int
            ) {
                wishListSetCustomPrice(
                    input: { id: $id, price: $price, currencyId: $currencyId }
                ) {
                    record {
                        id
                        customPrice {
                            price
                            currency { code }
                        }
                    }
                }
            }
        `,
    });
};