From 60ace793531f7bc0a0d01690896f5ad0d0cbfecc Mon Sep 17 00:00:00 2001 From: geumbin Date: Sun, 21 Apr 2024 04:43:24 +0900 Subject: [PATCH] =?UTF-8?q?:sparkles:=20Feat=20:=20Survey=20API=20?= =?UTF-8?q?=EC=B5=9C=EC=A2=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/survey/GenderRadio.tsx | 3 -- src/components/survey/PurposeCheckbox.tsx | 46 ----------------------- src/pages/SurveyPage.tsx | 22 +++++------ 3 files changed, 9 insertions(+), 62 deletions(-) diff --git a/src/components/survey/GenderRadio.tsx b/src/components/survey/GenderRadio.tsx index a8093a7..5287be8 100644 --- a/src/components/survey/GenderRadio.tsx +++ b/src/components/survey/GenderRadio.tsx @@ -7,7 +7,6 @@ interface Gender { } const GenderRadio: React.FC = ({ onGenderChange }) => { - const [gender, setGender] = useState('FEMALE'); const handleGenderChange = (event: React.ChangeEvent) => { @@ -23,12 +22,10 @@ const GenderRadio: React.FC = ({ onGenderChange }) => { - 여성 - 남성 diff --git a/src/components/survey/PurposeCheckbox.tsx b/src/components/survey/PurposeCheckbox.tsx index 730740b..4ff00a0 100644 --- a/src/components/survey/PurposeCheckbox.tsx +++ b/src/components/survey/PurposeCheckbox.tsx @@ -1,11 +1,9 @@ - import React, { useState, useEffect } from 'react'; import { Checkbox, Stack, Input, Text } from '@chakra-ui/react'; import * as S from '@/styles/survey/PurposeCheckbox.style'; interface Purpose { - onPurposeChange: (purpose: string[]) => void; } @@ -30,7 +28,6 @@ const PurposeCheckbox: React.FC = ({ onPurposeChange }) => { let updatedPurposes: string[]; if (isChecked) { - updatedPurposes = [...checkedPurposes, purpose]; } else { updatedPurposes = checkedPurposes.filter(item => item !== purpose); @@ -44,7 +41,6 @@ const PurposeCheckbox: React.FC = ({ onPurposeChange }) => { const newOtherPurpose = event.target.value; setOtherPurpose(newOtherPurpose); setIsOtherSelected(!!newOtherPurpose); - }; return ( @@ -72,7 +68,6 @@ const PurposeCheckbox: React.FC = ({ onPurposeChange }) => { - 기타 @@ -92,44 +87,3 @@ const PurposeCheckbox: React.FC = ({ onPurposeChange }) => { }; export default PurposeCheckbox; - -// import React from 'react'; -// import { Checkbox, Stack, Input, Text } from '@chakra-ui/react'; -// import * as S from '@/styles/survey/PurposeCheckbox.style'; - -// interface Purpose { -// onPurposeChange: (city: string) => void; -// } - -// const PurposeCheckbox: React.FC = ({ onPurposeChange }) => { -// const [purpose, setPurpose] = useState('서울'); -// const handlePurposeChange = (event: React.ChangeEvent) => { -// const newPurpose = event.target.value; -// setPurpose(newPurpose); -// onPurposeChange(newPurpose); -// }; - -// return ( -// <> -// -// Past-Forward 서비스를 알게 된 경로는 무엇입니까? -// (복수 선택 가능) -// -// -// -// 업무 목적 -// 개인 발전 -// 팀 협업 -// 프로젝트 관리 -// 학습 및 개선 -// -// -// 기타 -// -// -// -// -// -// -// ); -// }; diff --git a/src/pages/SurveyPage.tsx b/src/pages/SurveyPage.tsx index 493287d..4cf9f43 100644 --- a/src/pages/SurveyPage.tsx +++ b/src/pages/SurveyPage.tsx @@ -1,5 +1,4 @@ import React, { useState, useEffect } from 'react'; - import { useNavigate } from 'react-router-dom'; import { Text, Button, Divider } from '@chakra-ui/react'; import { PostSurvey } from '@/api/survey/postSurvey'; @@ -16,7 +15,6 @@ const SurveyPage: React.FC = () => { localStorage.setItem('surveyVisited', 'true'); }, []); - const navigate = useNavigate(); const handleSurveyButtonClick = () => { @@ -25,7 +23,6 @@ const SurveyPage: React.FC = () => { const handleSurvey = async () => { try { - console.log( '나이는:', age, @@ -39,31 +36,34 @@ const SurveyPage: React.FC = () => { path, '/목적은(복수선택):', purpose, - + ); + const SurveyRequest = await PostSurvey({ + age: numAge, + gender: gender, + occupation: job, + region: city, + source: path, + purposes: purpose, + }); console.log('설문조사 전송 성공', SurveyRequest); alert('설문조사가 전송되었습니다.'); navigate('/'); - } catch (error) { console.error('실패입니다.', error); } }; const [age, setAge] = useState(''); - const [gender, setGender] = useState('FEMALE'); const [job, setJob] = useState(''); const [city, setCity] = useState('서울'); const [path, setPath] = useState(''); const [purpose, setPurpose] = useState(); - const handleAgeChange = (age: string) => { setAge(age); }; - const numAge: number = parseInt(age, 10); - const handleGenderChange = (gender: string) => { setGender(gender); }; @@ -76,12 +76,10 @@ const SurveyPage: React.FC = () => { const handlePathChange = (path: string) => { setPath(path); }; - const handlePurposeChange = (purpose: string[]) => { setPurpose(purpose); }; - return ( <> @@ -99,9 +97,7 @@ const SurveyPage: React.FC = () => { - -