From ef175091ce14ac5ecfacccb358b68b49d4c081ee Mon Sep 17 00:00:00 2001 From: hwinkr Date: Tue, 1 Aug 2023 19:22:00 +0900 Subject: [PATCH 1/8] =?UTF-8?q?Chore:=20AnnounceItem=20=ED=83=80=EC=9E=85?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/@types/announcement.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/@types/announcement.ts b/src/@types/announcement.ts index 0834ac7a..db26c25f 100644 --- a/src/@types/announcement.ts +++ b/src/@types/announcement.ts @@ -1,9 +1,13 @@ +type AnnounceItemType = '고정' | '일반'; + export interface AnnounceItem { id: number; - major: string; title: string; link: string; content: string; uploadDate: string; - graduate: string | null; } + +export type AnnounceItemList = { + [key in AnnounceItemType]: AnnounceItem[]; +}; From 97de5851cb5baf28e79ea05dc2900457fd5f8c79 Mon Sep 17 00:00:00 2001 From: hwinkr Date: Tue, 1 Aug 2023 19:22:42 +0900 Subject: [PATCH 2/8] =?UTF-8?q?Test:=20=EA=B3=A0=EC=A0=95,=20=EC=9D=BC?= =?UTF-8?q?=EB=B0=98=20=EB=82=98=EB=88=88=EA=B2=83=20=EC=A0=81=EC=9A=A9?= =?UTF-8?q?=ED=95=B4=EC=84=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Card/AnnounceCard/index.test.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/Card/AnnounceCard/index.test.tsx b/src/components/Card/AnnounceCard/index.test.tsx index 201e4db5..6558704d 100644 --- a/src/components/Card/AnnounceCard/index.test.tsx +++ b/src/components/Card/AnnounceCard/index.test.tsx @@ -1,7 +1,7 @@ import http from '@apis/http'; import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import { AnnounceItem } from '@type/announcement'; +import { AnnounceItemList } from '@type/announcement'; import { MemoryRouter } from 'react-router-dom'; import AnnounceCard from '.'; @@ -29,16 +29,18 @@ describe('공지사항 카드 컴포넌트 테스트', () => { const axiosResult = await http.get( '/api/announcement?major=컴퓨터인공지능학부', ); - const announceList: AnnounceItem[] = axiosResult.data; + const announceList: AnnounceItemList = axiosResult.data; - announceList.forEach(async (annouce) => { + const { 고정, 일반 } = announceList; + + 일반.forEach(async (annouce) => { render(, { wrapper: MemoryRouter }); }); const annouceCards = screen.getAllByTestId('card'); annouceCards.forEach(async (card, idx) => { await userEvent.click(card); - expect(window.location.href).toBe(announceList[idx].link); + expect(window.location.href).toBe(일반[idx].link); }); }); }); From eb4206db6216df7c24d2fcd62cabc35a06119dca Mon Sep 17 00:00:00 2001 From: hwinkr Date: Tue, 1 Aug 2023 19:23:11 +0900 Subject: [PATCH 3/8] =?UTF-8?q?Refactor:=20AnnounceCard=EC=97=90=20pinned?= =?UTF-8?q?=20prop=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Card/AnnounceCard/index.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/Card/AnnounceCard/index.tsx b/src/components/Card/AnnounceCard/index.tsx index a5326084..1522d83d 100644 --- a/src/components/Card/AnnounceCard/index.tsx +++ b/src/components/Card/AnnounceCard/index.tsx @@ -3,12 +3,22 @@ import styled from '@emotion/styled'; import { THEME } from '@styles/ThemeProvider/theme'; import { AnnounceItem } from '@type/announcement'; -const AnnounceCard = ({ title, link, uploadDate }: AnnounceItem) => { +interface AnnounceCardProps extends AnnounceItem { + pinned?: boolean; +} + +const AnnounceCard = ({ + title, + link, + uploadDate, + pinned = false, +}: AnnounceCardProps) => { const onClick = () => { window.location.href = link; }; return ( + {pinned &&
고정
}
Date: Tue, 1 Aug 2023 19:23:35 +0900 Subject: [PATCH 4/8] =?UTF-8?q?Refactoe:=20=EA=B3=B5=EC=A7=80=EC=82=AC?= =?UTF-8?q?=ED=95=AD=20=EA=B3=A0=EC=A0=95,=20=EC=9D=BC=EB=B0=98=20?= =?UTF-8?q?=EB=82=98=EB=88=88=EA=B2=83=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Card/AnnounceCard/AnnounceList/index.tsx | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/components/Card/AnnounceCard/AnnounceList/index.tsx b/src/components/Card/AnnounceCard/AnnounceList/index.tsx index b839a305..35396306 100644 --- a/src/components/Card/AnnounceCard/AnnounceList/index.tsx +++ b/src/components/Card/AnnounceCard/AnnounceList/index.tsx @@ -1,9 +1,9 @@ -import { AnnounceItem } from '@type/announcement'; -import { AxiosError, AxiosResponse } from 'axios'; +import { AnnounceItemList } from '@type/announcement'; +import { AxiosError } from 'axios'; import AnnounceCard from '..'; -type Resource = AxiosResponse | AxiosError | null; +type Resource = AnnounceItemList | AxiosError | null; interface AnnounceListProps { resource: { @@ -14,15 +14,23 @@ interface AnnounceListProps { const AnnounceList = ({ resource }: AnnounceListProps) => { const announceList: Resource = resource.read(); + if (announceList === null || announceList instanceof Error) { + return null; + } + const { 고정: pinned, 일반: normal } = announceList as AnnounceItemList; + return ( <> - {Array.isArray(announceList) - ? announceList.map((announce, idx) => ( -
- -
- )) - : null} + {pinned.map((announce, idx) => ( +
+ +
+ ))} + {normal.map((announce, idx) => ( +
+ +
+ ))} ); }; From e7a87fd344ababd5ffa60f47acea8a50e4c6c596 Mon Sep 17 00:00:00 2001 From: hwinkr Date: Tue, 1 Aug 2023 19:57:59 +0900 Subject: [PATCH 5/8] =?UTF-8?q?Config:=20=ED=99=95=EC=84=B1=EA=B8=B0=20?= =?UTF-8?q?=EC=95=84=EC=9D=B4=EC=BD=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/@types/styles/icon.ts | 3 ++- src/components/Icon/index.tsx | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/@types/styles/icon.ts b/src/@types/styles/icon.ts index feea7006..ea8b12f3 100644 --- a/src/@types/styles/icon.ts +++ b/src/@types/styles/icon.ts @@ -12,4 +12,5 @@ export type IconKind = | 'right' | 'checkedRadio' | 'uncheckedRadio' - | 'cancel'; + | 'cancel' + | 'speaker'; diff --git a/src/components/Icon/index.tsx b/src/components/Icon/index.tsx index 04cbdcac..b4ea13fb 100644 --- a/src/components/Icon/index.tsx +++ b/src/components/Icon/index.tsx @@ -15,6 +15,7 @@ import { MdRadioButtonUnchecked, MdRadioButtonChecked, MdOutlineCancel, + MdCampaign, } from 'react-icons/md'; const ICON: { [key in IconKind]: IconType } = { @@ -32,6 +33,7 @@ const ICON: { [key in IconKind]: IconType } = { checkedRadio: MdRadioButtonChecked, uncheckedRadio: MdRadioButtonUnchecked, cancel: MdOutlineCancel, + speaker: MdCampaign, }; interface IconProps { From 4a94d606c225024e4697290e211203953621a1c5 Mon Sep 17 00:00:00 2001 From: hwinkr Date: Tue, 1 Aug 2023 19:58:29 +0900 Subject: [PATCH 6/8] =?UTF-8?q?Chore:=20=ED=95=99=EA=B5=90=20=EA=B3=B5?= =?UTF-8?q?=EC=A7=80=EC=82=AC=ED=95=AD=20=EA=B3=A0=EC=A0=95,=20=EC=9D=BC?= =?UTF-8?q?=EB=B0=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mocks/handlers/announceHandlers.ts | 111 +++++++++++++++++-------- 1 file changed, 75 insertions(+), 36 deletions(-) diff --git a/src/mocks/handlers/announceHandlers.ts b/src/mocks/handlers/announceHandlers.ts index 9933a6db..e8a7f90d 100644 --- a/src/mocks/handlers/announceHandlers.ts +++ b/src/mocks/handlers/announceHandlers.ts @@ -7,46 +7,85 @@ export const announceHandlers: RequestHandler[] = [ if (query.get('major') === 'undefined') { return res( ctx.status(200), - ctx.json([ - { - title: - '★대학원생 취·창업 역량 강화 프로그램★ 4단계 BK21 대학원혁신지원사업', - link: 'https://www.pknu.ac.kr/main/163?action=view&no=711472&cd=10001', - uploadDate: '2023-07-17', - }, - { - title: '2023-2학기 재(복)학생, 재입학생 등록금 납부 안내', - link: 'https://www.pknu.ac.kr/main/163?action=view&no=711433&cd=10001', - uploadDate: '2023-07-14', - }, - { - title: '2023-2학기 재(복)학생 등록금 분할납부 신청 안내', - link: 'https://www.pknu.ac.kr/main/163?action=view&no=711431&cd=10001', - uploadDate: '2023-07-14', - }, - ]), + ctx.json({ + 고정: [ + { + title: '2023-2학기 국가근로장학금 대학신청 일정 안내', + link: 'https://www.pknu.ac.kr/main/163?action=view&no=711641', + uploadDate: '2023-08-01', + }, + { + title: '2023-2학기 재(복)학생, 재입학생 등록금 납부 안내', + link: 'https://www.pknu.ac.kr/main/163?action=view&no=711433', + uploadDate: '2023-07-14 ', + }, + { + title: '2023-2학기 재(복)학생 등록금 분할납부 신청 안내', + link: 'https://www.pknu.ac.kr/main/163?action=view&no=711431', + uploadDate: '2023-07-14', + }, + ], + 일반: [ + { + title: '2023 정보융합대학 프로그래밍 경진대회 개최 (5/17)', + link: 'https://ce.pknu.ac.kr/ce/1814?action=view&no=9934358', + uploadDate: '2023-04-27', + }, + { + title: '★ (05/01부터 적용) 출석 인정 신청 방법 안내 ★', + link: 'https://ce.pknu.ac.kr/ce/1814?action=view&no=9934257', + uploadDate: '2023-04-26 ', + }, + { + title: + '2023-1학기 (재)부경대학교발전기금재단 정효택장학생 선발 안내(5/8~5/11)', + link: 'https://ce.pknu.ac.kr/ce/1814?action=view&no=9934104', + uploadDate: '2023-04-20', + }, + ], + }), ); } else if (query.get('major') === '컴퓨터인공지능학부') { return res( ctx.status(200), - ctx.json([ - { - title: '2023 정보융합대학 프로그래밍 경진대회 개최 (5/17)', - link: 'https://ce.pknu.ac.kr/ce/1814?action=view&no=9934358', - uploadDate: '2023-04-27', - }, - { - title: '★ (05/01부터 적용) 출석 인정 신청 방법 안내 ★', - link: 'https://ce.pknu.ac.kr/ce/1814?action=view&no=9934257', - uploadDate: '2023-04-26 ', - }, - { - title: - '2023-1학기 (재)부경대학교발전기금재단 정효택장학생 선발 안내(5/8~5/11)', - link: 'https://ce.pknu.ac.kr/ce/1814?action=view&no=9934104', - uploadDate: '2023-04-20', - }, - ]), + ctx.json({ + 고정: [ + { + title: '2023 정보융합대학 프로그래밍 경진대회 개최 (5/17)', + link: 'https://ce.pknu.ac.kr/ce/1814?action=view&no=9934358', + uploadDate: '2023-04-27', + }, + { + title: '★ (05/01부터 적용) 출석 인정 신청 방법 안내 ★', + link: 'https://ce.pknu.ac.kr/ce/1814?action=view&no=9934257', + uploadDate: '2023-04-26 ', + }, + { + title: + '2023-1학기 (재)부경대학교발전기금재단 정효택장학생 선발 안내(5/8~5/11)', + link: 'https://ce.pknu.ac.kr/ce/1814?action=view&no=9934104', + uploadDate: '2023-04-20', + }, + ], + 일반: [ + { + title: '2023 정보융합대학 프로그래밍 경진대회 개최 (5/17)', + link: 'https://ce.pknu.ac.kr/ce/1814?action=view&no=9934358', + uploadDate: '2023-04-27', + }, + { + title: '★ (05/01부터 적용) 출석 인정 신청 방법 안내 ★', + link: 'https://ce.pknu.ac.kr/ce/1814?action=view&no=9934257', + uploadDate: '2023-04-26 ', + }, + { + title: + '2023-1학기 (재)부경대학교발전기금재단 정효택장학생 선발 안내(5/8~5/11)', + link: 'https://ce.pknu.ac.kr/ce/1814?action=view&no=9934104', + uploadDate: '2023-04-20', + }, + ], + }), ); } }), From e2209fe064825fc55e312f141d3880e0f1b8db59 Mon Sep 17 00:00:00 2001 From: hwinkr Date: Tue, 1 Aug 2023 19:59:05 +0900 Subject: [PATCH 7/8] =?UTF-8?q?Chore:=20=ED=99=95=EC=84=B1=EA=B8=B0=20?= =?UTF-8?q?=EC=95=84=EC=9D=B4=EC=BD=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Card/AnnounceCard/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/Card/AnnounceCard/index.tsx b/src/components/Card/AnnounceCard/index.tsx index 1522d83d..cab19336 100644 --- a/src/components/Card/AnnounceCard/index.tsx +++ b/src/components/Card/AnnounceCard/index.tsx @@ -1,3 +1,4 @@ +import Icon from '@components/Icon'; import { css } from '@emotion/react'; import styled from '@emotion/styled'; import { THEME } from '@styles/ThemeProvider/theme'; @@ -18,13 +19,13 @@ const AnnounceCard = ({ }; return ( - {pinned &&
고정
}
+ {pinned && } {title}
Date: Tue, 1 Aug 2023 20:00:06 +0900 Subject: [PATCH 8/8] =?UTF-8?q?Chore:=20Axios=20=ED=83=80=EC=9E=85=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Card/AnnounceCard/AnnounceList/index.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/Card/AnnounceCard/AnnounceList/index.tsx b/src/components/Card/AnnounceCard/AnnounceList/index.tsx index 35396306..d6f28700 100644 --- a/src/components/Card/AnnounceCard/AnnounceList/index.tsx +++ b/src/components/Card/AnnounceCard/AnnounceList/index.tsx @@ -1,9 +1,13 @@ import { AnnounceItemList } from '@type/announcement'; -import { AxiosError } from 'axios'; +import { AxiosError, AxiosResponse } from 'axios'; import AnnounceCard from '..'; -type Resource = AnnounceItemList | AxiosError | null; +type Resource = + | AxiosResponse + | AnnounceItemList + | AxiosError + | null; interface AnnounceListProps { resource: {