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

const getAllNotification = async (queryParams) => {
    const response = await SendRequest({
        method: 'get',
        prefix: `notification?${queryParams.toString()}`,
    });

    return response.data;
};

const getNotificationById = async (id) => {
    const response = await SendRequest({
        method: 'get',
        prefix: `notification/${id}`,
    });

    return response.data;
};

const getNotificationDetail = async (id) => {
    const response = await SendRequest({
        method: 'get',
        prefix: `notification/${id}`,
    });

    return response.data;
};

// Create new notification log
const createNotificationLog = async (data) => {
    const response = await SendRequest({
        method: 'post',
        prefix: 'notification-log',
        params: data,
    });
    return response.data;
};

// Get notification logs by notification_error_id
const getNotificationLogByNotificationId = async (notificationId) => {
    const response = await SendRequest({
        method: 'get',
        prefix: `notification-log/notification_error/${notificationId}`,
    });
    return response.data;
};

export {
    getAllNotification,
    getNotificationById,
    getNotificationDetail,
    createNotificationLog,
    getNotificationLogByNotificationId
};
