import React, { useEffect, useState } from "react"; import styles from "./Transactions.module.css"; import { useParams } from "react-router-dom"; import { ColorRing } from "react-loader-spinner"; import { getTransactions } from "../helpers/transactionHelpers"; export default function Transactions({ propsShopId, sendParam, deviceType }) { const { shopId, tableId } = useParams(); if (sendParam) sendParam({ shopId, tableId }); const [transactions, setTransactions] = useState([]); const [isPaymentLoading, setIsPaymentLoading] = useState(false); useEffect(() => { const fetchTransactions = async () => { try { const response = await getTransactions(shopId || propsShopId, 5); console.log("modallll"); console.log(response); setTransactions(response); } catch (error) { console.error("Error fetching transactions:", error); } }; fetchTransactions(); }, [shopId]); const calculateTotalPrice = (detailedTransactions) => { return detailedTransactions.reduce((total, dt) => { return total + dt.qty * dt.Item.price; }, 0); }; const handlePayment = async (isCash) => { setIsPaymentLoading(true); try { // Implement payment logic here console.log(`Processing ${isCash ? "cash" : "cashless"} payment`); // Simulate payment process await new Promise((resolve) => setTimeout(resolve, 2000)); } catch (error) { console.error("Error processing payment:", error); } finally { setIsPaymentLoading(false); } }; return (