From fdfb47c3a825258b871ac5921605642e5e05fdd8 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 21 Feb 2023 12:04:20 +0700 Subject: fix --- src/lib/transaction/components/Transaction.jsx | 149 +++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 src/lib/transaction/components/Transaction.jsx (limited to 'src/lib/transaction/components/Transaction.jsx') diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx new file mode 100644 index 00000000..c9bdf715 --- /dev/null +++ b/src/lib/transaction/components/Transaction.jsx @@ -0,0 +1,149 @@ +import Spinner from "@/core/components/elements/Spinner/Spinner" +import useTransaction from "../hooks/useTransaction" +import TransactionStatusBadge from "./TransactionStatusBadge" +import Divider from "@/core/components/elements/Divider/Divider" +import { useRef, useState } from "react" +import { downloadPurchaseOrder } from "../utils/transactions" +import BottomPopup from "@/core/components/elements/Popup/BottomPopup" +import uploadPoApi from "../api/uploadPoApi" +import { toast } from "react-hot-toast" +import getFileBase64 from "@/core/utils/getFileBase64" +import currencyFormat from "@/core/utils/currencyFormat" +import VariantGroupCard from "@/lib/variant/components/VariantGroupCard" + +const Transaction = ({ id }) => { + const { transaction } = useTransaction({ id }) + + const poNumber = useRef('') + const poFile = useRef('') + const [ uploadPo, setUploadPo ] = useState(false) + const openUploadPo = () => setUploadPo(true) + const closeUploadPo = () => setUploadPo(false) + const submitUploadPo = async () => { + const file = poFile.current.files[0] + const name = poNumber.current.value + if (typeof file === 'undefined' || !name) { + toast.error('Nomor dan Dokumen PO harus diisi', { position: 'bottom-center' }) + return + } + if (file.size > 5000000) { + toast.error('Maksimal ukuran file adalah 5MB', { position: 'bottom-center' }) + return + } + const data = { name, file: await getFileBase64(file) } + const isUploaded = await uploadPoApi({ id, data }) + if (isUploaded) { + toast.success('Berhasil upload PO') + transaction.refetch() + closeUploadPo() + return + } + toast.error('Terjadi kesalahan internal, coba lagi nanti atau hubungi kami') + } + + return ( + <> + { transaction.isLoading && ( +
+ +
+ ) } + + { transaction.data?.name && ( + <> +
+ +
+ +
+
+ + { transaction.data?.name } + + + { transaction.data?.paymentTerm } + + + { transaction.data?.sales } + + + { transaction.data?.dateOrder } + +
+ + + +
+ + { transaction.data?.purchaseOrderName || '-' } + +
+

Dokumen PO

+ +
+
+ + + +
Detail Produk
+ +
+ +
+

Total Belanja

+

{ currencyFormat(transaction.data?.amountTotal) }

+
+
+ + + + +
+ + +
+
+ + +
+
+ + +
+
+ + )} + + + ) +} + +const DescriptionRow = ({ children, label }) => ( +
+ { label } + { children } +
+) + +export default Transaction \ No newline at end of file -- cgit v1.2.3 From 3f2ff1475676ba47a841796e39e7d17d627e5356 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 21 Feb 2023 14:46:24 +0700 Subject: fix --- src/lib/transaction/components/Transaction.jsx | 191 ++++++++++++++++++++++++- 1 file changed, 190 insertions(+), 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 c9bdf715..143b24bb 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -3,13 +3,18 @@ import useTransaction from "../hooks/useTransaction" import TransactionStatusBadge from "./TransactionStatusBadge" import Divider from "@/core/components/elements/Divider/Divider" import { useRef, useState } from "react" -import { downloadPurchaseOrder } from "../utils/transactions" +import { downloadPurchaseOrder, downloadQuotation } from "../utils/transactions" import BottomPopup from "@/core/components/elements/Popup/BottomPopup" import uploadPoApi from "../api/uploadPoApi" import { toast } from "react-hot-toast" import getFileBase64 from "@/core/utils/getFileBase64" import currencyFormat from "@/core/utils/currencyFormat" import VariantGroupCard from "@/lib/variant/components/VariantGroupCard" +import { ChevronDownIcon, ChevronRightIcon, ChevronUpIcon } from "@heroicons/react/24/outline" +import Link from "@/core/components/elements/Link/Link" +import Alert from "@/core/components/elements/Alert/Alert" +import checkoutPoApi from "../api/checkoutPoApi" +import cancelTransactionApi from "../api/cancelTransactionApi" const Transaction = ({ id }) => { const { transaction } = useTransaction({ id }) @@ -41,6 +46,37 @@ 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) + const submitCancelTransaction = async () => { + const isCancelled = await cancelTransactionApi({ transaction: transaction.data }) + if (isCancelled) { + toast.success('Berhasil batalkan transaksi') + transaction.refetch() + } + closeCancelTransaction() + } + + const checkout = async () => { + if (!transaction.data?.purchaseOrderFile) { + toast.error('Mohon upload dokumen PO anda sebelum melanjutkan pesanan') + return + } + await checkoutPoApi({ id }) + toast.success('Berhasil melanjutkan pesanan') + transaction.refetch() + } + return ( <> { transaction.isLoading && ( @@ -105,6 +141,122 @@ const Transaction = ({ id }) => { + + toggleSection('customer')} + /> + + { section.customer && } + + + + toggleSection('shipping')} + /> + + { section.shipping && } + + + + toggleSection('invoice')} + /> + + { section.invoice && } + + + +
+

Invoice

+
+ { transaction.data?.invoices?.map((invoice, index) => ( + +
+
+

{ invoice?.name }

+
+ { invoice.amountResidual > 0 ? ( +
Belum Lunas
+ ) : ( +
Lunas
+ ) } +

+ { currencyFormat(invoice.amountTotal) } +

+
+
+ +
+ + )) } + { transaction.data?.invoices?.length === 0 && ( + + Belum ada Invoice + + ) } +
+
+ + + +
+ { transaction.data?.status == 'draft' && ( + + ) } + + { transaction.data?.status != 'draft' && ( + + ) } +
+ + +
+ Apakah anda yakin membatalkan transaksi {transaction.data?.name}? +
+
+ + +
+
{ ) } +const SectionButton = ({ label, active, toggle }) => ( + +) + +const SectionContent = ({ address }) => { + let fullAddress = [] + if (address?.street) fullAddress.push(address.street) + if (address?.sub_district?.name) fullAddress.push(address.sub_district.name) + if (address?.district?.name) fullAddress.push(address.district.name) + if (address?.city?.name) fullAddress.push(address.city.name) + fullAddress = fullAddress.join(', ') + + return ( +
+ + { address.name } + + + { address.email || '-' } + + + { address.mobile || '-' } + + + { fullAddress } + +
+ ) +} + const DescriptionRow = ({ children, label }) => (
{ label } -- cgit v1.2.3 From de7361718def0f6bb32294bb074841ba2c0a3ce6 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 21 Feb 2023 16:25:35 +0700 Subject: fix --- src/lib/transaction/components/Transaction.jsx | 377 ++++++++++++------------- 1 file changed, 187 insertions(+), 190 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 143b24bb..e049a9ac 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -77,216 +77,213 @@ const Transaction = ({ id }) => { transaction.refetch() } - return ( - <> - { transaction.isLoading && ( -
- -
- ) } + if (transaction.isLoading) { + return ( +
+ +
+ ) + } - { transaction.data?.name && ( - <> -
- -
- -
-
- - { transaction.data?.name } - - - { transaction.data?.paymentTerm } - - - { transaction.data?.sales } - - - { transaction.data?.dateOrder } - + return transaction.data?.name && ( + <> +
+ +
+
- - +
+ + { transaction.data?.name } + + + { transaction.data?.paymentTerm } + + + { transaction.data?.sales } + + + { transaction.data?.dateOrder } + +
+ + -
- - { transaction.data?.purchaseOrderName || '-' } - -
-

Dokumen PO

- -
-
+
+ + { transaction.data?.purchaseOrderName || '-' } + +
+

Dokumen PO

+ +
+
- + -
Detail Produk
+
Detail Produk
-
- -
-

Total Belanja

-

{ currencyFormat(transaction.data?.amountTotal) }

-
-
+
+ +
+

Total Belanja

+

{ currencyFormat(transaction.data?.amountTotal) }

+
+
- - - toggleSection('customer')} - /> + + + toggleSection('customer')} + /> - { section.customer && } + { section.customer && } - - - toggleSection('shipping')} - /> + + + toggleSection('shipping')} + /> - { section.shipping && } + { section.shipping && } - - - toggleSection('invoice')} - /> + + + toggleSection('invoice')} + /> - { section.invoice && } + { section.invoice && } - + -
-

Invoice

-
- { transaction.data?.invoices?.map((invoice, index) => ( - -
-
-

{ invoice?.name }

-
- { invoice.amountResidual > 0 ? ( -
Belum Lunas
- ) : ( -
Lunas
- ) } -

- { currencyFormat(invoice.amountTotal) } -

-
-
- +
+

Invoice

+
+ { transaction.data?.invoices?.map((invoice, index) => ( + +
+
+

{ invoice?.name }

+
+ { invoice.amountResidual > 0 ? ( +
Belum Lunas
+ ) : ( +
Lunas
+ ) } +

+ { currencyFormat(invoice.amountTotal) } +

- - )) } - { transaction.data?.invoices?.length === 0 && ( - - Belum ada Invoice - - ) } -
-
- - +
+ +
+ + )) } + { transaction.data?.invoices?.length === 0 && ( + + Belum ada Invoice + + ) } +
+
-
- { transaction.data?.status == 'draft' && ( - - ) } - - { transaction.data?.status != 'draft' && ( - - ) } -
+ - + { transaction.data?.status == 'draft' && ( + + ) } + + { transaction.data?.status != 'draft' && ( + - -
- + Batalkan Transaksi + + ) } +
- +
+ Apakah anda yakin membatalkan transaksi {transaction.data?.name}? +
+
+ - -
-
- - )} + Ya, Batalkan + + +
+
+ +
+ + +
+
+ + +
+
+ + +
+
) } @@ -305,7 +302,7 @@ const SectionButton = ({ label, active, toggle }) => ( const SectionContent = ({ address }) => { let fullAddress = [] if (address?.street) fullAddress.push(address.street) - if (address?.sub_district?.name) fullAddress.push(address.sub_district.name) + if (address?.subDistrict?.name) fullAddress.push(address.sub_district.name) if (address?.district?.name) fullAddress.push(address.district.name) if (address?.city?.name) fullAddress.push(address.city.name) fullAddress = fullAddress.join(', ') -- cgit v1.2.3 From 5933732a74ae1ca4124ddd4e8265b1f443234736 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly 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 }) => { - toggleSection('customer')} - /> - - { section.customer && } - - - - toggleSection('shipping')} - /> - - { section.shipping && } - - - - toggleSection('invoice')} - /> - - { section.invoice && } + @@ -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 ( + <> + toggleSection('customer')} + /> + + { section.customer && } + + + + toggleSection('shipping')} + /> + + { section.shipping && } + + + + toggleSection('invoice')} + /> + { section.invoice && } + + ) +} + const SectionButton = ({ label, active, toggle }) => ( + + +
+ + {transaction.data?.purchaseOrderName || '-'} + +
+

Dokumen PO

+ +
- - + -
Detail Produk
+
Detail Produk
-
- -
-

Total Belanja

-

{ currencyFormat(transaction.data?.amountTotal) }

+
+ +
+

Total Belanja

+

{currencyFormat(transaction.data?.amountTotal)}

+
-
- - - + - + + + -
-

Invoice

-
- { transaction.data?.invoices?.map((invoice, index) => ( - -
-
-

{ invoice?.name }

-
- { invoice.amountResidual > 0 ? ( -
Belum Lunas
+
+

Invoice

+
+ {transaction.data?.invoices?.map((invoice, index) => ( + +
+
+

{invoice?.name}

+
+ {invoice.amountResidual > 0 ? ( +
Belum Lunas
) : ( -
Lunas
- ) } -

- { currencyFormat(invoice.amountTotal) } -

+
Lunas
+ )} +

+ {currencyFormat(invoice.amountTotal)} +

+
+
- -
- - )) } - { transaction.data?.invoices?.length === 0 && ( - - Belum ada Invoice - - ) } + + ))} + {transaction.data?.invoices?.length === 0 && ( + + Belum ada Invoice + + )} +
-
- + -
- { transaction.data?.status == 'draft' && ( - + )} + - ) } - + )} +
+ + - Download Quotation - - { transaction.data?.status != 'draft' && ( - - ) } -
+
+ Apakah anda yakin membatalkan transaksi{' '} + {transaction.data?.name}? +
+
+ + +
+ - -
- Apakah anda yakin membatalkan transaksi {transaction.data?.name}? -
-
- - -
-
- - -
- - -
-
- - -
-
- - -
-
- + +
+ + +
+
+ + +
+
+ + +
+
+ + ) ) } const SectionAddress = ({ address }) => { - const [ section, setSection ] = useState({ + const [section, setSection] = useState({ customer: false, invoice: false, shipping: false @@ -265,44 +248,40 @@ const SectionAddress = ({ address }) => { return ( <> - toggleSection('customer')} /> - { section.customer && } + {section.customer && } - - toggleSection('shipping')} /> - { section.shipping && } + {section.shipping && } - - toggleSection('invoice')} /> - { section.invoice && } + {section.invoice && } ) } const SectionButton = ({ label, active, toggle }) => ( - ) @@ -315,28 +294,20 @@ const SectionContent = ({ address }) => { fullAddress = fullAddress.join(', ') return ( -
- - { address.name } - - - { address.email || '-' } - - - { address.mobile || '-' } - - - { fullAddress } - +
+ {address.name} + {address.email || '-'} + {address.mobile || '-'} + {fullAddress}
) } const DescriptionRow = ({ children, label }) => ( -
- { label } - { children } +
+ {label} + {children}
) -export default Transaction \ No newline at end of file +export default Transaction -- cgit v1.2.3 From 7265295454801c1d921385a4b67fb3780b46771e Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 22 Feb 2023 14:00:00 +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 2220f3be..17eacd45 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -288,7 +288,7 @@ const SectionButton = ({ label, active, toggle }) => ( const SectionContent = ({ address }) => { let fullAddress = [] if (address?.street) fullAddress.push(address.street) - if (address?.subDistrict?.name) fullAddress.push(address.sub_district.name) + 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(', ') -- cgit v1.2.3 From ac3fdf7be9982e65d8f83a20bc487f8dd62e3bfc Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 22 Feb 2023 23:36:47 +0700 Subject: fix --- src/lib/transaction/components/Transaction.jsx | 61 +++++++++++++++++++++----- 1 file changed, 50 insertions(+), 11 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 17eacd45..7da33551 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -120,7 +120,10 @@ const Transaction = ({ id }) => {
Detail Produk
- +

Total Belanja

{currencyFormat(transaction.data?.amountTotal)}

@@ -137,7 +140,10 @@ const Transaction = ({ id }) => {

Invoice

{transaction.data?.invoices?.map((invoice, index) => ( - +

{invoice?.name}

@@ -157,7 +163,10 @@ const Transaction = ({ id }) => { ))} {transaction.data?.invoices?.length === 0 && ( - + Belum ada Invoice )} @@ -168,7 +177,10 @@ const Transaction = ({ id }) => {
{transaction.data?.status == 'draft' && ( - )} @@ -207,26 +219,50 @@ const Transaction = ({ id }) => { > Ya, Batalkan -
- +
- +
- +
- -
@@ -279,7 +315,10 @@ const SectionAddress = ({ address }) => { } const SectionButton = ({ label, active, toggle }) => ( - -- cgit v1.2.3