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


export const tradeOfferLotsQuery = ({
    page = 1,
    perPage,
    localeId = 1,
    filter = {} as unknown,
    query = "",
    currencyCode = "GBP",
}: {
    page?: number;
    perPage?: number;
    localeId?: number;
    filter?: unknown;
    query?: string;
    currencyCode?: string;
}) => {
    return JSON.stringify({
        variables: {
            localeId,
            page,
            perPage,
            query,
            filter,
            currencyCode,
        },
        query: /* GraphQL */`
            query allWinesTradeOfferLotsPagination(
                $localeId: Int! = 1,
                $page: PositiveInt! = 1,
                $perPage: PositiveInt! = 50,
                $query: String,
                $sort: TradeOfferLotSort! = RETAIL_COEF_ASC,
                $filter: TradeOfferLotsPaginationFilter!,
                $currencyCode: String,
            ) {
                tradeOfferLotsPagination(
                    localeId: $localeId
                    page: $page
                    perPage: $perPage
                    query: $query
                    sort: $sort
                    filter: $filter
                ) {
                    pageInfo {
                        totalItems
                        hasNextPage
                    }
                    items {
                        id
                        uuid
                        price(currencyCode: $currencyCode)
                        updatedAt
                        retailCoef
                        product {
                            bottleImage {
                                imageUrl(transformations: { width: 192, height: 192, resize: fit })
                            }
                            bottleSize {
                                volumeML
                            }
                            wine {
                                rating
                                keyWords
                                tradeName {
                                    tradeName
                                }
                                brand {
                                    name
                                }
                                vintageText
                                specialClassifications {
                                    name
                                }
                                country {
                                    localizedName(localeId: $localeId)
                                    codeISO
                                }
                                geoIndications {
                                    localizedName(localeId: $localeId)
                                }
                                nationalGIType {
                                    localizedShortName(localeId: $localeId)
                                }
                                wineColor {
                                    localizedName(localeId: $localeId)
                                }
                                wineType {
                                    localizedName(localeId: $localeId)
                                }
                                sweetnessLevel {
                                    localizedName(localeId: $localeId)
                                }
                            }
                            minimalRecommendedRetailPrice {
                                price(currencyCode: $currencyCode)
                            }
                        }
                    }
                }
            }
        `
    });
};