Commit 4f17e307 authored by Jiwon Yoon's avatar Jiwon Yoon
Browse files

Merge branch 'seoyeon_' into jiwon0718

parents 463ce408 117bbc7e
......@@ -17,7 +17,6 @@ export const ansSurvey = async (surveyId: string) => {
return data;
};
//동혁
export const getSurveys = async () => {
const { data } = await axios.get(`${baseUrl}/surveys/`);
return data;
......
......@@ -21,7 +21,7 @@ export const ACheckboxForm = ({ element, response, handleAnswer }: Props) => {
handleAnswer();
};
return (
<div className="flex w-full gap-4 justify-around my-3">
<div className="flex w-full gap-2 justify-around my-3">
{element.content.choices.map((choice) => (
<div>
<input
......
import React from "react";
export const ADateForm = () => {
return (
<div className="justify-start w-11/12 m-3 py-4">
<input type="date"></input>
</div>
);
};
import React, { useState } from "react";
import { useNavigate } from "react-router-dom";
import { BasicQuestionType, AnswerType, SurveyType } from "../types";
import { ACheckboxForm } from "./ACheckbox";
import { ADropdownForm } from "./ADropdown";
import { ACheckboxForm } from "./ACheckboxForm";
import { ADateForm } from "./ADateForm";
import { ADropdownForm } from "./ADropdownForm";
import { AEssayForm } from "./AEssayForm";
import { ARadioForm } from "./ARadioForm";
import { AFileForm } from "./AFileForm";
import { ARadioForm } from "./ARadioForm";
import { ARatingForm } from "./ARatingForm";
type Props = {
question: BasicQuestionType;
......@@ -70,6 +72,10 @@ export const AQuestion = ({
// currentId={currentId}
// />
// );
case "rating":
return <ARatingForm element={question} />;
case "date":
return <ADateForm />;
default:
return <></>;
}
......
......@@ -21,7 +21,7 @@ export const ARadioForm = ({ element, response, handleAnswer }: Props) => {
handleAnswer();
};
return (
<div className="flex w-full gap-4 justify-around my-3">
<div className="flex w-full gap-2 justify-around my-3">
{element.content.choices.map((choice) => (
<div>
<input
......
import React, { useState } from "react";
import { RatingType } from "../types";
type Props = {
element: RatingType;
};
export const ARatingForm = ({ element }: Props) => {
const [selectedchoice, setSelectedchoice] = useState("");
function buttonClick(event: React.MouseEvent<HTMLButtonElement>) {
event.preventDefault();
setSelectedchoice(event.currentTarget.name);
}
return (
<div className="flex w-full justify-center space-x-12 my-3">
<label className="mt-3">{element.content.minRateDescription}</label>
{element.content.choices.map((choice) => (
<div className="flex gap-4">
<button
type="button"
className="border border-themeColor rounded-full w-12 h-12 text-center hover:bg-slate-300"
name={choice.text}
onClick={buttonClick}
style={{
backgroundColor:
selectedchoice === choice.text ? "#58ACFA" : "white",
}}
>
{choice.text}
</button>
</div>
))}
<label className="mt-3">{element.content.maxRateDescription}</label>
</div>
);
};
import { NextFunction, Request, Response } from "express";
import { surveyDb } from "../db";
import { asyncWrap } from "../helpers/asyncWrap";
// import jwt, { JwtPayload } from "jsonwebtoken";
// import { cookieConfig, envConfig, jwtCofig } from "../config";
export interface TypedRequestAuth<T> extends Request {
auth: T;
......@@ -68,3 +70,29 @@ export const userBySurveyId = async (
);
}
};
// export const checksurvey = asyncWrap(async(req, res)=> {
// const {_id} = req.body
// const surveyExist = await surveyDb.isSurvey(_id);
// if (surveyExist) {
// return res.status(422).send("이미 제출된 설문조사입니다")
// }
// });
// export const surveynotexist = asyncWrap(async (req, res) => {
// const { _id } = req.body;
// console.log(`surveyId: ${_id}`);
// const checksurveyId = await surveyDb.findUserBySurveyId(_id);
// const surveytoken = jwt.sign({existsurveyId: checksurveyId?.id}, jwtCofig.secret, {
// expiresIn:jwtCofig.expires,
// });
// res.cookie(cookieConfig.name, surveytoken, {
// maxAge:cookieConfig.maxAge,
// path:"/",
// httpOnly: envConfig.mode === "production",
// secure: envConfig.mode === "production",
// })
// res.json({
// surveyId: checksurveyId?._id
// })
// });
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment