plan.api.js 893 Bytes
Newer Older
Choi Ga Young's avatar
Choi Ga Young committed
1
2
3
import axios from "axios";
import baseUrl from "../utils/baseUrl";

Kim, Subin's avatar
plan    
Kim, Subin committed
4
5
const getDetail = async (planId) => {
  const url = `${baseUrl}/api/plan/${planId}`
Kim, Subin's avatar
Kim, Subin committed
6
7
8
9
  const { data } = await axios.get(url)
  return data
}

Choi Ga Young's avatar
Choi Ga Young committed
10
11
12
13
14
15
const saveCheck = async (planId, planCk) => {
  const url = `${baseUrl}/api/plan/check/${planId}`
  const { data } = await axios.put(url, {planCk})
  return data
}

Kim, Subin's avatar
plan    
Kim, Subin committed
16
17
18
const submit = async (info) => {
  const url = `${baseUrl}/api/plan`
  const { data } = await axios.post(url, info)
Choi Ga Young's avatar
Choi Ga Young committed
19
20
21
  return data
}

Kim, Subin's avatar
plan    
Kim, Subin committed
22
23
24
const edit = async (info, planId) => {
  const url = `${baseUrl}/api/plan/${planId}`
  const { data } = await axios.put(url, info)
Choi Ga Young's avatar
Choi Ga Young committed
25
26
27
  return data
}

Kim, Subin's avatar
plan    
Kim, Subin committed
28
29
const remove = async (planId) => {
  const url = `${baseUrl}/api/plan/${planId}`
Kim, Subin's avatar
Kim, Subin committed
30
  const { data } = await axios.delete(url)
Choi Ga Young's avatar
Choi Ga Young committed
31
32
  return data
}
Kim, Subin's avatar
Kim, Subin committed
33

Choi Ga Young's avatar
Choi Ga Young committed
34
const planApi = {
Kim, Subin's avatar
Kim, Subin committed
35
  getDetail,
Choi Ga Young's avatar
Choi Ga Young committed
36
  saveCheck,
Kim, Subin's avatar
plan    
Kim, Subin committed
37
38
  submit,
  edit,
Kim, Subin's avatar
Kim, Subin committed
39
  remove
Choi Ga Young's avatar
Choi Ga Young committed
40
41
42
};

export default planApi