Skip to content

Commit

Permalink
Revert "Bc victor/bun 1682/session sharing checkout headless (#868)" …
Browse files Browse the repository at this point in the history
…(#878)

This reverts commit 5a0ffdda62025abcf781a799d64bb1f7fe94d673.
  • Loading branch information
bc-victor authored and libruce committed Dec 27, 2023
1 parent 728ebc7 commit 4e54144
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 85 deletions.
19 changes: 5 additions & 14 deletions apps/storefront/src/pages/invoice/utils/payment.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { getInvoiceCheckoutUrl } from '@/shared/service/b2b'
import { BcCartData } from '@/types/invoice'
import { attemptCheckoutLoginAndRedirect } from '@/utils/b3checkout'

export const getCheckouUrlAndCart = async (params: BcCartData) => {
const {
Expand All @@ -19,19 +18,11 @@ export const gotoInvoiceCheckoutUrl = async (
params: BcCartData,
isReplaceCurrentUrl?: boolean
) => {
const { checkoutUrl, cartId } = await getCheckouUrlAndCart(params)
const { checkoutUrl } = await getCheckouUrlAndCart(params)

try {
await attemptCheckoutLoginAndRedirect(
cartId,
checkoutUrl,
isReplaceCurrentUrl
)
} catch (e) {
if (isReplaceCurrentUrl) {
window.location.replace(checkoutUrl)
} else {
window.location.href = checkoutUrl
}
if (isReplaceCurrentUrl) {
window.location.replace(checkoutUrl)
} else {
window.location.href = checkoutUrl
}
}
23 changes: 9 additions & 14 deletions apps/storefront/src/pages/quote/components/QuoteDetailFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import { useContext } from 'react'
import { useLocation } from 'react-router-dom'
import { useB3Lang } from '@b3/lang'
import { Box } from '@mui/material'

import { CustomButton } from '@/components'
import { useMobile } from '@/hooks'
import { GlobaledContext } from '@/shared/global'
import { b2bQuoteCheckout, bcQuoteCheckout } from '@/shared/service/b2b'
import { getSearchVal } from '@/utils'
import {
attemptCheckoutLoginAndRedirect,
setQuoteToStorage,
} from '@/utils/b3checkout'
import * as cryptoJs from '@/utils/cryptoJs'

interface QuoteDetailFooterProps {
quoteId: string
Expand All @@ -22,7 +17,6 @@ interface QuoteDetailFooterProps {

function QuoteDetailFooter(props: QuoteDetailFooterProps) {
const { quoteId, role, isAgenting, status } = props
const globalStore = useContext(GlobaledContext)
const [isMobile] = useMobile()
const b3Lang = useB3Lang()
const location = useLocation()
Expand All @@ -45,19 +39,20 @@ function QuoteDetailFooter(props: QuoteDetailFooterProps) {
id: +quoteId,
})

setQuoteToStorage(quoteId, date)
const {
quoteCheckout: {
quoteCheckout: { checkoutUrl, cartId },
quoteCheckout: { checkoutUrl },
},
} = res

if (!globalStore.state.customer) {
window.location.href = checkoutUrl
return
}
sessionStorage.setItem('isNewStorefront', JSON.stringify(true))
sessionStorage.setItem('quoteCheckoutId', cryptoJs.cipherText(quoteId))
sessionStorage.setItem(
'quoteDate',
cryptoJs.cipherText(date?.toString() || '')
)

await attemptCheckoutLoginAndRedirect(cartId, checkoutUrl as string)
window.location.href = checkoutUrl
} catch (err) {
console.error(err)
}
Expand Down
18 changes: 0 additions & 18 deletions apps/storefront/src/shared/service/b2b/graphql/checkout.ts

This file was deleted.

39 changes: 0 additions & 39 deletions apps/storefront/src/utils/b3checkout.ts

This file was deleted.

0 comments on commit 4e54144

Please sign in to comment.