From 11e379a5b9b9920c4167fd2a9ec3d58f2987edc1 Mon Sep 17 00:00:00 2001 From: "bert.hausmans" Date: Tue, 14 Apr 2026 19:04:17 +0200 Subject: [PATCH] feat: add useShiftDetailStore for shift detail panel state Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/app/src/stores/useShiftDetailStore.ts | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 apps/app/src/stores/useShiftDetailStore.ts diff --git a/apps/app/src/stores/useShiftDetailStore.ts b/apps/app/src/stores/useShiftDetailStore.ts new file mode 100644 index 00000000..57986bef --- /dev/null +++ b/apps/app/src/stores/useShiftDetailStore.ts @@ -0,0 +1,53 @@ +import { defineStore } from 'pinia' +import { ref } from 'vue' +import type { ShiftAssignment } from '@/types/shiftAssignment' +import { ShiftAssignmentStatus } from '@/types/shiftAssignment' + +export const useShiftDetailStore = defineStore('shiftDetail', () => { + const isOpen = ref(false) + const selectedShiftId = ref(null) + const selectedSectionId = ref(null) + const selectedAssignmentIds = ref([]) + + function openPanel(shiftId: string, sectionId: string) { + selectedShiftId.value = shiftId + selectedSectionId.value = sectionId + selectedAssignmentIds.value = [] + isOpen.value = true + } + + function closePanel() { + isOpen.value = false + selectedShiftId.value = null + selectedSectionId.value = null + selectedAssignmentIds.value = [] + } + + function toggleAssignmentSelection(id: string) { + const idx = selectedAssignmentIds.value.indexOf(id) + if (idx === -1) selectedAssignmentIds.value.push(id) + else selectedAssignmentIds.value.splice(idx, 1) + } + + function selectAllPending(assignments: ShiftAssignment[]) { + selectedAssignmentIds.value = assignments + .filter(a => a.status === ShiftAssignmentStatus.PENDING_APPROVAL) + .map(a => a.id) + } + + function clearSelection() { + selectedAssignmentIds.value = [] + } + + return { + isOpen, + selectedShiftId, + selectedSectionId, + selectedAssignmentIds, + openPanel, + closePanel, + toggleAssignmentSelection, + selectAllPending, + clearSelection, + } +})