feat(admin-ui, medusa): admin UI metadata (#3644)

This commit is contained in:
Kasper Fabricius Kristensen
2023-03-31 12:07:24 +02:00
committed by GitHub
parent 4f4ccee7fb
commit 4342ac884b
59 changed files with 1904 additions and 963 deletions
+8
View File
@@ -957,8 +957,16 @@ class OrderService extends TransactionBaseService {
where: { id: order.billing_address_id },
})
if (address.metadata) {
address.metadata = setMetadata(addr, address.metadata)
}
await addrRepo.save({ ...addr, ...address })
} else {
if (address.metadata) {
address.metadata = setMetadata(null, address.metadata)
}
order.billing_address = addrRepo.create({ ...address })
}
}
+3 -3
View File
@@ -2,15 +2,15 @@ import { MedusaError } from "medusa-core-utils/dist"
/**
* Dedicated method to set metadata.
* @param obj - the entity to apply metadata to.
* @param metadata - the metadata to set
* @param obj - the entity to apply metadata to.
* @return resolves to the updated result.
*/
export function setMetadata(
obj: { metadata: Record<string, unknown> | null },
obj: { metadata: Record<string, unknown> | null } | null | undefined,
metadata: Record<string, unknown>
): Record<string, unknown> {
const existing = obj.metadata || {}
const existing = obj?.metadata || {}
const newData = {}
for (const [key, value] of Object.entries(metadata)) {