import { IconButton, Tooltip, Typography } from "@mui/material";
import { Grid } from "../../../../components/grid/Grid";
import { SPACING } from "../../../../data/spacing";
import { OPEN_MODAL } from "../../../../lib/redux/slices/appSlice";
import { SlaughterSubmitRealInventory } from "../slaughter-submit-real-inventory/SlaughterSubmitRealInventory";
import { useDispatch } from "react-redux";
import SettingsIcon from "@mui/icons-material/Settings";

export const RespSlaughterStockBarSystem = ({
  data,
  inventorySelectedKillHouse,
}) => {
  const dispatch = useDispatch();
  return (
    <Grid>
      {data?.map((item, i) => {
        return (
          <Grid
            container
            key={i}
            alignItems="center"
            justifyContent="start"
            p={SPACING.SMALL}
            flexWrap="nowrap"
          >
            <Grid>
              <Typography textAlign={"justify"} variant="caption">
                {`${i + 1}- مرغدار ${item[1]} کشتارگاه ${item[2]} با کدسفارش ${
                  item[3]
                } در شهرستان ${item[4]} با تعداد تخصیصی ${item[12]}`}
              </Typography>
              {item[17]}
              <Tooltip title="ورود بار به انبار" key={i}>
                <IconButton
                  // disabled={
                  //   item?.wareHouseAcceptedRealQuantity ||
                  //   item?.wareHouseAcceptedRealWeight
                  // }
                  size={"small"}
                  color="primary"
                  onClick={() => {
                    dispatch(
                      OPEN_MODAL({
                        title: "ثبت موجودی واقعی",
                        content: (
                          <SlaughterSubmitRealInventory
                            item={item}
                            inventorySelectedKillHouse={
                              inventorySelectedKillHouse
                            }
                          />
                        ),
                      })
                    );
                  }}
                >
                  <SettingsIcon fontSize="small" />
                </IconButton>
              </Tooltip>
            </Grid>
          </Grid>
        );
      })}
    </Grid>
  );
};
