commerce/framework/saleor/utils/get-vendors.ts

44 lines
969 B
TypeScript

import { SaleorConfig } from '../api'
import fetchAllProducts from '../api/utils/fetch-all-products'
import getAllProductVendors from './queries/get-all-product-vendors-query'
export type Brand = {
entityId: string
name: string
path: string
}
export type BrandEdge = {
node: Brand
}
export type Brands = BrandEdge[]
// TODO: Find a way to get vendors from meta
const getVendors = async (config: SaleorConfig): Promise<BrandEdge[]> => {
// const vendors = await fetchAllProducts({
// config,
// query: getAllProductVendors,
// variables: {
// first: 100,
// },
// })
// let vendorsStrings = vendors.map(({ node: { vendor } }) => vendor)
// return [...new Set(vendorsStrings)].map((v) => {
// const id = v.replace(/\s+/g, '-').toLowerCase()
// return {
// node: {
// entityId: id,
// name: v,
// path: `brands/${id}`,
// },
// }
// })
return []
}
export default getVendors