Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
name: LocalizedTextInput.createLocalizedString(resourceLanguages, doc.name),
slug: LocalizedTextInput.createLocalizedString(resourceLanguages, doc.slug),
// The product does not contain a "description" field by default. However,
// the form expects description to be a string. Hence, we have to fall back
// to a string here!
description: doc.description || '',
// The inventory should either be an empty string or a number. The inventory
// could be undefined, in which case toFormValue will set it to an empty
// string. This eases validation later on, as we don't have to deal with
// undefined anymore.
inventory: NumberInput.toFormValue(doc.inventory),
// parseMoneyValue will ensure that the price field will have currencyCode and
// amount filled out or set to empty strings. This reduces the cases we
// need to deal with (amount, currencyCode or the whole object being
// undefined).
price: MoneyInput.parseMoneyValue(doc.price, locale),
});
version: doc.version,
key: doc.key,
// The product does not contain a "description" field by default. However,
// the form expects description to be a string. Hence, we have to fall back
// to a string here!
description: doc.description || '',
// The inventory should either be an empty string or a number. The inventory
// could be undefined, in which case toFormValue will set it to an empty
// string. This eases validation later on, as we don't have to deal with
// undefined anymore.
inventory: NumberInput.toFormValue(doc.inventory),
// parseMoneyValue will ensure that the price field will have currencyCode and
// amount filled out or set to empty strings. This reduces the cases we
// need to deal with (amount, currencyCode or the whole object being
// undefined).
price: MoneyInput.parseMoneyValue(doc.price, locale),
status: doc.status,
});