diff --git a/src/app/components/FilterUI/FilterComponents/ClassType.tsx b/src/app/components/FilterUI/FilterComponents/ClassType.tsx new file mode 100644 index 0000000..9e8e861 --- /dev/null +++ b/src/app/components/FilterUI/FilterComponents/ClassType.tsx @@ -0,0 +1,65 @@ +/* + * セメスターフィルターのコンポーネント + */ + +"use client"; +import React from "react"; +import { ClassType } from "@/app/type"; +import { FlagButton } from "../UI/FlagButton"; + +/** + * クラス種別フィルターのプロパティ + */ +interface SemesterProp { + selectedClassTypes?: ClassType[]; + setSelectedClassTypes: (classType: ClassType[]) => void; +} + +const ClassType1: ClassType[] = ["基礎", "要求", "主題", "展開"]; +const ClassType2: ClassType[] = ["L", "A", "B", "C", "D", "E", "F"]; + +/** + * 種別フィルターのコンポーネント + * @param prop 種別フィルターのプロパティ + * @returns コンポーネント + */ +export const ClassTypeFilter: React.FC = (prop: SemesterProp) => { + const selectedClassTypes = prop.selectedClassTypes ?? []; + + // ボタンがクリックされたときの関数 + const onClick = (classType: ClassType) => { + if (selectedClassTypes.includes(classType)) { + // 既に含まれている場合、除外 + prop.setSelectedClassTypes( + selectedClassTypes.filter((c) => c !== classType), + ); + } else { + // 含まれていた場合、追加 + prop.setSelectedClassTypes([...selectedClassTypes, classType]); + } + }; + + return ( +
+ {ClassType1.map((c) => ( + onClick(c)} + className="col-span-2" + /> + ))} + + {ClassType2.map((c) => ( + onClick(c)} + className="aspect-square col-span-1" + /> + ))} +
+ ); +}; diff --git a/src/app/components/FilterUI/FilterComponents/Freeword.tsx b/src/app/components/FilterUI/FilterComponents/Freeword.tsx new file mode 100644 index 0000000..50d7b01 --- /dev/null +++ b/src/app/components/FilterUI/FilterComponents/Freeword.tsx @@ -0,0 +1,43 @@ +/* + * フリーワード検索のコンポーネントを定義する + */ + +"use client"; +import React from "react"; +import Checkbox from "../UI/Checkbox"; + +/** + * フリーワード検索のプロパティ + */ +interface FreewordProp { + isFreewordForSyllabusDetail?: boolean; + setFreewordTarget: (isFreewordForSyllabusDetail: boolean) => void; +} + +/** + * フリーワード検索のコンポーネント + * @param prop フリーワード検索のプロパティ + * @returns コンポーネント + */ +export const Freeword: React.FC = (prop: FreewordProp) => { + const isFreewordForSyllabusDetail = prop.isFreewordForSyllabusDetail ?? false; + return ( +
+ + +
+ ); +}; diff --git a/src/app/components/FilterUI/FilterComponents/RegistrationFilter.tsx b/src/app/components/FilterUI/FilterComponents/RegistrationFilter.tsx new file mode 100644 index 0000000..c9cf885 --- /dev/null +++ b/src/app/components/FilterUI/FilterComponents/RegistrationFilter.tsx @@ -0,0 +1,53 @@ +/* + * 履修登録済みか否かでフィルターするコンポーネント + */ + +"use client"; +import React from "react"; +import { FlagButton } from "../UI/FlagButton"; + +/** + * 履修登録済みか否かのフィルターのプロパティ + */ +interface RegistrationFilterProp { + showRegistered?: boolean; // 履修登録済みの講義を表示するか否か + showNotRegistered?: boolean; // 未履修の講義を表示するか否か + setShowRegistered: ( + showRegistered: boolean, + showNotRegistered: boolean, + ) => void; +} + +/** + * 履修登録済みか否かのフィルターのコンポーネント + * @param prop フィルターのプロパティ + * @returns コンポーネント + */ +export const RegistrationFilter: React.FC = ( + prop: RegistrationFilterProp, +) => { + const showRegistered = prop.showRegistered ?? true; + const showNotRegistered = prop.showNotRegistered ?? true; + + // ボタンがクリックされたときの関数 + const onClick = (showRegistered: boolean, showNotRegistered: boolean) => { + prop.setShowRegistered(showRegistered, showNotRegistered); + }; + + return ( +
+ onClick(showRegistered, !showNotRegistered)} + className="aspect-square" // 円形 + /> + onClick(!showRegistered, showNotRegistered)} + className="aspect-square" // 円形 + /> +
+ ); +}; diff --git a/src/app/components/FilterUI/FilterUI.tsx b/src/app/components/FilterUI/FilterUI.tsx index b5c04b9..a8a3879 100644 --- a/src/app/components/FilterUI/FilterUI.tsx +++ b/src/app/components/FilterUI/FilterUI.tsx @@ -8,6 +8,9 @@ import { ClassType, Evaluation, Semester } from "@/app/type"; import { SemestersCheckbox } from "./FilterComponents/Semester"; import { FilterCard } from "./UI/FilterCard"; import { EvaluationFilter } from "./FilterComponents/Evaluation"; +import { Freeword } from "./FilterComponents/Freeword"; +import { RegistrationFilter } from "./FilterComponents/RegistrationFilter"; +import { ClassTypeFilter } from "./FilterComponents/ClassType"; /** * フィルタの型定義 @@ -32,6 +35,15 @@ export const FilterUI: React.FC = () => { return (
+ + + setFilter({ ...filter, isFreewordForSyllabusDetail }) + } + /> + + { } /> + + + + setFilter({ ...filter, classTypes }) + } + /> + + + + setFilter({ ...filter, showRegistered, showNotRegistered })} + /> +
); };