Sootzani/components/Search.tsx

121 lines
4.4 KiB
TypeScript

"use client";
import React, { useState, useEffect } from "react";
import { Input } from "./ui/input";
import { Label } from "./ui/label";
import { Button } from "./ui/button";
import { CiSearch } from "react-icons/ci";
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { IoMdClose } from "react-icons/io";
import { useMediaQuery } from "react-responsive";
export default function Search({ mode }: { mode: string }) {
// useEffect(() => {
// const isMobile = useMediaQuery({ query: "(max-width: 768px)" });
// }, []);
return (
<div>
{mode === "controller" || mode === "admin" ? (
<div className="relative flex bg-gray-300 rounded-xl items-center">
<Input
// type="search"
id="default-search"
className={`mb-0 h-8 bg-[#D6D8DE66] border-none focus-visible:none rounded-lg
block w-full min-w-[13rem] lg:min-w-[16rem] text-xs text-black
text-opacity-60 dark:text-white
${mode === "controller" && "h-14 max-lg:min-w-[95vw]"}
${
mode === "admin" &&
"w-full min-w-full bg-white lg:min-w-full h-11"
}
`}
placeholder="جستجو..."
required
/>
{/* <Button
className="absolute left-0 bg-transparent h-auto w-auto text-slate-800"
>
<CiSearch />
</Button> */}
<button className="absolute left-3">
<CiSearch />
</button>
</div>
) : (
<>
<div className=" max-md:hidden relative flex bg-gray-300 rounded-xl items-center">
<Input
// type="search"
id="default-search"
className={`mb-0 h-8 bg-[#D6D8DE66] border-none focus-visible:none rounded-lg
block w-full min-w-[13rem] lg:min-w-[16rem] text-xs text-black
text-opacity-60 dark:text-white
${mode === "controller" && "h-12 max-lg:min-w-[95vw]"}
${
mode === "admin" &&
"w-full min-w-full bg-white lg:min-w-full h-11"
}
`}
placeholder="جستجو..."
required
/>
<button className="absolute left-3">
<CiSearch />
</button>
</div>
<div className="md:hidden">
<AlertDialog>
<AlertDialogTrigger asChild>
<button
// variant="outline"
// type="submit"
className=" bg-gradient2 text-white font-bold rounded-md p-1"
>
<CiSearch />
</button>
</AlertDialogTrigger>
<AlertDialogContent className=" h-1/5 min-w-[80%] max-w-fit">
<AlertDialogHeader className="w-full">
<AlertDialogTitle className=" py-1">
<p className="text-[#464646] text-base font-bold">
فرم جستجو
</p>
<AlertDialogCancel className="p-0 border-0 h-auto">
<IoMdClose />
</AlertDialogCancel>
</AlertDialogTitle>
<AlertDialogDescription className="justify-center sm:px-14 sm:py-6">
<Input
// type="search"
id="default-search"
className="mb-0 h-12 bg-gray border-none focus-visible:none rounded-lg
block w-full min-w-[13rem] lg:min-w-[16rem] text-xs text-black text-opacity-60 dark:text-white "
placeholder="جستجو..."
required
/>
<button className="absolute left-16 text-black">
<CiSearch />
</button>
</AlertDialogDescription>
</AlertDialogHeader>
</AlertDialogContent>
</AlertDialog>
</div>
</>
)}
</div>
);
}