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

학생 인증 기능 추가, 유저 정보 등록 리팩터링 #111

Merged
merged 35 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
435c447
feat: 스토리북 유틸리티 추가
mjsdo Jul 12, 2023
7ef22d8
feat: NameCard 추가
mjsdo Jul 12, 2023
2c013b4
feat: seconds 디폴트 값 추가
mjsdo Jul 12, 2023
a08fc86
feat: Track Type null 추가
mjsdo Jul 12, 2023
88daf97
feat: PreviewCertifiedMyInfo 추가
mjsdo Jul 12, 2023
173b0f3
fix: 타입 수정
mjsdo Jul 12, 2023
4803bac
feat: 학생 인증 성공 케이스 핸들링
mjsdo Jul 12, 2023
547e58b
feat: Button, MainLayout 스타일 업데이트
mjsdo Jul 13, 2023
8222a75
feat: RollingAllTracks 추가
mjsdo Jul 13, 2023
e9072c2
feat: IntroStudentCertification 페이지 추가
mjsdo Jul 13, 2023
036185d
feat: setMyInfo 파라미터 업데이트
mjsdo Jul 13, 2023
3155768
feat: gutter -> paddingX 이름 변경
mjsdo Jul 13, 2023
6d4589b
refactor: UserRegisterForm Context, Layout 삭제
mjsdo Jul 13, 2023
4da6f49
refactor: UserRegisterFormValues 타입 추가, Question 삭제
mjsdo Jul 13, 2023
745a0fc
refactor: css 업데이트
mjsdo Jul 13, 2023
16fd270
refactor: 유저정보 등록 페이지 submit handler 추가
mjsdo Jul 13, 2023
9714d3f
feat: intro page routes 추가
mjsdo Jul 13, 2023
e82e13a
chore: mock api 업데이트
mjsdo Jul 13, 2023
fb20f2d
chore: storybook 업데이트
mjsdo Jul 13, 2023
9b5d2dd
fix: undefined 세팅 안되는 문제
mjsdo Jul 13, 2023
d01e634
feat: IntroSsafyCertificationPage 스토리 추가, 조건 오류 수정
mjsdo Jul 13, 2023
301d1a3
fix: GlobalModal 스토리북 전역에서 렌더링하도록 변경
mjsdo Jul 13, 2023
4f264bc
fix: router 훅이 아니라 전역 router 사용하고 있던것 수정
mjsdo Jul 13, 2023
33c1f2b
feat: 스토리북에 Toaster 추가
mjsdo Jul 13, 2023
166139d
feat: SignIn, StudentCertification Page 스토리북 업데이트
mjsdo Jul 13, 2023
7e6f4f2
feat: RollingAllTracks 스토리 추가
mjsdo Jul 13, 2023
303649c
feat: RedirectionGuide 스토리 추가
mjsdo Jul 13, 2023
2d1eb3a
feat: 학생 인증 유도 페이지 버튼 텍스트 업데이트
mjsdo Jul 14, 2023
234174d
fix: 스토리 msw 핸들러 관련 버그 수정
mjsdo Jul 14, 2023
6cff1a4
fix: 버튼 텍스트 표시
mjsdo Jul 14, 2023
088425d
fix: 스토리 오타 수정
mjsdo Jul 14, 2023
437ac6f
refactor: page min height 추가
mjsdo Jul 14, 2023
210b1ca
refactor: page layout
mjsdo Jul 14, 2023
22a715b
refactor: page layout
mjsdo Jul 14, 2023
5a374a3
feat: 회원가입 이후, ssafyMember 구분 없이 intro 페이지로 리다이렉션
mjsdo Jul 14, 2023
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
6 changes: 6 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { authHandlers, memberHandlers } from '../src/mocks/handlers';
import { palettes } from '../src/styles/utils';
import { QueryClientProvider } from '@tanstack/react-query';
import { getQueryClient } from '../src/react-query/common';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { GlobalModal } from '../src/components/GlobalModal';
import { Toaster } from 'react-hot-toast';

initialize({
onUnhandledRequest: 'bypass',
Expand Down Expand Up @@ -44,6 +47,9 @@ const preview: Preview = {
decorators: [
(Story) => (
<QueryClientProvider client={getQueryClient()}>
<Toaster />
<ReactQueryDevtools initialIsOpen />
<GlobalModal />
<div>
<StorybookGlobalStyles />
<AppGlobalStyles />
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@
"devDependencies": {
"@emotion/babel-preset-css-prop": "^11.11.0",
"@faker-js/faker": "^8.0.2",
"@storybook/addon-a11y": "^7.0.8",
"@storybook/addon-a11y": "^7.0.27",
"@storybook/addon-coverage": "^0.0.8",
"@storybook/addon-essentials": "^7.0.8",
"@storybook/addon-interactions": "^7.0.8",
"@storybook/addon-links": "^7.0.8",
"@storybook/blocks": "^7.0.8",
"@storybook/addon-essentials": "^7.0.27",
"@storybook/addon-interactions": "^7.0.27",
"@storybook/addon-links": "^7.0.27",
"@storybook/blocks": "^7.0.27",
"@storybook/jest": "^0.1.0",
"@storybook/nextjs": "^7.0.8",
"@storybook/react": "^7.0.8",
"@storybook/test-runner": "^0.10.0",
"@storybook/testing-library": "^0.0.14-next.2",
"@storybook/nextjs": "^7.0.27",
"@storybook/react": "^7.0.27",
"@storybook/test-runner": "^0.11.0",
"@storybook/testing-library": "^0.2.0",
"@svgr/webpack": "^8.0.1",
"@tanstack/react-query-devtools": "^4.29.6",
"@testing-library/jest-dom": "^5.16.5",
Expand All @@ -82,7 +82,7 @@
"msw-storybook-addon": "^1.8.0",
"prettier": "^2.8.8",
"react-error-boundary": "^4.0.4",
"storybook": "^7.0.8",
"storybook": "^7.0.27",
"tsconfig-paths-webpack-plugin": "^4.0.1",
"typescript": "5.0.4"
},
Expand Down
1 change: 1 addition & 0 deletions src/components/Common/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ const variantsCss: Record<ButtonVariant, SerializedStyles> = {
backgroundColor: themeColorVars.mainColor.var,
'&:hover': { borderColor: palettes.white },
'&:active': {
borderColor: 'transparent',
backgroundColor: themeColorVars.mainDarkColor.var,
color: palettes.white,
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/Common/SsafyIcon/Track.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { defaultify } from '~/utils';
// import 구문 옆에다 주석 달면 린트 오류가 발생해서 여기 적어둡니다.

export interface TrackProps<Track extends keyof typeof tracks> {
name?: Track;
name?: Track | null;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

트랙이 없는경우 서버에서 값이 null로 넘어오기 때문에 추가

size?: TrackSize;
style?: CSSProperties;
theme?: Track extends 'fallback' | undefined ? FallbackTheme : undefined;
Expand Down
4 changes: 2 additions & 2 deletions src/components/DelayedRedirection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import { useEffect } from 'react';
interface DelayedRedirectionProps {
children: ReactNode;
to: UrlObject | string;
seconds: number;
seconds?: number;
replace?: boolean;
}

const DelayedRedirection = (props: DelayedRedirectionProps) => {
const { children, to, seconds, replace = false } = props;
const { children, to, seconds = 3, replace = false } = props;
Copy link
Collaborator

@otterp012 otterp012 Jul 16, 2023

Choose a reason for hiding this comment

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

좋습니다!
개인적으로 개발자간에 합의만 된다면 default value가 있는 게 좋다고 생각했어요

const router = useRouter();

useEffect(() => {
Expand Down
9 changes: 3 additions & 6 deletions src/components/GlobalModal/GlobalModal.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ export const BasicExample = () => {
})}
</div>

{/* 이 모달은 `_app.tsx`에서 한번만 렌더링합니다. */}
<GlobalModal />
{/* `GlobalModal`은 `_app.tsx`에서 한번만 렌더링합니다. */}
</>
);
};
Expand Down Expand Up @@ -86,8 +85,7 @@ export const OnlyCloseWhenActionIsPressed = () => {
<>
<Button onClick={handleOpenModal}>트리거 버튼</Button>

{/* 이 모달은 `_app.tsx`에서 한번만 렌더링합니다. */}
<GlobalModal />
{/* `GlobalModal`은 `_app.tsx`에서 한번만 렌더링합니다. */}
</>
);
};
Expand Down Expand Up @@ -123,8 +121,7 @@ export const ModalInModal = () => {
<Button onClick={handleOpenModal}>트리거 버튼</Button>
</div>

{/* 이 모달은 `_app.tsx`에서 한번만 렌더링합니다. */}
<GlobalModal />
{/* `GlobalModal`은 `_app.tsx`에서 한번만 렌더링합니다. */}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

스토리북의 Preview.tsx에 반영했습니다.

</>
);
};
5 changes: 3 additions & 2 deletions src/components/Layout/MainLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ReactNode } from 'react';

import { css } from '@emotion/react';

import { gutter } from '~/styles/utils';
import { paddingX } from '~/styles/utils';

// 임시 레이아웃입니다.
// 개발 단계에서, 보기 편하게 하기 위해서 넣어놨어요!
Expand All @@ -27,7 +27,8 @@ const selfCss = css({
maxWidth: 576,
minHeight: '100vh',
margin: '0 auto',
padding: `0 ${gutter.mainLayout / 2}px`,
padding: `0 ${paddingX.mainLayout}px`,
boxShadow: `20px 20px 40px #272b32, -20px -20px 40px #353a44;`,
overflow: 'hidden',
});
export default MainLayout;
49 changes: 0 additions & 49 deletions src/components/Layout/UserRegisterLayout.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/Layout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export { default as MainLayout } from './MainLayout';
export { default as LunchLayout } from './LunchLayout';
export { default as UserRegisterLayout } from './UserRegisterLayout';
48 changes: 48 additions & 0 deletions src/components/NameCard/NameCard.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import type { Meta, StoryObj } from '@storybook/react';
import type { UserInfo } from '~/services/member';

import { userInfo } from '~/mocks/handlers/member/data';
import { SsafyTrack } from '~/services/member';
import { disableArgs } from '~/stories/utils';

import NameCard from './index';

const meta: Meta<typeof NameCard> = {
title: 'NameCard',
component: NameCard,
tags: ['autodocs'],
argTypes: {
...disableArgs(['userInfo']),
},
};

export default meta;

type NameCardStory = StoryObj<NameCardStoryProps>;
interface NameCardStoryProps {
withBackground?: boolean;
track: SsafyTrack;
nickname: string;
}

export const Default: NameCardStory = {
args: {
withBackground: false,
track: SsafyTrack.EMBEDDED,
nickname: 'Kimee',
},
argTypes: {
track: {
control: 'radio',
options: Object.values(SsafyTrack),
},
},
render: (args) => {
const { withBackground, track, nickname } = args;
const user: UserInfo = userInfo.certifiedSsafyUserInfo;
user.nickname = nickname;
user.ssafyInfo.majorTrack = track;

return <NameCard userInfo={user} withBackground={withBackground} />;
},
};
49 changes: 49 additions & 0 deletions src/components/NameCard/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import type { UserInfo } from '~/services/member';

import { css } from '@emotion/react';

import Name from '~/components/Name';
import { fontCss, inlineFlex, palettes } from '~/styles/utils';

export interface NameCardProps {
userInfo: UserInfo;
withBackground?: boolean;
}

const NameCard = (props: NameCardProps) => {
const { userInfo, withBackground = false } = props;
const { ssafyInfo: { campus, semester } = {} } = userInfo;
const hasSsafyInfo = campus && semester;

return (
<div css={[selfCss, withBackground && backgroundCss]}>
<Name userInfo={userInfo} size="lg" />
{hasSsafyInfo && (
<div css={ssafyInfoCss}>{formatSsafyInfo(semester, campus)}</div>
)}
</div>
);
};

const formatSsafyInfo = (year: number, campus: string) => {
return `${campus}캠퍼스 SSAFY ${year}기`;
Copy link
Collaborator

@otterp012 otterp012 Jul 16, 2023

Choose a reason for hiding this comment

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

별건 아닌 부분이지만 아마 year 대신 semester를 사용해서 용어를 맞춰놔도 좋을 것 같아요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

저번에 말씀드렸듯이 의미상으로 semester가 아닌 year가 맞아서 이렇게 놔뒀습니다!

};

export default NameCard;

const selfCss = css(
{
padding: '6px 10px',
color: palettes.white,
borderRadius: 10,
},
fontCss.family.auto,
inlineFlex('flex-start', 'center')
);

const ssafyInfoCss = css(fontCss.style.B16);

const backgroundCss = css({
backgroundColor: palettes.white,
color: palettes.font.grey,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { Meta } from '@storybook/react';

import { userInfo } from '~/mocks/handlers/member/data';
import { PageLayout } from '~/stories/Layout';
import { disableArgs } from '~/stories/utils';

import PreviewCertifiedMyInfo from './index';

const meta: Meta<typeof PreviewCertifiedMyInfo> = {
title: 'PreviewCertifiedMyInfo',
component: PreviewCertifiedMyInfo,
tags: ['autodocs'],
decorators: [
(Story) => (
<PageLayout>
<Story />
</PageLayout>
),
],
argTypes: {
...disableArgs(['userInfo']),
},
};

export default meta;

export const Default = {
args: {
userInfo: userInfo.certifiedSsafyUserInfo,
},
};
51 changes: 51 additions & 0 deletions src/components/PreviewCertifiedMyInfo/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import type { UserInfo } from '~/services/member';

import { css } from '@emotion/react';

import { SsafyIcon, TrackSize } from '~/components/Common';
import NameCard from '~/components/NameCard';
import { flex, fontCss, palettes } from '~/styles/utils';

interface PreviewCertifiedMyInfoProps {
userInfo: UserInfo;
}

const PreviewCertifiedMyInfo = (props: PreviewCertifiedMyInfoProps) => {
const { userInfo } = props;

return (
<div css={selfCss}>
<div css={topLayerCss}>
<p>SSAFY 캐릭터 프로필이</p>
<p>생성되었습니다</p>
<p
css={[
fontCss.style.R16,
{ color: palettes.primary.default, marginTop: 18 },
]}
>
SSAFY만의 커뮤니티를 이용해보세요
</p>
</div>
<div css={bottomLayerCss}>
<SsafyIcon.Track
size={TrackSize.LG2}
name={userInfo?.ssafyInfo?.majorTrack}
/>

<NameCard userInfo={userInfo} withBackground />
</div>
</div>
);
};

export default PreviewCertifiedMyInfo;

const selfCss = css(
{ minHeight: '100vh', padding: '40px 0' },
flex('center', 'center', 'column', 120)
);

const topLayerCss = css({ textAlign: 'center' }, fontCss.style.B28);

const bottomLayerCss = css(flex('center', '', 'column', 26));
Loading