From f45452d71062bf7c57e31d45ec8800fcc4deca64 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Wed, 18 Sep 2024 13:42:10 +0700
Subject: <iman> update notifikasi berhasil checkout

---
 src/lib/checkout/components/FinishCheckout.jsx | 66 +++++++++++++++++++-------
 1 file changed, 48 insertions(+), 18 deletions(-)

(limited to 'src/lib/checkout/components/FinishCheckout.jsx')

diff --git a/src/lib/checkout/components/FinishCheckout.jsx b/src/lib/checkout/components/FinishCheckout.jsx
index 92245e31..fa600389 100644
--- a/src/lib/checkout/components/FinishCheckout.jsx
+++ b/src/lib/checkout/components/FinishCheckout.jsx
@@ -1,27 +1,57 @@
-import Link from '@/core/components/elements/Link/Link'
+import Link from 'next/link';
+import Image from '~/components/ui/image';
+import whatsappUrl from '@/core/utils/whatsappUrl';
+import { useEffect, useState } from 'react';
+import odooApi from '@/core/api/odooApi';
 
 const FinishCheckout = ({ query }) => {
+  const [data, setData] = useState();
+
+  useEffect(() => {
+    const fetchData = async () => {
+      const so_order = query?.order_id?.replaceAll('_', '/');
+      const data = await odooApi(
+        'GET',
+        `/api/v1/sale_order_number?sale_number=${so_order}`
+      );
+      setData(data[0]);
+    };
+    fetchData();
+  }, [query]);
   return (
-    <div className='mx-auto container p-4 md:p-0 mt-0 md:mt-10'>
-      <div className='rounded-xl bg-warning-100 text-center border border-warning-300 w-full md:w-1/2 mx-auto'>
-        <div className='px-4 py-6 text-warning-900'>
-          <p className='font-semibold mb-2'>Terima Kasih atas Pembelian Anda</p>
-          <p className='text-warning-800 mb-4 leading-6'>
-            Rincian belanja sudah kami kirimkan ke email anda. Mohon dicek kembali. jika tidak
-            menerima email, anda dapat menghubungi kami disini.
-          </p>
-          <p className='mb-2 font-medium'>{query?.order_id?.replaceAll('-', '/')}</p>
-          <p className='text-caption-2 text-warning-800'>No. Transaksi</p>
-        </div>
+    <div className='flex flex-col items-center'>
+      <Image
+        src='/images/CHECKOUT-PESANAN.svg'
+        alt='Checkout Pesanan'
+        width={450}
+        height={450}
+      />
+      <div className='text-title-sm md:text-title-lg text-center font-semibold'>
+        Terima Kasih atas Pembelian Kamu
+      </div>
+      <div className='flex flex-col justify-center items-center text-body-2 md:text-body-1 text-center mt-3 px-24 md:px-36 py-4 border-2 gap-y-2 rounded'>
+        <p className='font-bold'>No. Transaksi</p>
+        <p className='mb-2 font-medium text-red-500 text-xl'>
+          {query?.order_id?.replaceAll('_', '/')}
+        </p>
         <Link
-          href='/my/quotations'
-          className='bg-warning-400 text-warning-900 rounded-b-xl py-4 block'
+          href={`/my/quotations/${data?.id}`}
+          className='btn-solid-red rounded-md text-base'
         >
-          Lihat detail pembelian Anda disini
+          Cek Detail Transaksi
         </Link>
       </div>
+      <div className='mt-2 text-center leading-6 text-base'>
+        Rincian pembelian sudah kami kirimkan ke email kamu. Mohon dicek
+        kembali. jika tidak menerima email,
+        <br /> kamu dapat menghubungi kami{' '}
+        <a className='text-red-500' href={whatsappUrl()}>
+          di sini
+        </a>{' '}
+        atau kirim rincian pesanan ulang.
+      </div>
     </div>
-  )
-}
+  );
+};
 
-export default FinishCheckout
+export default FinishCheckout;
-- 
cgit v1.2.3


From 5cfa2d67c93e45c44d8d76cd5e08261a2ee08bd7 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 19 Sep 2024 15:46:05 +0700
Subject: <iman> update notif after checkout

---
 src/lib/checkout/components/FinishCheckout.jsx | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

(limited to 'src/lib/checkout/components/FinishCheckout.jsx')

diff --git a/src/lib/checkout/components/FinishCheckout.jsx b/src/lib/checkout/components/FinishCheckout.jsx
index fa600389..69bd935f 100644
--- a/src/lib/checkout/components/FinishCheckout.jsx
+++ b/src/lib/checkout/components/FinishCheckout.jsx
@@ -41,10 +41,9 @@ const FinishCheckout = ({ query }) => {
           Cek Detail Transaksi
         </Link>
       </div>
-      <div className='mt-2 text-center leading-6 text-base'>
+      <div className='mt-2 text-center leading-6 text-base p-4 md:p-0 md:max-w-[700px]'>
         Rincian pembelian sudah kami kirimkan ke email kamu. Mohon dicek
-        kembali. jika tidak menerima email,
-        <br /> kamu dapat menghubungi kami{' '}
+        kembali. jika tidak menerima email, kamu dapat menghubungi kami{' '}
         <a className='text-red-500' href={whatsappUrl()}>
           di sini
         </a>{' '}
-- 
cgit v1.2.3


From 87f284a2cc4ce1e618a1c7ad63898dbcb76a8b83 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Fri, 20 Sep 2024 09:22:13 +0700
Subject: <iman> save sementara

---
 src/lib/checkout/components/FinishCheckout.jsx | 34 ++++++++++++++++++++------
 1 file changed, 27 insertions(+), 7 deletions(-)

(limited to 'src/lib/checkout/components/FinishCheckout.jsx')

diff --git a/src/lib/checkout/components/FinishCheckout.jsx b/src/lib/checkout/components/FinishCheckout.jsx
index 69bd935f..e2f40d8d 100644
--- a/src/lib/checkout/components/FinishCheckout.jsx
+++ b/src/lib/checkout/components/FinishCheckout.jsx
@@ -3,28 +3,44 @@ import Image from '~/components/ui/image';
 import whatsappUrl from '@/core/utils/whatsappUrl';
 import { useEffect, useState } from 'react';
 import odooApi from '@/core/api/odooApi';
+import useDevice from '@/core/hooks/useDevice';
+import useAuth from '@/core/hooks/useAuth';
+import axios from 'axios';
 
 const FinishCheckout = ({ query }) => {
   const [data, setData] = useState();
+  const [transactionData, setTransactionData] = useState();
+  const { isDesktop, isMobile } = useDevice();
+  const auth = useAuth();
 
+  const so_order = query?.order_id?.replaceAll('-', '/');
   useEffect(() => {
     const fetchData = async () => {
-      const so_order = query?.order_id?.replaceAll('_', '/');
-      const data = await odooApi(
+      const fetchedData = await odooApi(
         'GET',
         `/api/v1/sale_order_number?sale_number=${so_order}`
       );
-      setData(data[0]);
+      setData(fetchedData[0]);
     };
     fetchData();
   }, [query]);
+  console.log('auth', auth);
+
+  // Kirim email ketika komponen ini dimount atau sesuai kondisi
+  const sendEmail = async () => {
+    await axios.post(
+      `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/finish-checkout?orderName=${query?.order_id}`,
+      {}
+    );
+  };
+
   return (
     <div className='flex flex-col items-center'>
       <Image
         src='/images/CHECKOUT-PESANAN.svg'
         alt='Checkout Pesanan'
-        width={450}
-        height={450}
+        width={isMobile ? 300 : 450}
+        height={isMobile ? 300 : 450}
       />
       <div className='text-title-sm md:text-title-lg text-center font-semibold'>
         Terima Kasih atas Pembelian Kamu
@@ -32,7 +48,7 @@ const FinishCheckout = ({ query }) => {
       <div className='flex flex-col justify-center items-center text-body-2 md:text-body-1 text-center mt-3 px-24 md:px-36 py-4 border-2 gap-y-2 rounded'>
         <p className='font-bold'>No. Transaksi</p>
         <p className='mb-2 font-medium text-red-500 text-xl'>
-          {query?.order_id?.replaceAll('_', '/')}
+          {query?.order_id?.replaceAll('-', '/')}
         </p>
         <Link
           href={`/my/quotations/${data?.id}`}
@@ -47,7 +63,11 @@ const FinishCheckout = ({ query }) => {
         <a className='text-red-500' href={whatsappUrl()}>
           di sini
         </a>{' '}
-        atau kirim rincian pesanan ulang.
+        atau{' '}
+        <span onClick={sendEmail} className='text-red-500 cursor-pointer'>
+          kirim rincian pesanan ulang
+        </span>
+        .
       </div>
     </div>
   );
-- 
cgit v1.2.3


From 56ed5980588447c6ba05529e91d6f82820f1b764 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Fri, 20 Sep 2024 09:43:57 +0700
Subject: <iman> delete console log

---
 src/lib/checkout/components/FinishCheckout.jsx | 1 -
 1 file changed, 1 deletion(-)

(limited to 'src/lib/checkout/components/FinishCheckout.jsx')

diff --git a/src/lib/checkout/components/FinishCheckout.jsx b/src/lib/checkout/components/FinishCheckout.jsx
index e2f40d8d..1be5c841 100644
--- a/src/lib/checkout/components/FinishCheckout.jsx
+++ b/src/lib/checkout/components/FinishCheckout.jsx
@@ -24,7 +24,6 @@ const FinishCheckout = ({ query }) => {
     };
     fetchData();
   }, [query]);
-  console.log('auth', auth);
 
   // Kirim email ketika komponen ini dimount atau sesuai kondisi
   const sendEmail = async () => {
-- 
cgit v1.2.3


From ec69b6f0131939ebfbff1d5082b1229f7b58799b Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Sat, 21 Sep 2024 11:08:50 +0700
Subject: <iman> add try catch

---
 src/lib/checkout/components/FinishCheckout.jsx | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

(limited to 'src/lib/checkout/components/FinishCheckout.jsx')

diff --git a/src/lib/checkout/components/FinishCheckout.jsx b/src/lib/checkout/components/FinishCheckout.jsx
index 1be5c841..4a67b252 100644
--- a/src/lib/checkout/components/FinishCheckout.jsx
+++ b/src/lib/checkout/components/FinishCheckout.jsx
@@ -6,6 +6,7 @@ import odooApi from '@/core/api/odooApi';
 import useDevice from '@/core/hooks/useDevice';
 import useAuth from '@/core/hooks/useAuth';
 import axios from 'axios';
+import { toast } from 'react-hot-toast';
 
 const FinishCheckout = ({ query }) => {
   const [data, setData] = useState();
@@ -27,10 +28,20 @@ const FinishCheckout = ({ query }) => {
 
   // Kirim email ketika komponen ini dimount atau sesuai kondisi
   const sendEmail = async () => {
-    await axios.post(
-      `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/finish-checkout?orderName=${query?.order_id}`,
-      {}
-    );
+    try {
+      const send = await axios.post(
+        `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/finish-checkout?orderName=${query?.order_id}`,
+        {}
+      );
+      if (send.status === 200) {
+        toast.success('Berhasil mengirim rincian pesanan');
+      } else {
+        toast.error('Gagal mengirimkan rincian pesanan');
+      }
+    } catch (error) {
+      console.error(error);
+      toast.error('Gagal mengirimkan rincian pesanan');
+    }
   };
 
   return (
-- 
cgit v1.2.3

