-
Notifications
You must be signed in to change notification settings - Fork 0
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
taken lectures api/#35 #36
Changes from 11 commits
2b3b861
45404ad
61e8442
ab4b204
fe690cf
03877b3
1c42387
4e1da15
4005d3f
26a7685
0a1a557
8a218ab
5aa2967
45eae33
5f3b5f6
6d2461e
be454f7
ca6c51d
aa0c3aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { API_PATH } from '../api-path'; | ||
|
||
type lectureInfo = { | ||
id: number; | ||
year: string; | ||
semester: string; | ||
lectureCode: string; | ||
lectureName: string; | ||
credit: number; | ||
}; | ||
export type TakenLectures = { | ||
totalCredit: number; | ||
takenLectures: lectureInfo[]; | ||
}; | ||
|
||
export const fetchTakenLectures = async (): Promise<TakenLectures> => { | ||
const response = await fetch(API_PATH.takenLectures); | ||
const data = await response.json(); | ||
return data; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [comment]
|
||
}; |
This file was deleted.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [comment]
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๋๋ฉ์ธ ์ปดํฌ๋ํธ์ ๋ํ ํ ์คํธ๊ฐ ๋ฐ๋์ ํ์ํ๋ค๊ณ ์๊ฐํ์๋ ์ด์ ๋ฅผ ์ฌ์ญค๋ณผ ์ ์์๊น์? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์.. ์ ๊ฐ ์ ์ ๋ง์ด ๊ณ ๋ฏผํ๋ ์ฃผ์ ๋ผ ๊ณ ๋ฏผ์ ํ๋ฆ์ ๋จ๊ฒจ๋ณด๊ฒ ์ต๋๋ค. ๋์์ด ๋์์ผ๋ฉด ์ข๊ฒ ๋ค์ :)
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (๋ฒ์ธ): ๋งํด ํ์ธ๋ฌ๊ฐ ํ ์คํธ ํผ๋ผ๋ฏธ๋์ ๋ํ ๋ ผ๋์ ๋ตํ ๊ธ์ด ์์ต๋๋ค. ๊ทธ๋ ์ฌ๋๋ค์ด ํตํฉ ํ ์คํธ์ ๊ดํ ์คํด๋ฅผ ๊ฐ์ง๊ณ ์๋ค๊ณ ์ง์ ํ๋ฉฐ, ์์ ์ ์๊ฐ์ ๋ฐ๋ฅด๋ฉด ํตํฉ ํ ์คํธ๋ ๊ฐ๋ฐ์๊ฐ ์๋ ๋ค๋ฅธ ์ฌ๋์ด ์์ฑํ ํ ์คํธ ์ฝ๋๋ก ํ ์คํธํ๋ ๊ฒฝ์ฐ๋ฅผ ๊ฐ๋ฆฌํจ๋ค๊ณ ๋ฐํ์ต๋๋ค. ๊ทธ๋ฆฌ๊ณ ์ฌ๋๋ค์ด ์ผ๋ฐ์ ์ผ๋ก ์ด์ผ๊ธฐํ๋ ํตํฉํ ์คํธ (์ฆ, ํธ๋กํผ ํ ์คํธ์ ํด๋นํ๋ ํตํฉํ ์คํธ)๋ ์์ ์ด ์ ์ํ sociable unittest์ ํด๋นํ๋ฉฐ, ์ผ๋ฐ์ ์ผ๋ก ์ธ๊ธ๋๋ ์ ๋ํ ์คํธ๋ solitary unittest์ ํด๋นํ๋ค๊ณ ์ค๋ช ํ์ต๋๋ค. ๊ด์ฌ ์์ผ์๋ฉด ์๋ ๋งํฌ ์ฝ์ด๋ณด์ธ์! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ํ
์คํธ๋ฅผ ํด์ผ ํ๋ ์ด์ ์ ๋ํด ํ์ธํ์ต๋๋ค!
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ํด๋น ๋ถ๋ถ์ ๋ํด์ ์ ์ ์๊ฒฌ์ ๋ง์๋๋ฆฌ๋ฉด ํ ์คํธ๋ ๊ฐ๋ฐ๊ณผ ๋์์ ์ด๋ค์ ธ์ผ ํ๋ค๊ณ ์๊ฐํฉ๋๋ค. ์ด ๋ถ๋ถ์ ํ๊ณ ์๊ฐ์ ๋ง์ ๋ ผ์ํ๋๋ก ํฉ์๋ค! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { TakenLectures, fetchTakenLectures } from '@/app/business/taken-lectures/taken-lecture-list.query'; | ||
import { Table } from '../view/molecule/table'; | ||
import TakenLectureTitle from './taken-lecture-title'; | ||
import Button from '../view/atom/button/button'; | ||
import Link from 'next/link'; | ||
|
||
const parseTakenLectures = (subjects: TakenLectures['takenLectures']) => { | ||
return subjects.map((subject) => [ | ||
subject.year, | ||
subject.semester, | ||
subject.lectureCode, | ||
subject.lectureName, | ||
subject.credit, | ||
]); | ||
}; | ||
|
||
const headerInfo = ['์๊ฐ๋ ๋', '์๊ฐํ๊ธฐ', '๊ณผ๋ชฉ์ฝ๋', '๊ณผ๋ชฉ๋ช ', 'ํ์ ']; | ||
|
||
export default async function TakenLectureList() { | ||
const data = await fetchTakenLectures(); | ||
const takenLectures = parseTakenLectures(data.takenLectures); | ||
|
||
return ( | ||
<div className="w-[800px] flex flex-col gap-2"> | ||
<TakenLectureTitle | ||
titleLabel="๋ด ๊ธฐ์ด์ ๊ณผ๋ชฉ" | ||
rightElement={ | ||
<div className="flex gap-2"> | ||
<Button label="์ปค์คํ ํ๊ธฐ" variant="secondary" size="md" /> | ||
<Link href="/file-upload"> | ||
<Button label="์ ๋ฐ์ดํธ" variant="secondary" size="md" /> | ||
</Link> | ||
</div> | ||
} | ||
/> | ||
<Table headerInfo={headerInfo} data={takenLectures} /> | ||
</div> | ||
); | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [request change]
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์ ๋๋ฉ์ธ ๋ก์ง์ด ํฌํจ๋์ด์์ง ์๊ณ ๋ ๋๋ง๋ง ํ๋ค๋ ๊ด์ ์์๋ view component๊ฐ ์ ์ ํ ๊ฒ ๊ฐ๋ค์! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. taken-lecture-title์ด๋ผ๋ ๋ค์ด๋ฐ์ด ์ ์ ํ์ง์๋ค๋ ์๊ฐ์ด ๋ญ๋๋ค. ํด๋น ์ปดํฌ๋ํธ๊ฐ ๊ฒฐ๊ณผ ํ์ด์ง์์๋ ์ฌ์ฌ์ฉ๋ ๊ฒ์ผ๋ก ์์๋๋๋ฐ, ๊ธฐ์ด์๊ณผ๋ชฉ ๋ฟ๋ง์๋๋ผ ๋ฏธ์ด์๊ณผ๋ชฉ์ ํ์ํ ๋๋ ํจ๊ป ๋ ธ์ถ๋๊ธฐ ๋๋ฌธ์ ๋๋ค. ๊ฒฐ๊ณผํ์ด์ง์์ ํด๋น ์ปดํฌ๋ํธ๋ฅผ ์ฌ์ฌ์ฉํด์ ๋
ธ์ถํ ๊ฒ์ผ๋ก ์์๋๋ (ํ์ฌ ๋ค์ ํ์ / ๋ฐ๋ผ์,
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๋ฏธ์ด์ ๊ณผ๋ชฉ ํ์์๋ ๋
ธ์ถ๋๋ ๊ฑธ ์๊ฐํ์ง ๋ชปํ๋ค์! taken lecture์์ lecture๋ก ๋ณ๊ฒฝํ๊ฒ ์ต๋๋ค! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๋ชจํธํ ๋ถ๋ถ์ด ์๋ค๋ ์๊ฒฌ์ ๋ํด์ ๊ณต๊ฐํฉ๋๋ค. table์์ ์์กด์ฑ์ ๊ฐ์ ธ๊ฐ๊ธด ์ด๋ ค์ธ ๊ฒ ๊ฐ๋ค์.
์ฌ์ฌํ ์ฌ๊ณผ์ ๋ง์...์ ์ ํ๋ฉฐ, ์ ํํ ๋ํ์ ํ๋ฆ์ ๊ธฐ์ต์ด ๋์ง์์ง๋ง ๋น์์๋ ๋น์ทํ ๋ฌธ์ ๋ก ์ด์ผ๊ธฐ๋ฅผ ๋๋ด๋ ๊ฒ์ผ๋ก ๊ธฐ์ตํ๊ณ ์์ต๋๋ค. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { ReactNode } from 'react'; | ||
|
||
type TakenLectureTitle = { | ||
titleLabel: string; | ||
rightElement: ReactNode; | ||
}; | ||
|
||
export default function TakenLectureTitle({ titleLabel, rightElement }: TakenLectureTitle) { | ||
return ( | ||
<div className="flex justify-between items-center w-full"> | ||
<div className="rounded-[100px] bg-light-blue-6 p-2.5 text-white text-lg font-bold">{titleLabel}</div> | ||
{rightElement} | ||
</div> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
import { ReactNode } from 'react'; | ||
|
||
type ListRootProps<T> = { | ||
data: T[]; | ||
render: (item: T) => ReactNode; | ||
type ListRootProps = { | ||
data: (string | number)[][]; | ||
render: (item: (string | number)[], index: number) => ReactNode; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [comment]
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. table column์๋ string number ์ธ ๋ฐ์ดํฐ ํ์ ์ด ๋ค์ด์ฌ ์ํฉ์ด ์์ ๊ฒ ๊ฐ์์ ์ ํ์ ์์ผฐ์ต๋๋ค! |
||
}; | ||
|
||
export function ListRoot<T>({ data, render }: ListRootProps<T>) { | ||
return <div className="rounded-2xl border-[1px] border-black-2 w-full">{data.map((item) => render(item))}</div>; | ||
export function ListRoot({ data, render }: ListRootProps) { | ||
return ( | ||
<div className="rounded-2xl border-[1px] border-black-2 w-full"> | ||
{data.map((item, index) => render(item, index))} | ||
</div> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,41 @@ | ||
import { TableHeader } from './table-header'; | ||
import { TableRoot } from './table-root'; | ||
import { ColType } from '../grid/grid-root'; | ||
import List from '../list'; | ||
import Grid from '../grid'; | ||
|
||
const Table = Object.assign(TableRoot, { | ||
Header: TableHeader, | ||
}); | ||
type TableProps = { | ||
headerInfo: string[]; | ||
data: (string | number)[][]; | ||
actionButton?: JSX.Element; | ||
}; | ||
|
||
export default Table; | ||
function isCol(cols: number): cols is ColType { | ||
if (cols === 3 || cols === 4 || cols === 5 || cols === 6) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
export function Table({ data, headerInfo, actionButton }: TableProps) { | ||
const cols = actionButton ? headerInfo.length + 1 : headerInfo.length; | ||
|
||
const render = (item: (string | number)[], index: number) => { | ||
return ( | ||
<List.Row key={index}> | ||
<Grid cols={isCol(cols) ? cols : 6}> | ||
{item.map((info) => ( | ||
<Grid.Column key={info}>{info}</Grid.Column> | ||
))} | ||
{actionButton ? <Grid.Column>{actionButton}</Grid.Column> : null} | ||
</Grid> | ||
</List.Row> | ||
); | ||
}; | ||
|
||
return ( | ||
<div className="flex flex-col gap-2.5 w-full"> | ||
<TableHeader headerInfo={headerInfo} cols={isCol(cols) ? cols : 6} /> | ||
<List data={data} render={render} /> | ||
</div> | ||
); | ||
} |
This file was deleted.
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.
๋ ๋ฒ ์ด์ ์ฌ์ฉ๋๋ ๊ณตํต๋ ํ์ ์ ๋ํด์ ํ์ผ๋ก ๋ถ๋ฆฌํ๋ ๊ฒ์ ์ด๋จ๊น ์ ์๋๋ ค์ :)
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.
lecture info ํ์ ์ taken lecture์์ ํ ๋ฒ ์ฌ์ฉ๋๋๋ฐ ๋ ๋ฒ ์ด์ ์ฌ์ฉ๋๋ค๋ ๊ฒ ์ด๋ค ๋ง์์ด์ ์ง ์กฐ๊ธ ๋ ์๋ ค์ฃผ์ค ์ ์๋์1?
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.
app/ui/taken-lectures/taken-lecture-list.tsx
์์ ์ฌ์ฉ๋๊ณ ์๋๋ถ๋ถ์์ ์ฐฉ๊ฐํ ๊ฒ ๊ฐ์ต๋๋ค. ํด๋น ๋ถ๋ถ์ ๊ทธ๋๋ก ์งํํด๋ ์ข์ ๊ฒ ๊ฐ์ต๋๋ค. ์ฃ์กํฉ๋๋ค :)