import React, { useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import {
  LOADING_END,
  LOADING_START,
} from "../../../../lib/redux/slices/appSlice";
import { jahadGetProfile } from "../../services/jahadGetProfile";
import { Box } from "@mui/material";
import { Grid } from "../../../../components/grid/Grid";
import { SPACING } from "../../../../data/spacing";
import { SimpleTable } from "../../../../components/simple-table/SimpleTable";

export const JahadProfile = () => {
  const dispatch = useDispatch();
  const { profile } = useSelector((state) => state.jahadSlice);

  useEffect(() => {
    dispatch(LOADING_START());
    dispatch(jahadGetProfile()).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={`اطلاعات ناظر جهاد - ${profile?.user.fullname}`}
                  columns={["نام کامل", "تلفن", "آدرس", "کد پستی"]}
                  data={[
                    [
                      profile?.user.fullname,
                      profile?.user.mobile,
                      profile?.address.address,
                      profile?.address.postalCode,
                    ],
                  ]}
                />
              </Grid>
              {/* <Grid>
            <ChangeCardInfo item={profile} />
          </Grid> */}
            </>
          </Grid>
        </Grid>
      </Grid>
    </Box>
  );
};
