feat: update customer groups (#1075)

* update customer service prep

* expand on the update customer groups test case

* add the test case for customer group update

* docs for `groups` prop on update customer endpoint

* refactor, update comments

* expend on integration tests, add customer mock with a group

* refactor to use `customerGroupService.list` method

* update units

* remove `updateCustomerGroups`

* fix rebase conflict

* fix customer seed data, add JoinTable on groups

* group retrieval using the expand param

* fix: use `buildQuery_`

* fix: validation for `groups`, enable `expand`param on update customer endpoint

* fix: remove fileds form the `FilterableCustomerGroupProps`

* fix: spearate body/query validation

Co-authored-by: fPolic <frane@medusajs.com>
This commit is contained in:
Frane Polić
2022-02-21 16:24:38 +01:00
committed by GitHub
co-authored by fPolic
parent c2241d1101
commit 75fb2ce9c3
9 changed files with 286 additions and 19 deletions
+19 -2
View File
@@ -43,7 +43,10 @@ export class Customer {
@JoinColumn({ name: "billing_address_id" })
billing_address: Address
@OneToMany(() => Address, (address) => address.customer)
@OneToMany(
() => Address,
(address) => address.customer
)
shipping_addresses: Address[]
@Column({ nullable: true, select: false })
@@ -55,9 +58,23 @@ export class Customer {
@Column({ default: false })
has_account: boolean
@OneToMany(() => Order, (order) => order.customer)
@OneToMany(
() => Order,
(order) => order.customer
)
orders: Order[]
@JoinTable({
name: "customer_group_customers",
inverseJoinColumn: {
name: "customer_group_id",
referencedColumnName: "id",
},
joinColumn: {
name: "customer_id",
referencedColumnName: "id",
},
})
@ManyToMany(() => CustomerGroup, { cascade: true })
groups: CustomerGroup[]