import { useSession } from './useSession'; import axios from 'axios'; import { useQuasar } from 'quasar'; import { useI18n } from 'vue-i18n'; export function usePrintService() { const quasar = useQuasar(); const { t } = useI18n(); const { getTokenMultimedia } = useSession(); function sendEmail(path, params) { return axios.post(path, params).then(() => quasar.notify({ message: t('globals.notificationSent'), type: 'positive', icon: 'check', }) ); } function openReport(path, params, isNewTab = '_self') { if (typeof params === 'string') params = JSON.parse(params); params = Object.assign( { access_token: getTokenMultimedia(), }, params ); const query = new URLSearchParams(params).toString(); window.open(`api/${path}?${query}`, isNewTab); } return { sendEmail, openReport, }; }