Sootzani-Inspector/components/Search.tsx

69 lines
1.9 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,
value,
action,
changeValue,
}: {
mode?: string;
value?: any;
action?: (any: any) => any;
changeValue?: (any: any) => any ;
}) {
// useEffect(() => {
// const isMobile = useMediaQuery({ query: "(max-width: 768px)" });
// }, []);
return (
<div className="relative flex items-center w-full bg-gray-300 lg:w-1/5 rounded-xl">
<Input
// type="search"
id="default-search"
className={`mb-0 h-8 bg-[#E9E9E9] border-none focus-visible:none rounded-lg
block w-full min-w-[13rem] text-xs md:text-sm text-black
text-opacity-60 dark:text-white
${mode === "controller" && "h-14 "}
${
mode === "admin" &&
"w-full min-w-full bg-white lg:min-w-full h-11"
}
`}
value={value}
onChange={(e) => {
if (changeValue) {
changeValue(e.target.value);
}
}}
placeholder="جستجو..."
required
/>
{/* <Button
className="absolute left-0 w-auto h-auto bg-transparent text-slate-800"
>
<CiSearch />
</Button> */}
<button onClick={action} className="absolute left-3">
<CiSearch />
</button>
</div>
);
}