ff-admin/src/stores/admin/scanner.ts

29 lines
682 B
TypeScript
Raw Normal View History

import { defineStore } from "pinia";
import { v4 as uuid } from "uuid";
export const useScannerStore = defineStore("scanner", {
state: () => {
return {
inUse: false as boolean,
roomId: undefined as undefined | string,
results: [] as Array<string>,
connectedDevices: 0 as number,
};
},
actions: {
startSession() {
if (this.inUse) return;
this.roomId = uuid();
this.inUse = true;
},
endSession() {
this.inUse = false;
this.roomId = undefined;
this.results = [];
},
removeElementFromResults(el: string) {
this.results = this.results.filter((result) => result !== el);
},
},
});