feat(admin,admin-ui,medusa): Add Medusa Admin plugin (#3334)

This commit is contained in:
Kasper Fabricius Kristensen
2023-03-03 10:09:16 +01:00
committed by GitHub
parent d6b1ad1ccd
commit 40de54b010
928 changed files with 85441 additions and 384 deletions

View File

@@ -0,0 +1,69 @@
import { Cart, Order } from "@medusajs/medusa"
/**
* Utility for extracting the customer name from a cart or order.
*/
const extractCustomerName = (obj?: Cart | Order) => {
if (!obj) {
return "N/A"
}
if (obj.customer) {
const firstName = obj.customer.first_name
const lastName = obj.customer.last_name
if (firstName && lastName) {
return `${firstName} ${lastName}`
}
if (firstName) {
return firstName
}
if (lastName) {
return lastName
}
}
if (obj.shipping_address) {
const firstName = obj.shipping_address.first_name
const lastName = obj.shipping_address.last_name
if (firstName && lastName) {
return `${firstName} ${lastName}`
}
if (firstName) {
return firstName
}
if (lastName) {
return lastName
}
}
if (obj.billing_address) {
const firstName = obj.billing_address.first_name
const lastName = obj.billing_address.last_name
if (firstName && lastName) {
return `${firstName} ${lastName}`
}
if (firstName) {
return firstName
}
if (lastName) {
return lastName
}
}
if (obj.email) {
return obj.email
}
return "N/A"
}
export default extractCustomerName