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 { cityVetGetProfileService } from "../services/city-vet-profile";

export const CityVetProfile = () => {
  const { cityVetGetProfile } = useSelector((state) => state.generalSlice);
  const dispatch = useDispatch();

  useEffect(() => {
    dispatch(LOADING_START());
    dispatch(cityVetGetProfileService()).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={[
                    [
                      cityVetGetProfile?.user?.firstName,
                      cityVetGetProfile?.user?.lastName,
                      cityVetGetProfile?.address?.province.name,
                      cityVetGetProfile?.address?.city.name,
                      cityVetGetProfile?.address?.address,
                      cityVetGetProfile?.address?.postalCode,
                    ],
                  ]}
                />
              </Grid>
            </>
          </Grid>
        </Grid>
      </Grid>
    </Box>
  );
};
