Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3659 | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

import { api } from '@shared/libs';

export const addCapsuleComment = async (url, { comment, rating }) => {
  try {
    const { message, comment: newComment, capsule } = await api.post(url, { comment, rating });
    return { message, comment: newComment, capsule };
  } catch (error) {
    console.error(error);
    throw new Error('Error al agregar el comentario');
  }
};

export const deleteCapsuleComment = async (url) => {
  try {
    const { message, capsule } = await api.post(url);
    return { message, capsule };
  } catch (error) {
    console.error(error);
    throw new Error('Error al eliminar el comentario');
  }
};

export const getCapsules = async (url, { params = undefined } = {}) => {
  try {
    return await api.get(url, { params });
  } catch (error) {
    console.error(error);
    throw new Error('Error al obtener las cápsulas');
  }
};

export const getLastCapsuleInProgress = async () => {
  try {
    return await api.get('/microlearning/last-capsule-in-progress');
  } catch (error) {
    console.error(error);
    throw new Error('Error al obtener la última cápsula en progreso');
  }
};

export const getCapsule = async (uuid) => {
  try {
    return await api.get(`/microlearning/capsules/${uuid}`);
  } catch (error) {
    console.error(error);
    throw new Error('Error al obtener la cápsula');
  }
};