From 5d8b2af2c9d521283970d175a1aad32d36aefd98 Mon Sep 17 00:00:00 2001 From: insvrgent Date: Mon, 13 Jan 2025 15:47:39 +0700 Subject: [PATCH] ok --- src/components/PaymentOptions.js | 286 ++++++++++++++++++++++++------- src/helpers/cafeHelpers.js | 16 ++ 2 files changed, 242 insertions(+), 60 deletions(-) diff --git a/src/components/PaymentOptions.js b/src/components/PaymentOptions.js index 0c7c21c..e646346 100644 --- a/src/components/PaymentOptions.js +++ b/src/components/PaymentOptions.js @@ -14,6 +14,15 @@ const SetPaymentQr = ({ shop }) => { left: shop.xposition, top: shop.yposition, }); + + const [isConfigFont, setIsConfigFont] = useState(false); + const [fontsize, setfontsize] = useState(shop.fontsize); + const [fontcolor, setfontcolor] = useState(shop.fontcolor); + const [initialFontPos, setInitialFontPos] = useState({ + left: shop.fontxposition, + top: shop.fontyposition, + }); + const [initialSize, setInitialSize] = useState(shop.scale); const [bgImageUrl, setBgImageUrl] = useState(getImageUrl(shop.qrBackground)); const qrBackgroundInputRef = useRef(null); @@ -30,12 +39,15 @@ const SetPaymentQr = ({ shop }) => { )}`; } }; - + const [isConfig, setIsConfig] = useState(false); + const [isConfigQR, setIsConfigQR] = useState(false); const [isViewTables, setIsViewTables] = useState(false); const [tables, setTables] = useState([]); + const [selectedTable, setSelectedTable] = useState(null); + useEffect(() => { const fetchData = async () => { try { @@ -57,7 +69,10 @@ const SetPaymentQr = ({ shop }) => { const details = { qrSize: initialSize, qrPosition: initialPos, - qrBackgroundFile, // Include qrBackground file + qrBackgroundFile, + fontsize, + fontcolor, + fontPosition: initialFontPos, }; // Call saveCafeDetails function with the updated details object @@ -79,10 +94,21 @@ const SetPaymentQr = ({ shop }) => { })); }; + const handleFontPositionChange = (e) => { + const { name, value } = e.target; + setInitialFontPos((prevPosition) => ({ + ...prevPosition, + [name]: parseFloat(value).toFixed(2), + })); + }; + const handleSizeChange = (e) => { setInitialSize(parseFloat(e.target.value).toFixed(2)); }; - + + const handleFontSizeChange = (e) => { + setfontsize(parseFloat(e.target.value).toFixed(2)); + }; const handleFileChange = (e) => { const file = e.target.files[0]; @@ -94,7 +120,7 @@ const SetPaymentQr = ({ shop }) => { return (
-

Konfigurasi pembayaran

+

QR kedai dan meja

{ }} > QR Code { top: `${initialPos.top}%`, transform: "translate(-50%, -50%)", }} /> +
50 ? -1 : 1})`, + position: "absolute", + fontSize: `${fontsize * 3}%`, + left: `${initialFontPos.left}%`, + top: `${initialFontPos.top}%`, + textAlign: initialFontPos.left > 50 ? 'right' : 'left' + }}> +

50 ? -1 : 1})`, + width: '200%', + lineHeight: 0, + fontFamily: 'Plus Jakarta Sans', + color: fontcolor + }} >{selectedTable == null ? 'Nomor meja' : selectedTable.tableNo}

+
{

Klik untuk ganti background

-

setIsConfig(!isConfig)}> {isConfig ? '˅' : '˃'} Konfigurasi QR

+

setIsConfig(!isConfig)}> {isConfig ? '˅' : '˃'} Konfigurasi

qrBackgroundInputRef.current.click()} style={styles.uploadButton}>Ganti
- {isConfig && <> -
-