summaryrefslogtreecommitdiff
path: root/src/lib/checkout
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/checkout')
-rw-r--r--src/lib/checkout/api/checkoutApi.js8
-rw-r--r--src/lib/checkout/components/Checkout.jsx6
2 files changed, 11 insertions, 3 deletions
diff --git a/src/lib/checkout/api/checkoutApi.js b/src/lib/checkout/api/checkoutApi.js
index 0d0cc918..24f1868a 100644
--- a/src/lib/checkout/api/checkoutApi.js
+++ b/src/lib/checkout/api/checkoutApi.js
@@ -11,11 +11,15 @@ export const checkoutApi = async ({ data }) => {
return dataCheckout
}
-export const getProductsCheckout = async (voucher) => {
+export const getProductsCheckout = async (voucher, query) => {
const id = getAuth()?.id
let products
- if(voucher){
+ if(voucher && query){
+ products = await odooApi('GET',`/api/v1/user/${id}/sale_order/checkout?voucher=${voucher}&source=buy`)
+ }else if (voucher){
products = await odooApi('GET',`/api/v1/user/${id}/sale_order/checkout?voucher=${voucher}`)
+ }else if (query) {
+ products = await odooApi('GET',`/api/v1/user/${id}/sale_order/checkout?source=buy`)
}else{
products = await odooApi('GET',`/api/v1/user/${id}/sale_order/checkout`)
}
diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx
index 11a14e31..17616938 100644
--- a/src/lib/checkout/components/Checkout.jsx
+++ b/src/lib/checkout/components/Checkout.jsx
@@ -34,12 +34,13 @@ const { getProductsCheckout } = require('../api/checkoutApi')
const Checkout = () => {
const router = useRouter()
+ const query = router.query.source ?? null
const auth = useAuth()
const [activeVoucher, SetActiveVoucher] = useState(null)
const { data: cartCheckout } = useQuery('cartCheckout-' + activeVoucher, () =>
- getProductsCheckout(activeVoucher)
+ getProductsCheckout(activeVoucher, query)
)
const [selectedAddress, setSelectedAddress] = useState({
@@ -298,6 +299,9 @@ const Checkout = () => {
voucher: activeVoucher,
type: 'sale_order'
}
+ if(query){
+ data.source = 'buy'
+ }
if (poNumber.current.value) data.po_number = poNumber.current.value
if (typeof file !== 'undefined') data.po_file = await getFileBase64(file)