fix: cleanup

This commit is contained in:
Sebastian Rindom committed 2021-10-19 19:16:47 +02:00
1 parent 06f5fe2670
commit 5441d47f88
6 files changed
+120 -54

No files matched your search

+16 -10
View File
@@ -151,9 +151,11 @@ export class Cart {
@JoinColumn({ name: "shipping_address_id" })
shipping_address: Address
@OneToMany(() => LineItem, (lineItem) => lineItem.cart, {
cascade: ["insert", "remove"],
})
@OneToMany(
() => LineItem,
lineItem => lineItem.cart,
{ cascade: ["insert", "remove"] }
)
items: LineItem[]
@Index()
@@ -202,9 +204,11 @@ export class Cart {
payment_session: PaymentSession
@OneToMany(() => PaymentSession, (paymentSession) => paymentSession.cart, {
cascade: true,
})
@OneToMany(
() => PaymentSession,
paymentSession => paymentSession.cart,
{ cascade: true }
)
payment_sessions: PaymentSession[]
@Index()
@@ -215,9 +219,11 @@ export class Cart {
@JoinColumn({ name: "payment_id" })
payment: Payment
@OneToMany(() => ShippingMethod, (method) => method.cart, {
cascade: ["soft-remove", "remove"],
})
@OneToMany(
() => ShippingMethod,
method => method.cart,
{ cascade: ["soft-remove", "remove"] }
)
shipping_methods: ShippingMethod[]
@DbAwareColumn({ type: "enum", enum: CartType, default: "default" })
@@ -267,7 +273,7 @@ export class Cart {
@AfterLoad()
private afterLoad() {
if (this.payment_sessions) {
this.payment_session = this.payment_sessions.find((p) => p.is_selected)
this.payment_session = this.payment_sessions.find(p => p.is_selected)
}
}
}
+4 -4
View File
@@ -771,8 +771,8 @@ class CartService extends BaseService {
addressOrId.country_code = addressOrId.country_code.toLowerCase()
if (addressOrId.id) {
cart.billing_address_id = addressOrId.id
cart.billing_address = addressOrId
const updated = await addrRepo.save(addressOrId)
cart.billing_address = updated
} else {
if (cart.billing_address_id) {
const addr = await addrRepo.findOne({
@@ -823,8 +823,8 @@ class CartService extends BaseService {
}
if (addressOrId.id) {
await addrRepo.save(addressOrId)
cart.shipping_address_id = addressOrId.id
const updated = await addrRepo.save(addressOrId)
cart.shipping_address = updated
} else {
if (cart.shipping_address_id) {
const addr = await addrRepo.findOne({