From de7361718def0f6bb32294bb074841ba2c0a3ce6 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Tue, 21 Feb 2023 16:25:35 +0700
Subject: fix

---
 src/lib/invoice/components/Invoice.jsx | 126 +++++++++++++++++++++++++++++++++
 1 file changed, 126 insertions(+)
 create mode 100644 src/lib/invoice/components/Invoice.jsx

(limited to 'src/lib/invoice/components/Invoice.jsx')

diff --git a/src/lib/invoice/components/Invoice.jsx b/src/lib/invoice/components/Invoice.jsx
new file mode 100644
index 00000000..de6eacca
--- /dev/null
+++ b/src/lib/invoice/components/Invoice.jsx
@@ -0,0 +1,126 @@
+import Spinner from "@/core/components/elements/Spinner/Spinner"
+import useInvoice from "../hooks/useInvoice"
+import { downloadInvoice, downloadTaxInvoice } from "../utils/invoices"
+import Divider from "@/core/components/elements/Divider/Divider"
+import VariantGroupCard from "@/lib/variant/components/VariantGroupCard"
+import currencyFormat from "@/core/utils/currencyFormat"
+
+const Invoice = ({ id }) => {
+  const { invoice } = useInvoice({ id })
+
+  if (invoice.isLoading) {
+    return (
+      <div className="flex justify-center my-4">
+        <Spinner className="w-6 text-gray_r-12/50 fill-gray_r-12" />
+      </div>
+    )
+  }
+
+  const address = invoice.data?.customer
+  let fullAddress = []
+  if (address?.street) fullAddress.push(address.street)
+  if (address?.subDistrict?.name) fullAddress.push(address.subDistrict.name)
+  if (address?.district?.name) fullAddress.push(address.district.name)
+  if (address?.city?.name) fullAddress.push(address.city.name)
+  fullAddress = fullAddress.join(', ')
+
+  return invoice.data?.name && (
+    <>
+      <div className="flex flex-col gap-y-4 p-4">
+        <DescriptionRow label="No Invoice">
+          { invoice.data?.name }
+        </DescriptionRow>
+        <DescriptionRow label="Status Transaksi">
+          { invoice.data?.amountResidual > 0 ? (
+            <span className="badge-solid-red">Belum Lunas</span>
+            ) : (
+            <span className="badge-solid-green">Lunas</span>
+          ) }
+        </DescriptionRow>
+        <DescriptionRow label="Purchase Order">
+          { invoice.data?.purchaseOrderName || '-' }
+        </DescriptionRow>
+        <DescriptionRow label="Ketentuan Pembayaran">
+          { invoice.data?.paymentTerm }
+        </DescriptionRow>
+        { invoice.data?.amountResidual > 0 && invoice.invoiceDate != invoice.invoiceDateDue && (
+          <DescriptionRow label="Tanggal Jatuh Tempo">
+            { invoice.data?.invoiceDateDue }
+          </DescriptionRow>
+        ) }
+        <DescriptionRow label="Nama Sales">
+          { invoice.data?.sales }
+        </DescriptionRow>
+        <DescriptionRow label="Tanggal Invoice">
+          { invoice.data?.invoiceDate }
+        </DescriptionRow>
+        <div className="flex items-center">
+          <p className="text-gray_r-11 leading-none">Faktur Pembelian</p>
+          <button 
+            type="button"
+            className="btn-light py-1.5 px-3 ml-auto"
+            onClick={() => downloadInvoice(invoice.data)}
+          >
+            Download
+          </button>
+        </div>
+        <div className="flex items-center">
+          <p className="text-gray_r-11 leading-none">Faktur Pajak</p>
+          <button 
+            type="button"
+            className="btn-light py-1.5 px-3 ml-auto"
+            onClick={() => downloadTaxInvoice(invoice.data)}
+            disabled={!invoice.data?.efaktur}
+          >
+            Download
+          </button>
+        </div>
+      </div>
+
+      <Divider />
+
+      <div className="p-4 font-medium">
+        Detail Penagihan
+      </div>
+      
+      <div className="flex flex-col gap-y-4 p-4 border-t border-gray_r-6">
+        <DescriptionRow label="Nama">
+          { address?.name }
+        </DescriptionRow>
+        <DescriptionRow label="Email">
+          { address?.email || '-' }
+        </DescriptionRow>
+        <DescriptionRow label="No Telepon">
+          { address?.mobile || '-' }
+        </DescriptionRow>
+        <DescriptionRow label="Alamat">
+          { fullAddress }
+        </DescriptionRow>
+      </div>
+
+      <Divider />
+
+      <div className="font-medium p-4">Detail Produk</div>
+
+      <div className="p-4 pt-0 flex flex-col gap-y-3">
+        <VariantGroupCard 
+          variants={invoice.data?.products} 
+          buyMore 
+        />
+        <div className="flex justify-between mt-3 font-medium">
+          <p>Total Belanja</p>
+          <p>{ currencyFormat(invoice.data?.amountTotal) }</p>
+        </div>
+      </div>
+    </>
+  )
+}
+
+const DescriptionRow = ({ children, label }) => (
+  <div className="grid grid-cols-2">
+    <span className="text-gray_r-11">{ label }</span>
+    <span className="text-right">{ children }</span>
+  </div>
+)
+
+export default Invoice
\ No newline at end of file
-- 
cgit v1.2.3


From 04fe185879061b404fe1baa468bf67d32b3fdd5f Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Tue, 21 Feb 2023 16:29:04 +0700
Subject: fix

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

(limited to 'src/lib/invoice/components/Invoice.jsx')

diff --git a/src/lib/invoice/components/Invoice.jsx b/src/lib/invoice/components/Invoice.jsx
index de6eacca..3e0baaee 100644
--- a/src/lib/invoice/components/Invoice.jsx
+++ b/src/lib/invoice/components/Invoice.jsx
@@ -55,7 +55,7 @@ const Invoice = ({ id }) => {
           { invoice.data?.invoiceDate }
         </DescriptionRow>
         <div className="flex items-center">
-          <p className="text-gray_r-11 leading-none">Faktur Pembelian</p>
+          <p className="text-gray_r-11 leading-none">Invoice</p>
           <button 
             type="button"
             className="btn-light py-1.5 px-3 ml-auto"
-- 
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/invoice/components/Invoice.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src/lib/invoice/components/Invoice.jsx')

diff --git a/src/lib/invoice/components/Invoice.jsx b/src/lib/invoice/components/Invoice.jsx
index 3e0baaee..aee4a498 100644
--- a/src/lib/invoice/components/Invoice.jsx
+++ b/src/lib/invoice/components/Invoice.jsx
@@ -10,7 +10,7 @@ const Invoice = ({ id }) => {
 
   if (invoice.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


From f66b12fd1d0b83af0d7230d7b1565fbe00afbe3c Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Wed, 22 Feb 2023 11:03:34 +0700
Subject: prettier

---
 src/lib/invoice/components/Invoice.jsx | 165 +++++++++++++++------------------
 1 file changed, 73 insertions(+), 92 deletions(-)

(limited to 'src/lib/invoice/components/Invoice.jsx')

diff --git a/src/lib/invoice/components/Invoice.jsx b/src/lib/invoice/components/Invoice.jsx
index aee4a498..eaf7b7e0 100644
--- a/src/lib/invoice/components/Invoice.jsx
+++ b/src/lib/invoice/components/Invoice.jsx
@@ -1,17 +1,17 @@
-import Spinner from "@/core/components/elements/Spinner/Spinner"
-import useInvoice from "../hooks/useInvoice"
-import { downloadInvoice, downloadTaxInvoice } from "../utils/invoices"
-import Divider from "@/core/components/elements/Divider/Divider"
-import VariantGroupCard from "@/lib/variant/components/VariantGroupCard"
-import currencyFormat from "@/core/utils/currencyFormat"
+import Spinner from '@/core/components/elements/Spinner/Spinner'
+import useInvoice from '../hooks/useInvoice'
+import { downloadInvoice, downloadTaxInvoice } from '../utils/invoices'
+import Divider from '@/core/components/elements/Divider/Divider'
+import VariantGroupCard from '@/lib/variant/components/VariantGroupCard'
+import currencyFormat from '@/core/utils/currencyFormat'
 
 const Invoice = ({ id }) => {
   const { invoice } = useInvoice({ id })
 
   if (invoice.isLoading) {
     return (
-      <div className="flex justify-center my-6">
-        <Spinner className="w-6 text-gray_r-12/50 fill-gray_r-12" />
+      <div className='flex justify-center my-6'>
+        <Spinner className='w-6 text-gray_r-12/50 fill-gray_r-12' />
       </div>
     )
   }
@@ -24,103 +24,84 @@ const Invoice = ({ id }) => {
   if (address?.city?.name) fullAddress.push(address.city.name)
   fullAddress = fullAddress.join(', ')
 
-  return invoice.data?.name && (
-    <>
-      <div className="flex flex-col gap-y-4 p-4">
-        <DescriptionRow label="No Invoice">
-          { invoice.data?.name }
-        </DescriptionRow>
-        <DescriptionRow label="Status Transaksi">
-          { invoice.data?.amountResidual > 0 ? (
-            <span className="badge-solid-red">Belum Lunas</span>
+  return (
+    invoice.data?.name && (
+      <>
+        <div className='flex flex-col gap-y-4 p-4'>
+          <DescriptionRow label='No Invoice'>{invoice.data?.name}</DescriptionRow>
+          <DescriptionRow label='Status Transaksi'>
+            {invoice.data?.amountResidual > 0 ? (
+              <span className='badge-solid-red'>Belum Lunas</span>
             ) : (
-            <span className="badge-solid-green">Lunas</span>
-          ) }
-        </DescriptionRow>
-        <DescriptionRow label="Purchase Order">
-          { invoice.data?.purchaseOrderName || '-' }
-        </DescriptionRow>
-        <DescriptionRow label="Ketentuan Pembayaran">
-          { invoice.data?.paymentTerm }
-        </DescriptionRow>
-        { invoice.data?.amountResidual > 0 && invoice.invoiceDate != invoice.invoiceDateDue && (
-          <DescriptionRow label="Tanggal Jatuh Tempo">
-            { invoice.data?.invoiceDateDue }
+              <span className='badge-solid-green'>Lunas</span>
+            )}
           </DescriptionRow>
-        ) }
-        <DescriptionRow label="Nama Sales">
-          { invoice.data?.sales }
-        </DescriptionRow>
-        <DescriptionRow label="Tanggal Invoice">
-          { invoice.data?.invoiceDate }
-        </DescriptionRow>
-        <div className="flex items-center">
-          <p className="text-gray_r-11 leading-none">Invoice</p>
-          <button 
-            type="button"
-            className="btn-light py-1.5 px-3 ml-auto"
-            onClick={() => downloadInvoice(invoice.data)}
-          >
-            Download
-          </button>
-        </div>
-        <div className="flex items-center">
-          <p className="text-gray_r-11 leading-none">Faktur Pajak</p>
-          <button 
-            type="button"
-            className="btn-light py-1.5 px-3 ml-auto"
-            onClick={() => downloadTaxInvoice(invoice.data)}
-            disabled={!invoice.data?.efaktur}
-          >
-            Download
-          </button>
+          <DescriptionRow label='Purchase Order'>
+            {invoice.data?.purchaseOrderName || '-'}
+          </DescriptionRow>
+          <DescriptionRow label='Ketentuan Pembayaran'>{invoice.data?.paymentTerm}</DescriptionRow>
+          {invoice.data?.amountResidual > 0 && invoice.invoiceDate != invoice.invoiceDateDue && (
+            <DescriptionRow label='Tanggal Jatuh Tempo'>
+              {invoice.data?.invoiceDateDue}
+            </DescriptionRow>
+          )}
+          <DescriptionRow label='Nama Sales'>{invoice.data?.sales}</DescriptionRow>
+          <DescriptionRow label='Tanggal Invoice'>{invoice.data?.invoiceDate}</DescriptionRow>
+          <div className='flex items-center'>
+            <p className='text-gray_r-11 leading-none'>Invoice</p>
+            <button
+              type='button'
+              className='btn-light py-1.5 px-3 ml-auto'
+              onClick={() => downloadInvoice(invoice.data)}
+            >
+              Download
+            </button>
+          </div>
+          <div className='flex items-center'>
+            <p className='text-gray_r-11 leading-none'>Faktur Pajak</p>
+            <button
+              type='button'
+              className='btn-light py-1.5 px-3 ml-auto'
+              onClick={() => downloadTaxInvoice(invoice.data)}
+              disabled={!invoice.data?.efaktur}
+            >
+              Download
+            </button>
+          </div>
         </div>
-      </div>
 
-      <Divider />
+        <Divider />
 
-      <div className="p-4 font-medium">
-        Detail Penagihan
-      </div>
-      
-      <div className="flex flex-col gap-y-4 p-4 border-t border-gray_r-6">
-        <DescriptionRow label="Nama">
-          { address?.name }
-        </DescriptionRow>
-        <DescriptionRow label="Email">
-          { address?.email || '-' }
-        </DescriptionRow>
-        <DescriptionRow label="No Telepon">
-          { address?.mobile || '-' }
-        </DescriptionRow>
-        <DescriptionRow label="Alamat">
-          { fullAddress }
-        </DescriptionRow>
-      </div>
+        <div className='p-4 font-medium'>Detail Penagihan</div>
 
-      <Divider />
+        <div className='flex flex-col gap-y-4 p-4 border-t border-gray_r-6'>
+          <DescriptionRow label='Nama'>{address?.name}</DescriptionRow>
+          <DescriptionRow label='Email'>{address?.email || '-'}</DescriptionRow>
+          <DescriptionRow label='No Telepon'>{address?.mobile || '-'}</DescriptionRow>
+          <DescriptionRow label='Alamat'>{fullAddress}</DescriptionRow>
+        </div>
+
+        <Divider />
 
-      <div className="font-medium p-4">Detail Produk</div>
+        <div className='font-medium p-4'>Detail Produk</div>
 
-      <div className="p-4 pt-0 flex flex-col gap-y-3">
-        <VariantGroupCard 
-          variants={invoice.data?.products} 
-          buyMore 
-        />
-        <div className="flex justify-between mt-3 font-medium">
-          <p>Total Belanja</p>
-          <p>{ currencyFormat(invoice.data?.amountTotal) }</p>
+        <div className='p-4 pt-0 flex flex-col gap-y-3'>
+          <VariantGroupCard variants={invoice.data?.products} buyMore />
+          <div className='flex justify-between mt-3 font-medium'>
+            <p>Total Belanja</p>
+            <p>{currencyFormat(invoice.data?.amountTotal)}</p>
+          </div>
         </div>
-      </div>
-    </>
+      </>
+    )
   )
 }
 
 const DescriptionRow = ({ children, label }) => (
-  <div className="grid grid-cols-2">
-    <span className="text-gray_r-11">{ label }</span>
-    <span className="text-right">{ children }</span>
+  <div className='grid grid-cols-2'>
+    <span className='text-gray_r-11'>{label}</span>
+    <span className='text-right'>{children}</span>
   </div>
 )
 
-export default Invoice
\ No newline at end of file
+export default Invoice
-- 
cgit v1.2.3


From ac3fdf7be9982e65d8f83a20bc487f8dd62e3bfc Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Wed, 22 Feb 2023 23:36:47 +0700
Subject: fix

---
 src/lib/invoice/components/Invoice.jsx | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

(limited to 'src/lib/invoice/components/Invoice.jsx')

diff --git a/src/lib/invoice/components/Invoice.jsx b/src/lib/invoice/components/Invoice.jsx
index eaf7b7e0..e34ad8c2 100644
--- a/src/lib/invoice/components/Invoice.jsx
+++ b/src/lib/invoice/components/Invoice.jsx
@@ -86,7 +86,10 @@ const Invoice = ({ id }) => {
         <div className='font-medium p-4'>Detail Produk</div>
 
         <div className='p-4 pt-0 flex flex-col gap-y-3'>
-          <VariantGroupCard variants={invoice.data?.products} buyMore />
+          <VariantGroupCard
+            variants={invoice.data?.products}
+            buyMore
+          />
           <div className='flex justify-between mt-3 font-medium'>
             <p>Total Belanja</p>
             <p>{currencyFormat(invoice.data?.amountTotal)}</p>
-- 
cgit v1.2.3

