Skip to content

Commit

Permalink
Merge pull request #212 from SV-Winter-BootCamp-Team-C/fe/fix/#208
Browse files Browse the repository at this point in the history
fix: ๋ถ„์„ ํŽ˜์ด์ง€ ๋””์ž์ธ ์ˆ˜์ •
  • Loading branch information
dmswn1004 authored Jan 30, 2024
2 parents 38369f5 + 9ad934e commit c3e070b
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 32 deletions.
1 change: 1 addition & 0 deletions frontend/src/components/staticresponse/StaticCheckBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function StaticCheckBox({ question, color, buttonStyle, index }: StaticCheckBoxP
id={`checkbox-${choice.choiceId}`}
className="absolute opacity-0"
checked={(question.objContent ?? []).includes(choice.choiceId)}
readOnly
/>
{(question.objContent ?? []).includes(choice.choiceId) && (
<img src={checkIcon} alt="Checked" className="w-4 h-4" />
Expand Down
8 changes: 1 addition & 7 deletions frontend/src/components/survey/SurveyCoverMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import menuDel from '../../assets/menuDel.svg';
import { useAuthStore } from '../../store/AuthStore';
import ShareMailModal from '../common/ShareMailModal';
import { deleteSurveyAPI } from '../../api/deleteSurvey';
import { getClient } from '../../queryClient';
import Alert from '../common/Alert';
import { ApiResponseError } from '../../types/apiResponseError';

Expand Down Expand Up @@ -100,12 +99,7 @@ function SurveyCoverMenu({ surveyId, open, attendCount, isDropdownOpen, setIsDro
const { mutate, isError: deleteError } = useMutation({
mutationFn: () => deleteSurveyAPI(surveyId, myId),
onSuccess: () => {
getClient.invalidateQueries({ queryKey: ['allSurveys'] });
getClient.refetchQueries({ queryKey: ['allSurveys'] });
getClient.invalidateQueries({ queryKey: ['myForm', myId] });
getClient.refetchQueries({ queryKey: ['myForm', myId] });
getClient.invalidateQueries({ queryKey: ['myResponse', myId] });
getClient.refetchQueries({ queryKey: ['myResponse', myId] });
window.location.reload();
setShowDeleteAlert(true);
},
onError: (error: AxiosError) => {
Expand Down
44 changes: 24 additions & 20 deletions frontend/src/components/surveyResult/Question/PieChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,26 @@ function PieChart({ index, question }: PieChartProps) {
const chartOptions = {
chart: {
type: 'donut',
width: 300,
height: 180.7,
background: 'transparent',
},
labels: question.choices?.map((choice) => choice.option),
legend: {
show: true,
position: 'right',
horizontalAlign: 'center',
position: 'left',
floating: true,
horizontalAlign: 'right',
fontSize: '14px',
fontWeight: 'medium',
itemMargin: {
horizontal: 2,
vertical: 1,
vertical: 2,
},
offsetX: -30,
offsetY: 0,
formatter(val: string) {
if (val.length > 10) {
return `${val.slice(0, 10)}...`;
}
return val;
},
},
dataLabels: {
Expand All @@ -50,16 +56,13 @@ function PieChart({ index, question }: PieChartProps) {
},
plotOptions: {
pie: {
donut: {
size: '65%',
},
stroke: {
width: 0,
curve: 'smooth',
},
},
},
colors: ['#66629F', '#918DCA', '#BFBBFF', '#E5E4FF'],
colors: ['#66629F', '#918DCA', '#BFBBFF', '#c5c4eb'],
};

return (
Expand All @@ -81,7 +84,7 @@ function PieChart({ index, question }: PieChartProps) {
<span className="text-[2rem] font-semibold text-center text-black -translate-y-4">Q{index}.</span>
</div>

<div className="flex justify-center items-center w-[14.375rem] max-w-[50rem] h-8 ">
<div className="flex justify-center items-center w-[37.5rem] h-8 ">
<p className="text-base text-black">{question.content}</p>
</div>

Expand All @@ -97,15 +100,16 @@ function PieChart({ index, question }: PieChartProps) {

<div className="py-6">
{chartSeries && total > 0 && chartSeries.length > 0 ? (
<Chart
options={chartOptions as any}
series={chartSeries as number[]}
type="donut"
width={300}
height={180.7}
key={`chart-${index}`}
className="flex items-center justify-center w-[18.75rem] h-[180.7px]"
/>
<div className="flex items-center justify-center min-w-[18.75rem] h-[180.7px]">
<Chart
key={`chart-${index}`}
options={chartOptions as any}
series={chartSeries as number[]}
type="donut"
width={500}
height={180.7}
/>
</div>
) : (
<p className="text-base text-gray">์„ค๋ฌธ ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.</p>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function SubjectQuestion({ index, question }: SubjectQuestionProps) {
<span className="text-[2rem] font-semibold text-center text-black -translate-y-4">Q{index}.</span>
</div>

<div className="flex justify-center items-center w-[14.375rem] max-w-[50rem] h-8 ">
<div className="flex justify-center items-center w-[37.5rem] h-8 ">
<p className="text-base text-black">{question.content}</p>
</div>

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/hooks/usePaginationSurveyList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const usePaginationSurveyList = (path: PathType) => {

const queryFn = QUERY_FN_MAP[path];

const { data, isError, isPending } = useQuery<SurveyCoverType, AxiosError>({
const { data, isError, isPending, refetch } = useQuery<SurveyCoverType, AxiosError>({
queryKey: [path, currentPage, userId, searchTerm, sort], // ๊ฒ€์ƒ‰์–ด๋ฅผ ์ฟผ๋ฆฌ ํ‚ค์— ์ถ”๊ฐ€
queryFn: () => queryFn({ userId: userId as number, currentPage, title: searchTerm, sort }), // API ํ˜ธ์ถœ ์‹œ ๊ฒ€์ƒ‰์–ด ์ „๋‹ฌ
select: (responseData) => {
Expand All @@ -58,6 +58,7 @@ const usePaginationSurveyList = (path: PathType) => {
setSearchTerm,
// sort,
handleSortChange,
refetch,
};
};

Expand Down
7 changes: 6 additions & 1 deletion frontend/src/pages/AllForm.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { useNavigate } from 'react-router-dom';
import { useEffect } from 'react';
import SurveyForm from '../components/survey/SurveyForm';
import usePaginationSurveyList from '../hooks/usePaginationSurveyList';

function AllForm() {
const navigate = useNavigate();

const { data, currentPage, handlePageChange, searchTerm, setSearchTerm, handleSortChange } =
const { data, currentPage, handlePageChange, searchTerm, setSearchTerm, handleSortChange, refetch } =
usePaginationSurveyList('allForm');

useEffect(() => {
refetch();
}, [refetch]);

return (
<SurveyForm
surveyData={data || { surveys: [], totalPages: 0 }}
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/pages/MyForm.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { useNavigate } from 'react-router-dom';
import { useEffect } from 'react';
import SurveyForm from '../components/survey/SurveyForm';
import usePaginationSurveyList from '../hooks/usePaginationSurveyList';

function MyForm() {
const navigate = useNavigate();

const { data, currentPage, handlePageChange, searchTerm, setSearchTerm, handleSortChange } =
const { data, currentPage, handlePageChange, searchTerm, setSearchTerm, handleSortChange, refetch } =
usePaginationSurveyList('myForm');

useEffect(() => {
refetch();
}, [refetch]);

return (
<SurveyForm
surveyData={data || { surveys: [], totalPages: 0 }}
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/pages/MyResponse.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { useEffect } from 'react';
import SurveyForm from '../components/survey/SurveyForm';
import usePaginationSurveyList from '../hooks/usePaginationSurveyList';

function MyResponse() {
const { data, currentPage, handlePageChange, searchTerm, setSearchTerm, handleSortChange } =
const { data, currentPage, handlePageChange, searchTerm, setSearchTerm, handleSortChange, refetch } =
usePaginationSurveyList('myResponse');

useEffect(() => {
refetch();
}, [refetch]);

return (
<SurveyForm
surveyData={data || { surveys: [], totalPages: 0 }}
Expand Down

0 comments on commit c3e070b

Please sign in to comment.