diff --git a/app/components/dropdown.tsx b/app/components/dropdown.tsx index becae39c..a014e42e 100644 --- a/app/components/dropdown.tsx +++ b/app/components/dropdown.tsx @@ -1,15 +1,15 @@ 'use client'; -import {FilterKey} from "@/app/profiles/page"; +import {DropdownKey} from "@/app/profiles/page"; type DropdownProps = { - id: FilterKey + id: DropdownKey options?: string[] value: string - onChange: (id: FilterKey, value: string) => void - onFocus?: (id: FilterKey) => void - onKeyDown?: (id: FilterKey, key: string) => void - onClick: (id: FilterKey) => void + onChange: (id: DropdownKey, value: string) => void + onFocus?: (id: DropdownKey) => void + onKeyDown?: (id: DropdownKey, key: string) => void + onClick: (id: DropdownKey) => void } export default function Dropdown( diff --git a/app/profiles/ProfileFilters.tsx b/app/profiles/ProfileFilters.tsx index 86e3a499..1e638cb4 100644 --- a/app/profiles/ProfileFilters.tsx +++ b/app/profiles/ProfileFilters.tsx @@ -3,7 +3,8 @@ import {useEffect, useRef, useState} from 'react'; import {Gender} from "@prisma/client"; import Dropdown from "@/app/components/dropdown"; -import {FilterKey} from "@/app/profiles/page"; +import Slider from '@mui/material/Slider'; +import {DropdownKey, RangeKey} from "@/app/profiles/page"; interface FilterProps { filters: { @@ -14,22 +15,28 @@ interface FilterProps { searchQuery: string; minAge?: number | null; maxAge?: number | null; + minIntroversion?: number | null; + maxIntroversion?: number | null; }; onFilterChange: (key: string, value: any) => void; onShowFilters: (value: boolean) => void; - onToggleFilter: (key: FilterKey, value: string) => void; + onToggleFilter: (key: DropdownKey, value: string) => void; onReset: () => void; } -export const dropdownConfig: { id: FilterKey, name: string }[] = [ +export const dropdownConfig: { id: DropdownKey, name: string }[] = [ {id: "connections", name: "Desired Connections"}, {id: "interests", name: "Core Interests"}, {id: "causeAreas", name: "Cause Areas"}, ] +export const rangeConfig: { id: RangeKey, name: string, min: number, max: number }[] = [ + {id: "age", name: "Age Range", min: 15, max: 60}, +] + export function ProfileFilters({filters, onFilterChange, onShowFilters, onToggleFilter, onReset}: FilterProps) { interface Item { - id: FilterKey; + id: DropdownKey; name: string; } @@ -92,7 +99,7 @@ export function ProfileFilters({filters, onFilterChange, onShowFilters, onToggle }, []); - const toggle = (id: FilterKey, optionId: string) => { + const toggle = (id: DropdownKey, optionId: string) => { dropDownStates[id].selected.set(prev => { const newSet = new Set(prev); if (newSet.has(optionId)) { @@ -104,24 +111,24 @@ export function ProfileFilters({filters, onFilterChange, onShowFilters, onToggle }); }; - const handleKeyDown = (id: FilterKey, key: string) => { + const handleKeyDown = (id: DropdownKey, key: string) => { if (key === 'Escape') dropDownStates[id].show.set(false); }; - const handleChange = (id: FilterKey, e: string) => { + const handleChange = (id: DropdownKey, e: string) => { dropDownStates[id].new.set(e); } - const handleFocus = (id: FilterKey) => { + const handleFocus = (id: DropdownKey) => { dropDownStates[id].show.set(true); } - const handleClick = (id: FilterKey) => { + const handleClick = (id: DropdownKey) => { const shown = dropDownStates[id].show.value; dropDownStates[id].show.set(!shown); } - function getDrowDown(id: FilterKey, name: string) { + function getDrowDown(id: DropdownKey, name: string) { return (