const URL = "/one-api/mockup/purchase/suratjalan/SuratJalan/";

/* QUERY */

export async function lookupEkpedisi(params) {
    try {
        var response = await axios.post(URL + 'LookupEkspedisi', params)
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            }
        }

        let data = response.data
        return data
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        }
    }
}

export async function lookupEkpedisiStaff(params) {
    try {
        var response = await axios.post(URL + 'LookupEkspedisiStaff', params)
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            }
        }

        let data = response.data
        return data
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        }
    }
}

export async function GetTFDataDetail(params) {
    try {
        var response = await axios.post(URL + 'LookupSuratJalanDetail', params)
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            }
        }

        let data = response.data
        return data
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        }
    }
}

export async function ListingSuratJalan(params) {
    try {
        var response = await axios.post(URL + 'LookupListSuratJalan', params)
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            }
        }

        let data = response.data
        return data
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        }
    }
}

export async function ListingBranch(params) {
    try {
        var response = await axios.post(URL + 'LookupListBranch', params)
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            }
        }

        let data = response.data
        return data
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        }
    }
}

export async function CheckPeriode(params) {
    try {
        var response = await axios.post(URL + 'CheckPeriode', params)
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            }
        }
        let data = response.data
        return data
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        }
    }
}

export async function lookupTransferRequest(params) {
    try {
        var response = await axios.post(URL + 'LookupTransferRequest', params)
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            }
        }
        let data = response.data
        return data
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        }
    }
}

export async function lookupTransferRequestDetail(params) {
    try {
        var response = await axios.post(URL + 'LookupTransferRequestDetail', params)
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            }
        }
        let data = response.data
        return data
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        }
    }
}

/* MUTATIONS */

export async function createSuratJalan(params) {
    try {
        var response = await axios.post(URL + 'CreateSuratJalan', params)
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            }
        }

        let data = response.data
        return data
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        }
    }
}

export async function updateSuratJalan(params) {
    try {
        var response = await axios.post(URL + 'UpdateSuratJalan', params)
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            }
        }

        let data = response.data
        return data
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        }
    }
}

export async function konfirmSuratJalan(params) {
    try {
        var response = await axios.post(URL + 'KonfirmSuratJalan', params)
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            }
        }

        let data = response.data
        return data
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        }
    }
}

export async function deleteSuratJalan(params) {
    try {
        var response = await axios.post(URL + 'DeleteSuratJalan', params)
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            }
        }

        let data = response.data
        return data
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        }
    }
}

export async function GenerateJurnal(params) {
    try {
        var response = await axios.post(URL + 'GenerateJurnal', params)
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            }
        }
        let data = response.data
        return data
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        }
    }
}