* fix babel transform-runtime regenerator required for migrations * add customer group model * add migration for customer group * add customer group model export * add customer group repository * add customer group service * add CustomerGroupRepository to "withTransaction" in CustomerGroupService * remove unnecessary argument to runtime plugin * service export ordering * add create customer group endpoint * add customergroup to route index in admin * add customer group service * add customer groups test * cleanup * duplicate error handling * ducplicate name integration test * add jsdoc * customergroup not customer * pr feedback * pipeline test * fix weird merge Co-authored-by: Sebastian Rindom <skrindom@gmail.com>
44 lines
984 B
JavaScript
44 lines
984 B
JavaScript
const { Customer, Address, CustomerGroup } = require("@medusajs/medusa")
|
|
|
|
module.exports = async (connection, data = {}) => {
|
|
const manager = connection.manager
|
|
|
|
const testAddr = await manager.create(Address, {
|
|
id: "test-address",
|
|
first_name: "Lebron",
|
|
last_name: "James",
|
|
})
|
|
|
|
await manager.save(testAddr)
|
|
|
|
const customer = await manager.create(Customer, {
|
|
id: "test-customer-1",
|
|
email: "test1@email.com",
|
|
})
|
|
|
|
customer.billing_address = testAddr
|
|
customer.shipping_addresses = [testAddr]
|
|
await manager.save(customer)
|
|
|
|
await manager.insert(Customer, {
|
|
id: "test-customer-2",
|
|
email: "test2@email.com",
|
|
})
|
|
|
|
await manager.insert(Customer, {
|
|
id: "test-customer-3",
|
|
email: "test3@email.com",
|
|
})
|
|
|
|
await manager.insert(Customer, {
|
|
id: "test-customer-has_account",
|
|
email: "test4@email.com",
|
|
has_account: true,
|
|
})
|
|
|
|
await manager.insert(CustomerGroup, {
|
|
id: "customer-group-1",
|
|
name: "vip-customers",
|
|
})
|
|
}
|