question.api.ts 770 Bytes
Newer Older
Yoon, Daeki's avatar
Yoon, Daeki committed
1
import axios from "./axios.config";
Yoon, Daeki's avatar
Yoon, Daeki committed
2
import { IQuestionData } from "../types";
Jiwon Yoon's avatar
Jiwon Yoon committed
3
4
import baseUrl from "./baseUrl";

Jiwon Yoon's avatar
Jiwon Yoon committed
5
6
7
8
9
10
11
12
13
14
15
export const createQuestion = async (surveyId: string) => {
  const { data } = await axios.post(
    `${baseUrl}/surveys/${surveyId}/questions`,
    {
      type: "essay",
      title: "",
      isRequired: false,
      comment: "",
      content: { choices: [] },
    }
  );
Jiwon Yoon's avatar
Jiwon Yoon committed
16
17
18
  return data;
};

Yoon, Daeki's avatar
Yoon, Daeki committed
19
export const updateQuestion = async (question: IQuestionData) => {
Jiwon Yoon's avatar
Jiwon Yoon committed
20
21
22
23
  const { data } = await axios.put(
    `${baseUrl}/questions/update/${question._id}`,
    question
  );
Jiwon Yoon's avatar
Jiwon Yoon committed
24
25
26
  return data;
};

27
28
29
30
export const deleteQuestion = async (questionId: string) => {
  const { data } = await axios.delete(
    `${baseUrl}/questions/delete/${questionId}`
  );
Jiwon Yoon's avatar
Jiwon Yoon committed
31
32
  return data;
};