From a3ec730b64199dd179ff9fd29216bf0d479fa952 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Thu, 29 Dec 2022 15:46:50 +0700 Subject: no message --- src/pages/shop/checkout.js | 232 ++++++++++++++++++++++++--------------------- 1 file changed, 123 insertions(+), 109 deletions(-) diff --git a/src/pages/shop/checkout.js b/src/pages/shop/checkout.js index 0fbf8556..6b3231df 100644 --- a/src/pages/shop/checkout.js +++ b/src/pages/shop/checkout.js @@ -8,6 +8,7 @@ import Layout from "../../components/Layout"; import LineDivider from "../../components/LineDivider"; import Link from "../../components/Link"; import ProgressBar from "../../components/ProgressBar"; +import Spinner from "../../components/Spinner"; import apiOdoo from "../../helpers/apiOdoo"; import { useAuth } from "../../helpers/auth"; import { getCart } from "../../helpers/cart"; @@ -24,6 +25,7 @@ export default function Checkout() { const [totalPriceBeforeTax, setTotalPriceBeforeTax] = useState(0); const [totalTaxAmount, setTotalTaxAmount] = useState(0); const [totalDiscountAmount, setTotalDiscountAmount] = useState(0); + const [isLoading, setIsLoading] = useState(true); const payments = [ { name: 'BCA', number: '8870-4000-81' }, @@ -99,136 +101,148 @@ export default function Checkout() { } }, [products]); + useEffect(() => { + if (address && products) setIsLoading(false); + }, [address, products]); + return ( - - - - - -
- + {isLoading && ( +
+
- Jika mengalami kesulitan dalam melakukan pembelian di website Indoteknik. Hubungi kami disini - + )} - + { products && address && ( + <> + -
-
-

Alamat Pengiriman

- Ubah Alamat -
+ - { selectedAddress && ( -
-

{ selectedAddress.name }

-

{ selectedAddress.mobile }

-

{ selectedAddress.street } { selectedAddress.street2 }

-
- ) } -
- - - -
- {products && products.map((product, index) => ( -
-
- {product.parent.name} + +
+
-
- - {product.parent.name} - -

- {product.code || '-'} - {product.attributes.length > 0 ? ` | ${product.attributes.join(', ')}` : ''} -

-

- {currencyFormat(product.price.price_discount)} × {product.quantity} Barang -

-

- {currencyFormat(product.quantity * product.price.price_discount)} -

+ Jika mengalami kesulitan dalam melakukan pembelian di website Indoteknik. Hubungi kami disini + + + + +
+
+

Alamat Pengiriman

+ Ubah Alamat
+ + { selectedAddress && ( +
+

{ selectedAddress.name }

+

{ selectedAddress.mobile }

+

{ selectedAddress.street } { selectedAddress.street2 }

+
+ ) }
- ))} -
- - - - {products && ( -
-
-

Ringkasan Pesanan

-

{products.length} Barang

+ + + +
+ {products.map((product, index) => ( +
+
+ {product.parent.name} +
+
+ + {product.parent.name} + +

+ {product.code || '-'} + {product.attributes.length > 0 ? ` | ${product.attributes.join(', ')}` : ''} +

+

+ {currencyFormat(product.price.price_discount)} × {product.quantity} Barang +

+

+ {currencyFormat(product.quantity * product.price.price_discount)} +

+
+
+ ))}
-
-
-
-

Subtotal

-

{currencyFormat(totalPriceBeforeTax)}

+ + + +
+
+

Ringkasan Pesanan

+

{products.length} Barang

-
-

PPN 11%

-

{currencyFormat(totalTaxAmount)}

+
+
+
+

Subtotal

+

{currencyFormat(totalPriceBeforeTax)}

+
+
+

PPN 11%

+

{currencyFormat(totalTaxAmount)}

+
+
+

Total Diskon

+

- {currencyFormat(totalDiscountAmount)}

+
-
-

Total Diskon

-

- {currencyFormat(totalDiscountAmount)}

+
+
+

Grand Total

+

{currencyFormat(totalPriceBeforeTax + totalTaxAmount - totalDiscountAmount)}

+

*) Belum termasuk biaya pengiriman

+

+ Dengan melakukan pembelian melalui website Indoteknik, saya menyetujui Syarat & Ketentuan yang berlaku +

-
-
-

Grand Total

-

{currencyFormat(totalPriceBeforeTax + totalTaxAmount - totalDiscountAmount)}

+ + + +
+

Pilih Metode Pembayaran

+
+ { payments.map((payment, index) => ( + + )) } +
-

*) Belum termasuk biaya pengiriman

-

- Dengan melakukan pembelian melalui website Indoteknik, saya menyetujui Syarat & Ketentuan yang berlaku -

-
- )} - - -
-

Pilih Metode Pembayaran

-
- { payments.map((payment, index) => ( + + +
- )) } -
-
- - - -
- -
+
+ + ) } ) } \ No newline at end of file -- cgit v1.2.3