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

