import { Box, Typography } from "@mui/material";
import { Grid } from "../components/grid/Grid";
import LinkItem from "../components/link-item/LinkItem";
import { SPACING } from "../data/spacing";
import { ProvinceSmsComponent } from "../features/province/components/province-sms/province-sms-component";
import { FaComments, FaEnvelope, FaNewspaper, FaSms } from "react-icons/fa";
import { NavLink, useLocation } from "react-router-dom";

import {
  ROUTE_ADMINX_DASHBOARD_NEWS,
  ROUTE_ADMINX_ROUTE_AGE_MESSAGE,
  ROUTE_ADMINX_ROUTE_MANAGE_PROCESS_MOBILE_MESSAGE,
  ROUTE_ADMINX_ROUTE_SMS,
  ROUTE_ADMINX_ROUTE_SMS_MANAGE,
  ROUTE_ADMINX_ROUTE_SMS_SEND,
  ROUTE_ADMINX_SEND_ANNOUNCEMENT,
  ROUTE_ADMINX_SEND_MESSAGE,
  ROUTE_ADMINX_SEND_REPORT,
  ROUTE_PROVINCE_DASHBOARD_NEWS,
  ROUTE_PROVINCE_ROUTE_SMS,
  ROUTE_PROVINCE_ROUTE_SMS_MANAGE,
  ROUTE_PROVINCE_ROUTE_SMS_SEND,
  ROUTE_PROVINCE_SEND_ANNOUNCEMENT,
  ROUTE_PROVINCE_SEND_MESSAGE,
  ROUTE_PROVINCE_SEND_REPORT,
  ROUTE_SUPER_ADMIN_DASHBOARD_NEWS,
  ROUTE_SUPER_ADMIN_ROUTE_AGE_MESSAGE,
  ROUTE_SUPER_ADMIN_ROUTE_MANAGE_PROCESS_MOBILE_MESSAGE,
  ROUTE_SUPER_ADMIN_ROUTE_SMS,
  ROUTE_SUPER_ADMIN_ROUTE_SMS_MANAGE,
  ROUTE_SUPER_ADMIN_ROUTE_SMS_SEND,
  ROUTE_SUPER_ADMIN_SEND_ANNOUNCEMENT,
  ROUTE_SUPER_ADMIN_SEND_MESSAGE,
  ROUTE_SUPER_ADMIN_SEND_REPORT,
} from "../routes/routes";
import { BackButton } from "../components/back-button/BackButton";
import { ProvinceSmsManageComponent } from "../features/province/components/province-sms-manage/ProvinceSmsManage";
import { ProvinceSmsAnnouncement } from "../features/province/components/province-sms-announcement/ProvinceSmsAnnouncement";
import { getRoleFromUrl } from "../utils/getRoleFromUrl";
import { ProvinceSendReport } from "../features/province/components/province-send-report/ProvinceSendReport";
import { ProvincePolicyMobileMessage } from "../features/province/components/province-policy-mobile-message/ProvincePolicyMobileMessage";
import { ProvinceAgeMessage } from "../features/province/components/province-age-message/ProvinceAgeMessage";
import { ProvinceDashboardNews } from "../features/province/components/province-dashboard-news/ProvinceDashboardNews";
const SendMassage = () => {
  const { pathname } = useLocation();

  return (
    <>
      <Box display={"flex"} justifyContent="center">
        <Grid
          container
          direction="column"
          justifyContent="center"
          xs={12}
          sm={12}
          md={10}
          lg={10}
        >
          {pathname === ROUTE_PROVINCE_ROUTE_SMS ||
          pathname === ROUTE_SUPER_ADMIN_ROUTE_SMS ||
          pathname === ROUTE_ADMINX_ROUTE_SMS ? (
            <Grid
              container
              direction="column"
              justifyContent="center"
              alignItems="center"
              my={SPACING.MEDIUM}
            >
              <Grid mb={SPACING.SMALL}>
                <Typography variant="h5" color="textSecondary">
                  پیامک ها
                </Typography>
              </Grid>
              <Grid
                container
                gap={SPACING.SMALL}
                xs={12}
                justifyContent="center"
              >
                <NavLink
                  to={
                    getRoleFromUrl() === "SuperAdmin"
                      ? ROUTE_SUPER_ADMIN_ROUTE_SMS_SEND
                      : getRoleFromUrl() === "AdminX"
                      ? ROUTE_ADMINX_ROUTE_SMS_SEND
                      : ROUTE_PROVINCE_ROUTE_SMS_SEND
                  }
                  active={
                    pathname === ROUTE_PROVINCE_ROUTE_SMS_SEND ? "true" : null
                  }
                >
                  <LinkItem
                    icon={<FaSms size={30} color="#244CCC" />}
                    title="ارسال پیامک"
                    description="ارسال پیامک برای نقش ها و کاربران مختلف"
                  />
                </NavLink>
                <NavLink
                  to={
                    getRoleFromUrl() === "SuperAdmin"
                      ? ROUTE_SUPER_ADMIN_ROUTE_SMS_MANAGE
                      : getRoleFromUrl() === "AdminX"
                      ? ROUTE_ADMINX_ROUTE_SMS_MANAGE
                      : ROUTE_PROVINCE_ROUTE_SMS_MANAGE
                  }
                  active={
                    pathname === ROUTE_PROVINCE_ROUTE_SMS_MANAGE ? "true" : null
                  }
                >
                  <LinkItem
                    icon={<FaComments size={30} color="#244CCC" />}
                    title="مدیریت پیامک اطلاع رسانی"
                    description="تعیین گزینه های اطلاع رسانی برای نقش ها و مراحل مختلف"
                  />
                </NavLink>
                <NavLink
                  to={
                    getRoleFromUrl() === "SuperAdmin"
                      ? ROUTE_SUPER_ADMIN_SEND_MESSAGE
                      : getRoleFromUrl() === "AdminX"
                      ? ROUTE_ADMINX_SEND_MESSAGE
                      : ROUTE_PROVINCE_SEND_MESSAGE
                  }
                  active={
                    pathname === ROUTE_PROVINCE_SEND_MESSAGE ? "true" : null
                  }
                >
                  <LinkItem
                    icon={<FaComments size={30} color="#244CCC" />}
                    title="مدیریت پیام های سیستمی"
                    description="تعیین گزینه های اطلاع رسانی برای نقش ها و مراحل مختلف"
                  />
                </NavLink>
                <NavLink
                  to={
                    getRoleFromUrl() === "SuperAdmin"
                      ? ROUTE_SUPER_ADMIN_SEND_ANNOUNCEMENT
                      : getRoleFromUrl() === "AdminX"
                      ? ROUTE_ADMINX_SEND_ANNOUNCEMENT
                      : ROUTE_PROVINCE_SEND_ANNOUNCEMENT
                  }
                  active={
                    pathname === ROUTE_PROVINCE_SEND_ANNOUNCEMENT
                      ? "true"
                      : null
                  }
                >
                  <LinkItem
                    icon={<FaComments size={30} color="#244CCC" />}
                    title="اعلانات"
                    description="تعیین گزینه های اطلاع رسانی برای نقش ها و مراحل مختلف"
                  />
                </NavLink>
                {getRoleFromUrl() === "SuperAdmin" && (
                  <NavLink
                    to={
                      getRoleFromUrl() === "SuperAdmin"
                        ? ROUTE_SUPER_ADMIN_SEND_REPORT
                        : getRoleFromUrl() === "AdminX"
                        ? ROUTE_ADMINX_SEND_REPORT
                        : ROUTE_PROVINCE_SEND_REPORT
                    }
                    active={
                      pathname === ROUTE_PROVINCE_SEND_REPORT ? "true" : null
                    }
                  >
                    <LinkItem
                      icon={<FaComments size={30} color="#244CCC" />}
                      title="گزارش دهی"
                      description="تعیین گزینه های اطلاع رسانی برای نقش ها و مراحل مختلف"
                    />
                  </NavLink>
                )}
                {(getRoleFromUrl() === "SuperAdmin" ||
                  getRoleFromUrl() === "AdminX") && (
                  <NavLink
                    to={
                      getRoleFromUrl() === "SuperAdmin"
                        ? ROUTE_SUPER_ADMIN_ROUTE_MANAGE_PROCESS_MOBILE_MESSAGE
                        : ROUTE_ADMINX_ROUTE_MANAGE_PROCESS_MOBILE_MESSAGE
                    }
                    active={
                      pathname ===
                      ROUTE_SUPER_ADMIN_ROUTE_MANAGE_PROCESS_MOBILE_MESSAGE
                        ? "true"
                        : null
                    }
                  >
                    <LinkItem
                      icon={<FaEnvelope size={30} color="#244CCC" />}
                      title="پیغام متحرک"
                    />
                  </NavLink>
                )}

                {(getRoleFromUrl() === "SuperAdmin" ||
                  getRoleFromUrl() === "AdminX") && (
                  <NavLink
                    to={
                      getRoleFromUrl() === "SuperAdmin"
                        ? ROUTE_SUPER_ADMIN_ROUTE_AGE_MESSAGE
                        : ROUTE_ADMINX_ROUTE_AGE_MESSAGE
                    }
                    active={
                      pathname === ROUTE_SUPER_ADMIN_ROUTE_AGE_MESSAGE
                        ? "true"
                        : null
                    }
                  >
                    <LinkItem
                      icon={<FaSms size={30} color="#244CCC" />}
                      title="پیغام بازه سنی"
                    />
                  </NavLink>
                )}

                {(getRoleFromUrl() === "SuperAdmin" ||
                  getRoleFromUrl() === "AdminX") && (
                  <NavLink
                    to={
                      getRoleFromUrl() === "SuperAdmin"
                        ? ROUTE_SUPER_ADMIN_DASHBOARD_NEWS
                        : getRoleFromUrl() === "AdminX"
                        ? ROUTE_ADMINX_DASHBOARD_NEWS
                        : ROUTE_PROVINCE_DASHBOARD_NEWS
                    }
                    active={
                      pathname === ROUTE_SUPER_ADMIN_DASHBOARD_NEWS
                        ? "true"
                        : null
                    }
                  >
                    <LinkItem
                      icon={<FaNewspaper size={30} color="#244CCC" />}
                      title="اطلاعیه داشبورد"
                    />
                  </NavLink>
                )}
              </Grid>
            </Grid>
          ) : (
            <BackButton />
          )}
          {(pathname === ROUTE_PROVINCE_ROUTE_SMS_SEND ||
            pathname === ROUTE_SUPER_ADMIN_ROUTE_SMS_SEND ||
            pathname === ROUTE_ADMINX_ROUTE_SMS_SEND) && (
            <ProvinceSmsComponent />
          )}
          {(pathname === ROUTE_PROVINCE_ROUTE_SMS_MANAGE ||
            pathname === ROUTE_SUPER_ADMIN_ROUTE_SMS_MANAGE ||
            pathname === ROUTE_ADMINX_ROUTE_SMS_MANAGE) && (
            <ProvinceSmsManageComponent />
          )}
          {(pathname === ROUTE_PROVINCE_SEND_ANNOUNCEMENT ||
            pathname === ROUTE_SUPER_ADMIN_SEND_ANNOUNCEMENT ||
            pathname === ROUTE_ADMINX_SEND_ANNOUNCEMENT) && (
            <ProvinceSmsAnnouncement />
          )}
          {(pathname === ROUTE_PROVINCE_SEND_REPORT ||
            pathname === ROUTE_SUPER_ADMIN_SEND_REPORT ||
            pathname === ROUTE_ADMINX_SEND_REPORT) && <ProvinceSendReport />}

          {(pathname ===
            ROUTE_SUPER_ADMIN_ROUTE_MANAGE_PROCESS_MOBILE_MESSAGE ||
            pathname === ROUTE_ADMINX_ROUTE_MANAGE_PROCESS_MOBILE_MESSAGE) && (
            <ProvincePolicyMobileMessage />
          )}

          {(pathname === ROUTE_SUPER_ADMIN_ROUTE_AGE_MESSAGE ||
            pathname === ROUTE_ADMINX_ROUTE_AGE_MESSAGE) && (
            <ProvinceAgeMessage />
          )}

          {(pathname === ROUTE_SUPER_ADMIN_DASHBOARD_NEWS ||
            pathname === ROUTE_ADMINX_DASHBOARD_NEWS ||
            pathname === ROUTE_PROVINCE_DASHBOARD_NEWS) && (
            <ProvinceDashboardNews />
          )}
        </Grid>
      </Box>
    </>
  );
};
export default SendMassage;
