From 76961c8312312609dbef0646274f6dd1f6c2bf19 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Fri, 3 Mar 2023 16:44:12 +0700
Subject: add midtrans payment email notification

---
 src/lib/checkout/components/FinishCheckout.jsx | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 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 a7d65dd0..f5346d67 100644
--- a/src/lib/checkout/components/FinishCheckout.jsx
+++ b/src/lib/checkout/components/FinishCheckout.jsx
@@ -1,8 +1,16 @@
 import Link from '@/core/components/elements/Link/Link'
-import useTransaction from '@/lib/transaction/hooks/useTransaction'
+import axios from 'axios'
+import { useEffect } from 'react'
 
-const FinishCheckout = ({ id }) => {
-  const { transaction } = useTransaction({ id })
+const FinishCheckout = ({ query }) => {
+  useEffect(() => {
+    if (query?.order_id) {
+      console.log(`${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/finish-checkout?orderName=${query.order_id}`);
+      axios.post(
+        `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/finish-checkout?orderId=${query.order_id}`
+      )
+    }
+  }, [query])
 
   return (
     <div className='p-4'>
@@ -13,11 +21,11 @@ const FinishCheckout = ({ id }) => {
             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'>{transaction.data?.name}</p>
+          <p className='mb-2 font-medium'>{query?.order_id?.replaceAll('-', '/')}</p>
           <p className='text-caption-2 text-yellow_r-11'>No. Transaksi</p>
         </div>
         <Link
-          href={transaction.data?.id ? `/my/transaction/${transaction.data.id}` : '/'}
+          href='/my/transactions'
           className='bg-yellow_r-6 text-yellow_r-12 rounded-b-xl py-4 block'
         >
           Lihat detail pembelian Anda disini
-- 
cgit v1.2.3

