const AssignmentSidebar = { template: `
{{ title }}
{{ agent.name }}
{{ agent.dept }} Division • {{ agent.role }}
Selected Date
{{ dateFormatted }}
{{ dateFull }}
`, setup() { const { computed, ref, watch } = Vue; const isOpen = computed(() => store.viewSettings.rightDrawerOpen); const agent = computed(() => store.selection.agent); const date = computed(() => store.selection.date); const mode = computed(() => store.selection.mode); const isAssignment = computed(() => mode.value === 'assignment'); const isProfile = computed(() => mode.value === 'profile'); // Local state for assignment const selectedShifts = ref([]); const customStart = ref(''); const customEnd = ref(''); // Watch for selection change to load data watch([agent, date, isOpen], () => { if (isOpen.value && isAssignment.value && agent.value && date.value) { // Load existing shifts from store selectedShifts.value = store.getAgentShifts(agent.value.id, date.value); customStart.value = ''; // Reset custom times for now customEnd.value = ''; } }); // Basic Conflict Check const hasConflict = computed(() => { return !!ValidationUtils.hasConflict(selectedShifts.value); }); const conflictMessage = computed(() => { return ValidationUtils.getConflictMessage(selectedShifts.value); }); const close = () => { store.viewSettings.rightDrawerOpen = false; }; const save = () => { if (isAssignment.value && agent.value && date.value) { store.assignShifts(agent.value.id, date.value, selectedShifts.value, { start: customStart.value, end: customEnd.value }); } // For profile, it's already bound to agent object (which is ref from store) close(); }; const dateFormatted = computed(() => { if (!date.value) return ''; return date.value.toLocaleDateString('en-US', { weekday: 'long' }); }); const dateFull = computed(() => { if (!date.value) return ''; return date.value.toLocaleDateString('en-US', { day: 'numeric', month: 'long', year: 'numeric' }); }); // Extended Shift Options const shiftOptions = [ { id: 'm', label: 'Morning Shift', desc: '08:00 - 14:00', color: 'green-7' }, { id: 'a', label: 'Afternoon Shift', desc: '14:00 - 22:00', color: 'blue-7' }, { id: 'e', label: 'EOD Support', desc: '18:00 - 20:00', color: 'pink-7' }, { id: 't', label: 'Training', desc: 'All Day', color: 'orange-7' }, { id: 'v', label: 'Vacation', desc: 'Approved', color: 'purple-7' } ]; return { isOpen, close, save, agent, date, isAssignment, isProfile, title: computed(() => isAssignment.value ? 'Assignment Entry' : 'Agent Profile'), dateFormatted, dateFull, shiftOptions, selectedShifts, customStart, customEnd, hasConflict, conflictMessage, roles: store.consts.ROLES, depts: store.consts.DEPARTMENTS, skills: store.consts.SKILLS } } };