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


export const userProductRecognitions = ({
    page = 1,
    perPage = 15,
    currencyCode = "GBP",
    countryId = 37,
}) => {
    return JSON.stringify({
        variables: {
            page,
            perPage,
            currencyCode,
            countryId,
        },
        query: /* GraphQL */ `
            query productRecognitionsPagination(
                $page: PositiveInt! = 1, 
                $perPage: PositiveInt = 5, 
                $localeId: Int! = 1,
                $currencyCode: String,
                $countryId: Int,
            ) {
                me {
                    productRecognitionsPagination(page: $page, perPage: $perPage) {
                        pageInfo {
                            hasNextPage
                        }
                        items {
                            id
                            tasting {
                                id
                            }
                            images {
                                imageUrl(
                                    transformations: {width: 192, height: 192, resize: fit}
                                )
                            }
                            createdAt
                            product {
                                slug
                                bottleSize {
                                    volumeML
                                }
                                packageType {
                                    id
                                }
                                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 {
                                    id
                                }
                                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 {
                    id
                    codeISO
                    localizedName(localeId: $localeId)
                }
                nationalGIType {
                    localizedShortName(localeId: $localeId)
                }
                geoIndications {
                    localizedShortName(localeId: $localeId)
                }
                specialClassifications {
                    name
                }
                vintageText

                vintageList {
                    vintageText
                    products {
                        bottleSize {
                            volumeML
                        }
                        packageType {
                            id
                        }
                        tradeOfferLotCount(filter: { countryId: $countryId })
                    }
                }
            }

            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 {
                    localizedShortName(localeId: $localeId)
                }
                specialClassifications {
                    name
                }
                vintageTextDraft: vintageText
            }
        `
    });
};



// пометка RecognitionRequest'а продегустированным
//
// где input
// {
//   "recognitionId": 1
// }
export const userTastingCreate = ({
    input
}) => {
    return JSON.stringify({
        variables: {
            input
        },
        query: /* GraphQL */ `
            mutation tastingCreate($input: TastingCreateInput!) {
                tastingCreate(input: $input) {
                    record {
                        id
                    }
                    updatedRecognitions {
                        id
                    }
                }
            }
        `
    });
};