Commit 1a0e2250 authored by Nawasan Wisitsingkhon's avatar Nawasan Wisitsingkhon

category admin -> can search

parent 5f1c16ca
......@@ -18,8 +18,10 @@ import { Edit } from "@mui/icons-material";
import UpdateCategory from "@/components/category/UpdateCategory";
import DeleteCategory from "@/components/category/DeleteCategory";
import Head from "next/head";
import { useRouter } from "next/router";
export default function AdminCategory() {
const router = useRouter();
const [modal, setModal] = useState(false);
const [message, setMessage] = useState({ message: "", error: false });
const [deleteState, setDeleteState] = useState({
......@@ -68,7 +70,15 @@ export default function AdminCategory() {
</TableRow>
</TableHead>
<TableBody>
{category.map((cate, idx) => (
{category.map(
(cate, idx) =>
(!router.query?.q ||
cate.id === Number(router.query.q) ||
String(cate.name)
.toLocaleLowerCase()
.includes(
String(router.query.q).toLocaleLowerCase()
)) && (
<TableRow key={idx}>
<TableCell>{cate.id}</TableCell>
<TableCell>{cate.name}</TableCell>
......@@ -96,7 +106,8 @@ export default function AdminCategory() {
</Button>
</TableCell>
</TableRow>
))}
)
)}
</TableBody>
</Table>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment