1
0
mirror of https://github.com/vercel/commerce.git synced 2025-09-19 14:20:15 +00:00
Files
assets
components
config
docs
framework
bigcommerce
api
cart
catalog
customers
definitions
fragments
operations
utils
concat-cookie.ts
create-api-handler.ts
errors.ts
fetch-graphql-api.ts
fetch-store-api.ts
fetch.ts
filter-edges.ts
get-cart-cookie.ts
is-allowed-method.ts
parse-item.ts
set-product-locale-meta.ts
types.ts
wishlist
checkout.ts
index.ts
cart
products
scripts
wishlist
README.md
index.tsx
schema.d.ts
schema.graphql
use-customer.tsx
use-login.tsx
use-logout.tsx
use-price.tsx
use-signup.tsx
commerce
lib
pages
public
.editorconfig
.env.template
.gitignore
.prettierignore
README.md
codegen.json
global.d.ts
license.md
next-env.d.ts
next.config.js
package.json
postcss.config.js
tailwind.config.js
tsconfig.json
yarn.lock
commerce/framework/bigcommerce/api/utils/set-product-locale-meta.ts
2020-12-29 19:14:49 -05:00

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
}
}
}