From f99e0aba70efad0deb907d8e27f09fc9f527c8a4 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 17 Feb 2023 17:07:50 +0700 Subject: Refactor --- src/pages/shop/quotation/finish.js | 39 ----------- src/pages/shop/quotation/index.js | 140 ------------------------------------- 2 files changed, 179 deletions(-) delete mode 100644 src/pages/shop/quotation/finish.js delete mode 100644 src/pages/shop/quotation/index.js (limited to 'src/pages/shop/quotation') diff --git a/src/pages/shop/quotation/finish.js b/src/pages/shop/quotation/finish.js deleted file mode 100644 index f7983fef..00000000 --- a/src/pages/shop/quotation/finish.js +++ /dev/null @@ -1,39 +0,0 @@ -import WithAuth from "@/components/auth/WithAuth"; -import Link from "@/components/elements/Link"; -import Header from "@/components/layouts/Header"; -import Layout from "@/components/layouts/Layout"; -import { useAuth } from "@/core/utils/auth"; -import { EnvelopeIcon } from "@heroicons/react/24/outline"; -import { useRouter } from "next/router"; - -export default function FinishQuotation() { - const router = useRouter(); - const { id } = router.query; - const [ auth ] = useAuth(); - - return ( - - -
- -
-
- - - -
-

- Terima Kasih { auth?.name } -

-

- Penawaran harga kamu di Indoteknik.com berhasil dikirimkan, tim kami akan segera menghubungi anda. -

- { id && ( - Lihat Penawaran - )} - Ke Halaman Utama -
- - - ); -} \ No newline at end of file diff --git a/src/pages/shop/quotation/index.js b/src/pages/shop/quotation/index.js deleted file mode 100644 index e1c196db..00000000 --- a/src/pages/shop/quotation/index.js +++ /dev/null @@ -1,140 +0,0 @@ -import WithAuth from "@/components/auth/WithAuth"; -import LineDivider from "@/components/elements/LineDivider"; -import Link from "@/components/elements/Link"; -import AppBar from "@/components/layouts/AppBar"; -import Layout from "@/components/layouts/Layout"; -import VariantCard from "@/components/variants/VariantCard"; -import apiOdoo from "@/core/utils/apiOdoo"; -import { useAuth } from "@/core/utils/auth"; -import { deleteItemCart, getCart } from "@/core/utils/cart"; -import currencyFormat from "@/core/utils/currencyFormat"; -import { useRouter } from "next/router"; -import { useEffect, useState } from "react"; -import { toast } from "react-hot-toast"; - -export default function Quotation() { - const router = useRouter(); - const [ auth ] = useAuth(); - const [ products, setProducts ] = useState([]); - const [ totalAmount, setTotalAmount ] = useState(0); - const [ totalDiscountAmount, setTotalDiscountAmount ] = useState(0); - - useEffect(() => { - const getProducts = async () => { - let cart = getCart(); - let productIds = Object - .values(cart) - .filter((itemCart) => itemCart.selected == true) - .map((itemCart) => itemCart.product_id); - if (productIds.length > 0) { - productIds = productIds.join(','); - let dataProducts = await apiOdoo('GET', `/api/v1/product_variant/${productIds}`); - dataProducts = dataProducts.map((product) => ({ - ...product, - quantity: cart[product.id].quantity, - selected: cart[product.id].selected, - })); - setProducts(dataProducts); - } - }; - getProducts(); - }, [ router, auth ]); - - useEffect(() => { - if (products) { - let calculateTotalAmount = 0; - let calculateTotalDiscountAmount = 0; - products.forEach(product => { - calculateTotalAmount += product.price.price * product.quantity; - calculateTotalDiscountAmount += (product.price.price - product.price.price_discount) * product.quantity; - }); - setTotalAmount(calculateTotalAmount); - setTotalDiscountAmount(calculateTotalDiscountAmount); - } - }, [products]); - - const submitQuotation = async () => { - let productOrder = products.map((product) => ({ 'product_id': product.id, 'quantity': product.quantity })); - let data = { - 'partner_shipping_id': auth.partner_id, - 'partner_invoice_id': auth.partner_id, - 'order_line': JSON.stringify(productOrder) - }; - const quotation = await apiOdoo('POST', `/api/v1/partner/${auth.partner_id}/sale_order/checkout`, data); - for (const product of products) { - deleteItemCart(product.id); - } - if (quotation?.id) { - router.push(`/shop/quotation/finish?id=${quotation.id}`); - return; - }; - toast.error('Terdapat kesalahan internal, hubungi kami'); - } - return ( - - - - -
-

Produk

- {products.map((product, index) => ( - - ))} -
- - - -
-
-

Ringkasan Penawaran

-

{products.length} Barang

-
-
-
-
-

Total Belanja

-

{currencyFormat(totalAmount)}

-
-
-

Total Diskon

-

{'- ' + currencyFormat(totalDiscountAmount)}

-
-
-

Subtotal

-

{currencyFormat(totalAmount - totalDiscountAmount)}

-
-
-

PPN 11% (Incl.)

-

{currencyFormat((totalAmount - totalDiscountAmount) * 0.11)}

-
-
-
-
-

Grand Total

-

{currencyFormat(totalAmount - totalDiscountAmount)}

-
-

*) Belum termasuk biaya pengiriman

-

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

-
- - - -
- -
-
-
- ) -} \ No newline at end of file -- cgit v1.2.3 From 047aacc646c86b316c4d42fb720cbc841426df27 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 24 Feb 2023 10:05:06 +0700 Subject: fix --- src/pages/shop/quotation/finish.jsx | 41 +++++++++++++++++++++++++++++++++++++ src/pages/shop/quotation/index.jsx | 10 +++++++++ 2 files changed, 51 insertions(+) create mode 100644 src/pages/shop/quotation/finish.jsx create mode 100644 src/pages/shop/quotation/index.jsx (limited to 'src/pages/shop/quotation') diff --git a/src/pages/shop/quotation/finish.jsx b/src/pages/shop/quotation/finish.jsx new file mode 100644 index 00000000..98ffeec2 --- /dev/null +++ b/src/pages/shop/quotation/finish.jsx @@ -0,0 +1,41 @@ +import Link from '@/core/components/elements/Link/Link' +import BasicLayout from '@/core/components/layouts/BasicLayout' +import useAuth from '@/core/hooks/useAuth' +import { EnvelopeIcon } from '@heroicons/react/24/outline' +import { useRouter } from 'next/router' + +export default function FinishQuotation() { + const auth = useAuth() + const router = useRouter() + const { id } = router.query + return ( + +
+
+ + + +
+

Terima Kasih {auth?.name}

+

+ Penawaran harga kamu di Indoteknik.com berhasil dikirimkan, tim kami akan segera menghubungi + anda. +

+ {id && ( + + Lihat Penawaran + + )} + + Ke Halaman Utama + +
+
+ ) +} diff --git a/src/pages/shop/quotation/index.jsx b/src/pages/shop/quotation/index.jsx new file mode 100644 index 00000000..744b75fe --- /dev/null +++ b/src/pages/shop/quotation/index.jsx @@ -0,0 +1,10 @@ +import AppLayout from '@/core/components/layouts/AppLayout' +import QuotationComponent from '@/lib/quotation/components/Quotation' + +export default function Quotation() { + return ( + + + + ) +} -- cgit v1.2.3 From ffa261e6adef70a2845878cf93e6e492eb8cee62 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Mon, 27 Feb 2023 10:49:45 +0700 Subject: footer --- src/pages/shop/quotation/finish.jsx | 59 +++++++++++++++++++------------------ src/pages/shop/quotation/index.jsx | 9 ++++-- 2 files changed, 37 insertions(+), 31 deletions(-) (limited to 'src/pages/shop/quotation') diff --git a/src/pages/shop/quotation/finish.jsx b/src/pages/shop/quotation/finish.jsx index 98ffeec2..15881ea0 100644 --- a/src/pages/shop/quotation/finish.jsx +++ b/src/pages/shop/quotation/finish.jsx @@ -1,6 +1,7 @@ import Link from '@/core/components/elements/Link/Link' import BasicLayout from '@/core/components/layouts/BasicLayout' import useAuth from '@/core/hooks/useAuth' +import IsAuth from '@/lib/auth/components/IsAuth' import { EnvelopeIcon } from '@heroicons/react/24/outline' import { useRouter } from 'next/router' @@ -9,33 +10,35 @@ export default function FinishQuotation() { const router = useRouter() const { id } = router.query return ( - -
-
- - - -
-

Terima Kasih {auth?.name}

-

- Penawaran harga kamu di Indoteknik.com berhasil dikirimkan, tim kami akan segera menghubungi - anda. -

- {id && ( - - Lihat Penawaran - - )} - - Ke Halaman Utama - -
-
+ + +
+
+ + + +
+

Terima Kasih {auth?.name}

+

+ Penawaran harga kamu di Indoteknik.com berhasil dikirimkan, tim kami akan segera + menghubungi anda. +

+ {id && ( + + Lihat Penawaran + + )} + + Ke Halaman Utama + +
+
+
) } diff --git a/src/pages/shop/quotation/index.jsx b/src/pages/shop/quotation/index.jsx index 744b75fe..ff8b8644 100644 --- a/src/pages/shop/quotation/index.jsx +++ b/src/pages/shop/quotation/index.jsx @@ -1,10 +1,13 @@ import AppLayout from '@/core/components/layouts/AppLayout' +import IsAuth from '@/lib/auth/components/IsAuth' import QuotationComponent from '@/lib/quotation/components/Quotation' export default function Quotation() { return ( - - - + + + + + ) } -- cgit v1.2.3