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

[혜수] 피드백 페이지 생성 #405

Merged
merged 32 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
42eb6d6
✨ : #398 - 피드백 보기 활성화
suehdn Jan 3, 2024
97b43db
♻️ : #398 - line-height 누락되는 폰트 사이즈 없도록 == -> <로 변경
suehdn Jan 3, 2024
85900b5
✨ : #398 - 피드백 쿼리키 추가
suehdn Jan 3, 2024
6cbbb63
✨ : #398 - getFeedbacks type추가
suehdn Jan 3, 2024
6152ea5
✨ : #398 - api feedback 변경
suehdn Jan 3, 2024
3479314
✨ : #398 - getFeedbacks api 추가
suehdn Jan 3, 2024
5e4e5ec
✨ : #398 - useGetFeedbacksQuery 추가
suehdn Jan 3, 2024
997a30d
✨ : #398 - 피드백 페이지 추가
suehdn Jan 3, 2024
033c03f
♻️ : #398 - 피드백 페이지 쿼리 사용 -> planId로 수정
suehdn Jan 3, 2024
b53d1ec
✨ : #398 -EvaluateRadio 컴포넌트 추가
suehdn Jan 4, 2024
04f6f11
✨ : #398 - WrongApproach 컴포넌트 추가
suehdn Jan 4, 2024
ad3b967
💄 : #398 - WrongApproach 컴포넌트 스타일 추가
suehdn Jan 4, 2024
752d8c4
✨ : #398 - 피드백 하기 페이지 추가
suehdn Jan 4, 2024
c4efbe4
♻️ : #398 - evaluate 페이지 필요없는 코드 제거
suehdn Jan 4, 2024
9cf0888
✨ : #398 - 피드백 완료 모달 추가
suehdn Jan 4, 2024
fbae2b4
♻️ : #398 - API 수정에 따른 타입 수정
suehdn Jan 6, 2024
3261f1c
✨ : #398 - 쿼리에 planId 추가
suehdn Jan 6, 2024
34898b6
✨ : #398 - arrow right 아이콘 추가
suehdn Jan 6, 2024
6181bf1
✨ : #398 - FeedbackItem 컴포넌트 생성
suehdn Jan 6, 2024
68e0cf7
✨ : #398 - 피드백 평가 페이지 피드백 기초 완성
suehdn Jan 6, 2024
8337a6d
💄 : #398 - 피드백 제한시간 정렬 추가
suehdn Jan 6, 2024
5d2e90c
💄 : #398 - 피드백하기 라디오 스타일
suehdn Jan 6, 2024
c83e851
✨ : #398 - 12월 예외처리 및 기간 만료시 피드백 페이지 버튼 변환 완료
suehdn Jan 6, 2024
65d5572
💄 : #398 - 피드백 하기 버튼 그림자 추가
suehdn Jan 9, 2024
273fa3d
✨ : #396 - 수정된 API 타입 추가
suehdn Jan 9, 2024
b85f39c
✨ : #398 - useGetFeedbacksQuery 연결 & 년도정보 추가
suehdn Jan 9, 2024
9a71e9f
✨ : #398 - 쿼리에 planId가 없을 때 잘못된 접근입니다 페이지 띄우도록 추가
suehdn Jan 9, 2024
f5489b5
✨ : #398 - poseFeedbacks 관련 API 추가
suehdn Jan 9, 2024
54babc4
♻️ : #398 - 필요없는 코드 제거
suehdn Jan 9, 2024
4475f2c
✨ : #398 - postFeedbacks API 연결
suehdn Jan 9, 2024
bc5a9fe
♻️ : #398 - wrongapproach 컴포넌트 확장성 추가
suehdn Jan 10, 2024
c91144c
✨ : #398 - 피드백 post시 예외처리 추가
suehdn Jan 10, 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
15 changes: 15 additions & 0 deletions src/apis/client/getFeedbacks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { DOMAIN } from '@/constants/api';
import { GetFeedbacksResponse } from '@/types/apis/feedback/GetFeedbacks';
import { axiosInstanceClient } from '../axiosInstanceClient';

export const getFeedbacks = async (planId: number) => {
const { data } = await axiosInstanceClient.get<GetFeedbacksResponse>(
DOMAIN.GET_FEEDBACKS(planId),
{
params: {
planId,
},
},
);
return data;
};
16 changes: 0 additions & 16 deletions src/apis/client/postFeedback.ts

This file was deleted.

13 changes: 13 additions & 0 deletions src/apis/client/postFeedbacks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { DOMAIN } from '@/constants';
import { PostFeedbacksRequest } from '@/types/apis/feedback/PostFeedbaks';
import { axiosInstanceClient } from '../axiosInstanceClient';

export const postFeedbacks = async ({ planId, body }: PostFeedbacksRequest) => {
const { data } = await axiosInstanceClient.post(
DOMAIN.POST_FEEDBACKS(planId),
{
...body,
},
);
return data;
};
8 changes: 4 additions & 4 deletions src/app/(header)/home/_components/Plan/Plan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ export default function Plan({
<p className={classNames(`plan__title`, 'font-size-md')}>{title}</p>
<p className={classNames('font-size-base')}>달성률: {achieveRate}%</p>
<Link
href={''}
href={`/feedback/${planId}`}
className={classNames(
'plan__feedback',
'font-size-sm',
'color-origin-secondary',
'border-origin-secondary',
'color-origin-primary',
'border-origin-primary',
'border-round',
)}>
피드백 보기 (업데이트 중!)
피드백 보기
</Link>
</div>
</Link>
Expand Down
65 changes: 65 additions & 0 deletions src/app/feedback/[planId]/_components/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
.feedback {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
overflow-y: scroll;
margin-left: var(--scroll-margin-left);
padding: 2rem 0;
&__breadcrumb {
display: flex;
align-self: flex-start;
gap: 0.5rem;
a {
text-decoration: none;
color: var(--origin-text-100);
}
}
&__title {
margin-top: 2rem;
margin-bottom: 0rem;
}
&__circular-progressbar {
width: 4rem;
height: 4rem;
.CircularProgressbar-text {
font-size: 2rem;
fill: var(--origin-text-100);
}
.CircularProgressbar-path {
stroke: var(--origin-primary);
stroke-linecap: round;
}
.CircularProgressbar-trail {
stroke: var(--origin-secondary);
}
.CircularProgressbar-path {
stroke: var(--origin-primary);
}
}
&__evaluate {
width: 100%;
display: flex;
align-items: center;
gap: 1rem;
margin: 1rem 0;
&-item {
display: flex;
flex-direction: column;
gap: 1rem;
width: 100%;
max-height: calc(100% - 14rem);
overflow-y: scroll;
margin-left: var(--scroll-margin-left);
padding-bottom: 1rem;
}
}
&__back-to-plans {
width: 100%;
text-decoration: none;
position: absolute;
bottom: 6rem;
max-width: calc(100% - 3rem);
}
}
90 changes: 90 additions & 0 deletions src/app/feedback/[planId]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
'use client';

import { Button } from '@/components';
import FeedbackItem from '@/components/FeedbackItem/FeedbackItem';
import { useGetFeedbacksQuery } from '@/hooks/apis/useGetFeedbacksQuery';
import { useScroll } from '@/hooks/useScroll';
import classNames from 'classnames';
import Link from 'next/link';
import { CircularProgressbar } from 'react-circular-progressbar';
import 'react-circular-progressbar/dist/styles.css';
import './_components/index.scss';

export default function FeedbackPage({
params,
}: {
params: { planId: string };
}) {
const { planId } = params;
const { feedback } = useGetFeedbacksQuery(parseInt(planId, 10));
const { achieveRate, title, feedbacks } = feedback;
const { handleScroll, scrollableRef } = useScroll();
let plan_evaluate_text = '';

if (achieveRate >= 80) {
plan_evaluate_text = '매우 잘 지키고 있어요!';
} else if (achieveRate >= 50) {
plan_evaluate_text = '잘 지키고 있어요!';
} else {
plan_evaluate_text = '잘 지켜주세요!';
}

return (
<div className={classNames('feedback')}>
<div className="feedback__breadcrumb font-size-base color-origin-text-100">
<Link href="/home">홈</Link>
&gt;
<Link href={`/plans/${planId}`}>내 계획</Link>
&gt;
<span>피드백</span>
</div>
<div className={classNames('font-size-xl', 'feedback__title')}>
피드백
</div>
<div className={classNames('feedback__evaluate')}>
<CircularProgressbar
value={achieveRate}
text={`${achieveRate}%`}
className={classNames('feedback__circular-progressbar')}
/>
<div className={classNames('feedback__evaluate-text', 'font-size-md')}>
<p
className={classNames(
'feedback__evaluate-title',
'color-origin-primary',
)}>
{title}
</p>
<span>계획을 </span>
<span className={classNames('color-origin-primary')}>
{plan_evaluate_text}
</span>
</div>
</div>
<div
ref={scrollableRef}
onScroll={handleScroll}
className={classNames('feedback__evaluate-item')}>
{feedbacks.map((item) => {
return (
<FeedbackItem
data={item}
title={title}
planId={parseInt(planId, 10)}
remindTime={feedback.remindTime}
createdYear={feedback.createdYear}
key={item.remindMonth}
/>
);
})}
</div>
<Link
href={`/plans/${planId}`}
className={classNames('feedback__back-to-plans')}>
<Button background="primary" color="white-100" border={false}>
계획으로 돌아가기
</Button>
</Link>
</div>
);
}
48 changes: 48 additions & 0 deletions src/app/feedback/evaluate/_components/EvaluateRadio.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import classNames from 'classnames';
import { ChangeEvent } from 'react';

type EvaluateRadioProps = {
evaluateOption: number;
setEvaluateOption: React.Dispatch<React.SetStateAction<number>>;
};

type Option = {
value: string;
label: string;
};

export default function EvaluateRadio({
evaluateOption,
setEvaluateOption,
}: EvaluateRadioProps) {
const options: Option[] = [
{ value: '100', label: '매우 잘함 (100%)' },
{ value: '75', label: '잘 함 (75%)' },
{ value: '50', label: '보통 (50%)' },
{ value: '25', label: '대체로 못함 (25%)' },
{ value: '0', label: '전혀 못함 (0%)' },
];

const handleOptionChange = (event: ChangeEvent<HTMLInputElement>) => {
setEvaluateOption(parseInt(event.target.value, 10));
};

return (
<div className={classNames('evaluate-radio')}>
{options.map((option) => (
<>
<label key={option.value}>
<input
type="radio"
value={option.value}
checked={evaluateOption === parseInt(option.value, 10)}
onChange={handleOptionChange}
/>
{option.label}
</label>
<br></br>
</>
))}
</div>
);
}
54 changes: 54 additions & 0 deletions src/app/feedback/evaluate/_components/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
.feedback {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: flex-start;
overflow-y: scroll;
margin-left: var(--scroll-margin-left);
padding: 2rem 0;
gap: 2rem;
&__breadcrumb {
display: flex;
gap: 0.5rem;
a {
text-decoration: none;
color: var(--origin-text-100);
}
}
&__send {
width: 100%;
text-decoration: none;
position: absolute;
bottom: 6rem;
max-width: calc(100% - 3rem);
}
&__content {
width: 100%;
}
}
.evaluate-radio {
appearance: none;
display: flex;
flex-direction: column;
margin: 1.5rem 0;
label {
display: flex;
align-items: center;
&:hover {
cursor: pointer;
}
}
input[type='radio'] {
appearance: none;
width: 0.9rem;
height: 0.9rem;
border-radius: 100%;
margin-right: 0.5rem;
border: 1px solid var(--origin-primary);

&:checked {
background-color: var(--origin-primary);
}
}
}
Loading