import { Chip, DialogContent, DialogTitle, Divider, Grid, Stack, Typography } from "@mui/material";
import { useTranslations } from "next-intl";
import moment from "jalali-moment";

const LegalTableContent = ({ rowId, row }) => {
    const t = useTranslations();
    return (
      <>
          <DialogTitle>{t("UserInfoDialog.user_info")}</DialogTitle>
          <DialogContent>
              <Grid container spacing={2} sx={{ my: 2 }}>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.is_legal_person")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">{t("UserInfoDialog.legal_person")}</Typography>
                      </Stack>
                  </Grid>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.id")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">{row.original.id || t("UserInfoDialog.no_info")}</Typography>
                      </Stack>
                  </Grid>
              </Grid>
              <Grid container spacing={2} sx={{ my: 2 }}>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.navgan_plan_id")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.project_title || t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.activity_type")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.activity_category_name || t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
              </Grid>
              <Grid container spacing={2} sx={{ my: 2 }}>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.first_name")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.first_name || t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.last_name")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.last_name || t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
              </Grid>
              <Grid container spacing={2} sx={{ my: 2 }}>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.father_name")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.father_name || t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.gender")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.gender ? t("UserInfoDialog.female") : t("UserInfoDialog.male")}
                          </Typography>
                      </Stack>
                  </Grid>
              </Grid>
              <Grid container spacing={2} sx={{ my: 2 }}>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.national_id")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.national_id || t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip
                            label={
                                row.original.national_serial_number
                                  ? t("UserInfoDialog.national_serial_number")
                                  : t("UserInfoDialog.national_tracking_code")
                            }
                            sx={{ mr: 1 }}
                          />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.national_serial_number ||
                                row.original.national_tracking_code ||
                                t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
              </Grid>
              <Grid container spacing={2} sx={{ my: 2 }}>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.education_id")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.education_title || t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.occupation_id")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.occupation_title || t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
              </Grid>
              <Grid container spacing={2} sx={{ my: 2 }}>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.phone_number")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.phone_number || t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.birthday")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.birthday
                                ? moment(row.original.birthday).locale("fa").format("YYYY/MM/DD")
                                : t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
              </Grid>
              <Grid container spacing={2} sx={{ my: 2 }}>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.province_id")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.province_name || t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.city_id")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.city_name || t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
              </Grid>
              <Grid container spacing={2} sx={{ my: 2 }}>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.shenase_meli")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.shenase_meli || t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.postal_code")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.postal_code || t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
              </Grid>
              <Grid container spacing={2} sx={{ my: 2 }}>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.company_register_date")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.company_register_date
                                ? moment(row.original.company_register_date).locale("fa").format("YYYY/MM/DD")
                                : t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.register_number")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.register_number || t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
              </Grid>
              <Grid container spacing={2} sx={{ my: 2 }}>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.navgan_id")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.navgan_id || t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.navgan_type")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.navgan_type || t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
              </Grid>
              <Grid container spacing={2} sx={{ my: 2 }}>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.company_name")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.company_name || t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.tel_number")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.telephone_number || t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
              </Grid>
              <Grid container spacing={2} sx={{ my: 2 }}>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.vehicle_type")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.vehicle_type || t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.investment")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {
                                  (row.original.investment_amount / 1000000) >= 1000
                                    ? t("UserInfoDialog.milyard", { value: (row.original.investment_amount / 1000000000) })
                                    : t("UserInfoDialog.toman", { value: (row.original.investment_amount / 1000000) })
                              }
                          </Typography>
                      </Stack>
                  </Grid>
              </Grid>
              <Grid container spacing={2} sx={{ my: 2 }}>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.requested_facilities")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {
                                  (row.original.requested_facility_amount / 1000000) >= 1000
                                    ? t("UserInfoDialog.milyard", {value : (row.original.requested_facility_amount / 1000000000)})
                                    :t("UserInfoDialog.toman", {value : (row.original.requested_facility_amount / 1000000)})
                              }
                          </Typography>
                      </Stack>
                  </Grid>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.applicant_payment")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {
                                  (row.original.person_share / 1000000) >= 1000
                                    ? t("UserInfoDialog.milyard", {value : (row.original.person_share / 1000000000)})
                                    :t("UserInfoDialog.toman", {value : (row.original.person_share / 1000000)})
                              }
                          </Typography>
                      </Stack>
                  </Grid>
              </Grid>
              <Grid container spacing={2} sx={{ my: 2 }}>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.user_committed_employment")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.user_committed_employment || t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
                  <Grid item xs={12} sm={6}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.user_existing_employment")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.user_existing_employment || t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
              </Grid>
              <Grid container spacing={2} sx={{ my: 2 }}>
                  <Grid item xs={12} sm={12}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.plate")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Stack sx={{ border: 1, borderColor: "divider", borderRadius: 1 }} direction={"row"}>
                              <Stack
                                sx={{
                                    borderRight: 1,
                                    borderColor: "divider",
                                    textAlign: "center",
                                    width: "100%",
                                    px: 1,
                                }}
                              >
                                  {row.original.plate_number.split("-")[3] || t("UserInfoDialog.no_info")}
                              </Stack>
                              <Stack spacing={1} direction={"row"} sx={{ width: "100%" }}>
                                  <Stack
                                    sx={{
                                        textAlign: "center",
                                        width: "100%",
                                        pl: 1,
                                    }}
                                  >
                                      {row.original.plate_number.split("-")[2] || t("UserInfoDialog.no_info")}
                                  </Stack>
                                  <Stack
                                    sx={{
                                        textAlign: "center",
                                        width: "100%",
                                        pl: 1,
                                    }}
                                  >
                                      {row.original.plate_number.split("-")[1] || t("UserInfoDialog.no_info")}
                                  </Stack>
                                  <Stack
                                    sx={{
                                        textAlign: "center",
                                        width: "100%",
                                        px: 1,
                                    }}
                                  >
                                      {row.original.plate_number.split("-")[0] || t("UserInfoDialog.no_info")}
                                  </Stack>
                              </Stack>
                          </Stack>
                      </Stack>
                  </Grid>
              </Grid>
              <Grid container spacing={2} sx={{ my: 2 }}>
                  <Grid item xs={12} sm={12}>
                      <Stack direction="row" alignItems="center" sx={{ width: "100%" }}>
                          <Chip label={t("UserInfoDialog.address")} sx={{ mr: 1 }} />
                          <Divider sx={{ flexGrow: 1, mx: 1 }} />
                          <Typography variant="body1">
                              {row.original.address || t("UserInfoDialog.no_info")}
                          </Typography>
                      </Stack>
                  </Grid>
              </Grid>
          </DialogContent>
      </>
    );
};
export default LegalTableContent;
