Skip to content

Commit

Permalink
feat: 수강신청 관련 modal, 연결 (#37)
Browse files Browse the repository at this point in the history
* feat: .gitignore 수정, .env 제거

* chore: env ignore

* feat: 관심과목 페이지 레이아웃, 강좌조회 구현 #19

* feat: 신청, 삭제 버튼 레이아웃 구현 #19

* feat: 관심과목 담기 api 연동 #19

* feat: 관심과목 등록 내역 조회 기능 구현, api 연동 #19

* feat: 강의 삭제 api 연동 #19

* feat: 등록과목수, 학점 동적 업데이트 #19

* feat: 검색 버튼 로고 추가 #19

* feat: 접속 대기시간 모달 추가

* feat: 매크로 방지 코드 modal 추가

* feat: 수강 신청 안내 모달

* Merge develop

* feat: 수강 인원 정보, 데이터 처리 로딩바 추가

* feat: 백엔드 연결 완료

* fix: modal 안나오는 문제 해결

* refactor: 타입 수정

---------

Co-authored-by: zhy2on <52701529+zhy2on@users.noreply.github.com>
  • Loading branch information
Anhye0n and zhy2on authored Aug 3, 2024
1 parent 3ab93e3 commit 39b0f3b
Show file tree
Hide file tree
Showing 22 changed files with 1,084 additions and 25 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>수강신청</title>
</head>
Expand Down
Binary file added public/favicon.ico
Binary file not shown.
10 changes: 10 additions & 0 deletions src/apis/api/course.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,13 @@ export const deleteCourse = async (id: number) => {
console.error('delete course fail: ', error);
}
};

export const getMacroCode = async () => {
try {
const {data} = await baseAPI.get('/api/auth/macro');
return data;
} catch (error) {
console.error('Get macro code fail', error);
throw error;
}
};
Binary file added src/assets/img/check.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/img/logo.webp
Binary file not shown.
Binary file added src/assets/img/warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/components/CourseRegister/RegisterFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function RegisterFilters({setList}: FiltersProps) {
</CuriNoWrap>
);
} else {
return <FilterInput sizes='l' onChange={value => handleInput(value)} />;
return <FilterInput disabled={searchOption === '관심과목'} sizes='l' onChange={value => handleInput(value)} />;
}
};

Expand Down Expand Up @@ -121,7 +121,7 @@ function RegisterFilters({setList}: FiltersProps) {
</SearchWrap>
</SearchBox>
</FilterBox>
<FilterButton label='검색' filter={filter} setList={setList} />
<FilterButton label='검색' page='수강신청' filter={filter} setList={setList} />
</RegisterFilterContainer>
);
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/CourseRegister/RegisteredList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ function RegisteredList() {
await getRegisterdList().then(res => {
if (res) {
setList(res);
return;
}

setList([]);
});
};

Expand All @@ -37,7 +40,6 @@ function RegisteredList() {
}, []);

const handleAction = async (
action: string,
scheduleId: number | undefined,
) => {
if (scheduleId) {
Expand Down
25 changes: 9 additions & 16 deletions src/components/CourseRegister/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {useEffect, useState} from 'react';
import {useAppSelector} from '@/store/hooks';
import {useState} from 'react';
import {CourseTypes} from '@/assets/types/tableType';
import RegisterFilters from './RegisterFilters';
import Table from '../common/Table';
import {TableTitle, TableTitleWrap} from '../LectureList';
import {getWishlist, postCourse} from '@/apis/api/course';
import RegisteredList from './RegisteredList';
import {useDispatch} from 'react-redux';
import {setCourseName, setModalName, setScheduleId} from '@store/modalSlice.ts';

const colData = [
{name: 'action', value: '신청', initialWidth: 30, enableFilters: false},
Expand All @@ -24,27 +24,20 @@ const colData = [
];

function CourseRegister() {
const studentId = useAppSelector(state => state.userInfo.username);
const [list, setList] = useState<CourseTypes[]>([]);

useEffect(() => {
const getList = async () => {
await getWishlist(studentId).then(res => {
setList(res);
});
};

getList();
}, []);
const dispatch = useDispatch();

const handleAction = async (
action: string,
scheduleId: number | undefined,
curiNm: string | undefined,
) => {
if (scheduleId) {
await postCourse(scheduleId).then(() => {
console.log('register success');
});
// 접속 대기 띄우기
dispatch(setScheduleId(scheduleId));
dispatch(setCourseName(curiNm));

Check failure on line 39 in src/components/CourseRegister/index.tsx

View workflow job for this annotation

GitHub Actions / build

Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
dispatch(setModalName('macro'));
}
};

Expand Down
22 changes: 21 additions & 1 deletion src/components/common/FilterButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,37 @@ import search from '@assets/img/search.png';
import {CourseTypes} from '@/assets/types/tableType';
import {getCourseList, getWishlist} from '@/apis/api/course';
import {useAppSelector} from '@/store/hooks';
import {openModalHandler} from '@components/common/Modal/handlers/handler.tsx';
import {useDispatch} from 'react-redux';

interface ButtonProps {
label: string;
page?: string;
filter?: CourseTypes;
setList: React.Dispatch<React.SetStateAction<CourseTypes[]>>;
}

function FilterButton({label, filter = {}, setList}: ButtonProps) {
function FilterButton({label, page, filter = {}, setList}: ButtonProps) {
const studentId = useAppSelector(state => state.userInfo.username);

const dispatch = useDispatch();
const handleClick = async () => {

if (page === '수강신청') {
if (!confirm('수강신청 연습 시작하시겠습니까?')) return;

openModalHandler(dispatch, 'waiting');

const getList = async () => {
await getWishlist(studentId).then(res => {
setList(res);
});
};

getList();
return;
}

if (filter.curiNm === 'wish') {
await getWishlist(studentId).then(res => {
setList(res);
Expand Down
8 changes: 7 additions & 1 deletion src/components/common/FilterInput.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import styled, { css } from 'styled-components';

interface InputInterface {
disabled?: boolean;
sizes: string;
onChange: (value: string) => void;
}

function FilterInput({ sizes, onChange }: InputInterface) {
function FilterInput({ disabled, sizes, onChange }: InputInterface) {
return (
<>
<InputWrap
disabled={disabled}
sizes={sizes}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
onChange(e.target.value)
Expand Down Expand Up @@ -50,6 +52,10 @@ const InputWrap = styled.input<{ sizes: string }>`
height: 2.4rem;
border: 1px solid ${props => props.theme.colors.neutral5};
padding-left: 0.8rem;
&:disabled {
background: ${props => props.theme.colors.neutral5};
}
`;

export default FilterInput;
Loading

0 comments on commit 39b0f3b

Please sign in to comment.