import { Box } from "@mui/system";
import { useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import { Grid } from "../../../../components/grid/Grid";
import { SimpleTable } from "../../../../components/simple-table/SimpleTable";
import { SPACING } from "../../../../data/spacing";
import {
  LOADING_END,
  LOADING_START,
} from "../../../../lib/redux/slices/appSlice";
import { ChangeCardInfo } from "../../../authentication/components/change-card-info/ChangeCardInfo";
import { slaughterHouseVetGetProfile } from "../../services/slaughter-house-vet-get-profile";
// import { ChangeCardInfo } from "../../../authentication/components/change-card-info/ChangeCardInfo";

export const SlaughterHouseVetProfile = () => {
  const dispatch = useDispatch();
  const { profile } = useSelector((state) => state.slaughterHouseVetSlice);

  useEffect(() => {
    dispatch(LOADING_START());
    dispatch(slaughterHouseVetGetProfile()).then((r) => {
      dispatch(LOADING_END());
    });
  }, []);

  return (
    <Box>
      <Grid container gap={SPACING.LARGE}>
        <Grid container direction="column" xs={12}>
          <Grid
            container
            direction="column"
            justifyContent="space-between"
            gap={SPACING.SMALL}
          >
            <>
              <Grid>
                <SimpleTable
                  name={"اطلاعات کشتارگاه"}
                  columns={[
                    "نام کشتارگاه",
                    "استان",
                    "شهر",
                    "مالک کشتارگاه",
                    "شماره تماس",
                  ]}
                  data={[
                    [
                      profile?.killHouseVet?.killHouse?.name,
                      profile?.killHouseVet?.killHouse?.killHouseOperator
                        ?.address.province.name,
                      profile?.killHouseVet?.killHouse?.killHouseOperator
                        ?.address.city.name,
                      profile?.killHouseVet?.killHouse?.killHouseOperator?.user
                        .fullname,
                      profile?.killHouseVet?.killHouse?.killHouseOperator?.user
                        .mobile,
                      //   profile.address?.address,
                      //   profile.address?.postalCode,
                    ],
                  ]}
                />
              </Grid>
              <Grid>
                <ChangeCardInfo item={profile?.vet} />
              </Grid>
            </>
          </Grid>
        </Grid>
      </Grid>
    </Box>
  );
};
