import React, { createContext, useContext, useEffect, useMemo, useState, } from "react"; import Breadcrumb from "../../components/common/Breadcrumb"; import { useEmployee } from "../../hooks/useEmployees"; import EmployeeSearchInput from "../../components/common/EmployeeSearchInput"; import { useForm } from "react-hook-form"; import Label from "../../components/common/Label"; import AdvancePaymentList from "../../components/AdvancePayment/AdvancePaymentList"; import { employee } from "../../data/masters"; import { formatFigure } from "../../utils/appUtils"; export const AdvancePaymentContext = createContext(); export const useAdvancePaymentContext = () => { const context = useContext(AdvancePaymentContext); if (!context) { throw new Error( "useAdvancePaymentContext must be used within an AdvancePaymentProvider" ); } return context; }; const AdvancePaymentPage = () => { const [balance, setBalance] = useState(null); const { control, reset, watch } = useForm({ defaultValues: { employeeId: "", }, }); const selectedEmployeeId = watch("employeeId"); useEffect(() => { const selectedEmpoyee = sessionStorage.getItem("transaction-empId"); reset({ employeeId: selectedEmpoyee || "", }); }, [reset]); return (
{balance ? ( <> 0 ? "text-success" : "text-danger" } fs-5 fw-bold ms-1`} > {balance > 0 ? ( ) : ( )}{" "} {formatFigure(balance, { type: "currency", currency: "INR", })} ) : ( <> )}
); }; export default AdvancePaymentPage;