import DoctorsTable from "@/components/DoctorsTable";
import ExpertiseFilterBox from "@/components/ExpertiseFilterBox";
import Loader from "@/components/Loader";
import RoleGuard from "@/components/RoleGuard";
import SearchBox from "@/components/SearchBox";
import UsersTableExport from "@/components/usersTableExport";

import {Plus} from "lucide-react";
import Link from "next/link";
import React, {Suspense} from "react";

export default function Page() {
  return (
    <>
      <section>
        <div className="flex items-center justify-between">
          <div className="flex items-center justify-start gap-x-8">
            <SearchBox
              inputName="search"
              label="جستجو نام خانوادگی"
              hasLabel
              placeholder="جستجو نام خانوادگی پزشک ..."
              route="doctors"
            />

            <ExpertiseFilterBox />
          </div>
          <div className="flex items-center justify-end gap-x-7">
            <RoleGuard roles={["ADMIN", "DEVELOPER", "COORDINATOR"]}>
              <Link
                href={"/doctors/new"}
                className="text-white bg-primary py-1.5 px-3 rounded-lg flex items-center gap-x-2 text-sm"
              >
                <Plus size={"20"} />
                <span>افزودن پزشک جدید</span>
              </Link>
            </RoleGuard>
            <RoleGuard roles={["ADMIN","DEVELOPER","COORDINATOR"]}>
              <UsersTableExport table="DOCTOR" />
            </RoleGuard>
          </div>
        </div>
        <div className="space-y-4 mt-10">
          <Suspense fallback={<Loader />}>
            <DoctorsTable />
          </Suspense>
        </div>
      </section>
    </>
  );
}
