Skip to content

Commit 0989483

Browse files
authored
Merge pull request #54 from eurofurence/fix/formjs
Fix formjs-vue2 by replacing it with fetch and kicking it from project dependencies
2 parents b7758d1 + d604ea4 commit 0989483

3 files changed

Lines changed: 20 additions & 72 deletions

File tree

package-lock.json

Lines changed: 0 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"dependencies": {
2020
"chokidar": "^3.6.0",
2121
"dayjs": "^1.11.11",
22-
"formjs-vue2": "^1.4.0",
2322
"laravel-precognition-vue-inertia": "^0.5.5",
2423
"pica": "^9.0.1",
2524
"primeicons": "^7.0.0",

resources/js/Components/POS/QZPrintService.vue

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import {usePage} from "@inertiajs/vue3";
33
import {onMounted} from "vue";
44
import qz from "qz-tray";
5-
import { http } from "formjs-vue2"
65
76
const page = usePage();
87
@@ -57,12 +56,19 @@ function startQZPrint() {
5756
5857
function pollPrintJobs() {
5958
setInterval(() => {
60-
http.get(route('pos.auth.printers.jobs'),{},{
61-
onSuccess(printJobs) {
59+
fetch(route('pos.auth.printers.jobs'), {
60+
cache: 'no-store',
61+
headers: {
62+
'Accept': 'application/json'
63+
}
64+
})
65+
.then((data) => data.json())
66+
.then((printJobs) => {
6267
printJobs.data.forEach((job) => {
6368
console.log("job", job);
64-
http.post(route('pos.auth.printers.jobs.printed', {job: job.id}), {}, {
65-
onSuccess() {
69+
fetch(route('pos.auth.printers.jobs.printed', {job: job.id}), {
70+
method: 'POST'
71+
}).then(() => {
6672
var printerOptions = (job.type === 'badge') ? {
6773
colorType: 'color',
6874
size: job.paper.mm,
@@ -88,17 +94,21 @@ function pollPrintJobs() {
8894
qz.print(config, data).catch((err) => {
8995
console.error(err);
9096
});
91-
}
92-
});
97+
});
9398
});
94-
}
95-
})
99+
})
96100
},5000)
97101
}
98102
99103
function findPrinters() {
100104
qz.printers.details().then((printers) => {
101-
http.post(route('pos.auth.printers.store'), {printers: printers});
105+
fetch(route('pos.auth.printers.store'), {
106+
method: "POST",
107+
body: JSON.stringify({printers: printers}),
108+
headers: {
109+
'Content-Type': 'application/json'
110+
}
111+
});
102112
}).catch((err) => {
103113
console.error(err);
104114
});

0 commit comments

Comments
 (0)