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


export const tradeOfferLotsQuery = ({
    page = 1,
    perPage = 50,
    localeId = 1,
    filter,
    query = "",
    currencyCode = "GBP",
    countryId = 37,
}) => {
    return JSON.stringify({
        variables: {
            localeId,
            page,
            perPage,
            // sort,
            query,
            filter,
            currencyCode,
            countryId,
        },
        query: `
            query retailProductsPagination(
                $localeId: Int!, 
                $page: PositiveInt, 
                $perPage: PositiveInt, 
                $query: String, 
                $sort: ProductSort = WINE_NAME_ASC, 
                $currencyCode: String,
                $countryId: Int,
                $filter: RetailProductsPaginationFilter = {}, 
            ) {
                retailProductsPagination(
                    localeId: 1
                    page: $page
                    perPage: $perPage
                    query: $query
                    sort: $sort
                    filter: $filter
                ) {
                    pageInfo {
                        totalItems
                        hasNextPage
                    }
                    items {
                        id
                        slug
                        wine {
                            tradeName {
                                tradeName
                            }
                            brand {
                                name
                            }
                            keyWords
                            specialClassifications {
                                name
                            }
                            vintageText
                            country {
                                localizedName(localeId: $localeId)
                                codeISO
                            }
                            geoIndications {
                                localizedName(localeId: $localeId)
                            }
                            nationalGIType {
                                localizedShortName(localeId: $localeId)
                            }
                            rating
                            wineColor {
                                localizedName(localeId: $localeId)
                            }
                            wineType {   
                                localizedName(localeId: $localeId)                           
                            }
                            sweetnessLevel {
                                localizedName(localeId: $localeId)
                            }
                        }
                        bottleSize {
                            volumeML
                        }
                        bottleImage {
                            imageUrl
                        }
                        minimalRecommendedRetailPrice {
                            price(currencyCode: $currencyCode)
                        }

                        tradeOfferLotCount(filter: { countryId: $countryId }) 
                                        
                        maximumTradeOfferLot(filter: { countryId: $countryId }) {
                            pricePerBottle: price(wineLotId: 1, currencyCode: $currencyCode)
                            price(currencyCode: $currencyCode)

                            lot {
                                bottleQuantity
                            }

                            retailCoef
                        }
                        minimalTradeOfferLot(filter: { countryId: $countryId }) {
                            pricePerBottle: price(wineLotId: 1, currencyCode: $currencyCode)
                            price(currencyCode: $currencyCode)

                            lot {
                                bottleQuantity
                            }
                                
                            retailCoef
                        }
                    }
                }
            }
        `
    });
};