Skip to content
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

Merged
merged 19 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/business/api-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ const BASE_URL = process.env.API_MOCKING === 'enable' ? 'http://localhost:9090'

export const API_PATH = {
revenue: `${BASE_URL}/revenue`,
takenLectures: `${BASE_URL}/taken-lectures`,
};
20 changes: 20 additions & 0 deletions app/business/taken-lectures/taken-lecture-list.query.ts
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;
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋‘ ๋ฒˆ ์ด์ƒ ์‚ฌ์šฉ๋˜๋Š” ๊ณตํ†ต๋œ ํƒ€์ž…์— ๋Œ€ํ•ด์„œ ํŒŒ์ผ๋กœ ๋ถ„๋ฆฌํ•˜๋Š” ๊ฒƒ์€ ์–ด๋–จ๊นŒ ์ œ์•ˆ๋“œ๋ ค์š” :)

Copy link
Member Author

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?

Copy link
Member

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์—์„œ ์‚ฌ์šฉ๋˜๊ณ  ์žˆ๋Š”

const parseTakenLectures = (subjects: TakenLectures['takenLectures']) =>

๋ถ€๋ถ„์—์„œ ์ฐฉ๊ฐํ•œ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ํ•ด๋‹น ๋ถ€๋ถ„์€ ๊ทธ๋Œ€๋กœ ์ง„ํ–‰ํ•ด๋„ ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ์ฃ„์†กํ•ฉ๋‹ˆ๋‹ค :)

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[comment]

  • ํ˜„์žฌ ์š”๊ตฌ์‚ฌํ•ญ์—๋Š” ์—๋Ÿฌ ๋ฐœ์ƒ ์‹œ์˜ ์ฒ˜๋ฆฌ ๋ฐฉ์•ˆ์ด ํฌํ•จ๋˜์–ด ์žˆ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์ด ๋ถ€๋ถ„์— ๋Œ€ํ•œ ์ •์˜๊ฐ€ ํ•„์š”ํ•˜๋ฏ€๋กœ, ํšŒ๊ณ  ์‹œ๊ฐ„์— ๋…ผ์˜ํ•ด๋ด…์‹œ๋‹ค!

};
62 changes: 62 additions & 0 deletions app/mocks/data.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,65 @@ export const revenue = [
{ month: 'Nov', revenue: 3000 },
{ month: 'Dec', revenue: 4800 },
];

export const takenLectures = JSON.parse(`{
"totalCredit": 115,
"takenLectures": [
{
"id": 140,
"year": "CUSTOM",
"semester": "CUSTOM",
"lectureCode": "HED01407",
"lectureName": "๋”ฅ๋Ÿฌ๋‹",
"credit": 3
},
{
"id": 139,
"year": "CUSTOM",
"semester": "CUSTOM",
"lectureCode": "HED01311",
"lectureName": "์ž๊ธฐ์ฃผ๋„ํ•™์Šต",
"credit": 2
},
{
"id": 135,
"year": "2023",
"semester": "1ํ•™๊ธฐ",
"lectureCode": "HED01413",
"lectureName": "์บก์Šคํ†ค๋””์ž์ธ",
"credit": 3
},
{
"id": 128,
"year": "2023",
"semester": "1ํ•™๊ธฐ",
"lectureCode": "HED01404",
"lectureName": "๋น…๋ฐ์ดํ„ฐ๊ธฐ์ˆ ํŠน๋ก 1",
"credit": 3
},
{
"id": 126,
"year": "2023",
"semester": "1ํ•™๊ธฐ",
"lectureCode": "HED01318",
"lectureName": "๋ชจ๋ฐ”์ผ์ปดํ“จํŒ…",
"credit": 3
},
{
"id": 125,
"year": "2023",
"semester": "1ํ•™๊ธฐ",
"lectureCode": "HED01407",
"lectureName": "๋”ฅ๋Ÿฌ๋‹",
"credit": 3
},
{
"id": 124,
"year": "2023",
"semester": "1ํ•™๊ธฐ",
"lectureCode": "HED01317",
"lectureName": "๋ฐ์ดํ„ฐ๋ฒ ์ด์Šคํ”„๋กœ์ ํŠธ",
"credit": 3
}
]
}`);
5 changes: 4 additions & 1 deletion app/mocks/handlers.mock.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HttpResponse, http, delay } from 'msw';
import { revenue } from './data.mock';
import { revenue, takenLectures } from './data.mock';
import { API_PATH } from '../business/api-path';

export const handlers = [
Expand All @@ -8,4 +8,7 @@ export const handlers = [
console.log(revenue);
return HttpResponse.json(revenue);
}),
http.get(API_PATH.takenLectures, () => {
return HttpResponse.json(takenLectures);
}),
];
29 changes: 0 additions & 29 deletions app/ui/sample.stories.tsx

This file was deleted.

39 changes: 39 additions & 0 deletions app/ui/taken-lectures/taken-lecture-list.tsx
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[comment]

  • ๋„๋ฉ”์ธ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ์ ์ ˆํ•˜๊ฒŒ ์ž‘์„ฑ๋œ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.
  • ๋˜ํ•œ, ์ €๋Š” ๋„๋ฉ”์ธ ์ปดํฌ๋„ŒํŠธ์— ๋Œ€ํ•œ ํ…Œ์ŠคํŠธ๊ฐ€ ๋ฐ˜๋“œ์‹œ ํ•„์š”ํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ๋„๋ฉ”์ธ ์ปดํฌ๋„ŒํŠธ์— ๋Œ€ํ•œ ํ…Œ์ŠคํŠธ ์ž‘์„ฑ์„ ์ œ์•ˆํ•˜๊ณ ์ž ํ•˜๋Š”๋ฐ, ๋‹ค๋ฅธ ๋ถ„๋“ค์˜ ์˜๊ฒฌ์€ ์–ด๋– ์‹ ๊ฐ€์š”?

Copy link
Member

@yougyung yougyung Feb 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋„๋ฉ”์ธ ์ปดํฌ๋„ŒํŠธ์— ๋Œ€ํ•œ ํ…Œ์ŠคํŠธ๊ฐ€ ๋ฐ˜๋“œ์‹œ ํ•„์š”ํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ•˜์‹œ๋Š” ์ด์œ ๋ฅผ ์—ฌ์ญค๋ณผ ์ˆ˜ ์žˆ์„๊นŒ์š”?

Copy link
Collaborator

@seonghunYang seonghunYang Feb 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์Œ.. ์ œ๊ฐ€ ์ „์— ๋งŽ์ด ๊ณ ๋ฏผํ–ˆ๋˜ ์ฃผ์ œ๋ผ ๊ณ ๋ฏผ์˜ ํ๋ฆ„์„ ๋‚จ๊ฒจ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ๋„์›€์ด ๋˜์—ˆ์œผ๋ฉด ์ข‹๊ฒ ๋„ค์š” :)

  1. ์ฒซ ๋ฒˆ์งธ๋กœ ๊ณ ๋ คํ•ด์•ผ ํ•  ์ค‘์š”ํ•œ ์งˆ๋ฌธ์€ "์–ด๋–ค ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋ฉด ๊ฐ€์žฅ ํšจ๊ณผ์ ์ผ๊นŒ?"์ž…๋‹ˆ๋‹ค. 'ํšจ๊ณผ์ '์ด๋ž€ ๊ฐ€์žฅ ์ ์ ˆํ•œ ์ฝ”๋“œ์˜ ์–‘์œผ๋กœ "์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์˜๋„๋Œ€๋กœ ๋™์ž‘ํ•จ์„ ๊ฒ€์ฆ"ํ•˜๋Š” ํ…Œ์ŠคํŠธ์˜ ๋ชฉ์ ์„ ๋‹ฌ์„ฑํ•˜๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋Š” ๊ณผ์ •์—์„œ ๋ชจ๋“  ๊ฒƒ์— ๋Œ€ํ•œ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋Š” ๊ฒƒ์€ ์ง€๋ฃจํ•˜๊ณ , ์ƒ๋‹นํžˆ ์†Œ๋ชจ์ ์ด๋ฉฐ ๋•Œ๋ก  ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค๋Š” ๊ฒƒ์„ ์•Œ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ, ์–ด๋–ป๊ฒŒ ๊ฐ€์žฅ ์ ์ ˆํ•œ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•  ๊ฒƒ์ธ์ง€์— ๋Œ€ํ•œ ๊ณ ๋ฏผ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ์ด ์งˆ๋ฌธ์— ๋Œ€ํ•œ ๋‹ต์„ ์ฐพ๊ธฐ ์œ„ํ•ด ์—ฌ๋Ÿฌ ์ฐธ๊ณ ์ž๋ฃŒ๋ฅผ ๊ฒ€ํ† ํ–ˆ์Šต๋‹ˆ๋‹ค.
  2. ๊ฐ€์žฅ ๋จผ์ € ์‚ดํŽด๋ณธ ๊ฒƒ์€ ๋งˆํ‹ด ํŒŒ์šธ๋Ÿฌ์˜ "ํ…Œ์ŠคํŠธ ํ”ผ๋ผ๋ฏธ๋“œ"์ž…๋‹ˆ๋‹ค. ๊ฐ„๋‹จํžˆ ๋งํ•˜๋ฉด, ์œ ๋‹› ํ…Œ์ŠคํŠธ > ํ†ตํ•ฉ ํ…Œ์ŠคํŠธ > E2E ํ…Œ์ŠคํŠธ์˜ ์ˆœ์„œ๋กœ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. FE ๊ด€์ ์—์„œ๋Š” ๋กœ์ง์„ ๊ฐ€์ง„ ํ›…๊ณผ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ์œ ๋‹› ํ…Œ์ŠคํŠธ ๋‹จ์œ„๋ผ๊ณ  ์ƒ๊ฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ์•„๋ž˜์— ์ฒจ๋ถ€๋œ ๊ธ€์„ ์ฐธ๊ณ ํ•˜์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.
    ์›๋ฌธ: https://martinfowler.com/bliki/TestPyramid.html
    ๋ฒˆ์—ญ: https://blog.voidmainvoid.net/451
    (์›๋ฌธ์„ ์ฝ๋Š” ๊ฒƒ์„ ์ถ”์ฒœ๋“œ๋ฆฝ๋‹ˆ๋‹ค. ์ฐธ๊ณ ๋กœ ๋งˆํ‹ด ํŒŒ์šธ๋Ÿฌ๋Š” ์ œ๊ฐ€ ๊ฐ€์žฅ ์ข‹์•„ํ•˜๋Š” ํ”„๋กœ๊ทธ๋ž˜๋จธ ์ค‘ ํ•œ๋ช…์ž…๋‹ˆ๋‹ค)
  3. ํ•˜์ง€๋งŒ "ํ…Œ์ŠคํŠธ ํ”ผ๋ผ๋ฏธ๋“œ"์— ๋Œ€ํ•ด ์˜๋ฌธ์ด ์ƒ๊ฒผ์Šต๋‹ˆ๋‹ค. ๊ทธ ์˜๋ฌธ์€ "FE์—์„œ๋„ ์ด 'ํ…Œ์ŠคํŠธ ํ”ผ๋ผ๋ฏธ๋“œ'๊ฐ€ ์œ ํšจํ•œ๊ฐ€?"์ž…๋‹ˆ๋‹ค. ์ œ ๊ฒฝํ—˜์ƒ BE ๊ด€์ ์—์„œ๋Š” ํ…Œ์ŠคํŠธ ํ”ผ๋ผ๋ฏธ๋“œ๊ฐ€ ์œ ํšจํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” ๋„๋ฉ”์ธ > ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ > ์–ด๋Œ‘ํ„ฐ์˜ ์˜์กด์„ฑ ํ๋ฆ„์ด ์œ ๋‹› ํ…Œ์ŠคํŠธ > ํ†ตํ•ฉ ํ…Œ์ŠคํŠธ > E2E ํ…Œ์ŠคํŠธ์˜ ํ๋ฆ„๊ณผ ์ผ์น˜ํ•˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ FE์—์„œ๋Š” ๊ทธ๋ ‡์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง๊ณผ ์ปดํฌ๋„ŒํŠธ๋Š” ๊ฐ๊ธฐ ๋‹ค๋ฅธ ๊ณ„์ธต์„ ๊ฐ€์ง€๋ฉฐ, ๋‘˜์€ ๋ฐ˜๋“œ์‹œ ๊ฒฐํ•ฉํ•ด์„œ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค. ์ฆ‰, ๋กœ์ง๊ณผ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๊ฒฐํ•ฉ๋˜์–ด ์ œ๋Œ€๋กœ ๋™์ž‘ํ•˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•ด์•ผ "์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์˜๋„๋Œ€๋กœ ์ž‘๋™ํ•˜๋Š” ๊ฒƒ์„ ๊ฒ€์ฆ"ํ•˜๋Š” ๋ชฉํ‘œ๋ฅผ ๋‹ฌ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์—„๋ฐ€ํžˆ ๋งํ•˜๋ฉด, ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง๊ณผ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๊ฒฐํ•ฉ๋œ ํ…Œ์ŠคํŠธ(๋„๋ฉ”์ธ ์ปดํฌ๋„ŒํŠธ๋ผ๊ณ  ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค)๋Š” ํ†ตํ•ฉ ํ…Œ์ŠคํŠธ์— ๊ฐ€๊น์Šต๋‹ˆ๋‹ค.
  4. ์ด ์˜๋ฌธ์„ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด ๋‹ค์–‘ํ•œ ์‚ฌ๋žŒ๋“ค์˜ ์˜๊ฒฌ์„ ์ˆ˜์ง‘ํ–ˆ๊ณ , ์ด ๋ฌธ์ œ๊ฐ€ ๋‚˜๋งŒ์˜ ๋ฌธ์ œ๊ฐ€ ์•„๋‹ˆ๋ผ๋Š” ์‚ฌ์‹ค์„ ๊นจ๋‹ฌ์•˜์Šต๋‹ˆ๋‹ค.
    img
  • ์š”์•ฝํ•˜๋ฉด, ๋งˆํ‹ด ํŒŒ์šธ๋Ÿฌ์˜ "ํ…Œ์ŠคํŠธ ํ”ผ๋ผ๋ฏธ๋“œ"๋Š” ๊ตฌ์‹์ด๋ฉฐ, ํ†ตํ•ฉ ํ…Œ์ŠคํŠธ๋ฅผ ์œ ๋‹› ํ…Œ์ŠคํŠธ๋ณด๋‹ค ๋งŽ์ด ์ž‘์„ฑํ•˜๋Š” ๊ฒƒ์ด ๋” ํ˜„๋ช…ํ•˜๋‹ค๋Š” ์ฃผ์žฅ์ž…๋‹ˆ๋‹ค. ์ด ํ…Œ์ŠคํŠธ ๋ชจ๋ธ์„ FE ๋ถ„์•ผ์—์„œ๋Š” "ํŠธ๋กœํ”ผ ํ…Œ์ŠคํŠธ"๋ผ๊ณ  ๋ถ€๋ฆ…๋‹ˆ๋‹ค.
  1. ๊ทธ ๋‹ค์Œ์œผ๋กœ ํŠธ๋กœํ”ผ ํ…Œ์ŠคํŠธ์˜ ๊ฐœ๋…์„ ์ œ์•ˆํ•œ ์‚ฌ๋žŒ์ธ Kent C.Dodds์˜ ๊ธ€์„ ์ฐพ์•„ ์ฝ์—ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ์˜ ๊ธ€์„ ์š”์•ฝํ•˜๋ฉด, ํ†ตํ•ฉ ํ…Œ์ŠคํŠธ๋Š” ์œ ๋‹› ํ…Œ์ŠคํŠธ๋ณด๋‹ค ๋” ์ ์€ ์ฝ”๋“œ๋กœ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์˜๋„๋Œ€๋กœ ์ž‘๋™ํ•จ์„ ๋” ์ž˜ ๋ณด์žฅํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ํ†ตํ•ฉ ํ…Œ์ŠคํŠธ๋ฅผ ์ž‘์„ฑํ•ด์•ผ ํ•œ๋‹ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ํ•ด๋‹น ๊ธ€์„ ์•„๋ž˜์— ์ฒจ๋ถ€ํ•ฉ๋‹ˆ๋‹ค.
    Write tests. Not too many. Mostly integration: https://kentcdodds.com/blog/write-tests
    ("Not too many. Mostly integration"์ด๋ผ๋Š” ์ œ๋ชฉ์ด ์ธ์ƒ์ ์ž…๋‹ˆ๋‹ค. ์ฐธ๊ณ ๋กœ, Kent C.Dodds๋Š” ์œ ๋ช… FE ๊ฐœ๋ฐœ์ž์ด๋ฉฐ RTL๋ฅผ ๊ฐœ๋ฐœํ–ˆ์Šต๋‹ˆ๋‹ค.)
  2. ์ •๋ฆฌํ•˜๋ฉด ์šฐ๋ฆฌ๋Š” โ€œ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์˜๋„๋Œ€๋กœ ๋™์ž‘ํ•จโ€์„ ๋ณด์žฅํ•˜๊ธฐ ์œ„ํ•ด์„œ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ์šฐ๋ฆฌ์˜ ์‹œ๊ฐ„์€ ์ œํ•œ๋˜์–ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์–ด๋–ค ํ…Œ์ŠคํŠธ์— ์‹œ๊ฐ„์„ ํˆฌ์žํ• ์ง€ ๊ฒฐ์ •ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ „ํ†ต์ ์ธ "ํ…Œ์ŠคํŠธ ํ”ผ๋ผ๋ฏธ๋“œ" ๋ชจํ˜•์ด ์žˆ์ง€๋งŒ, ์ด๋Š” ํ˜„๋Œ€ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜๊ณผ ํ”„๋ก ํŠธ์—”๋“œ์—๋Š” ์ ํ•ฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์ด๋Š” ์œ ๋‹›ํ…Œ์ŠคํŠธ๊ฐ€ ๋” ๋งŽ์€ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋„๋ก ์š”๊ตฌํ•˜๋ฉฐ, ํ”„๋ก ํŠธ์—”๋“œ์—์„œ๋Š” ์œ ๋‹›ํ…Œ์ŠคํŠธ ํ†ต๊ณผ๊ฐ€ ์˜๋„ํ•œ ๋™์ž‘์„ ๋ณด์žฅํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค(์ด๋Š” ๋กœ์ง๊ณผ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๊ฒฐํ•ฉ๋œ ํ”„๋ก ํŠธ์—”๋“œ์˜ ํŠน์„ฑ ๋•Œ๋ฌธ์ด๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค). ์ด์— ๋Œ€ํ•œ ๋Œ€์•ˆ์œผ๋กœ, ํ†ตํ•ฉ ํ…Œ์ŠคํŠธ๋ฅผ ์ž‘์„ฑํ•˜๋Š” ๊ฒƒ์„ ์ œ์•ˆํ•ฉ๋‹ˆ๋‹ค. ์ด๋ฅผ ๊ฐœ๋…์ ์œผ๋กœ ํŠธ๋กœํ”ผ ํ…Œ์ŠคํŠธ ๋ชจํ˜•์ด๋ผ ๋ถ€๋ฅด๋ฉฐ, ์šฐ๋ฆฌ ํ”„๋กœ์ ํŠธ์—์„œ๋Š” ๋„๋ฉ”์ธ ์ปดํฌ๋„ŒํŠธ์— ๋Œ€ํ•œ ํ…Œ์ŠคํŠธ๊ฐ€ ์ ํ•ฉํ•˜๋‹ค๊ณ  ํŒ๋‹จํ–ˆ์Šต๋‹ˆ๋‹ค.

Copy link
Collaborator

@seonghunYang seonghunYang Feb 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(๋ฒˆ์™ธ): ๋งˆํ‹ด ํŒŒ์šธ๋Ÿฌ๊ฐ€ ํ…Œ์ŠคํŠธ ํ”ผ๋ผ๋ฏธ๋“œ์— ๋Œ€ํ•œ ๋…ผ๋ž€์— ๋‹ตํ•œ ๊ธ€์ด ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Š” ์‚ฌ๋žŒ๋“ค์ด ํ†ตํ•ฉ ํ…Œ์ŠคํŠธ์— ๊ด€ํ•œ ์˜คํ•ด๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค๊ณ  ์ง€์ ํ•˜๋ฉฐ, ์ž์‹ ์˜ ์ƒ๊ฐ์— ๋”ฐ๋ฅด๋ฉด ํ†ตํ•ฉ ํ…Œ์ŠคํŠธ๋Š” ๊ฐœ๋ฐœ์ž๊ฐ€ ์•„๋‹Œ ๋‹ค๋ฅธ ์‚ฌ๋žŒ์ด ์ž‘์„ฑํ•œ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋กœ ํ…Œ์ŠคํŠธํ•˜๋Š” ๊ฒฝ์šฐ๋ฅผ ๊ฐ€๋ฆฌํ‚จ๋‹ค๊ณ  ๋ฐํ˜”์Šต๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์‚ฌ๋žŒ๋“ค์ด ์ผ๋ฐ˜์ ์œผ๋กœ ์ด์•ผ๊ธฐํ•˜๋Š” ํ†ตํ•ฉํ…Œ์ŠคํŠธ (์ฆ‰, ํŠธ๋กœํ”ผ ํ…Œ์ŠคํŠธ์— ํ•ด๋‹นํ•˜๋Š” ํ†ตํ•ฉํ…Œ์ŠคํŠธ)๋Š” ์ž์‹ ์ด ์ •์˜ํ•œ sociable unittest์— ํ•ด๋‹นํ•˜๋ฉฐ, ์ผ๋ฐ˜์ ์œผ๋กœ ์–ธ๊ธ‰๋˜๋Š” ์œ ๋‹›ํ…Œ์ŠคํŠธ๋Š” solitary unittest์— ํ•ด๋‹นํ•œ๋‹ค๊ณ  ์„ค๋ช…ํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ด€์‹ฌ ์žˆ์œผ์‹œ๋ฉด ์•„๋ž˜ ๋งํฌ ์ฝ์–ด๋ณด์„ธ์š”!

https://martinfowler.com/articles/2021-test-shapes.html

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ…Œ์ŠคํŠธ๋ฅผ ํ•ด์•ผ ํ•˜๋Š” ์ด์œ ์— ๋Œ€ํ•ด ํ™•์ธํ–ˆ์Šต๋‹ˆ๋‹ค!
์ถ”๊ฐ€์ ์œผ๋กœ ์ €๋Š” ๊ถ๊ธˆํ•œ๊ฒŒ ์žˆ๋Š”๋ฐ, ๋„๋ฉ”์ธ ์ปดํฌ๋„ŒํŠธ์— ๋Œ€ํ•œ ํ…Œ์ŠคํŠธ ์ž‘์„ฑ์ด ์–ธ์ œ ์ ํ•ฉํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ•˜๋‚˜์š”?
์ €๋Š” ์ปดํฌ๋„ŒํŠธ์— ๋Œ€ํ•œ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์„ ๋‹ค ๊ตฌํ˜„ํ•œ ํ›„์— ์ง„ํ–‰ํ•˜๋Š” ๊ฒƒ์ด ์ ํ•ฉํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค!
์ด์œ ๋Š” ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค

  • ๊ฐœ๋ฐœ์„ ํ•˜๋ฉด์„œ tdd๋ฅผ ํ• ๋งŒํผ ๊ฒ€์ฆํ•ด์•ผ ์˜ˆ์™ธ ์ผ€์ด์Šค๊ฐ€ ๋งŽ์ง€ ์•Š์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค

Copy link
Collaborator

@seonghunYang seonghunYang Feb 26, 2024

Choose a reason for hiding this comment

The 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>
);
}
15 changes: 15 additions & 0 deletions app/ui/taken-lectures/taken-lecture-title.tsx
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[request change]

  • ์ œ ์ƒ๊ฐ์—๋Š” ํ˜„์žฌ 'taken-lecture-title' ์ปดํฌ๋„ŒํŠธ์˜ ๋ถ„๋ฆฌ ์ˆ˜์ค€์„ ๊ณ ๋ คํ–ˆ์„ ๋•Œ, 'taken-lecture-title' ์ปดํฌ๋„ŒํŠธ๊ฐ€ view ์ปดํฌ๋„ŒํŠธ๋กœ ๋” ์ ์ ˆํ•ด ๋ณด์ž…๋‹ˆ๋‹ค. ์ด์œ ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:
    • 'taken-lecture-title' ์ปดํฌ๋„ŒํŠธ ๋‚ด๋ถ€์—๋Š” ๋น„์ฆˆ๋‹ˆ์Šค ๋„๋ฉ”์ธ ๋กœ์ง์ด ์—†์Šต๋‹ˆ๋‹ค.
    • ๋”ฐ๋ผ์„œ 'taken-lecture-title' ์ปดํฌ๋„ŒํŠธ๋Š” ํ˜„์žฌ view ๊ด€์‹ฌ์‚ฌ๋งŒ์„ ์ˆ˜ํ–‰ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.
      • view ๊ด€์‹ฌ์‚ฌ๋Š” props๋ฅผ ๋ฐ›์•„ ํ™”๋ฉด์— ๊ทธ๋ ค์ฃผ๋Š” presentational component๋ฅผ ๋œปํ•ฉ๋‹ˆ๋‹ค.
  • 'ํ˜„์žฌ ๋ถ„๋ฆฌ ์ˆ˜์ค€'์ด๋ผ๊ณ  ๋งํ•œ ๊ฒƒ์€ '์ปค์Šคํ…€ํ•˜๊ธฐ'์™€ '์—…๋ฐ์ดํŠธ' ๋ฒ„ํŠผ์— ๋„๋ฉ”์ธ ๋กœ์ง์ด ์ถ”๊ฐ€๋  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. ๋งŒ์•ฝ ๊ทธ๋ ‡๊ฒŒ ๋œ๋‹ค๋ฉด 'taken-lecture-title' ์ปดํฌ๋„ŒํŠธ๋Š” props๋กœ ๋ฒ„ํŠผ์„ ๋ฐ›๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ, ๋‚ด๋ถ€์—์„œ ์ž์ฒด์ ์œผ๋กœ '์ปค์Šคํ…€ํ•˜๊ธฐ'์™€ '์—…๋ฐ์ดํŠธ' ๋ฒ„ํŠผ์„ ๋ Œ๋”๋งํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ํ•ด๋‹น ๋น„์ฆˆ๋‹ˆ์Šค ๋„๋ฉ”์ธ ๋กœ์ง์ด 'taken-lecture-title' ์ปดํฌ๋„ŒํŠธ์— ์œ„์น˜ํ•œ๋‹ค๋ฉด, ๋„๋ฉ”์ธ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๋” ์ ์ ˆํ•˜๋‹ค๊ณ  ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
    • ๊ฒฐ๊ตญ ๋„๋ฉ”์ธ ์ปดํฌ๋„ŒํŠธ๋กœ ๋ถ„๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ํ•ด๋‹น ๋ฒ„ํŠผ์„ props๋กœ ๋ฐ›๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ, ๋‚ด๋ถ€์—์„œ ๋ Œ๋”๋งํ•˜๊ณ  ๊ฑฐ๊ธฐ์— ๋น„์ฆˆ๋‹ˆ์Šค ๋„๋ฉ”์ธ ๋กœ์ง์„ ์ž‘์„ฑํ•  ํ•„์š”๊ฐ€ ์žˆ์–ด๋ณด์ด๋„ค์š”!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•— ๋„๋ฉ”์ธ ๋กœ์ง์ด ํฌํ•จ๋˜์–ด์žˆ์ง€ ์•Š๊ณ  ๋ Œ๋”๋ง๋งŒ ํ•œ๋‹ค๋Š” ๊ด€์ ์—์„œ๋Š” view component๊ฐ€ ์ ์ ˆํ•  ๊ฒƒ ๊ฐ™๋„ค์š”!
์ €๋Š” ๋„๋ฉ”์ธ ์ปดํฌ๋„ŒํŠธ์˜ ์ •์˜๋ฅผ ๋„๋ฉ”์ธ์— ์ข…์†๋œ๋‹ค๊ณ  ์ƒ๊ฐํ•ด์„œ ๊ทธ๋ ‡๊ฒŒ ๋ถ„๋ฆฌ๋ฅผ ํ–ˆ์Šต๋‹ˆ๋‹ค!
taken lecture title์€ "๊ธฐ์ด์ˆ˜ ๊ณผ๋ชฉ์— ๋Œ€ํ•œ ์ •๋ณด(์ œ๋ชฉ)์„ ๋ Œ๋”๋งํ•œ๋‹ค" ๋ผ๋Š” ์—ญํ• ๋กœ ์ •์˜ํ•  ์ˆ˜ ์žˆ๊ณ  ์—ญํ• ์ด ๋„๋ฉ”์ธ์— ์ข…์† ๋œ๋‹ค๊ณ  ์ƒ๊ฐํ•ด์„œ ๋„๋ฉ”์ธ ์ปดํฌ๋„ŒํŠธ๋กœ ๋ถ„๋ฆฌํ–ˆ์Šต๋‹ˆ๋‹ค
ํ˜น์‹œ ์ด์— ๋Œ€ํ•ด์„œ๋Š” ์–ด๋–ป๊ฒŒ ์ƒ๊ฐํ•˜์‹œ๋‚˜์š”??

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • ์ข‹์€ ์˜๊ฒฌ์ด๋„ค์š”. "๊ธฐ์ด์ˆ˜ ๊ณผ๋ชฉ์— ๋Œ€ํ•œ ์ •๋ณด(์ œ๋ชฉ)์„ ๋ Œ๋”๋งํ•œ๋‹ค"๋ผ๋Š” ์—ญํ• ๋กœ ์ •์˜ํ•˜๋ฉด ๋„๋ฉ”์ธ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๋งž์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์ œ ์˜๊ฒฌ์œผ๋ก  ํ˜„์žฌ taken lecture title ์ปดํฌ๋„ŒํŠธ๊ฐ€ ํ•ด๋‹น ์—ญํ• ์„ ์ถฉ์‹คํžˆ ์ˆ˜ํ–‰ํ•˜๊ณ  ์žˆ๋‹ค๊ณ  ๋ณด์ด์ง€๋Š” ์•Š์Šต๋‹ˆ๋‹ค. ์ด ๋ถ€๋ถ„์— ๋Œ€ํ•ด ํšŒ๊ณ  ์‹œ๊ฐ„์— ๋” ์ด์•ผ๊ธฐํ•ด ๋ณด๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™๋„ค์š”!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

taken-lecture-title์ด๋ผ๋Š” ๋„ค์ด๋ฐ์ด ์ ์ ˆํ•˜์ง€์•Š๋‹ค๋Š” ์ƒ๊ฐ์ด ๋“ญ๋‹ˆ๋‹ค. ํ•ด๋‹น ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๊ฒฐ๊ณผ ํŽ˜์ด์ง€์—์„œ๋„ ์žฌ์‚ฌ์šฉ๋  ๊ฒƒ์œผ๋กœ ์˜ˆ์ƒ๋˜๋Š”๋ฐ, ๊ธฐ์ด์ˆ˜๊ณผ๋ชฉ ๋ฟ๋งŒ์•„๋‹ˆ๋ผ ๋ฏธ์ด์ˆ˜๊ณผ๋ชฉ์„ ํ‘œ์‹œํ• ๋•Œ๋„ ํ•จ๊ป˜ ๋…ธ์ถœ๋˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

๊ฒฐ๊ณผํŽ˜์ด์ง€์—์„œ ํ•ด๋‹น ์ปดํฌ๋„ŒํŠธ๋ฅผ ์žฌ์‚ฌ์šฉํ•ด์„œ ๋…ธ์ถœํ•  ๊ฒƒ์œผ๋กœ ์˜ˆ์ƒ๋˜๋Š” (ํ˜„์žฌ ๋“ค์€ ํ•™์ /
๊ธฐ์ค€ ํ•™์ )์ •๋ณด๊ฐ€ ๋ฏธ์ด์ˆ˜ ๊ณผ๋ชฉ ํ‘œ์‹œ์—์„œ ์‚ฌ์šฉ๋˜๋Š” ๊ฒฝ์šฐ์—๋„ ๊ธฐ์ด์ˆ˜๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋…ธ์ถœ ํ•˜๊ณ  ์žˆ์ง€๋งŒ, ์ด๋Š” ๊ธฐ์ด์ˆ˜์— ๋Œ€ํ•œ title์ด ์•„๋‹ˆ๋ผ table์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ๋…ธ์ถœํ•˜๋Š” ๊ฒƒ์ด๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.

๋”ฐ๋ผ์„œ,

  1. table-info ๋„ค์ด๋ฐ์„ ๋ณ€๊ฒฝํ•˜๊ณ 
    • ๋ฐ˜๋“œ์‹œ ํ•ด๋‹น ์ด๋ฆ„์ผ ํ•„์š”๋Š” ์—†๊ณ , table์— ์˜์กดํ•œ ๋„ค์ด๋ฐ
  2. view์ปดํฌ๋„ŒํŠธ๋กœ ์œ„์น˜
    ์‹œํ‚ค๋Š”๊ฒƒ์ด ์ ์ ˆํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋ฏธ์ด์ˆ˜ ๊ณผ๋ชฉ ํ‘œ์‹œ์—๋„ ๋…ธ์ถœ๋˜๋Š” ๊ฑธ ์ƒ๊ฐํ•˜์ง€ ๋ชปํ–ˆ๋„ค์š”! taken lecture์—์„œ lecture๋กœ ๋ณ€๊ฒฝํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค!
table์— ์˜์กดํ•œ ๋„ค์ด๋ฐ์„ ๋ง์”€ํ•˜์…จ๋Š”๋ฐ ์•„๋ž˜ ๊ฐ™์€ ๊ฒฝ์šฐ์—๋„ taken-lecture-title ์ปดํฌ๋„ŒํŠธ๋Š” ์‚ฌ์šฉ๋  ์˜ˆ์ •์ž…๋‹ˆ๋‹ค!
table์— ์˜์กดํ•œ ๋„ค์ด๋ฐ์„ ๊ฐ€์ ธ๊ฐ€๊ธฐ์—” ์• ๋งคํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ•˜๋Š”๋ฐ ํ˜น์‹œ ์–ด๋–ป๊ฒŒ ์ƒ๊ฐํ•˜์‹œ๋‚˜์š”!? ( ์ €๋ฒˆ์— ์นดํŽ˜์—์„œ ์ €ํฌ๋ผ๋ฆฌ ์–˜๊ธฐํ–ˆ๋˜ ๊ฑฐ,,,,,, ๊ธฐ์–ตํ•˜์‹œ๋‚˜์—ฌ??)
image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋ชจํ˜ธํ•œ ๋ถ€๋ถ„์ด ์žˆ๋‹ค๋Š” ์˜๊ฒฌ์— ๋Œ€ํ•ด์„œ ๊ณต๊ฐํ•ฉ๋‹ˆ๋‹ค. table์—์„œ ์˜์กด์„ฑ์„ ๊ฐ€์ ธ๊ฐ€๊ธด ์–ด๋ ค์šธ ๊ฒƒ ๊ฐ™๋„ค์š”.

์ €๋ฒˆ์— ์นดํŽ˜์—์„œ ์ €ํฌ๋ผ๋ฆฌ ์–˜๊ธฐํ–ˆ๋˜ ๊ฑฐ,,,,,, ๊ธฐ์–ตํ•˜์‹œ๋‚˜์—ฌ??

์‹ฌ์‹ฌํ•œ ์‚ฌ๊ณผ์˜ ๋ง์”€...์„ ์ „ํ•˜๋ฉฐ, ์ •ํ™•ํ•œ ๋Œ€ํ™”์˜ ํ๋ฆ„์€ ๊ธฐ์–ต์ด ๋‚˜์ง€์•Š์ง€๋งŒ ๋‹น์‹œ์—๋„ ๋น„์Šทํ•œ ๋ฌธ์ œ๋กœ ์ด์•ผ๊ธฐ๋ฅผ ๋‚˜๋ˆด๋˜ ๊ฒƒ์œผ๋กœ ๊ธฐ์–ตํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. lecture-info ๋“ฑ ์—ฌ๋Ÿฌ ํ›„๋ณด๊ตฐ์ด ์žˆ์—ˆ๋˜ ๊ฒƒ์œผ๋กœ ๊ธฐ์–ตํ•˜๋Š”๋ฐ ํ•ด๋‹น ๋„ค์ด๋ฐ์€ ๋‚ด์ผ ํšŒ์˜๋•Œ ์ด์•ผ๊ธฐํ•ด๋ด๋„ ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค !

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>
);
}
14 changes: 9 additions & 5 deletions app/ui/view/molecule/list/list-root.tsx
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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[comment]

  • ์ œ๋„ค๋ฆญ์—์„œ string์ด๋ž‘ number๋กœ๋งŒ ํƒ€์ž…์„ ์ œํ•œํ•œ ์ด์œ ๊ฐ€ ์žˆ์„๊นŒ์š”?

Copy link
Member Author

Choose a reason for hiding this comment

The 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>
);
}
43 changes: 38 additions & 5 deletions app/ui/view/molecule/table/index.tsx
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>
);
}
41 changes: 0 additions & 41 deletions app/ui/view/molecule/table/table-root.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion app/ui/view/molecule/table/table.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from '@storybook/react';
import Table from '.';
import Button from '../../atom/button/button';
import { Table } from '.';

const meta = {
title: 'ui/view/molecule/Table',
Expand Down
Loading