Skip to content

Commit

Permalink
fix: start and end default values
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinWu098 committed Dec 29, 2023
1 parent 6525a42 commit 0a94429
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion components/search/filterComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const CustomFilterCheckbox = (props: FilterCheckboxProps) => {

interface CalendarFilterProps {
onStartChange: Dispatch<SetStateAction<string>>;
onEndChange: Dispatch<SetStateAction<string | undefined>>;
onEndChange: Dispatch<SetStateAction<string>>;
defaultStart: string | undefined;
defaultEnd: string | undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion components/search/filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface SearchFilterProps {
setEnrollment: Dispatch<SetStateAction<boolean[]>>;
setAvailable: Dispatch<SetStateAction<boolean[]>>;
setStart: Dispatch<SetStateAction<string>>;
setEnd: Dispatch<SetStateAction<string | undefined>>;
setEnd: Dispatch<SetStateAction<string>>;
setInstitution: Dispatch<SetStateAction<string>>;
setMin: Dispatch<SetStateAction<number>>;
setMax: Dispatch<SetStateAction<number>>;
Expand Down
10 changes: 8 additions & 2 deletions components/search/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,14 @@ const Search = () => {
const [format, setFormat] = useState([true, true]);
const [enrollment, setEnrollment] = useState([true]);
const [available, setAvailable] = useState([true]);
const [start, setStart] = useState(new Date().toLocaleDateString("en-CA"));
const [end, setEnd] = useState<string>();
const [start, setStart] = useState(() => {
const today = new Date();
const year = today.getFullYear();
const month = (today.getMonth() + 1).toString().padStart(2, "0");
const day = today.getDate().toString().padStart(2, "0");
return `${year}-${month}-${day}`;
});
const [end, setEnd] = useState("");
const [institution, setInstitution] = useState("Any Institution");
const [min, setMin] = useState(0);
const [max, setMax] = useState(20);
Expand Down

0 comments on commit 0a94429

Please sign in to comment.