From 5933732a74ae1ca4124ddd4e8265b1f443234736 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Tue, 21 Feb 2023 21:51:51 +0700
Subject: fix

---
 src/lib/transaction/components/Transaction.jsx | 79 ++++++++++++++------------
 1 file changed, 43 insertions(+), 36 deletions(-)

(limited to 'src/lib/transaction/components/Transaction.jsx')

diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx
index e049a9ac..0759dbf8 100644
--- a/src/lib/transaction/components/Transaction.jsx
+++ b/src/lib/transaction/components/Transaction.jsx
@@ -46,15 +46,6 @@ const Transaction = ({ id }) => {
     toast.error('Terjadi kesalahan internal, coba lagi nanti atau hubungi kami')
   }
 
-  const [ section, setSection ] = useState({
-    customer: false,
-    invoice: false,
-    shipping: false
-  })
-  const toggleSection = (name) => {
-    setSection({ ...section, [name]: !section[name] })
-  }
-
   const [ cancelTransaction, setCancelTransaction ] = useState(false)
   const openCancelTransaction = () => setCancelTransaction(true)
   const closeCancelTransaction = () => setCancelTransaction(false)
@@ -142,33 +133,7 @@ const Transaction = ({ id }) => {
 
       <Divider />
       
-      <SectionButton 
-        label="Detail Pelanggan" 
-        active={section.customer}
-        toggle={() => toggleSection('customer')}
-      />
-
-      { section.customer && <SectionContent address={transaction.data?.address?.customer} /> }
-
-      <Divider />
-      
-      <SectionButton 
-        label="Detail Pengiriman" 
-        active={section.shipping}
-        toggle={() => toggleSection('shipping')}
-      />
-
-      { section.shipping && <SectionContent address={transaction.data?.address?.shipping} /> }
-
-      <Divider />
-      
-      <SectionButton 
-        label="Detail Penagihan" 
-        active={section.invoice}
-        toggle={() => toggleSection('invoice')}
-      />
-
-      { section.invoice && <SectionContent address={transaction.data?.address?.invoice} /> }
+      <SectionAddress address={transaction.data?.address} />
 
       <Divider />
 
@@ -288,6 +253,48 @@ const Transaction = ({ id }) => {
   )
 }
 
+const SectionAddress = ({ address }) => {
+  const [ section, setSection ] = useState({
+    customer: false,
+    invoice: false,
+    shipping: false
+  })
+  const toggleSection = (name) => {
+    setSection({ ...section, [name]: !section[name] })
+  }
+
+  return (
+    <>
+      <SectionButton 
+        label="Detail Pelanggan" 
+        active={section.customer}
+        toggle={() => toggleSection('customer')}
+      />
+
+      { section.customer && <SectionContent address={address?.customer} /> }
+
+      <Divider />
+      
+      <SectionButton 
+        label="Detail Pengiriman" 
+        active={section.shipping}
+        toggle={() => toggleSection('shipping')}
+      />
+
+      { section.shipping && <SectionContent address={address?.shipping} /> }
+
+      <Divider />
+      
+      <SectionButton 
+        label="Detail Penagihan" 
+        active={section.invoice}
+        toggle={() => toggleSection('invoice')}
+      />
+      { section.invoice && <SectionContent address={address?.invoice} /> }
+    </>
+  )
+}
+
 const SectionButton = ({ label, active, toggle }) => (
   <button className="p-4 font-medium flex justify-between w-full" onClick={toggle}>
     <span>{label}</span>
-- 
cgit v1.2.3


From 98c8fc56db91664b98a50e9113787b56fe785b9e Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Tue, 21 Feb 2023 22:33:32 +0700
Subject: fix

---
 src/lib/transaction/components/Transaction.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src/lib/transaction/components/Transaction.jsx')

diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx
index 0759dbf8..0017afba 100644
--- a/src/lib/transaction/components/Transaction.jsx
+++ b/src/lib/transaction/components/Transaction.jsx
@@ -70,7 +70,7 @@ const Transaction = ({ id }) => {
 
   if (transaction.isLoading) {
     return (
-      <div className="flex justify-center my-4">
+      <div className="flex justify-center my-6">
         <Spinner className="w-6 text-gray_r-12/50 fill-gray_r-12" />
       </div>
     )
-- 
cgit v1.2.3

