From 73ab0c2087883c2bb7a0370b40b744224e5bec44 Mon Sep 17 00:00:00 2001 From: naka-12 <104970808+naka-12@users.noreply.github.com> Date: Wed, 16 Apr 2025 02:14:24 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E6=8E=88=E6=A5=AD=E3=82=92=E5=AD=A6?= =?UTF-8?q?=E9=83=A8=E3=81=A7=E3=83=95=E3=82=A3=E3=83=AB=E3=82=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../course/components/SelectCourseDialog.tsx | 98 +++++++++++++++---- .../course/components/TagFilter.tsx | 34 +++++++ 2 files changed, 113 insertions(+), 19 deletions(-) create mode 100644 web/components/course/components/TagFilter.tsx diff --git a/web/components/course/components/SelectCourseDialog.tsx b/web/components/course/components/SelectCourseDialog.tsx index 52f5dafa..6b31c0e1 100644 --- a/web/components/course/components/SelectCourseDialog.tsx +++ b/web/components/course/components/SelectCourseDialog.tsx @@ -3,7 +3,54 @@ import type { Course, Day } from "common/types"; import { useEffect, useState } from "react"; import courseApi from "~/api/course"; import CourseRegisterConfirmDialog from "./CourseRegisterConfirmDialog"; +import TagFilter from "./TagFilter"; +const faculties = [ + "all", + "zenki", + "law", + "medicine", + "engineering", + "arts", + "science", + "agriculture", + "economics", + "liberal-arts", + "education", + "pharmacy", +] as const; +export type FacultyKey = (typeof faculties)[number]; +const facultyRegExMap = new Map([ + ["all", /.*/], + ["zenki", /^[34].*/], + ["law", /^01.*/], + ["medicine", /^02.*/], + ["engineering", /^FEN.*/], + ["arts", /^04.*/], + ["science", /^05.*/], + ["agriculture", /^06.*/], + ["economics", /^07.*/], + ["liberal-arts", /^08.*/], + ["education", /^09.*/], + ["pharmacy", /^10.*/], +]); + +const facultyNameMap = new Map([ + ["all", "全て"], + ["zenki", "前期教養"], + ["law", "法"], + ["medicine", "医"], + ["engineering", "工"], + ["arts", "文"], + ["science", "理"], + ["agriculture", "農"], + ["economics", "経済"], + ["liberal-arts", "後期教養"], + ["education", "教育"], + ["pharmacy", "薬"], +]); + +// TODO: フィルタのロジックが異様にばらけているのでリファクタしよう・・ export default function SelectCourseDialog({ open, onClose, @@ -21,6 +68,7 @@ export default function SelectCourseDialog({ }) { const [availableCourses, setAvailableCourses] = useState([]); const [searchText, setSearchText] = useState(""); + const [selectedFaculty, setSelectedFaculty] = useState("all"); const [filteredAvailableCourses, setFilteredAvailableCourses] = useState< Course[] >([]); @@ -89,9 +137,9 @@ export default function SelectCourseDialog({

{currentEdit?.course?.name ?? "-"}

-

{`${ - currentEdit?.course?.teacher ?? "-" - } / ${currentEdit?.course?.id ?? "-"}`}

+

{`${currentEdit?.course?.teacher ?? "-"} / ${ + currentEdit?.course?.id ?? "-" + }`}

- - ))} + {filteredAvailableCourses + .filter((course) => + facultyRegExMap.get(selectedFaculty)?.test(course.id), + ) + .map((course) => ( +
  • + +
  • + ))} )} diff --git a/web/components/course/components/TagFilter.tsx b/web/components/course/components/TagFilter.tsx new file mode 100644 index 00000000..444e8204 --- /dev/null +++ b/web/components/course/components/TagFilter.tsx @@ -0,0 +1,34 @@ +type Props = { + keyNameMap: Map; + selectedTag: T; + onTagChange: (tag: T) => void; +}; + +export default function TagFilter({ + keyNameMap, + selectedTag, + onTagChange, +}: Props) { + const tags = Array.from(keyNameMap.keys()); + return ( +
    + {tags.map((tag) => ( +
    + onTagChange(tag)} + /> + +
    + ))} +
    + ); +} From 4088879d4585fe0735ef39768d791e0219979cf4 Mon Sep 17 00:00:00 2001 From: naka-12 <104970808+naka-12@users.noreply.github.com> Date: Wed, 16 Apr 2025 02:30:27 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E3=83=95=E3=82=A3=E3=83=AB=E3=82=BF?= =?UTF-8?q?=E3=81=AE=E3=82=B9=E3=82=BF=E3=82=A4=E3=83=AB=E3=82=92=E8=AA=BF?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/app/globals.css | 8 ++++++++ web/components/course/components/TagFilter.tsx | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/web/app/globals.css b/web/app/globals.css index d0c12603..c529adeb 100644 --- a/web/app/globals.css +++ b/web/app/globals.css @@ -16,3 +16,11 @@ .cm-pb-footer { padding-bottom: calc(3rem + env(safe-area-inset-bottom)); } + +.scrollbar-hide::-webkit-scrollbar { + display: none; +} +.scrollbar-hide { + -ms-overflow-style: none; + scrollbar-width: none; +} diff --git a/web/components/course/components/TagFilter.tsx b/web/components/course/components/TagFilter.tsx index 444e8204..926641bf 100644 --- a/web/components/course/components/TagFilter.tsx +++ b/web/components/course/components/TagFilter.tsx @@ -11,7 +11,7 @@ export default function TagFilter({ }: Props) { const tags = Array.from(keyNameMap.keys()); return ( -
    +
    {tags.map((tag) => (
    ({ /> From 255026ba8d84cea3f02855e426d49c8e5cdee227 Mon Sep 17 00:00:00 2001 From: naka-12 <104970808+naka-12@users.noreply.github.com> Date: Wed, 16 Apr 2025 02:50:42 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=E6=8E=88=E6=A5=AD=E7=99=BB=E9=8C=B2?= =?UTF-8?q?=E3=83=80=E3=82=A4=E3=82=A2=E3=83=AD=E3=82=B0=E3=81=AE=E3=82=B9?= =?UTF-8?q?=E3=82=BF=E3=82=A4=E3=83=AB=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/app/globals.css | 4 + .../CourseRegisterConfirmDialog.tsx | 4 +- .../course/components/SelectCourseDialog.tsx | 80 ++++++++++--------- 3 files changed, 48 insertions(+), 40 deletions(-) diff --git a/web/app/globals.css b/web/app/globals.css index c529adeb..b4c8ea0d 100644 --- a/web/app/globals.css +++ b/web/app/globals.css @@ -8,6 +8,10 @@ max-height: 450px; } +.btn { + @apply font-normal; +} + .cm-li-btn { @apply no-animation h-auto w-full justify-start rounded-none border-none bg-white px-6 py-4 text-left font-normal text-base shadow-none hover:bg-zinc-100 focus:bg-zinc-300; } diff --git a/web/components/course/components/CourseRegisterConfirmDialog.tsx b/web/components/course/components/CourseRegisterConfirmDialog.tsx index 074c480c..bdbc9b0c 100644 --- a/web/components/course/components/CourseRegisterConfirmDialog.tsx +++ b/web/components/course/components/CourseRegisterConfirmDialog.tsx @@ -46,9 +46,7 @@ export default function CourseRegisterConfirmDialog({ return (
    -

    - {mode === "add" ? "変更" : "削除"}の確認 -

    +

    {mode === "add" ? "変更" : "削除"}の確認

    {mode === "add" ? "次のように変更" : "次の授業を削除"} します。よろしいですか? diff --git a/web/components/course/components/SelectCourseDialog.tsx b/web/components/course/components/SelectCourseDialog.tsx index 6b31c0e1..38dfa20a 100644 --- a/web/components/course/components/SelectCourseDialog.tsx +++ b/web/components/course/components/SelectCourseDialog.tsx @@ -1,6 +1,7 @@ import { DAY_TO_JAPANESE_MAP } from "common/consts"; import type { Course, Day } from "common/types"; import { useEffect, useState } from "react"; +import { MdClose, MdSearch } from "react-icons/md"; import courseApi from "~/api/course"; import CourseRegisterConfirmDialog from "./CourseRegisterConfirmDialog"; import TagFilter from "./TagFilter"; @@ -93,7 +94,7 @@ export default function SelectCourseDialog({ return ( // biome-ignore lint/a11y/useKeyWithClickEvents:

    e.stopPropagation()} >
    @@ -110,29 +111,31 @@ export default function SelectCourseDialog({
    -

    - {currentEdit - ? `${DAY_TO_JAPANESE_MAP.get(currentEdit.columnName)}曜${ - currentEdit.rowIndex + 1 - }限の授業を選択` - : "授業を選択"} -

    - +
    +

    + {currentEdit + ? `${DAY_TO_JAPANESE_MAP.get(currentEdit.columnName)}曜${ + currentEdit.rowIndex + 1 + }限の授業を編集中` + : "編集"} +

    + +
    -

    現在の授業

    +

    現在の授業

    {currentEdit?.course ? ( -
    +

    {currentEdit?.course?.name ?? "-"} @@ -143,7 +146,7 @@ export default function SelectCourseDialog({

    - { - const text = e.target.value.trim(); - setSearchText(text); - const newFilteredCourses = availableCourses.filter((course) => - course.name.includes(text), - ); - setFilteredAvailableCourses(newFilteredCourses); - }} - /> +