diff --git a/src/composables/usePlannerState.js b/src/composables/usePlannerState.js new file mode 100644 index 0000000..1af94ac --- /dev/null +++ b/src/composables/usePlannerState.js @@ -0,0 +1,33 @@ +import { ref } from 'vue' + +const numbers = ref([]) +const clickCount = ref(1) +const listOfTrips = ref([]) + +function createEmptyGrid() { + return Array.from({ length: 100 }, (_, i) => ({ + variable: [], + x: i % 10, + y: 9 - Math.floor(i / 10), + index: i, + isPlatform: false, + isQR: false, + BgImg: 'images/ArUco-marker.jpg', + })) +} + +function ensureGridInitialized() { + if (numbers.value.length === 0) { + numbers.value = createEmptyGrid() + } +} + +export function usePlannerState() { + ensureGridInitialized() + + return { + numbers, + clickCount, + listOfTrips, + } +} diff --git a/src/views/PlannerView.vue b/src/views/PlannerView.vue index f18135e..0da68eb 100644 --- a/src/views/PlannerView.vue +++ b/src/views/PlannerView.vue @@ -1,5 +1,5 @@