diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-02-21 21:51:51 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-02-21 21:51:51 +0700 |
| commit | 5933732a74ae1ca4124ddd4e8265b1f443234736 (patch) | |
| tree | d3950bab4c7c1fa319184c69e94a853d9877570e /src/lib/transaction/components/Transaction.jsx | |
| parent | 04fe185879061b404fe1baa468bf67d32b3fdd5f (diff) | |
fix
Diffstat (limited to 'src/lib/transaction/components/Transaction.jsx')
| -rw-r--r-- | src/lib/transaction/components/Transaction.jsx | 79 |
1 files changed, 43 insertions, 36 deletions
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> |
