From ebc09c5062cc7996b0f2aaf879062fc950c2e1c2 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 25 Jan 2023 11:17:37 +0700 Subject: Transaction detail and variant card component --- src/components/elements/DescriptionRow.js | 10 +++++ src/components/elements/Disclosure.js | 14 +++++++ src/components/transactions/TransactionDetail.js | 21 +++++++++++ src/components/variants/VariantCard.js | 48 ++++++++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 src/components/elements/DescriptionRow.js create mode 100644 src/components/elements/Disclosure.js create mode 100644 src/components/transactions/TransactionDetail.js create mode 100644 src/components/variants/VariantCard.js (limited to 'src/components') diff --git a/src/components/elements/DescriptionRow.js b/src/components/elements/DescriptionRow.js new file mode 100644 index 00000000..7fe9e3a1 --- /dev/null +++ b/src/components/elements/DescriptionRow.js @@ -0,0 +1,10 @@ +const DescriptionRow = ({ label, children }) => ( +
+

{ label }

+
+ { children } +
+
+); + +export default DescriptionRow; \ No newline at end of file diff --git a/src/components/elements/Disclosure.js b/src/components/elements/Disclosure.js new file mode 100644 index 00000000..0aaedf87 --- /dev/null +++ b/src/components/elements/Disclosure.js @@ -0,0 +1,14 @@ +const { ChevronUpIcon, ChevronDownIcon } = require("@heroicons/react/24/outline"); + +const Disclosure = ({ label, active, onClick }) => ( +
+

{ label }

+ { onClick && ( active ? ( + + ) : ( + + ) ) } +
+); + +export default Disclosure; \ No newline at end of file diff --git a/src/components/transactions/TransactionDetail.js b/src/components/transactions/TransactionDetail.js new file mode 100644 index 00000000..6d304d31 --- /dev/null +++ b/src/components/transactions/TransactionDetail.js @@ -0,0 +1,21 @@ +import DescriptionRow from "../elements/DescriptionRow"; + +const CustomerSection = ({ address }) => { + const 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); + return ( +
+ { address?.name } + { address?.email || '-' } + { address?.mobile || '-' } + { fullAddress.join(', ') } +
+ ); +}; + +export { + CustomerSection +}; \ No newline at end of file diff --git a/src/components/variants/VariantCard.js b/src/components/variants/VariantCard.js new file mode 100644 index 00000000..cb4d8272 --- /dev/null +++ b/src/components/variants/VariantCard.js @@ -0,0 +1,48 @@ +import { createSlug } from "@/core/utils/slug"; +import Image from "../elements/Image"; +import Link from "../elements/Link"; +import currencyFormat from "@/core/utils/currencyFormat"; + +export default function VariantCard({ + data, + openOnClick = true +}) { + let product = data; + + const Card = () => ( +
+
+ {product.parent.name} +
+
+

+ {product.parent.name} +

+

+ {product.code || '-'} + {product.attributes.length > 0 ? ` ・ ${product.attributes.join(', ')}` : ''} +

+

+ {currencyFormat(product.price.price_discount)} × {product.quantity} Barang +

+

+ {currencyFormat(product.quantity * product.price.price_discount)} +

+
+
+ ); + + if (openOnClick) { + return ( + + + + ); + } + + return ; +} \ No newline at end of file -- cgit v1.2.3