import { SendRequest } from '../components/Global/ApiRequest';

const getAllJadwalShift = async (queryParams) => {
    try {
        const response = await SendRequest({
            method: 'get',
            prefix: `jadwal-shift?${queryParams.toString()}`,
        });
        return response;
    } catch (error) {
        console.error('getAllJadwalShift error:', error);
        return {
            status: 500,
            data: {
                data: [],
                paging: {
                    page: 1,
                    limit: 10,
                    total: 0,
                    page_total: 0
                },
                total: 0
            },
            error: error.message
        };
    }
};

const createJadwalShift = async (queryParams) => {
    const response = await SendRequest({
        method: 'post',
        prefix: `jadwal-shift`,
        data: queryParams,
    });
    return {
        statusCode: response.statusCode || 200,
        data: response.data,
        message: response.message
    };
};

const updateJadwalShift = async (id, queryParams) => {
    const response = await SendRequest({
        method: 'put',
        prefix: `jadwal-shift/${id}`,
        data: queryParams,
    });
    return {
        statusCode: response.statusCode || 200,
        data: response.data,
        message: response.message
    };
};

const deleteJadwalShift = async (id) => {
    const response = await SendRequest({
        method: 'delete',
        prefix: `jadwal-shift/${id}`,
    });
    return {
        statusCode: response.statusCode || 200,
        data: response.data,
        message: response.message
    };
};

export { getAllJadwalShift, createJadwalShift, updateJadwalShift, deleteJadwalShift };
