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

[Refactor]Complete #110

Merged
merged 38 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1de7d2e
setting: TypeScript 라이브러리 설치
zelkovaria Apr 21, 2024
d73eec6
setting: Type 설치
zelkovaria Apr 21, 2024
c70683c
setting: tsconfig 파일 추가
zelkovaria Apr 21, 2024
80f5593
refactor: Apply 페이지의 기본적인 요소들에 type 지정
zelkovaria Apr 21, 2024
e79533b
refactor: SVG 파일 type 선언 추가
zelkovaria Apr 22, 2024
983c86a
refactor: CardLanyard component를 tsx로 리팩토링
zelkovaria Apr 22, 2024
a964217
refactor: SmallButton component를 tsx로 리팩토링
zelkovaria Apr 22, 2024
fd8f688
fix: pcWidth를 로 수정
zelkovaria Apr 22, 2024
24d3e04
refactor: 지원한 이력에 대한 isExist 변수명을 hasAlreadyApplied로 변경
zelkovaria Apr 23, 2024
2f91ecf
refactor: isExist의 초기값 수정
zelkovaria Apr 26, 2024
afcab09
refactor: statusCode에 type 명시
zelkovaria Apr 26, 2024
a3236cd
refactor: sethasAlreadyApplied 함수명 수정
zelkovaria Apr 27, 2024
96022ba
Merge pull request #109 from mju-likelion/apply
zelkovaria Apr 28, 2024
680aa2d
refactor: Theme에서 typographies 분리
zelkovaria May 7, 2024
e35dcd7
refactor: Theme에서 colors 분리
zelkovaria May 7, 2024
a1bce28
refactor: Theme 파일 삭제 및 device별 size 분리
zelkovaria May 7, 2024
09e900b
refactor: styles에 index 파일 추가
zelkovaria May 7, 2024
765270d
refactor: App에서 import되는 theme 수정
zelkovaria May 7, 2024
e355a9b
refactor: Complete 컴포넌트를 ts로 리팩토링
zelkovaria May 7, 2024
8edf0a8
fix: CardLanyard 컴포넌트의 theme 관련 prop 수정
zelkovaria May 7, 2024
294de05
fix: SmallButton 컴포넌트의 theme 관련 prop 수정
zelkovaria May 7, 2024
93dba6b
fix: Apply 컴포넌트의 theme 관련 prop 수정
zelkovaria May 7, 2024
75c95f5
refactor: InputWraaper 컴포넌트 명을 InputWrapper로 수정
zelkovaria May 7, 2024
0c2beef
refactor: rest 사용 수정
zelkovaria May 7, 2024
7a1f3c4
refactor: Apply의 StatusCode를 enum으로 관리
zelkovaria May 7, 2024
8de0bb2
refactor: ERROR_CODE의 이름을 STATUS_CODE로 수정
zelkovaria May 8, 2024
cf20a1f
fix: error의 type 삭제
zelkovaria May 10, 2024
3769577
refactor: blank line추가
zelkovaria May 12, 2024
1df5705
refactor: theme를 camelCase로 변경
zelkovaria May 12, 2024
5bcec7d
refactor: styles 파일들 확장자 변경
zelkovaria May 12, 2024
8f2ebe9
refactor: 일반 컴포넌트 props naming의 $ 제거
zelkovaria May 15, 2024
e3d0cb1
refactor: CardLanyard의 prop들 type 변경 및 반영
zelkovaria May 15, 2024
e0b430d
refactor: boolean type을 optioanl하게 변경 및 default 값 지정
zelkovaria May 15, 2024
d55a552
refactor: styles import 경로 수정
zelkovaria May 15, 2024
97e3f2c
fix: 비정상적인 setIsLoading 수정
zelkovaria May 15, 2024
99ac726
setting: typescript parser 추가
zelkovaria May 20, 2024
034cf61
setting: 불필요한 dependency 제거
zelkovaria May 20, 2024
941739c
refactor: 주석 convention 수정
zelkovaria May 21, 2024
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
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.7",
"@types/react": "^18.2.79",
"@types/react-dom": "^18.2.25",
"@types/react-router-dom": "^5.3.3",
"axios": "^1.6.5",
"react": "^18.2.0",
"react-confetti": "^6.1.0",
Expand All @@ -21,6 +26,7 @@
"react-toastify": "^10.0.4",
"styled-components": "^6.1.8",
"styled-reset": "^4.5.2",
"typescript": "^5.4.5",
"web-vitals": "^2.1.4",
"yup": "^1.3.3"
},
Expand Down Expand Up @@ -49,6 +55,7 @@
]
},
"devDependencies": {
"@types/styled-components": "^5.1.34",
zelkovaria marked this conversation as resolved.
Show resolved Hide resolved
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jsx-a11y": "^6.8.0",
Expand Down
7 changes: 2 additions & 5 deletions src/App.js → src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { ThemeProvider } from 'styled-components';
import { BrowserRouter } from 'react-router-dom';
import { Theme } from './styles/Theme';
import { theme } from './styles/index';
zelkovaria marked this conversation as resolved.
Show resolved Hide resolved
import GlobalStyle from './styles/GlobalStyle';
import RoutesContainer from './components/RoutesContainer';
import useRouteTracker from './hooks/useRouteTracker';

function App() {
// useRouteTracker();

return (
<ThemeProvider theme={Theme}>
<ThemeProvider theme={theme}>
<GlobalStyle />
<BrowserRouter>
<RoutesContainer />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,40 @@
import styled from 'styled-components';
import { PropsWithChildren } from 'react';
import { ReactComponent as CardString } from '../../assets/imgs/card_string_bg.svg';

/**
* @param {string} width
* @param {string} height
*/
interface CardLanyardProps {
width: string;
height: string;
$pcWidth: string;
$pcHeight: string;
zelkovaria marked this conversation as resolved.
Show resolved Hide resolved
}

const CardLanyard = ({ width, height, pcWidth, pcHeight, children }) => {
const CardLanyard = ({
width,
height,
$pcWidth,
$pcHeight,
children,
}: PropsWithChildren<CardLanyardProps>) => {
return (
<CardContainer
width={width}
height={height}
$pcWidth={pcWidth}
$pcHeight={pcHeight}
$pcWidth={$pcWidth}
$pcHeight={$pcHeight}
>
<NameCardString />
<CardBody>{children}</CardBody>
</CardContainer>
);
};

const CardContainer = styled.div`
const CardContainer = styled.div<CardLanyardProps>`
position: relative;
width: ${({ width }) => width};
height: ${({ height }) => height};

@media ${({ theme }) => theme.devices.DESKTOP} {
@media ${({ theme }) => theme.size.desktop} {
width: ${({ $pcWidth }) => $pcWidth};
height: ${({ $pcHeight }) => $pcHeight};
}
Expand All @@ -38,7 +47,7 @@ const NameCardString = styled(CardString)`
top: -44px;
width: 64px;
height: 62px;
@media ${({ theme }) => theme.devices.DESKTOP} {
@media ${({ theme }) => theme.size.desktop} {
top: -88px;
width: 126px;
height: 122px;
Expand All @@ -49,7 +58,7 @@ const CardBody = styled.div`
display: flex;
align-items: center;
justify-content: center;
background-color: ${({ theme }) => theme.colors.MODAL_BG};
background-color: ${({ theme }) => theme.colors.background200};
border-bottom: 24px;
box-shadow: 7px 6px 0.4em #161515;
border-radius: 24px;
Expand Down
38 changes: 0 additions & 38 deletions src/components/checkPage/SmallButton.js

This file was deleted.

50 changes: 50 additions & 0 deletions src/components/checkPage/SmallButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { PropsWithChildren } from 'react';
import styled from 'styled-components';

interface SmallButtonProps {
type: 'submit';
onClick?: React.MouseEventHandler<HTMLButtonElement>;
disabled: boolean;
zelkovaria marked this conversation as resolved.
Show resolved Hide resolved
}

const SmallButton = ({
children,
type,
onClick,
disabled,
}: PropsWithChildren<SmallButtonProps>) => {
return (
<Wrapper type={type} onClick={onClick} disabled={disabled}>
{children}
</Wrapper>
);
};

const Wrapper = styled.button`
border-radius: 40px;
font-size: 12px;
font-weight: 300;
padding: 9px 16px;
width: 110px;
height: 40px;
color: ${({ theme }) => theme.colors.white};
background-color: ${({ theme }) => theme.colors.pink100};

&:hover {
background-color: ${({ theme }) => theme.colors.pink200};
}

&:disabled {
background-color: ${({ theme }) => theme.colors.background100};
}

@media ${({ theme }) => theme.size.desktop} {
${({ theme }) => theme.typographies.smallBtnTxt};
padding: 14px 48px;
border-radius: 40px;
width: 160px;
height: 54px;
}
`;

export default SmallButton;
62 changes: 38 additions & 24 deletions src/pages/Apply.js → src/pages/Apply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,28 @@ import Input from '../components/checkPage/Input';
import SmallButton from '../components/checkPage/SmallButton';
import { idValidationSchema } from '../validation/idValidationSchema';
import CheckCard from '../components/checkPage/CheckCard';
import axios, { AxiosError } from 'axios';

interface StudentData {
id: string;
}

enum STATUS_CODE {
'SUCCESS' = '201',
'SERVER_ERROR' = '401',
'ALREADY_APPLIED' = '4090',
}

const Apply = () => {
const [isExist, setIsExist] = useState(undefined);
const [hasAlreadyApplied, setHasAlreadyApplied] = useState<boolean>(false);
const [value, setValue] = useState('');
const [isLoading, setIsLoading] = useState(false);
const navigate = useNavigate();

const startDay = new Date('2024-03-01 00:00:00').getTime();
const lastDay = new Date('2024-03-07 23:59:59').getTime();

const handleFormSubmit = async (data) => {
const handleFormSubmit = async (data: StudentData) => {
setValue(data.id);

const today = new Date().getTime();
Expand All @@ -30,23 +41,26 @@ const Apply = () => {
const response = await Axios.post('/apply', {
studentId: data.id,
});
const statusCode = response.data.statusCode;
if (statusCode === '201') {
const statusCode: STATUS_CODE | undefined = response.data.statusCode;
if (statusCode === STATUS_CODE.SUCCESS) {
sessionStorage.setItem('studentId', data.id);
navigate('/write');
}
} catch (error) {
const statusCode = error.response.data.statusCode;
if (statusCode === '4090') {
setIsExist(true);
} else if (statusCode === '400') {
alert(error.response.data.message);
} else {
alert(
'서버에 이슈가 있습니다. 문제가 지속될 경우 관리자에게 문의해주세요.',
);
if (axios.isAxiosError(error)) {
const statusCode: STATUS_CODE | undefined =
error.response?.data.statusCode;
if (statusCode === STATUS_CODE.ALREADY_APPLIED) {
setHasAlreadyApplied(true);
} else if (statusCode === STATUS_CODE.SERVER_ERROR) {
alert(error.response?.data.message);
} else {
alert(
'서버에 이슈가 있습니다. 문제가 지속될 경우 메인 홈페이지의 채팅을 통해 관리자에게 문의해주세요.',
);
}
setIsLoading(false);
Copy link
Member

Choose a reason for hiding this comment

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

지금은 에러나는 경우에만 setIsLoading(false); 가 실행되고 있습니다. 오히려 정상적인 경우에는 loading 이 무제한으로 걸리고 있어요. 수정될 필요가 있습니다
finally 를 찾아보시는 것도 도움이 될거에요

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

말씀해주신대로 반영을 해서 수정해봤읍니다 ,,,!! 여유있으실 때 확인해주시면 감사하겠습니다 선생림!!🥹👍🏻

}
setIsLoading(false);
}
} else {
alert(
Expand Down Expand Up @@ -80,33 +94,33 @@ const Apply = () => {

return (
<Container>
{isExist === undefined && (
{!hasAlreadyApplied && (
<form onSubmit={handleSubmit(handleFormSubmit)}>
<CardLanyard
width={'250px'}
height={'318px'}
pcWidth={'544px'}
pcHeight={'358px'}
$pcWidth={'544px'}
$pcHeight={'358px'}
>
<ContentsWrapper>
<SubTitle>지원하기</SubTitle>
<InputWraaper>
<InputWrapper>
<Input
inputSize={inputSizeValue}
captionSize={captionSizeValue}
messageSize={messageSizeValue}
hookFormRegister={register}
messageErrors={errors}
/>
</InputWraaper>
</InputWrapper>
<SmallButton disabled={isLoading} type="submit">
{isLoading ? '로딩중' : '지원하기'}
</SmallButton>
</ContentsWrapper>
</CardLanyard>
</form>
)}
{isExist && <CheckCard status="rejected" value={value} />}
{hasAlreadyApplied && <CheckCard status="rejected" value={value} />}
</Container>
);
};
Expand All @@ -116,14 +130,14 @@ const Container = styled.div`
align-items: center;
width: 100%;
height: calc(100vh - 100px - 56px);
@media ${({ theme }) => theme.devices.TABLET} {
@media ${({ theme }) => theme.size.tablet} {
height: calc(100vh - 100px - 70px);
}
`;
const InputWraaper = styled.div`
const InputWrapper = styled.div`
margin: 34px 0 60px 0;

@media ${({ theme }) => theme.devices.DESKTOP} {
@media ${({ theme }) => theme.size.desktop} {
margin: 18px 0 40px 0;
}
`;
Expand All @@ -132,7 +146,7 @@ const ContentsWrapper = styled.div`
display: flex;
flex-direction: column;
align-items: center;
@media ${({ theme }) => theme.devices.DESKTOP} {
@media ${({ theme }) => theme.size.desktop} {
margin: 85px 54px 24px 52px;
}
`;
Expand Down
6 changes: 3 additions & 3 deletions src/pages/Check.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ const Check = () => {
>
<ContentsWrapper>
<SubTitle>지원 확인하기</SubTitle>
<InputWraaper>
<InputWrapper>
<Input
inputSize={inputSizeValue}
captionSize={captionSizeValue}
messageSize={messageSizeValue}
hookFormRegister={register}
messageErrors={errors}
/>
</InputWraaper>
</InputWrapper>
<SmallButton disabled={isLoading} type="submit">
{isLoading ? '로딩중' : '확인하기'}
</SmallButton>
Expand All @@ -96,7 +96,7 @@ const Container = styled.div`
height: calc(100vh - 100px - 70px);
}
`;
const InputWraaper = styled.div`
const InputWrapper = styled.div`
margin: 34px 0 60px 0;

@media ${({ theme }) => theme.devices.DESKTOP} {
Expand Down
Loading