diff --git a/assets/js/react/components/CheckBox.tsx b/assets/js/react/components/CheckBox.tsx new file mode 100644 index 0000000..1506ef5 --- /dev/null +++ b/assets/js/react/components/CheckBox.tsx @@ -0,0 +1,48 @@ +import * as React from "react" +import clsx from "clsx" +import { + Input as BaseInput, + InputOwnerState, + InputProps, + MultiLineInputProps, +} from "@mui/base/Input" + +import { FieldContext } from "./FieldSet" +import { resolveSlotProps } from "../utils/props" + +export type CheckBoxProps = Omit + +export const CheckBox = React.forwardRef( + function CheckBox( + props: CheckBoxProps, + ref: React.ForwardedRef + ) { + const fieldContext = React.useContext(FieldContext) + const { disabled = fieldContext?.disabled, className, ...other } = props + + const inputSlotProps = (ownerState: InputOwnerState) => { + const resolved = resolveSlotProps(props.slotProps?.input, ownerState) + return { + ...resolved, + className: clsx( + "w-5 h-5 accent-black cursor-pointer -translate-y-[3px]", + resolved?.className + ), + style: { + color: "black", + }, + } + } + + return ( + + ) + } +) diff --git a/assets/js/react/components/FilterModal.tsx b/assets/js/react/components/FilterModal.tsx index b3cff6d..3c68019 100644 --- a/assets/js/react/components/FilterModal.tsx +++ b/assets/js/react/components/FilterModal.tsx @@ -2,10 +2,12 @@ import * as React from "react" import { Controller, useForm } from "react-hook-form" import { Button } from "./Button" -import { Field } from "./FieldSet" +import { CheckBox } from "./CheckBox" +import { Field, FieldSet } from "./FieldSet" import { Input } from "./Input" import { Label } from "./Label" import { Modal } from "./Modal" +import { Mode, getModeName } from "../types/Mode" import { SelectLanguage, SelectLanguageProps } from "./SelectLanguage" import { Slider } from "./Slider" @@ -77,7 +79,8 @@ export function FilterModal({ }, } - const controlFIDERating = register("fideRating") + const registerRating = register("rating") + const registerModes = register("modes") return ( - +

Find coaches that have a rating within the specified range. Keep in mind, a higher rating does not necessarily mean a better coach{" "} for you. If you are unsure of this or do not have any preference, leave as is.

-
+
( { event && onChange(event) - setValue("fideRating.0", newValue[0]) - setValue("fideRating.1", newValue[1]) + setValue("rating.0", newValue[0]) + setValue("rating.1", newValue[1]) }} step={10} min={FIDE_RATING_MIN} @@ -154,17 +157,32 @@ export function FilterModal({ - +
- +
+ +
+

+ Prefer a specific game mode? We{"'"}ll prioritize coaches that + specialize in the modes selected. +

+
+ {(Object.keys(Mode) as Mode[]).map((m) => ( +
+ +
{getModeName(m)}
+
+ ))} +
+
) diff --git a/assets/js/react/components/FilterScroll.tsx b/assets/js/react/components/FilterScroll.tsx index da460d5..3800b39 100644 --- a/assets/js/react/components/FilterScroll.tsx +++ b/assets/js/react/components/FilterScroll.tsx @@ -21,10 +21,10 @@ const filters: FilterOption[] = [ title: "FIDE 2000+", Icon: RisingGraphIcon, enable: (p) => { - p.fideRating[0] = Math.max(2000, p.fideRating[0]) + p.rating[0] = Math.max(2000, p.rating[0]) return p }, - isEnabled: (p) => p.fideRating[0] >= 2000, + isEnabled: (p) => p.rating[0] >= 2000, }, { title: "English Speaking", diff --git a/assets/js/react/types/Mode.ts b/assets/js/react/types/Mode.ts new file mode 100644 index 0000000..29e76f0 --- /dev/null +++ b/assets/js/react/types/Mode.ts @@ -0,0 +1,9 @@ +export enum Mode { + RAPID = "RAPID", + BLITZ = "BLITZ", + BULLET = "BULLET", +} + +export const getModeName = (m: Mode) => { + return m.charAt(0) + m.toLowerCase().slice(1) +} diff --git a/assets/js/react/types/SearchParams.ts b/assets/js/react/types/SearchParams.ts index 743a657..e8cd7fc 100644 --- a/assets/js/react/types/SearchParams.ts +++ b/assets/js/react/types/SearchParams.ts @@ -1,5 +1,8 @@ +import { Mode } from "./Mode" + export type SearchParams = { - fideRating: [number, number] + rating: [number, number] + modes: Mode[] languages: string[] } @@ -7,6 +10,7 @@ export const FIDE_RATING_MIN = 1500 export const FIDE_RATING_MAX = 3200 export const defaultSearchParams: SearchParams = { - fideRating: [FIDE_RATING_MIN, FIDE_RATING_MAX], + rating: [FIDE_RATING_MIN, FIDE_RATING_MAX], + modes: [Mode.RAPID, Mode.BLITZ, Mode.BULLET], languages: [], }