diff --git a/src/app/components/mii-list/filter-select.tsx b/src/app/components/mii-list/filter-select.tsx new file mode 100644 index 0000000..f7358f4 --- /dev/null +++ b/src/app/components/mii-list/filter-select.tsx @@ -0,0 +1,53 @@ +"use client"; + +import { redirect, useSearchParams } from "next/navigation"; +import { useState } from "react"; +import TagSelector from "../tag-selector"; + +export default function FilterSelect() { + const searchParams = useSearchParams(); + const rawTags = searchParams.get("tags"); + const preexistingTags = rawTags + ? rawTags + .split(",") + .map((tag) => tag.trim()) + .filter((tag) => tag.length > 0) + : []; + + const [isOpen, setIsOpen] = useState(false); + const [tags, setTags] = useState(preexistingTags); + + const handleSubmit = () => { + redirect(`/?tags=${encodeURIComponent(tags.join(","))}`); + }; + + return ( +
+ + +
+
+ + +
+ + +
+
+ ); +} diff --git a/src/app/components/mii-list/index.tsx b/src/app/components/mii-list/index.tsx index 5670c9b..245840d 100644 --- a/src/app/components/mii-list/index.tsx +++ b/src/app/components/mii-list/index.tsx @@ -7,6 +7,7 @@ import { prisma } from "@/lib/prisma"; import SortSelect from "./sort-select"; import Carousel from "../carousel"; import LikeButton from "../like-button"; +import FilterSelect from "./filter-select"; interface Props { searchParams: Promise<{ [key: string]: string | string[] | undefined }>; @@ -94,7 +95,7 @@ export default async function MiiList({ searchParams, userId, where }: Props) { return (
-
+

{totalMiiCount == shownMiiCount ? ( <> @@ -108,12 +109,7 @@ export default async function MiiList({ searchParams, userId, where }: Props) {

- {/* todo: replace with react-select */} -
- - todo -
- +
diff --git a/src/app/components/mii-list/sort-select.tsx b/src/app/components/mii-list/sort-select.tsx index ff4d2e1..6d3c4a8 100644 --- a/src/app/components/mii-list/sort-select.tsx +++ b/src/app/components/mii-list/sort-select.tsx @@ -25,7 +25,7 @@ export default function SortSelect() { return (
{/* Toggle button to open the dropdown */} -