diff --git a/apps/storefront/src/pages/pdp/PDP.tsx b/apps/storefront/src/pages/pdp/PDP.tsx
index 87ba6d9a..97f1b2b5 100644
--- a/apps/storefront/src/pages/pdp/PDP.tsx
+++ b/apps/storefront/src/pages/pdp/PDP.tsx
@@ -22,6 +22,7 @@ import {
B3SStorage,
snackbar,
isAllRequiredOptionFilled,
+ getDefaultCurrencyInfo,
} from '@/utils'
import {
@@ -173,17 +174,6 @@ const PDP = ({
const sku = (document.querySelector('[data-product-sku]')?.innerHTML ?? '').trim()
const form = document.querySelector('form[data-cart-item-add]')
- const getDefaultCurrencyInfo = () => {
- const currencies = B3SStorage.get('currencies')
- if (currencies) {
- const {
- currencies: currencyArr,
- } = currencies
- const defaultCurrency = currencyArr.find((currency: any) => currency.is_default)
- return defaultCurrency
- }
- }
-
const {
currency_code: currencyCode,
} = getDefaultCurrencyInfo()
diff --git a/apps/storefront/src/pages/quote/QuoteDetail.tsx b/apps/storefront/src/pages/quote/QuoteDetail.tsx
index 2784c72a..8d8829c8 100644
--- a/apps/storefront/src/pages/quote/QuoteDetail.tsx
+++ b/apps/storefront/src/pages/quote/QuoteDetail.tsx
@@ -25,6 +25,7 @@ import {
getB2BQuoteDetail,
getBcQuoteDetail,
exportB2BQuotePdf,
+ exportBcQuotePdf,
} from '@/shared/service/b2b'
import {
@@ -139,8 +140,9 @@ const QuoteDetail = () => {
},
}
- const quotePdf = await exportB2BQuotePdf(data)
+ const fn = +role === 99 ? exportBcQuotePdf : exportB2BQuotePdf
+ const quotePdf = await fn(data)
if (quotePdf) {
window.open(`${quotePdf.quotePdfExport.url}`, '_blank')
}
@@ -346,6 +348,7 @@ const QuoteDetail = () => {
)
}
diff --git a/apps/storefront/src/pages/quote/QuoteDraft.tsx b/apps/storefront/src/pages/quote/QuoteDraft.tsx
index 9c3f27e2..68c8bc91 100644
--- a/apps/storefront/src/pages/quote/QuoteDraft.tsx
+++ b/apps/storefront/src/pages/quote/QuoteDraft.tsx
@@ -42,6 +42,7 @@ import {
storeHash,
addQuoteDraftProduce,
snackbar,
+ getDefaultCurrencyInfo,
} from '@/utils'
import {
@@ -305,19 +306,6 @@ const QuoteDraft = ({
setEdit(true)
}
- const getDefaultCurrencyInfo = () => {
- const currencies = B3SStorage.get('currencies')
- if (currencies) {
- const {
- currencies: currencyArr,
- } = currencies
-
- const defaultCurrency = currencyArr.find((currency: CustomFieldItems) => currency.is_default)
-
- return defaultCurrency
- }
- }
-
const {
token: currencyToken,
} = getDefaultCurrencyInfo()
@@ -467,17 +455,6 @@ const QuoteDraft = ({
return items
})
- const getDefaultCurrencyInfo = () => {
- const currencies = B3SStorage.get('currencies')
- if (currencies) {
- const {
- currencies: currencyArr,
- } = currencies
- const defaultCurrency = currencyArr.find((currency: any) => currency.is_default)
- return defaultCurrency
- }
- }
-
const currency = getDefaultCurrencyInfo()
const data = {
diff --git a/apps/storefront/src/pages/quote/components/QuoteDetailFooter.tsx b/apps/storefront/src/pages/quote/components/QuoteDetailFooter.tsx
index 7771652f..c4d574e2 100644
--- a/apps/storefront/src/pages/quote/components/QuoteDetailFooter.tsx
+++ b/apps/storefront/src/pages/quote/components/QuoteDetailFooter.tsx
@@ -1,6 +1,3 @@
-import {
- useNavigate,
-} from 'react-router-dom'
import {
Box,
Button,
@@ -10,18 +7,28 @@ import {
useMobile,
} from '@/hooks'
+import {
+ b2bQuoteCheckout,
+ bcQuoteCheckout,
+} from '@/shared/service/b2b'
+
+import {
+ snackbar,
+} from '@/utils'
+
interface QuoteDetailFooterProps {
quoteId: string,
quoteDate: string,
+ role: string | number,
}
const QuoteDetailFooter = (props: QuoteDetailFooterProps) => {
const {
quoteId,
quoteDate,
+ role,
} = props
const [isMobile] = useMobile()
- const navigate = useNavigate()
const containerStyle = isMobile ? {
alignItems: 'flex-end',
@@ -30,6 +37,30 @@ const QuoteDetailFooter = (props: QuoteDetailFooterProps) => {
alignItems: 'center',
}
+ const handleQuoteCheckout = async () => {
+ try {
+ const fn = +role === 99 ? bcQuoteCheckout : b2bQuoteCheckout
+
+ const res = await fn({
+ id: +quoteId,
+ })
+
+ const {
+ quoteCheckout: {
+ quoteCheckout: {
+ checkoutUrl,
+ },
+ },
+ } = res
+ localStorage.setItem('quoteCheckoutId', quoteId)
+ localStorage.setItem('quoteDate', quoteDate)
+
+ window.location.href = checkoutUrl
+ } catch (err: any) {
+ snackbar.error(err)
+ }
+ }
+
return (
{
padding: '0.8rem 1rem',
height: 'auto',
display: 'flex',
- zIndex: '10',
+ zIndex: '999',
justifyContent: isMobile ? 'center' : 'flex-end',
displayPrint: 'none',
...containerStyle,
@@ -50,9 +81,7 @@ const QuoteDetailFooter = (props: QuoteDetailFooterProps) => {