ok
This commit is contained in:
7
package-lock.json
generated
7
package-lock.json
generated
@@ -15,6 +15,7 @@
|
|||||||
"@testing-library/react": "^13.4.0",
|
"@testing-library/react": "^13.4.0",
|
||||||
"@testing-library/user-event": "^13.5.0",
|
"@testing-library/user-event": "^13.5.0",
|
||||||
"caniuse-lite": "^1.0.30001690",
|
"caniuse-lite": "^1.0.30001690",
|
||||||
|
"html-to-image": "^1.11.11",
|
||||||
"html2canvas": "^1.4.1",
|
"html2canvas": "^1.4.1",
|
||||||
"jsqr": "^1.4.0",
|
"jsqr": "^1.4.0",
|
||||||
"qrcode.react": "^3.1.0",
|
"qrcode.react": "^3.1.0",
|
||||||
@@ -10264,6 +10265,12 @@
|
|||||||
"node": ">=12"
|
"node": ">=12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/html-to-image": {
|
||||||
|
"version": "1.11.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/html-to-image/-/html-to-image-1.11.11.tgz",
|
||||||
|
"integrity": "sha512-9gux8QhvjRO/erSnDPv28noDZcPZmYE7e1vFsBLKLlRlKDSqNJYebj6Qz1TGd5lsRV+X+xYyjCKjuZdABinWjA==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/html-webpack-plugin": {
|
"node_modules/html-webpack-plugin": {
|
||||||
"version": "5.6.0",
|
"version": "5.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-5.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-5.6.0.tgz",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "groovebrew-mockup",
|
"name": "groovebrew-mockup",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"homepage": ".",
|
"homepage": "https://dev.kedaimaster.com",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.13.3",
|
"@emotion/react": "^11.13.3",
|
||||||
"@emotion/styled": "^11.13.0",
|
"@emotion/styled": "^11.13.0",
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
"@testing-library/react": "^13.4.0",
|
"@testing-library/react": "^13.4.0",
|
||||||
"@testing-library/user-event": "^13.5.0",
|
"@testing-library/user-event": "^13.5.0",
|
||||||
"caniuse-lite": "^1.0.30001690",
|
"caniuse-lite": "^1.0.30001690",
|
||||||
|
"html-to-image": "^1.11.11",
|
||||||
"html2canvas": "^1.4.1",
|
"html2canvas": "^1.4.1",
|
||||||
"jsqr": "^1.4.0",
|
"jsqr": "^1.4.0",
|
||||||
"qrcode.react": "^3.1.0",
|
"qrcode.react": "^3.1.0",
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
.modalContent {
|
.modalContent {
|
||||||
width: 80vw;
|
width: 80vw;
|
||||||
|
max-height: 80vh;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: visible; /* Add this line to enable scrolling */
|
overflow: visible; /* Add this line to enable scrolling */
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ import {
|
|||||||
saveCafeDetails,
|
saveCafeDetails,
|
||||||
setConfirmationStatus,
|
setConfirmationStatus,
|
||||||
} from "../helpers/cafeHelpers";
|
} from "../helpers/cafeHelpers";
|
||||||
import Switch from "react-switch"; // Import the Switch component
|
|
||||||
|
import { toPng } from 'html-to-image';
|
||||||
|
|
||||||
const SetPaymentQr = ({ shop }) => {
|
const SetPaymentQr = ({ shop }) => {
|
||||||
const [initialPos, setInitialPos] = useState({
|
const [initialPos, setInitialPos] = useState({
|
||||||
@@ -15,6 +16,7 @@ const SetPaymentQr = ({ shop }) => {
|
|||||||
top: shop.yposition,
|
top: shop.yposition,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const [isViewingQR, setIsViewingQR] = useState(false);
|
||||||
const [isConfigFont, setIsConfigFont] = useState(false);
|
const [isConfigFont, setIsConfigFont] = useState(false);
|
||||||
const [fontsize, setfontsize] = useState(shop.fontsize);
|
const [fontsize, setfontsize] = useState(shop.fontsize);
|
||||||
const [fontcolor, setfontcolor] = useState(shop.fontcolor);
|
const [fontcolor, setfontcolor] = useState(shop.fontcolor);
|
||||||
@@ -48,6 +50,8 @@ const SetPaymentQr = ({ shop }) => {
|
|||||||
|
|
||||||
const [selectedTable, setSelectedTable] = useState(null);
|
const [selectedTable, setSelectedTable] = useState(null);
|
||||||
|
|
||||||
|
const [tableNo, setTableNo] = useState(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -118,6 +122,45 @@ const SetPaymentQr = ({ shop }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCreate = async () => {
|
||||||
|
// if (newTable) {
|
||||||
|
try {
|
||||||
|
const createdTable = await createTable(shop.cafeId, {
|
||||||
|
// ...newTable,
|
||||||
|
tableNo,
|
||||||
|
});
|
||||||
|
setTables([...tables, createdTable]);
|
||||||
|
setTableNo("");
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error creating table:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function downloadQrCodeContainer({ selectedTable, shop }) {
|
||||||
|
const node = document.getElementById('qr-code-container');
|
||||||
|
|
||||||
|
if (!node) return;
|
||||||
|
|
||||||
|
const isTableSelected = selectedTable != null;
|
||||||
|
|
||||||
|
toPng(node, { pixelRatio: 2 }) // Adjust pixel ratio for higher resolution
|
||||||
|
.then((dataUrl) => {
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = dataUrl;
|
||||||
|
|
||||||
|
// Set the file name based on whether selectedTable exists
|
||||||
|
link.download = isTableSelected
|
||||||
|
? `QR Meja (${selectedTable.tableNo}).png`
|
||||||
|
: `QR ${shop.name}.png`;
|
||||||
|
|
||||||
|
link.click();
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error('Could not download the image', err);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={styles.container}>
|
<div style={styles.container}>
|
||||||
<h3 style={styles.title}>QR kedai dan meja</h3>
|
<h3 style={styles.title}>QR kedai dan meja</h3>
|
||||||
@@ -156,6 +199,7 @@ const SetPaymentQr = ({ shop }) => {
|
|||||||
textAlign: initialFontPos.left > 50 ? 'right' : 'left'
|
textAlign: initialFontPos.left > 50 ? 'right' : 'left'
|
||||||
}}>
|
}}>
|
||||||
<h1 style={{
|
<h1 style={{
|
||||||
|
visibility: !selectedTable && isViewingQR ? 'hidden' : 'visible',
|
||||||
transform: `scaleX(${initialFontPos.left > 50 ? -1 : 1})`,
|
transform: `scaleX(${initialFontPos.left > 50 ? -1 : 1})`,
|
||||||
width: '200%',
|
width: '200%',
|
||||||
lineHeight: 0,
|
lineHeight: 0,
|
||||||
@@ -171,11 +215,13 @@ const SetPaymentQr = ({ shop }) => {
|
|||||||
onChange={handleFileChange}
|
onChange={handleFileChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
{!isViewingQR ?
|
||||||
|
<>
|
||||||
<div style={styles.uploadMessage}>
|
<div style={styles.uploadMessage}>
|
||||||
<p>Klik untuk ganti background</p>
|
<p>Klik untuk ganti background</p>
|
||||||
</div>
|
</div>
|
||||||
<div style={styles.resultMessage}>
|
<div style={styles.resultMessage}>
|
||||||
<p onClick={() => setIsConfig(!isConfig)}> {isConfig ? '˅' : '˃'} Konfigurasi</p>
|
<p onClick={() => {setIsConfig(!isConfig); setIsConfigQR(false); setIsConfigFont(false)}}> {isConfig ? '˅' : '˃'} Konfigurasi</p>
|
||||||
<div
|
<div
|
||||||
onClick={() => qrBackgroundInputRef.current.click()} style={styles.uploadButton}>Ganti</div>
|
onClick={() => qrBackgroundInputRef.current.click()} style={styles.uploadButton}>Ganti</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -332,9 +378,9 @@ const SetPaymentQr = ({ shop }) => {
|
|||||||
{isViewTables &&
|
{isViewTables &&
|
||||||
<div style={{marginTop: '34px', marginLeft: '15px'}}>
|
<div style={{marginTop: '34px', marginLeft: '15px'}}>
|
||||||
<div style={styles.resultMessage}>
|
<div style={styles.resultMessage}>
|
||||||
<input style={{borderRadius: '12px', paddingLeft: '13px'}} placeholder="Meja A1"/>
|
<input style={{borderRadius: '12px', paddingLeft: '13px', marginRight: '10px'}} placeholder="Meja A1" onChange={(e) => setTableNo(e.target.value)} value={tableNo}/>
|
||||||
<div
|
<div
|
||||||
onClick={() => qrBackgroundInputRef.current.click()} style={styles.uploadButton}>Buat meja</div>
|
onClick={handleCreate} style={styles.uploadButton}>Buat meja</div>
|
||||||
</div>
|
</div>
|
||||||
{tables && tables
|
{tables && tables
|
||||||
.filter((table) => table.tableNo !== 0)
|
.filter((table) => table.tableNo !== 0)
|
||||||
@@ -364,12 +410,31 @@ const SetPaymentQr = ({ shop }) => {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style={styles.buttonContainer}>
|
<div style={styles.buttonContainer}>
|
||||||
<button onClick={handleSave} style={styles.saveButton}>
|
<button onClick={handleSave} style={styles.saveButton}>
|
||||||
Simpan
|
Simpan
|
||||||
</button>
|
</button>
|
||||||
|
<button onClick={()=>setIsViewingQR(true)} style={styles.saveButton}>
|
||||||
|
Download QR {selectedTable? 'meja' : 'kedai'}
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</> :
|
||||||
|
<>
|
||||||
|
<div style={styles.uploadMessage}>
|
||||||
|
<p>QR ini akan menjadi identifikasi bahwa pelanggan memesan dari {selectedTable? `(${selectedTable?.tableNo})` : 'link kafe ini. Untuk mengantarkan pelanggan ke meja yang teridentifikasi, anda perlu membuat meja.'}</p>
|
||||||
|
</div>
|
||||||
|
<div style={styles.buttonContainer}>
|
||||||
|
<button onClick={()=>downloadQrCodeContainer({selectedTable, shop})} style={styles.saveButton}>
|
||||||
|
Download QR {selectedTable? 'meja' : 'kedai'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div style={styles.backButtonContainer}>
|
||||||
|
<p onClick={()=>setIsViewingQR(false)} >
|
||||||
|
Kembali
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -377,6 +442,9 @@ const SetPaymentQr = ({ shop }) => {
|
|||||||
// Styles
|
// Styles
|
||||||
const styles = {
|
const styles = {
|
||||||
container: {
|
container: {
|
||||||
|
overflowY: 'auto',
|
||||||
|
overflowX: 'hidden',
|
||||||
|
maxHeight: '100%',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
backgroundColor: "white",
|
backgroundColor: "white",
|
||||||
padding: "20px",
|
padding: "20px",
|
||||||
@@ -401,6 +469,7 @@ const styles = {
|
|||||||
uploadMessage: {
|
uploadMessage: {
|
||||||
fontWeight: 600,
|
fontWeight: 600,
|
||||||
textAlign: "left",
|
textAlign: "left",
|
||||||
|
fontSize: "15px"
|
||||||
},
|
},
|
||||||
uploadButton: {
|
uploadButton: {
|
||||||
paddingRight: '10px',
|
paddingRight: '10px',
|
||||||
@@ -415,6 +484,7 @@ const styles = {
|
|||||||
},
|
},
|
||||||
resultMessage: {
|
resultMessage: {
|
||||||
marginTop: "-24px",
|
marginTop: "-24px",
|
||||||
|
marginBottom: "10px",
|
||||||
textAlign: "left",
|
textAlign: "left",
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
justifyContent: 'space-between'
|
justifyContent: 'space-between'
|
||||||
@@ -422,9 +492,18 @@ const styles = {
|
|||||||
buttonContainer: {
|
buttonContainer: {
|
||||||
marginTop: "20px",
|
marginTop: "20px",
|
||||||
textAlign: "left",
|
textAlign: "left",
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'space-evenly'
|
||||||
|
},
|
||||||
|
backButtonContainer: {
|
||||||
|
marginTop: "2px",
|
||||||
|
marginBottom: "-10px",
|
||||||
|
textAlign: "left",
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'space-evenly'
|
||||||
},
|
},
|
||||||
saveButton: {
|
saveButton: {
|
||||||
padding: "10px 20px",
|
padding: "10px 15px",
|
||||||
fontSize: "16px",
|
fontSize: "16px",
|
||||||
backgroundColor: "#28a745",
|
backgroundColor: "#28a745",
|
||||||
color: "#fff",
|
color: "#fff",
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ export default function Invoice({ table, sendParam, deviceType, socket }) {
|
|||||||
|
|
||||||
{table.tableNo != null && (
|
{table.tableNo != null && (
|
||||||
<div className={styles.OrderTypeContainer}>
|
<div className={styles.OrderTypeContainer}>
|
||||||
<span htmlFor="orderType">Diantar ke meja {table.tableNo}</span>
|
<span htmlFor="orderType">Diantar ke {table.tableNo}</span>
|
||||||
{/* <select
|
{/* <select
|
||||||
id="orderType"
|
id="orderType"
|
||||||
value={orderType}
|
value={orderType}
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ const LinktreePage = ({ user, setModal }) => {
|
|||||||
];
|
];
|
||||||
console.log(items)
|
console.log(items)
|
||||||
|
|
||||||
const selectedItems = items.items?.find(item => (item.userId || item.cafeId) === selectedItemId);
|
const selectedItems = items?.items?.find(item => (item.userId || item.cafeId) === selectedItemId);
|
||||||
|
|
||||||
// If the selected tenant is found, extract the cafes
|
// If the selected tenant is found, extract the cafes
|
||||||
const selectedSubItems = selectedItems?.subItems || [];
|
const selectedSubItems = selectedItems?.subItems || [];
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ export default function Invoice({ table, sendParam, deviceType, socket }) {
|
|||||||
<h2 className={styles["Invoice-detail"]}>
|
<h2 className={styles["Invoice-detail"]}>
|
||||||
{orderType === "pickup"
|
{orderType === "pickup"
|
||||||
? "Diambil di kasir"
|
? "Diambil di kasir"
|
||||||
: `Diantar ke meja nomor ${table.tableNo || tableNumber || "-"}`}
|
: `Diantar ke ${table.tableNo || tableNumber || "-"}`}
|
||||||
</h2>
|
</h2>
|
||||||
<div className={styles.TotalContainer}>
|
<div className={styles.TotalContainer}>
|
||||||
<span>Total:</span>
|
<span>Total:</span>
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ export default function Transactions({ propsShopId, sendParam, deviceType, handl
|
|||||||
<h2 className={styles["Transactions-detail"]}>
|
<h2 className={styles["Transactions-detail"]}>
|
||||||
{transaction.serving_type === "pickup"
|
{transaction.serving_type === "pickup"
|
||||||
? "Ambil sendiri"
|
? "Ambil sendiri"
|
||||||
: `Diantar ke meja ${transaction.Table ? transaction.Table.tableNo : "N/A"
|
: `Diantar ke ${transaction.Table ? transaction.Table.tableNo : "N/A"
|
||||||
}`}
|
}`}
|
||||||
</h2>
|
</h2>
|
||||||
{transaction.notes != "" && (
|
{transaction.notes != "" && (
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ export default function Transactions({ propsShopId, sendParam, deviceType, handl
|
|||||||
<p>Pembayaran: {transaction.payment_type}</p>
|
<p>Pembayaran: {transaction.payment_type}</p>
|
||||||
<p>{transaction.serving_type === "pickup"
|
<p>{transaction.serving_type === "pickup"
|
||||||
? "Ambil sendiri"
|
? "Ambil sendiri"
|
||||||
: `Diantar ke meja ${transaction.Table ? transaction.Table.tableNo : "N/A"
|
: `Diantar ke ${transaction.Table ? transaction.Table.tableNo : "N/A"
|
||||||
}`}</p>
|
}`}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -163,7 +163,7 @@ export default function Transactions({ propsShopId, sendParam, deviceType, handl
|
|||||||
<h2 className={styles["Transactions-detail"]}>
|
<h2 className={styles["Transactions-detail"]}>
|
||||||
{transaction.serving_type === "pickup"
|
{transaction.serving_type === "pickup"
|
||||||
? "Ambil sendiri"
|
? "Ambil sendiri"
|
||||||
: `Diantar ke meja ${transaction.Table ? transaction.Table.tableNo : "N/A"
|
: `Diantar ke ${transaction.Table ? transaction.Table.tableNo : "N/A"
|
||||||
}`}
|
}`}
|
||||||
</h2>
|
</h2>
|
||||||
{transaction.notes != "" && (
|
{transaction.notes != "" && (
|
||||||
|
|||||||
Reference in New Issue
Block a user