import { getLocale, getMessages } from "next-intl/server"; import Link from "next/link"; import React from "react"; import CardNormal from "src/components/Cards/CardNormal"; import ProductCarousel from "src/components/Carousel/ProductCarousel"; import graphql from "src/utils/graphql"; const gql = ` query Products_connection($locale: I18NLocaleCode, $page: Int, $pageSize: Int,$category:String,$brand:String) { products_connection( pagination: { page: $page, pageSize: $pageSize } locale: $locale sort: ["createdAt:desc"] filters: { or:[ {brand: { slug: { eqi: $brand } }} {category:{ slug: { eqi: $category } }} ] } ) { nodes { title documentId images { alternativeText documentId url } category { documentId title slug } brand { title documentId slug image { url alternativeText documentId } } slug } } } ` const getProducts = async (brand = "", category = "") => { const locale = await getLocale() const products = await graphql(gql, { page: 1, pageSize: 20, locale: "en", brand: brand, category: category }) return products.products_connection.nodes; } const Products = async () => { const products1 = await getProducts("active") const products2 = await getProducts("", "construction") const t = await getMessages() return (