Skip to content
Open
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
332 changes: 332 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.7.7",
"js-cookie": "^3.0.5",
"moment": "^2.30.1",
"react": "^18.3.1",
"react-calendar": "^5.0.0",
"react-dom": "^18.3.1",
"react-router-dom": "^6.26.2",
"react-scripts": "5.0.1",
"recharts": "^2.12.7",
"styled-components": "^6.1.13",
"web-vitals": "^2.1.4"
},
Expand All @@ -37,5 +41,6 @@
"last 1 firefox version",
"last 1 safari version"
]
}
},
"proxy": "http://13.125.238.177:8080"
}
2 changes: 1 addition & 1 deletion src/components/features/EditSurvey/Question/Checkbox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const Container = styled.div`
`;

const DescriptionContainer = styled.div`
width: 100%
width: 80%;
margin-top: 10px;
margin-left: 30px;
background-color: #ffffff;
Expand Down
83 changes: 43 additions & 40 deletions src/components/features/EditSurvey/QuestionItem.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, { useState, useEffect, useRef } from "react";
import styled from "styled-components";
import axios from "axios";
// import axios from "axios";
import AI from "../../../assets/images/buttons/ai.png";
import { AiResponseModal } from "../../common/Modal/AiResponseModal";
import { AiMeaningModal } from "../../common/Modal/AiMeaningModal";
import { AiLikertModal } from "../../common/Modal/AiLikertModal";
import { Checkbox } from "./Question/Checkbox";
import { LongAnswer } from "./Question/LongAnswer";
import { ShortAnswer } from "./Question/ShortAnswer";
Expand All @@ -24,7 +25,8 @@ export const QuestionItem = ({ question = { options: [] }, setQuestions }) => {
const [selectedType, setSelectedType] = useState("체크박스");
const [isDropdownOpen, setDropdownOpen] = useState(false);
const [isModalOpen, setIsModalOpen] = useState(false);
const [aiResponse, setAiResponse] = useState("");
const [modalType, setModalType] = useState(null);
// const [aiResponse, setAiResponse] = useState("");
const dropdownRef = useRef(null);

const handleDropdownToggle = () => {
Expand Down Expand Up @@ -76,16 +78,16 @@ export const QuestionItem = ({ question = { options: [] }, setQuestions }) => {
}
};

const QUESTION_TYPE_TIMES = {
CHECK_CHOICE: 1, // 체크박스
SEMANTIC_RATINGS: 2, // 의미분별척도
LIKERT_SCORES: 2, // 리커트척도
MULTIPLE_CHOICE: 1, // 객관식
NUMERIC_RESPONSE: 1, // 숫자응답
PHONE_NUMBER: 1, // 전화번호
SUBJECTIVE: 3, // 주관식
DESCRIPTIVE: 5, // 서술형
};
// const QUESTION_TYPE_TIMES = {
// CHECK_CHOICE: 1, // 체크박스
// SEMANTIC_RATINGS: 2, // 의미분별척도
// LIKERT_SCORES: 2, // 리커트척도
// MULTIPLE_CHOICE: 1, // 객관식
// NUMERIC_RESPONSE: 1, // 숫자응답
// PHONE_NUMBER: 1, // 전화번호
// SUBJECTIVE: 3, // 주관식
// DESCRIPTIVE: 5, // 서술형
// };

const handleClickOutside = (event) => {
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
Expand All @@ -101,12 +103,12 @@ export const QuestionItem = ({ question = { options: [] }, setQuestions }) => {
}, []);

const handleAIButtonClick = async () => {
const requestData = {
survey_title: question.survey_title,
text: question.text,
question_type: selectedType,
response_time: QUESTION_TYPE_TIMES[selectedType],
};
// const requestData = {
// survey_title: question.survey_title,
// text: question.text,
// question_type: selectedType,
// response_time: QUESTION_TYPE_TIMES[selectedType],
// };

// if (selectedType === "의미 분별 척도") {
// requestData.semantic_option = {
Expand All @@ -117,22 +119,24 @@ export const QuestionItem = ({ question = { options: [] }, setQuestions }) => {
// requestData.options = question.options;
// }

try {
const response = await axios.post(
"http://localhost:8080/api/prompt",
requestData,
{
headers: {
"Content-Type": "application/json",
},
}
);
setAiResponse(response.data);
console.log(response.data);
setIsModalOpen(true);
} catch (error) {
console.error("Error fetching AI response:", error);
// try {
// const response = await axios.post("/api/prompt", requestData, {
// headers: {
// "Content-Type": "application/json",
// },
// });
// setAiResponse(response.data);
// console.log(response.data);
// setIsModalOpen(true);
// } catch (error) {
// console.error("Error fetching AI response:", error);
// }
if (selectedType === "의미 분별 척도") {
setModalType("meaning");
} else if (selectedType === "리커트 척도") {
setModalType("likert");
}
setIsModalOpen(true);
};

const closeModal = () => {
Expand Down Expand Up @@ -176,12 +180,11 @@ export const QuestionItem = ({ question = { options: [] }, setQuestions }) => {
</TitleContainer>
{renderComponent()}

{isModalOpen && (
<AiResponseModal
response={aiResponse}
isOpen={isModalOpen}
onClose={closeModal}
/>
{isModalOpen && modalType === "meaning" && (
<AiMeaningModal isOpen={isModalOpen} onClose={closeModal} />
)}
{isModalOpen && modalType === "likert" && (
<AiLikertModal isOpen={isModalOpen} onClose={closeModal} />
)}
</Container>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/features/HomePage/HomeBanner.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import styled from "styled-components";
import sursim from "../../../assets/images/sursim.png";
import sursim from "../../../assets/images/sursim_home.png";
import banner from "../../../assets/images/logos/BannerLogo.png";
import { useNavigate } from "react-router-dom";

Expand Down
42 changes: 42 additions & 0 deletions src/components/features/HomePage/SurveyList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,48 @@ const SurveyData = [
points: 500,
duration: "24/04/23~24/04/30",
},
{
id: 8,
title: "환경 보호 인식 조사",
target: "20대~50대",
points: 800,
duration: "24/05/15 ~ 24/05/21",
},
{
id: 9,
title: "직장 내 스트레스 요인 조사",
target: "20대~40대",
points: 900,
duration: "24/05/22 ~ 24/05/28",
},
{
id: 10,
title: "건강식품 구매 의향 조사",
target: "30대~60대",
points: 750,
duration: "24/05/29 ~ 24/06/04",
},
{
id: 11,
title: "학생들의 학습 환경 조사",
target: "학생",
points: 650,
duration: "24/06/05 ~ 24/06/11",
},
{
id: 12,
title: "여행 소비 트렌드 조사",
target: "20대~40대",
points: 700,
duration: "24/06/12 ~ 24/06/18",
},
{
id: 13,
title: "디지털 기기 사용 패턴 조사",
target: "10대~50대",
points: 720,
duration: "24/06/19 ~ 24/06/25",
},
];

const itemsPerPage = 6;
Expand Down
Loading