diff --git a/components/searchHead/SmSearch.js b/components/searchHead/SmSearch.js index e9c1001..fd5048e 100644 --- a/components/searchHead/SmSearch.js +++ b/components/searchHead/SmSearch.js @@ -1,7 +1,13 @@ import SearchD from "@/components/icons/SearchD"; import { Button, ButtonGroup, TextField } from "@mui/material"; -function SmSearch({ placeholder }) { +function SmSearch({ placeholder, onSearch }) { + const handleSearchChange = (event) => { + if (onSearch) { + onSearch(event.target.value); + } + }; + return ( { setTimeout(() => { @@ -14,15 +17,32 @@ function SpecialtiesPage() { }, 2000); }, []); + // Filter specialties when search query changes + useEffect(() => { + if (searchQuery.trim() === "") { + setFilteredSpecialties(specialtiesData); + } else { + const query = searchQuery.toLowerCase().trim(); + const filtered = specialtiesData.filter((specialty) => + specialty.name.toLowerCase().includes(query) + ); + setFilteredSpecialties(filtered); + } + }, [searchQuery]); + + const handleSearch = (query) => { + setSearchQuery(query); + }; + return ( - + - + ); } diff --git a/components/specialties/list/ItemSpecialties.js b/components/specialties/list/ItemSpecialties.js index 28350a4..27ef9ad 100644 --- a/components/specialties/list/ItemSpecialties.js +++ b/components/specialties/list/ItemSpecialties.js @@ -1,9 +1,17 @@ import TextLoading from "@/app/component/loading/Text"; import React from "react"; +import { useRouter } from "next/navigation"; function ItemSpecialties({ data, loading }) { + const router = useRouter(); + + const handleClick = () => { + router.push(`/doctors?specialties=${data.id}`); + }; + return ( @@ -12,19 +11,25 @@ function List({ loading }) { لیست تخصص ها - - {specialties.map((speciality) => ( - - ))} - + {specialties.length === 0 ? ( + + تخصصی با این عنوان یافت نشد! + + ) : ( + + {specialties.map((speciality) => ( + + ))} + + )}