mirror of
https://github.com/vercel/commerce.git
synced 2025-08-15 05:11:22 +00:00
.vscode
assets
components
config
framework
bigcommerce
api
definitions
endpoints
fragments
operations
utils
concat-cookie.ts
errors.ts
fetch-graphql-api.ts
fetch-store-api.ts
fetch.ts
filter-edges.ts
get-cart-cookie.ts
parse-item.ts
set-product-locale-meta.ts
types.ts
index.ts
auth
cart
customer
lib
product
scripts
types
wishlist
.env.template
README.md
commerce.config.json
fetcher.ts
index.tsx
next.config.js
provider.ts
schema.d.ts
schema.graphql
commerce
local
saleor
shopify
swell
vendure
lib
pages
public
.editorconfig
.env.template
.gitignore
.prettierignore
.prettierrc
README.md
codegen.bigcommerce.json
codegen.json
commerce.config.json
global.d.ts
jsconfig.json
license.md
next-env.d.ts
next.config.js
package.json
postcss.config.js
swell-js.d.ts
tailwind.config.js
tsconfig.js
tsconfig.json
yarn.lock
22 lines
555 B
TypeScript
22 lines
555 B
TypeScript
import type { ProductNode } from '../operations/get-all-products'
|
|
import type { RecursivePartial } from './types'
|
|
|
|
export default function setProductLocaleMeta(
|
|
node: RecursivePartial<ProductNode>
|
|
) {
|
|
if (node.localeMeta?.edges) {
|
|
node.localeMeta.edges = node.localeMeta.edges.filter((edge) => {
|
|
const { key, value } = edge?.node ?? {}
|
|
if (key && key in node) {
|
|
;(node as any)[key] = value
|
|
return false
|
|
}
|
|
return true
|
|
})
|
|
|
|
if (!node.localeMeta.edges.length) {
|
|
delete node.localeMeta
|
|
}
|
|
}
|
|
}
|