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

feat: 연구 결과 피드백 없을 때 마크업 #492

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added public/images/result/empty.webp
Binary file not shown.
14 changes: 9 additions & 5 deletions src/components/header/MobileHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@ import { HEAD_1_BOLD } from '~/styles/typo';
// NOTE: MobileHeader 임시 네이밍, 추후 수정 필요
interface Props {
title: string;
hasMenu?: boolean;
}

function MobileHeader(props: Props) {
function MobileHeader({ title, hasMenu = true }: Props) {
const [isSideMenuOpen, toggleSideMenu] = useBoolean(false);

return (
<>
<header css={headerCss}>
<h1>{props.title}</h1>
<button type="button" css={menuButtonCss} onClick={toggleSideMenu}>
<MenuBarIcon color="#394258" />
</button>
<h1>{title}</h1>

{hasMenu && (
<button type="button" css={menuButtonCss} onClick={toggleSideMenu}>
<MenuBarIcon color="#394258" />
</button>
)}
</header>
<div css={blankCss} />
<SideMenu isOpen={isSideMenuOpen} onClose={toggleSideMenu} />
Expand Down
74 changes: 74 additions & 0 deletions src/pages/result/base.page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { type FC, useEffect } from 'react';
import Image from 'next/image';
import { useRouter } from 'next/router';
import { css, type Theme } from '@emotion/react';

import BottomBar from '~/components/bottomBar/BottomBar';
import Button from '~/components/button/Button';
import MobileHeader from '~/components/header/MobileHeader';
import FixedSpinner from '~/components/loading/FixedSpinner';
import LoadingHandler from '~/components/loading/LoadingHandler';
import useGetFeedbackSummaryBySurveyId from '~/hooks/api/feedbacks/useGetFeedbackSummaryBySurveyId';
import useGetSurveyIdByUserStatus from '~/hooks/api/surveys/useGetSurveyIdByUserStatus';
import { HEAD_2_BOLD } from '~/styles/typo';

const ResultBasePage: FC = () => {
const { data, isLoading } = useGetSurveyIdByUserStatus();
Copy link
Member Author

Choose a reason for hiding this comment

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

요 훅 내부적으로 유저 상태를 enabled 옵션으로 쓰더라구요 ~


return (
<LoadingHandler isLoading={isLoading} fallback={<FixedSpinner />}>
{data && <WhenSurveyIdLoaded surveyId={data.survey_id} />}
</LoadingHandler>
);
};

export default ResultBasePage;

interface WhenSurveyIdLoadedProps {
surveyId: string;
}

const WhenSurveyIdLoaded: FC<WhenSurveyIdLoadedProps> = ({ surveyId }) => {
const router = useRouter();
const { data } = useGetFeedbackSummaryBySurveyId(surveyId);

useEffect(
function replaceWhenHasFeedback() {
if (!data) return;
if (data.all_feedback_count > 0) router.replace('/result');
},
[data, router],
);
Comment on lines +35 to +41
Copy link
Member Author

Choose a reason for hiding this comment

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

피드백이 한 개라도 있는 사용자라면 리플레이스 함요 ~


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>
<Button color="blue">질문 폼 공유하기</Button>
</main>
<BottomBar />
</>
);
};

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};
`;
Loading