37 lines
827 B
JavaScript
37 lines
827 B
JavaScript
|
import { useSession } from './useSession';
|
||
|
import axios from 'axios';
|
||
|
import { useQuasar } from 'quasar';
|
||
|
|
||
|
export function usePrintService() {
|
||
|
const quasar = useQuasar();
|
||
|
const { getToken } = useSession();
|
||
|
|
||
|
function sendEmail(path, params) {
|
||
|
return axios.post(path, params).then(() =>
|
||
|
quasar.notify({
|
||
|
message: 'Notification sent',
|
||
|
type: 'positive',
|
||
|
icon: 'check',
|
||
|
})
|
||
|
);
|
||
|
}
|
||
|
|
||
|
function openReport(path, params) {
|
||
|
params = Object.assign(
|
||
|
{
|
||
|
access_token: getToken(),
|
||
|
},
|
||
|
params
|
||
|
);
|
||
|
|
||
|
const query = new URLSearchParams(params).toString();
|
||
|
|
||
|
window.open(`api/${path}?${query}`);
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
sendEmail,
|
||
|
openReport,
|
||
|
};
|
||
|
}
|