mirror of
https://github.com/vercel/commerce.git
synced 2025-07-24 10:41:23 +00:00
rename folder
This commit is contained in:
23
providers/saleor/utils/get-categories.ts
Normal file
23
providers/saleor/utils/get-categories.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { Category } from '@commerce/types/site'
|
||||
import { SaleorConfig } from '../api'
|
||||
import { CollectionCountableEdge } from '../schema'
|
||||
import * as query from './queries'
|
||||
|
||||
const getCategories = async (config: SaleorConfig): Promise<Category[]> => {
|
||||
const { data } = await config.fetch(query.CollectionMany, {
|
||||
variables: {
|
||||
first: 100,
|
||||
},
|
||||
})
|
||||
|
||||
return (
|
||||
data.collections?.edges?.map(({ node: { id, name, slug } }: CollectionCountableEdge) => ({
|
||||
id,
|
||||
name,
|
||||
slug,
|
||||
path: `/${slug}`,
|
||||
})) ?? []
|
||||
)
|
||||
}
|
||||
|
||||
export default getCategories
|
Reference in New Issue
Block a user