Add multi-select machine filters
Replace machine dropdowns with multi-select chips and pass machine lists in queries. Signed-off-by: codex@lucy.xalior.com
This commit is contained in:
@@ -9,7 +9,7 @@ const querySchema = z.object({
|
||||
year: z.coerce.number().int().optional(),
|
||||
sort: z.enum(["year_desc", "year_asc", "title", "entry_id_desc"]).optional(),
|
||||
dLanguageId: z.string().trim().length(2).optional(),
|
||||
dMachinetypeId: z.coerce.number().int().positive().optional(),
|
||||
dMachinetypeId: z.string().optional(),
|
||||
filetypeId: z.coerce.number().int().positive().optional(),
|
||||
schemetypeId: z.string().trim().length(2).optional(),
|
||||
sourcetypeId: z.string().trim().length(1).optional(),
|
||||
@@ -17,6 +17,15 @@ const querySchema = z.object({
|
||||
isDemo: z.coerce.boolean().optional(),
|
||||
});
|
||||
|
||||
function parseIdList(value: string | undefined) {
|
||||
if (!value) return undefined;
|
||||
const ids = value
|
||||
.split(",")
|
||||
.map((id) => Number(id.trim()))
|
||||
.filter((id) => Number.isFinite(id) && id > 0);
|
||||
return ids.length ? ids : undefined;
|
||||
}
|
||||
|
||||
export async function GET(req: NextRequest) {
|
||||
const { searchParams } = new URL(req.url);
|
||||
const parsed = querySchema.safeParse({
|
||||
@@ -39,7 +48,8 @@ export async function GET(req: NextRequest) {
|
||||
headers: { "content-type": "application/json" },
|
||||
});
|
||||
}
|
||||
const data = await searchReleases(parsed.data);
|
||||
const dMachinetypeId = parseIdList(parsed.data.dMachinetypeId);
|
||||
const data = await searchReleases({ ...parsed.data, dMachinetypeId });
|
||||
return new Response(JSON.stringify(data), {
|
||||
headers: { "content-type": "application/json" },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user