import api from "src/api";

const base = "/franchisor/permissions/groups";

export const getUserTypes = async () => {
  const { data } = await api.get(base);
  return data.payload;
};

export const createUserType = async (payload) => {
  const { data } = await api.post(base, payload);
  return data.payload;
};

export const updateUserType = async (id, payload) => {
  const { data } = await api.put(`${base}/${id}`, payload);
  return data.payload;
};

export const deleteUserType = async (id) => {
  const { data } = await api.delete(`${base}/${id}`);
  return data.payload;
};

export const getUserTypePermissions = async (id) => {
  const { data } = await api.get(`${base}/${id}/permissions`);
  return data.payload;
};

export const updateUserTypePermissions = async (id, permissions) => {
  const { data } = await api.put(`${base}/${id}/permissions`, {
    permissions,
  });
  return data.payload;
};
