-
Notifications
You must be signed in to change notification settings - Fork 0
科目詳細ページを実装 #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
T-shinku0314
wants to merge
1
commit into
main
Choose a base branch
from
feature/subjects-detail
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
科目詳細ページを実装 #25
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| import type { Metadata } from "next"; | ||
| import Link from "next/link"; | ||
| import { ChevronLeftIcon } from "lucide-react"; | ||
| import { api } from "@/lib/api"; | ||
|
|
||
| export const dynamic = "force-dynamic"; | ||
|
|
||
| export const metadata: Metadata = { | ||
| title: "科目詳細", | ||
| }; | ||
|
|
||
| type DetailRow = { | ||
| label: string; | ||
| value: string | null | undefined; | ||
| }; | ||
|
|
||
| function DetailSection({ label, value }: DetailRow) { | ||
| if (!value) return null; | ||
| return ( | ||
| <div className="border-b-2 border-border-primary py-3 flex flex-col gap-2"> | ||
| <p className="font-medium text-xl text-label-primary">{label}</p> | ||
| <p className="text-base text-label-secondary leading-normal tracking-[0.48px] whitespace-pre-wrap">{value}</p> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default async function Page({ params }: { params: Promise<{ id: string }> }) { | ||
| const { id } = await params; | ||
|
|
||
| const { data, error } = await api.GET("/v1/subjects/{id}", { | ||
| params: { path: { id } }, | ||
| }); | ||
|
|
||
| if (error || !data) { | ||
| return ( | ||
| <div className="py-20 text-center"> | ||
| <p className="text-accent-error text-sm">情報の取得に失敗しました。</p> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| const { name, syllabus } = data.subject; | ||
|
|
||
| const rows: DetailRow[] = [ | ||
| { label: "概要", value: syllabus.summary }, | ||
| { label: "到達目標", value: syllabus.learningOutcomes }, | ||
| { label: "提出課題等", value: syllabus.assignments }, | ||
| { label: "評価方法・基準", value: syllabus.evaluationMethod }, | ||
| { label: "テキスト", value: syllabus.textbooks }, | ||
| { label: "参考書", value: syllabus.referenceBooks }, | ||
| { label: "履修条件", value: syllabus.prerequisites }, | ||
| { label: "事前学習", value: syllabus.preLearning }, | ||
| { label: "事後学習", value: syllabus.postLearning }, | ||
| { label: "履修上の留意点", value: syllabus.notes }, | ||
| { label: "キーワード", value: syllabus.keywords }, | ||
| { label: "対象コース・領域", value: syllabus.targetCourses }, | ||
| { label: "対象領域", value: syllabus.targetAreas }, | ||
| { label: "科目群・科目区分", value: syllabus.classifications }, | ||
| { label: "教授言語", value: syllabus.teachingLanguage }, | ||
| { label: "授業内容とスケジュール", value: syllabus.contentsAndSchedule }, | ||
| { label: "授業・試験の形式", value: syllabus.teachingAndExamForm }, | ||
| { label: "DSOP対象科目", value: syllabus.dsopSubject }, | ||
| ]; | ||
|
|
||
| return ( | ||
| <div> | ||
| {/* ヘッダー */} | ||
| <div className="flex items-center gap-4 py-3 border-b-2 border-border-primary"> | ||
| <Link href="/subjects" className="text-label-secondary hover:text-label-primary transition-colors"> | ||
| <ChevronLeftIcon className="w-6 h-6" /> | ||
| </Link> | ||
| <h1 className="text-xl font-medium text-accent-brand">{name}</h1> | ||
| </div> | ||
|
|
||
| {/* 詳細リスト */} | ||
| <div className="flex justify-center p-[10px]"> | ||
| <div className="flex-1 max-w-[836px]"> | ||
| {rows.map((row) => ( | ||
| <DetailSection key={row.label} label={row.label} value={row.value} /> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
今回は難しいかもだから直さなくてもいいけど、エラーハンドリングを適切にできると良さそう
404の時はNot Found的な感じかな
https://developer.mozilla.org/ja/docs/Web/HTTP/Reference/Status
↑とかみてみると面白いかも
サーバー側もやってみて、ここら辺の理解を深めよう