import { Typography } from "@mui/material";
import { Grid } from "../../../../components/grid/Grid";
import { SPACING } from "../../../../data/spacing";
import { formatJustDate } from "../../../../utils/formatTime";

export const ProvinceCaseOverview = ({ item }) => {
  return (
    <Grid
      container
      direction={{ xs: "column", sm: "row" }}
      justifyContent="space-between"
      gap={SPACING.SMALL}
      mt={SPACING.SMALL}
    >
      <Grid>
        <Grid container gap={SPACING.SMALL}>
          <Typography variant="caption">مرغداری:</Typography>
          <Typography variant="caption">{item?.poultry?.unitName}</Typography>
        </Grid>
        <Grid container gap={SPACING.SMALL}>
          <Typography variant="caption">مرغدار:</Typography>
          <Typography variant="caption">
            {item?.poultry?.user?.fullname}
          </Typography>
        </Grid>
        <Grid container gap={SPACING.SMALL}>
          <Typography variant="caption">موبایل:</Typography>
          <Typography variant="caption">
            {item?.poultry?.user?.mobile}
          </Typography>
        </Grid>
        <Grid container gap={SPACING.SMALL}>
          <Typography variant="caption">تاریخ کشتار:</Typography>
          <Typography variant="caption">
            {formatJustDate(item?.sendDate)}
          </Typography>
        </Grid>
        <Grid container gap={SPACING.SMALL}>
          <Typography variant="caption">زمان و تاریخ ثبت:</Typography>
          <Typography variant="caption">
            {formatJustDate(item?.createDate)}
          </Typography>
        </Grid>
        <Grid container gap={SPACING.SMALL}>
          <Typography variant="caption">شهرستان:</Typography>
          <Typography variant="caption">
            {item?.poultry?.address?.city?.name}
          </Typography>
        </Grid>
      </Grid>
      <Grid>
        <Grid container gap={SPACING.SMALL}>
          <Typography variant="caption">تعداد:</Typography>
          <Typography variant="caption">
            {item?.quantity?.toLocaleString()}
          </Typography>
        </Grid>
        <Grid container gap={SPACING.SMALL}>
          <Typography variant="caption">متوسط وزن:</Typography>
          <Typography variant="caption">{item?.IndexWeight}</Typography>
        </Grid>
        <Grid container gap={SPACING.SMALL}>
          <Typography variant="caption">وزن حدودی:</Typography>
          <Typography variant="caption">{item?.hatching?.weight}</Typography>
        </Grid>
        <Grid container gap={SPACING.SMALL}>
          <Typography variant="caption">سن گله:</Typography>
          <Typography variant="caption">{item?.hatching?.age}</Typography>
        </Grid>
        <Grid container gap={SPACING.SMALL}>
          <Typography variant="caption">نژاد:</Typography>
          <Typography variant="caption">{item?.chickenBreed}</Typography>
        </Grid>
        <Grid container gap={SPACING.SMALL}>
          <Typography variant="caption">قیمت پیشنهادی:</Typography>
          <Typography variant="caption">
            {item?.amount?.toLocaleString()} ریال
          </Typography>
        </Grid>
      </Grid>
      <Grid>
        {item?.provinceKillRequests?.provinceKillRequestSerializer.length ? (
          <>
            <Grid container gap={SPACING.SMALL}>
              <Typography variant="caption">خریداران:</Typography>
            </Grid>
            {item?.provinceKillRequests?.provinceKillRequestSerializer?.map(
              (item, i) => {
                return (
                  <Grid key={i} container gap={SPACING.TINY}>
                    <Typography variant="caption">{i + 1}- </Typography>
                    <Typography variant="caption">
                      {item?.killhouseUser?.name}
                    </Typography>
                    <Typography variant="caption">
                      ({item?.killhouseUser?.killHouseOperator?.user?.mobile})
                    </Typography>
                    <Typography variant="caption">تعداد: </Typography>
                    <Typography variant="caption">
                      {item?.mainQuantity?.toLocaleString()}
                    </Typography>
                    <Typography variant="caption">محل کشتار: </Typography>
                    <Typography variant="caption">{item?.killPlace}</Typography>
                  </Grid>
                );
              }
            )}
          </>
        ) : (
          <>
            <Grid container gap={SPACING.SMALL}>
              <Typography variant="caption">خریداران: بدون خریدار</Typography>
            </Grid>
          </>
        )}
      </Grid>
      <Grid>
        <Grid container gap={SPACING.SMALL}>
          <Typography variant="caption">قیمت مرغ:</Typography>
          <Typography variant="caption">
            {item?.amount?.toLocaleString()} ریال
          </Typography>
        </Grid>
        {/* <Grid container gap={SPACING.SMALL}>
          <Typography variant="caption">مبلغ قابل پرداخت:</Typography>
          <Typography variant="caption">55112</Typography>
        </Grid>
        <Grid container gap={SPACING.SMALL}>
          <Typography variant="caption">باقی مانده قابل پرداخت:</Typography>
          <Typography variant="caption">44</Typography>
        </Grid>
        <Grid container gap={SPACING.SMALL}>
          <Typography variant="caption">مبلغ پرداخت شده:</Typography>
          <Typography variant="caption">258522</Typography>
        </Grid> */}
      </Grid>
    </Grid>
  );
};
