/* eslint-disable handle-callback-err */
import { PostData, GetURL, GetData } from '../helpers'
import url from '../url'

export const getListPosts = async (body) =>
    PostData(url.urlGetListPosts, body)
        .then((res) => res)
        .catch((err) => null)

export const createPosts = async (body) =>
    PostData(url.urlCreatePosts, body)
        .then((res) => res)
        .catch((err) => null)

export const updatePosts = async (body) =>
    PostData(url.urlUpdatePosts, body)
        .then((res) => res)
        .catch((err) => null)

export const detailPosts = async (id, body) =>
    GetURL(`${url.urlDetailPosts}/${id}`, body)
        .then((res) => res)
        .catch((err) => null)

export const deletePosts = async (body) =>
    PostData(url.urlDeletePosts, body)
        .then((res) => res)
        .catch((err) => null)

export const changeStatusPosts = async (body) =>
    PostData(url.changeStatusPosts, body)
        .then((res) => res)
        .catch((err) => null)
