schedule.api.js 1.14 KB
Newer Older
Kim, Subin's avatar
Kim, Subin committed
1
import axios from "axios";
Kim, Subin's avatar
Kim, Subin committed
2
import baseUrl from "../utils/baseUrl";
Kim, Subin's avatar
Kim, Subin committed
3

4
5
6
7
8
9
const getOne = async (id, userId = "ku") => {
    const { data } = await axios.get(`${baseUrl}/api/schedule/${userId}?scheduleId=${id}`);
    return data
}

const getbyMonth = async (date, userId = "ku") => {
Kim, Subin's avatar
Kim, Subin committed
10
    const { data } = await axios.get(`${baseUrl}/api/schedule/${userId}?dateMonth=${date}`);
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    return data
}

const getbyDate = async (date, userId = "ku") => {
    const { data } = await axios.get(`${baseUrl}/api/schedule/${userId}?date=${date}`);
    return data
}

const submit = async (schedule, userId = "ku") => {
    const { data } = await axios.post(`${baseUrl}/api/schedule/${userId}`, schedule);
    return data
}

const edit = async (id, schedule, userId = "ku") => {
    const { data } = await axios.put(`${baseUrl}/api/schedule/${userId}?scheduleId=${id}`, schedule);
    return data
}

const remove = async (id, userId = "ku") => {
    const { data } = await axios.delete(`${baseUrl}/api/schedule/${userId}?scheduleId=${id}`);
Kim, Subin's avatar
Kim, Subin committed
31
32
33
34
    return data
}

const scheduleApi = {
35
36
37
38
39
40
    getOne,
    getbyMonth,
    getbyDate,
    submit,
    edit,
    remove
Kim, Subin's avatar
Kim, Subin committed
41
42
43
}

export default scheduleApi