import axios from 'axios';

export const sysadminApi = axios.create({
    baseURL: 'http://localhost:3002',
    headers: {
        'Content-Type': 'application/json'
    }
});

// User API Calls
export const fetchUsers = async (filters: any) => {
    const res = await sysadminApi.post('/users/paginate', filters);
    return res.data;
};

export const updateUserProfile = async (data: any) => {
    const res = await sysadminApi.post('/users/update', data);
    return res.data;
};

export const setVerifiedStatus = async (userId: string, isVerified: boolean) => {
    const res = await sysadminApi.post('/users/set-verified', { userId, isVerified });
    return res.data;
};

export const deleteUser = async (userId: string) => {
    const res = await sysadminApi.post('/users/delete', { userId });
    return res.data;
};

export const getOrganizationsStatus = async (userId: string) => {
    const res = await sysadminApi.post('/users/organizations-status', { userId });
    return res.data;
};

// Wap Servers API Calls
export const fetchWapServers = async (filters: any) => {
    const res = await sysadminApi.post('/wap/paginate', filters);
    return res.data;
};

// Companies API Calls
export const fetchCompanies = async (filters: any) => {
    const res = await sysadminApi.post('/companies/paginate', filters);
    return res.data;
};

export const updateCompany = async (data: any) => {
    const res = await sysadminApi.post('/companies/update', data);
    return res.data;
};

export const setCompanyBanned = async (id: string, banned: boolean) => {
    const res = await sysadminApi.post('/companies/set-banned', { id, banned });
    return res.data;
};

// Services API Calls
export const fetchServices = async (filters: any) => {
    const res = await sysadminApi.post('/services/paginate', filters);
    return res.data;
};

export const setServiceBanned = async (id: string, banned: boolean) => {
    const res = await sysadminApi.post('/services/set-banned', { id, banned });
    return res.data;
};
