Skip to content

Commit

Permalink
fix: address not populating inside a quote
Browse files Browse the repository at this point in the history
  • Loading branch information
kris-liu-smile authored and BrianJiang2021 committed Jul 11, 2023
1 parent f0027a1 commit 599c765
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions apps/storefront/src/pages/quote/QuoteDraft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,22 @@ function QuoteDraft({ setOpenPage }: QuoteDraftProps) {
init()
}, [])

const getAddress = () => {
const addresssaveInfo = {
shippingAddress: {},
billingAddress: {},
}
if (billingRef?.current) {
addresssaveInfo.billingAddress = billingRef.current.getContactInfoValue()
}
if (shippingRef?.current) {
addresssaveInfo.shippingAddress =
shippingRef.current.getContactInfoValue()
}

return addresssaveInfo
}

const handleSaveInfoClick = async () => {
const saveInfo = {
...info,
Expand All @@ -282,12 +298,11 @@ function QuoteDraft({ setOpenPage }: QuoteDraftProps) {
if (!contactInfo) return
saveInfo.contactInfo = contactInfo
}
if (billingRef?.current) {
saveInfo.billingAddress = billingRef.current.getContactInfoValue()
}
if (shippingRef?.current) {
saveInfo.shippingAddress = shippingRef.current.getContactInfoValue()
}

const { shippingAddress, billingAddress } = getAddress()

saveInfo.shippingAddress = shippingAddress
saveInfo.billingAddress = billingAddress

const isComplete = Object.keys(saveInfo.contactInfo).every(
(key: string) => {
Expand Down Expand Up @@ -424,12 +439,17 @@ function QuoteDraft({ setOpenPage }: QuoteDraftProps) {
return newAddress
}

const shippingAddress = info?.shippingAddress
? perfectAddress(info.shippingAddress)
const {
shippingAddress: editShippingAddress,
billingAddress: editBillingAddress,
} = getAddress()

const shippingAddress = editShippingAddress
? perfectAddress(editShippingAddress)
: {}

const billingAddress = info?.billingAddress
? perfectAddress(info.billingAddress)
const billingAddress = editBillingAddress
? perfectAddress(editBillingAddress)
: {}

let allPrice = 0
Expand Down

0 comments on commit 599c765

Please sign in to comment.