mirror of
https://github.com/trafficlunar/tomodachi-share.git
synced 2026-05-13 13:17:45 +00:00
Merge 25dafcc24b into a000447b0a
This commit is contained in:
commit
0d11b41a45
4 changed files with 16 additions and 19 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import { useState, useTransition } from "react";
|
import { useTransition } from "react";
|
||||||
import { Icon } from "@iconify/react";
|
import { Icon } from "@iconify/react";
|
||||||
import type { MiiGender, MiiPlatform } from "@tomodachi-share/shared";
|
import type { MiiGender, MiiPlatform } from "@tomodachi-share/shared";
|
||||||
import { useNavigate, useSearchParams } from "react-router";
|
import { useNavigate, useSearchParams } from "react-router";
|
||||||
|
|
@ -8,12 +8,11 @@ export default function GenderSelect() {
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const [, startTransition] = useTransition();
|
const [, startTransition] = useTransition();
|
||||||
|
|
||||||
const [selected, setSelected] = useState<MiiGender | null>((searchParams.get("gender") as MiiGender) ?? null);
|
const selected = (searchParams.get("gender") as MiiGender) ?? null;
|
||||||
const platform = (searchParams.get("platform") as MiiPlatform) || undefined;
|
const platform = (searchParams.get("platform") as MiiPlatform) || undefined;
|
||||||
|
|
||||||
const handleClick = (gender: MiiGender) => {
|
const handleClick = (gender: MiiGender) => {
|
||||||
const filter = selected === gender ? null : gender;
|
const filter = selected === gender ? null : gender;
|
||||||
setSelected(filter);
|
|
||||||
|
|
||||||
const params = new URLSearchParams(searchParams);
|
const params = new URLSearchParams(searchParams);
|
||||||
params.set("page", "1");
|
params.set("page", "1");
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { useState, useTransition } from "react";
|
import { useTransition } from "react";
|
||||||
import { Icon } from "@iconify/react";
|
import { Icon } from "@iconify/react";
|
||||||
import type { MiiMakeup } from "@tomodachi-share/shared";
|
import type { MiiMakeup } from "@tomodachi-share/shared";
|
||||||
import { useNavigate, useSearchParams } from "react-router";
|
import { useNavigate, useSearchParams } from "react-router";
|
||||||
|
|
@ -8,11 +8,10 @@ export default function MakeupSelect() {
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const [, startTransition] = useTransition();
|
const [, startTransition] = useTransition();
|
||||||
|
|
||||||
const [selected, setSelected] = useState<MiiMakeup | null>((searchParams.get("makeup") as MiiMakeup) ?? null);
|
const selected = (searchParams.get("makeup") as MiiMakeup) ?? null;
|
||||||
|
|
||||||
const handleClick = (makeup: MiiMakeup) => {
|
const handleClick = (makeup: MiiMakeup) => {
|
||||||
const filter = selected === makeup ? null : makeup;
|
const filter = selected === makeup ? null : makeup;
|
||||||
setSelected(filter);
|
|
||||||
|
|
||||||
const params = new URLSearchParams(searchParams);
|
const params = new URLSearchParams(searchParams);
|
||||||
params.set("page", "1");
|
params.set("page", "1");
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import type { MiiPlatform } from "@tomodachi-share/shared";
|
import type { MiiPlatform } from "@tomodachi-share/shared";
|
||||||
import { type ChangeEvent, useState, useTransition } from "react";
|
import { type ChangeEvent, useTransition } from "react";
|
||||||
import { useLocation, useNavigate, useSearchParams } from "react-router";
|
import { useLocation, useNavigate, useSearchParams } from "react-router";
|
||||||
|
|
||||||
export default function OtherFilters() {
|
export default function OtherFilters() {
|
||||||
|
|
@ -9,16 +9,14 @@ export default function OtherFilters() {
|
||||||
const [, startTransition] = useTransition();
|
const [, startTransition] = useTransition();
|
||||||
|
|
||||||
const platform = (searchParams.get("platform") as MiiPlatform) || undefined;
|
const platform = (searchParams.get("platform") as MiiPlatform) || undefined;
|
||||||
const [allowCopying, setAllowCopying] = useState<boolean>((searchParams.get("allowCopying") as unknown as boolean) ?? false);
|
const allowCopying = searchParams.get("allowCopying") === "true";
|
||||||
const [quarantined, setQuarantined] = useState<boolean>((searchParams.get("quarantined") as unknown as boolean) ?? false);
|
const quarantined = searchParams.get("quarantined") === "true";
|
||||||
|
|
||||||
const handleChangeAllowCopying = (e: ChangeEvent<HTMLInputElement>) => {
|
const handleChangeAllowCopying = (e: ChangeEvent<HTMLInputElement>) => {
|
||||||
setAllowCopying(e.target.checked);
|
|
||||||
|
|
||||||
const params = new URLSearchParams(searchParams);
|
const params = new URLSearchParams(searchParams);
|
||||||
params.set("page", "1");
|
params.set("page", "1");
|
||||||
|
|
||||||
if (!allowCopying) {
|
if (e.target.checked) {
|
||||||
params.set("allowCopying", "true");
|
params.set("allowCopying", "true");
|
||||||
} else {
|
} else {
|
||||||
params.delete("allowCopying");
|
params.delete("allowCopying");
|
||||||
|
|
@ -30,12 +28,10 @@ export default function OtherFilters() {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleChangeQuarantined = (e: ChangeEvent<HTMLInputElement>) => {
|
const handleChangeQuarantined = (e: ChangeEvent<HTMLInputElement>) => {
|
||||||
setQuarantined(e.target.checked);
|
|
||||||
|
|
||||||
const params = new URLSearchParams(searchParams);
|
const params = new URLSearchParams(searchParams);
|
||||||
params.set("page", "1");
|
params.set("page", "1");
|
||||||
|
|
||||||
if (!quarantined) {
|
if (e.target.checked) {
|
||||||
params.set("quarantined", "true");
|
params.set("quarantined", "true");
|
||||||
} else {
|
} else {
|
||||||
params.delete("quarantined");
|
params.delete("quarantined");
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { useState, useTransition } from "react";
|
import { useTransition } from "react";
|
||||||
import { Icon } from "@iconify/react";
|
import { Icon } from "@iconify/react";
|
||||||
import type { MiiPlatform } from "@tomodachi-share/shared";
|
import type { MiiPlatform } from "@tomodachi-share/shared";
|
||||||
import { useNavigate, useSearchParams } from "react-router";
|
import { useNavigate, useSearchParams } from "react-router";
|
||||||
|
|
@ -7,19 +7,22 @@ export default function PlatformSelect() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const [, startTransition] = useTransition();
|
const [, startTransition] = useTransition();
|
||||||
|
const selected = (searchParams.get("platform") as MiiPlatform) ?? null;
|
||||||
const [selected, setSelected] = useState<MiiPlatform | null>((searchParams.get("platform") as MiiPlatform) ?? null);
|
|
||||||
|
|
||||||
const handleClick = (platform: MiiPlatform) => {
|
const handleClick = (platform: MiiPlatform) => {
|
||||||
const filter = selected === platform ? null : platform;
|
const filter = selected === platform ? null : platform;
|
||||||
setSelected(filter);
|
|
||||||
|
|
||||||
const params = new URLSearchParams(searchParams);
|
const params = new URLSearchParams(searchParams);
|
||||||
|
params.set("page", "1");
|
||||||
|
|
||||||
if (filter) {
|
if (filter) {
|
||||||
params.set("platform", filter);
|
params.set("platform", filter);
|
||||||
} else {
|
} else {
|
||||||
params.delete("platform");
|
params.delete("platform");
|
||||||
}
|
}
|
||||||
|
if (params.get("gender") === "NONBINARY") params.delete("gender");
|
||||||
|
params.delete("makeup");
|
||||||
|
params.delete("allowCopying");
|
||||||
|
|
||||||
startTransition(() => {
|
startTransition(() => {
|
||||||
navigate(`?${params.toString()}`);
|
navigate(`?${params.toString()}`);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue