Skip to content

Commit

Permalink
결과 페이지 피드백 없을 때, 공유 버튼 로직 (#496)
Browse files Browse the repository at this point in the history
* feat: 피드백 없을 때 버튼 로직

* style: bottom bar 높이 리메이너 적용

* feat: 결과 페이지 바텀 바 적용

* chore: lint

* test: callback url 때문에 테스트 꺠지는 것 수정 (#497)
  • Loading branch information
hyesungoh authored Mar 26, 2024
1 parent 8abe2c5 commit 13c0a9e
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 106 deletions.
21 changes: 13 additions & 8 deletions src/components/bottomBar/BottomBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,26 @@ const BottomBar = () => {
};

return (
<footer css={BottomBarCss(theme)}>
{TAB_ITEMS.map((item) => (
<Link key={item.path} href={item.path} css={[IconBoxCss(theme), getIsSelected(item.path) && selectedCss]}>
<item.icon color={getIconColor(item.path)} />
<span>{item.text}</span>
</Link>
))}
</footer>
<>
<footer css={BottomBarCss(theme)}>
{TAB_ITEMS.map((item) => (
<Link key={item.path} href={item.path} css={[IconBoxCss(theme), getIsSelected(item.path) && selectedCss]}>
<item.icon color={getIconColor(item.path)} />
<span>{item.text}</span>
</Link>
))}
</footer>
{/* NOTE: height remainer */}
<div style={{ height: 73 }}></div>
</>
);
};

export default BottomBar;

const BottomBarCss = (theme: Theme) => css`
position: fixed;
z-index: ${theme.zIndex.fixed};
bottom: 0;
left: 0;
Expand Down
9 changes: 0 additions & 9 deletions src/features/gallery/PublishMyCard/InducePublishCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,3 @@ const imageCss = css`
top: 49px;
right: 24px;
`;

const closeButtonCss = css`
position: absolute;
top: 0;
right: 0;
width: fit-content;
padding: 10px;
`;
2 changes: 1 addition & 1 deletion src/features/home/KakaoLogin.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('components/kakaoLoginButton/KakaoLoginButton', () => {
render(<KakaoLoginButton />);
const loginButton = screen.getByRole('button');
fireEvent.click(loginButton);
expect(signIn).toHaveBeenCalledWith('kakao');
expect(signIn).toBeCalled();
});

// TODO: 추후 로그아웃 기능 구현이 필요하다면 주석 살리기
Expand Down
3 changes: 1 addition & 2 deletions src/pages/result/SurveyIdLoaded.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ const pillContainer = css`
display: flex;
flex-wrap: wrap;
gap: 11px 10px;
white-space: pre-wrap;
`;

Expand Down Expand Up @@ -461,7 +460,7 @@ const bubbleVariants: Variants = {
const topIconCss = css`
position: fixed;
right: 13px;
bottom: 60px;
bottom: 68px;
`;

const getTendencyCount = (
Expand Down
69 changes: 69 additions & 0 deletions src/pages/result/WhenEmptyFeedback.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { type FC } from 'react';
import Image from 'next/image';
import { css, type Theme } from '@emotion/react';

import BottomBar from '~/components/bottomBar/BottomBar';
import Button from '~/components/button/Button';
import CopyLink from '~/components/copyLink/CopyLink';
import MobileHeader from '~/components/header/MobileHeader';
import LinkIcon from '~/components/icons/LinkIcon';
import Toast from '~/components/toast/Toast';
import useToast from '~/components/toast/useToast';
import { HEAD_2_BOLD } from '~/styles/typo';

interface Props {
surveyId: string;
}

const WhenEmptyFeeback: FC<Props> = ({ surveyId }) => {
const { fireToast } = useToast();

const onCopyLink = () => {
fireToast({
content: (
<>
<LinkIcon />
<Toast.Text>나의 질문 폼 링크가 복사되었어요</Toast.Text>
</>
),
higherThanCTA: true,
});
};

return (
<>
<main css={mainCss}>
<MobileHeader title="연구 결과" hasMenu={false} />
<Image css={imageCss} alt="빈 폴더" src="/images/result/empty.webp" width={212} height={162} />
<span css={spanCss}>아직 도착한 피드백이 없어요</span>

<CopyLink copyText={`/review/${surveyId}`} onCopy={onCopyLink}>
<Button color="blue">질문 폼 공유하기</Button>
</CopyLink>
</main>
<BottomBar />
</>
);
};

export default WhenEmptyFeeback;

const mainCss = css`
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 100dvh;
`;

const imageCss = css`
margin-bottom: 30px;
`;

const spanCss = (theme: Theme) => css`
${HEAD_2_BOLD};
margin-bottom: 32px;
color: ${theme.colors.gray_400};
`;
74 changes: 0 additions & 74 deletions src/pages/result/base.page.tsx

This file was deleted.

35 changes: 23 additions & 12 deletions src/pages/result/index.page.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,32 @@
import { type ReactElement } from 'react';
import { type FC, type ReactElement } from 'react';
import { useSession } from 'next-auth/react';

import BottomBar from '~/components/bottomBar/BottomBar';
import LayoutPaddingTo23 from '~/components/layout/LayoutPaddingTo23';
import FixedSpinner from '~/components/loading/FixedSpinner';
import LoadingHandler from '~/components/loading/LoadingHandler';
import SEO from '~/components/SEO/SEO';
import useToast from '~/components/toast/useToast';
import useGetFeedbackSummaryBySurveyId from '~/hooks/api/feedbacks/useGetFeedbackSummaryBySurveyId';
import useGetSurveyIdByUserStatus from '~/hooks/api/surveys/useGetSurveyIdByUserStatus';
import useDidUpdate from '~/hooks/lifeCycle/useDidUpdate';
import useInternalRouter from '~/hooks/router/useInternalRouter';

import SurveyIdLoaded from './SurveyIdLoaded';
import WhenEmptyFeedback from './WhenEmptyFeedback';

const Result = () => {
// NOTE: 아래 3개의 훅은 필요한 곳 찾아 사용 필요
// const { data } = useGetFeedbackById(1);
// const { data: ass } = useGetAllFeedbacksBySurveyId('123');
// const { data } = useGetAllReviewersBySurveyId('123');

// NOTE: 현재 쌓인 데이터가 없어서, 개발할 시 mock에 요청 보내면서 해당 데이터 사용 X
// <LoadingHandler isLoading={false} fallback={<FixedSpinner />}>
// {data && <SurveyIdLoaded surveyId={'123'} />}
// 위처럼 변경해서 개발 필요
const { isLoading, data } = useCheckSurveyId();

return (
<>
<SEO />

<LoadingHandler isLoading={isLoading} fallback={<FixedSpinner />}>
{/* TODO: useCheckSurveyId 의 데이터 넣기 필요 */}
{data && <SurveyIdLoaded surveyId={data.survey_id} />}
{data && <FeedbackCountHandler surveyId={data.survey_id} />}
</LoadingHandler>

<BottomBar />
</>
);
};
Expand Down Expand Up @@ -62,3 +57,19 @@ const useCheckSurveyId = () => {

return { isLoading, data };
};

interface FeedbackCountHandlerProps {
surveyId: string;
}

const FeedbackCountHandler: FC<FeedbackCountHandlerProps> = ({ surveyId }) => {
const { data, isLoading } = useGetFeedbackSummaryBySurveyId(surveyId);

const isFeedbackEmpty = data && data.all_feedback_count === 0;

return (
<LoadingHandler isLoading={isLoading} fallback={<FixedSpinner />}>
{isFeedbackEmpty ? <WhenEmptyFeedback surveyId={surveyId} /> : <SurveyIdLoaded surveyId={surveyId} />}
</LoadingHandler>
);
};

0 comments on commit 13c0a9e

Please sign in to comment.