import React, { useEffect, useRef, useCallback } from "react"; import { useDispatch, useSelector } from "react-redux"; import { Button } from "@mui/material"; import { useNavigate } from "react-router-dom"; import { getKillhouseApprovedPriceState } from "../../../province/services/get-approved-price-state"; import { Grid } from "../../../../components/grid/Grid"; import { StewardShowProducts } from "../steward-show-products/StewardShowProducts"; import { DRAWER } from "../../../../lib/redux/slices/appSlice"; import { StewardAllocationToGuild } from "../../../guild/components/StewardAllocationToGuild"; import { ROUTE_STEWARD_DAILY_LIST } from "../../../../routes/routes"; import { StewardShowAllocations } from "../steward-show-allocations/StewardShowAllocations"; import { checkPathStartsWith } from "../../../../utils/checkPathStartsWith"; export const StewardSellInProvince = () => { const dispatch = useDispatch(); const allocationsRef = useRef(null); const selectedSubUser = useSelector( (state) => state.userSlice.selectedSubUser ); const { stewardProducts } = useSelector((state) => state.stewardSlice); const navigate = useNavigate(); const { priceInfo } = useSelector((state) => state.slaughterSlice); const fetchData = useCallback(async () => { dispatch( getKillhouseApprovedPriceState({ role_key: checkPathStartsWith("steward") ? selectedSubUser?.key || "" : "", }) ); if (allocationsRef.current?.updateTable) { allocationsRef.current.updateTable(); } }, [dispatch, selectedSubUser?.key]); useEffect(() => { fetchData(); }, [selectedSubUser?.key]); return ( ); };