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

컴포넌트 사용성 개선 및 라우팅 제한 추가, github action workflow 오류 해결 등 버그 5건 수정 #524

Merged
merged 9 commits into from
Sep 5, 2023
4 changes: 2 additions & 2 deletions .github/workflows/backend-pr-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Send Slack notification When Review Completed
if: contains(github.event.comment.body, 'review-complete') # check the comment if it contains the keywords
if: contains(github.event.comment.body, 'be-리뷰완') # check the comment if it contains the keywords
Copy link
Member Author

Choose a reason for hiding this comment

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

백엔드랑 프론트엔드 모두 action을 trigger하는 키워드가 같으면
채널 2개에 각각 알림이 가버려서...... 백엔드랑 프론트엔드 키워드를 다르게 변경해봤습니다!!

uses: slackapi/slack-github-action@v1.24.0
with:
channel-id: ${{ secrets.SLACK_BE_CHANNEL }} # Slack 채널 ID
Expand All @@ -35,7 +35,7 @@ jobs:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_TOKEN }} # Slack 토큰

- name: Send Slack notification When Re-review Requested
if: contains(github.event.comment.body, 'review-request')
if: contains(github.event.comment.body, 'be-리뷰요청')
uses: slackapi/slack-github-action@v1.24.0
with:
channel-id: ${{ secrets.SLACK_BE_CHANNEL }}
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/backend-pr-deadline-slack-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ on:
paths:
- 'backend/**'

defaults:
run:
working-directory: backend

jobs:
pull_request_open:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/frontend-pr-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Send Slack notification When Review Completed
if: contains(github.event.comment.body, 'review-complete') # check the comment if it contains the keywords
if: contains(github.event.comment.body, 'fe-리뷰완') # check the comment if it contains the keywords
uses: slackapi/slack-github-action@v1.24.0
with:
channel-id: ${{ secrets.SLACK_FE_CHANNEL }} # Slack 채널 ID
Expand All @@ -35,7 +35,7 @@ jobs:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_TOKEN }} # Slack 토큰

- name: Send Slack notification When Re-review Requested
if: contains(github.event.comment.body, 'review-request') # check the comment if it contains the keywords
if: contains(github.event.comment.body, 'fe-리뷰요청') # check the comment if it contains the keywords
uses: slackapi/slack-github-action@v1.24.0
with:
channel-id: ${{ secrets.SLACK_FE_CHANNEL }} # Slack 채널 ID
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/frontend-pr-deadline-slack-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ on:
paths:
- 'frontend/**'

defaults:
Copy link
Member Author

Choose a reason for hiding this comment

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

working directory 가 있으니까 .github/workflows/scripts/calculatePRDeadline.js 의 경로가 제대로 인식이 안되더라구요... 그래서 지웠습니다😂😂

run:
working-directory: frontend

jobs:
pull_request_open:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/frontend-storybook-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Storybook-Deploy
name: Deploy
Copy link
Member Author

Choose a reason for hiding this comment

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

Deploy 로 원상복구했더니 제대로 스토리북 배포에 대한 action이 일어나더라구요(휴..)


on:
pull_request:
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import PostOptionProvider from '@hooks/context/postOption';

import router from '@routes/router';

import ChannelTalk from '@pages/ChannelTalk';
import ErrorBoundaryForTopClass from '@pages/ErrorBoundaryForTopClass';

import ChannelTalk from '@components/ChannelTalk';
Copy link
Member Author

Choose a reason for hiding this comment

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

pages에서 components 경로로 채널톡 컴포넌트 옮겼습니다


import { GlobalStyle } from '@styles/globalStyle';
import { theme } from '@styles/theme';

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/PostForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
POST_DEADLINE_POLICY,
POST_TITLE_POLICY,
} from '@constants/policyMessage';
import { CATEGORY_COUNT_LIMIT, IMAGE_BASE_URL, POST_CONTENT, POST_TITLE } from '@constants/post';
Copy link
Member Author

Choose a reason for hiding this comment

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

IMAGE_BASE_URL 안쓰고 있어서 지웠어요~

import { CATEGORY_COUNT_LIMIT, POST_CONTENT, POST_TITLE } from '@constants/post';

import { calculateDeadlineTime } from '@utils/post/calculateDeadlineTime';
import { checkWriter } from '@utils/post/checkWriter';
Expand Down
15 changes: 3 additions & 12 deletions frontend/src/components/common/Toast/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,9 @@ export const fadeInOutAnimation = keyframes`
`;

export const Wrapper = styled.div<{ $position: 'top' | 'bottom' }>`
display: grid;
grid-template-columns: 1fr;
grid-template-rows: ${props => POSITION[props.$position]};
align-items: end;
justify-items: center;

width: 100vw;
height: 100vh;

position: fixed;
top: 0;
left: 0;

top: ${props => POSITION[props.$position]};
Copy link
Collaborator

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.

맞아요 그러면 같은 위치에 다수의 toast들이 띄워져서 겹치는데, 이런 경우의 수 때문에 뭔가 전역으로 관리하는게 낫지 않나.. 라는 생각이 들더라구요🤔😀

`;

export const Content = styled.div<{ $size: Size | 'free' }>`
Expand All @@ -49,5 +40,5 @@ export const Content = styled.div<{ $size: Size | 'free' }>`

animation: ${fadeInOutAnimation} ${TOAST_TIME}s linear infinite;

z-index: ${theme.zIndex.modal};
z-index: ${theme.zIndex.select};
`;
4 changes: 3 additions & 1 deletion frontend/src/components/post/PostListPage/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ export const ButtonContainer = styled.div`
align-items: end;
gap: 20px;
width: 62px;
padding-right: 10px;
position: sticky;
position: fixed;
left: 90%;
bottom: 24px;
`;

Expand Down
24 changes: 24 additions & 0 deletions frontend/src/hooks/query/user/useUpdateUserInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';

import { UpdateUserInfoRequest } from '@type/user';

import { updateUserInfo } from '@api/userInfo';

import { QUERY_KEY } from '@constants/queryKey';

export const useUpdateUserInfo = () => {
const queryClient = useQueryClient();

const LOGGED_IN = true;
const { mutate, isLoading, isSuccess, isError, error } = useMutation({
mutationFn: async (userInfo: UpdateUserInfoRequest) => await updateUserInfo(userInfo),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: [QUERY_KEY.USER_INFO, LOGGED_IN] });
},
onError: () => {
window.console.error('개인 정보 등록에 실패했습니다.');
},
});

return { mutate, isLoading, isSuccess, isError, error };
};
6 changes: 1 addition & 5 deletions frontend/src/pages/VoteStatisticsPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,13 @@ export default function VoteStatisticsPage() {
isLoading: isVoteResultLoading,
} = useFetch(() => getPostStatistics(postId));

const movePostDetailPage = () => {
navigate(`${PATH.POST}/${postId}`);
};

if (postDetail && !checkWriter(postDetail.writer.id)) return <Navigate to={PATH.HOME} />;

return (
<Layout isSidebarVisible={true}>
<S.HeaderWrapper>
<NarrowTemplateHeader>
<IconButton category="back" onClick={movePostDetailPage} />
<IconButton category="back" onClick={() => navigate(-1)} />
</NarrowTemplateHeader>
</S.HeaderWrapper>
<S.Container>
Expand Down
12 changes: 10 additions & 2 deletions frontend/src/pages/post/PostDetail/InnerHeaderPart/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useState } from 'react';
import { useNavigate } from 'react-router-dom';

import { PostAction, PostMenuItem } from '@type/menu';

Expand Down Expand Up @@ -39,7 +40,9 @@ export default function InnerHeaderPart({
isClosed,
handleEvent: { movePage, controlPost },
}: PostDetailPageChildProps) {
const { moveWritePostPage, moveVoteStatisticsPage, movePostListPage } = movePage;
const navigate = useNavigate();

const { moveWritePostPage, moveVoteStatisticsPage } = movePage;
const { setEarlyClosePost, deletePost, reportPost, reportNickname } = controlPost;
const { isOpen, toggleComponent, closeComponent } = useToggle();
const [action, setAction] = useState<PostAction | null>(null);
Expand All @@ -55,7 +58,12 @@ export default function InnerHeaderPart({

return (
<>
<IconButton category="back" onClick={movePostListPage} />
<IconButton
category="back"
onClick={() => {
navigate(-1);
}}
/>
<S.HeaderWrapper>
{!isWriter ? (
<>
Expand Down
51 changes: 41 additions & 10 deletions frontend/src/pages/user/RegisterPersonalInfo/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { ChangeEvent, FormEvent, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { ChangeEvent, FormEvent, useEffect, useState } from 'react';
import { Navigate, useNavigate } from 'react-router-dom';

import { updateUserInfo } from '@api/userInfo';
import { useUpdateUserInfo } from '@hooks/query/user/useUpdateUserInfo';
import { useToast } from '@hooks/useToast';

import Accordion from '@components/common/Accordion';
import IconButton from '@components/common/IconButton';
import Layout from '@components/common/Layout';
import LogoButton from '@components/common/LogoButton';
import NarrowTemplateHeader from '@components/common/NarrowTemplateHeader';
import SquareButton from '@components/common/SquareButton';
import Toast from '@components/common/Toast';

import { BIRTH_YEAR } from '@constants/user';

import { setCookieToken } from '@utils/cookie';
import { getCookieToken, setCookieToken } from '@utils/cookie';

import * as S from './style';

Expand All @@ -23,6 +25,10 @@ interface UserInfoForm {

export default function RegisterPersonalInfo() {
const navigate = useNavigate();
const hasEssentialInfo = getCookieToken().hasEssentialInfo === 'true';

const { mutate: updateUserInfo, isSuccess, isError, error } = useUpdateUserInfo();
const { isToastOpen, openToast, toastMessage } = useToast();

const [userInfoForm, setUserInfoForm] = useState<UserInfoForm>({
gender: '',
Expand Down Expand Up @@ -62,18 +68,38 @@ export default function RegisterPersonalInfo() {

const submittedUserInfo = { gender, birthYear: Number(birthYear) };
updateUserInfo(submittedUserInfo);
setCookieToken('hasEssentialInfo', true);

alert('개인 정보 등록 완료!');
navigate('/');
};

useEffect(() => {
if (isSuccess) {
setCookieToken('hasEssentialInfo', true);
alert('개인 정보가 등록 완료되었습니다.');
navigate('/');
}
}, [isSuccess]);

useEffect(() => {
if (isError && error instanceof Error) {
openToast('개인 정보를 이미 등록 완료하셨습니다.');
Copy link
Member Author

Choose a reason for hiding this comment

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

백엔드에서는 이미 성별이 할당되었습니다 라는 메시지를 보내주고 있는데.. 이 메시지를 그대로 보여주는거보다 커스텀된 메시지를 보여주는게 좋을거 같더라구요! 다만 500 에러가 난 경우에는 알 수 없는 서버 오류가 났습니다 라고 알려줘야 할텐데...
백엔드가 보내주는 에러 메시지를 수정해달라고 요청하는 것이 좋을지 아니면 에러 코드에 대한 각기 다른 메시지를 프론트가 커스텀하는것이 좋을지 고민이 됩니다🤔🤔

Copy link
Collaborator

Choose a reason for hiding this comment

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

만약 하나라도 커스텀하면 모두 커스텀하고,
그렇지 않다면 모두 백엔드와 에러메세지를 협의하는 것이 좋을 것 같아요.
방식이 섞여버리면 에러를 다룰때 헷갈릴 것 같아요.

개인적으로는 지금처럼 백엔드에서 작성하면 좋을 것 같아요.

Copy link
Collaborator

Choose a reason for hiding this comment

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

저도 프론트에서 알 수 있는 에러라면 프론트가 처리하고, 구체적으로 알 수 없는 에러는 현재처럼 백엔드에서 보내주는 것을 보내주면 좋겠다고 생각이 들어요

return;
}
}, [isError, error]);

if (hasEssentialInfo) {
alert('개인 정보를 이미 등록 완료하셨습니다.');
return <Navigate to={'/'} />;
}

return (
<Layout isSidebarVisible={true}>
<S.Wrapper>
<S.HeaderWrapper>
<NarrowTemplateHeader>
<IconButton category="back" />
<LogoButton
content="icon"
style={{ width: '33px', height: '33px' }}
onClick={() => navigate('/')}
/>
</NarrowTemplateHeader>
</S.HeaderWrapper>
<S.Title>개인 정보 등록</S.Title>
Expand Down Expand Up @@ -147,6 +173,11 @@ export default function RegisterPersonalInfo() {
</S.ButtonWrapper>
</S.InfoForm>
</S.MainWrapper>
{isToastOpen && (
<Toast size="md" position="bottom">
{toastMessage}
</Toast>
)}
</S.Wrapper>
</Layout>
);
Expand Down