|
22 | 22 | import { getAgentOptions } from '$lib/services/agent-service'; |
23 | 23 | import { utcToLocal } from '$lib/helpers/datetime'; |
24 | 24 | import { ConversationChannel, TimeRange } from '$lib/helpers/enums'; |
25 | | - import { TIME_RANGE_OPTIONS } from '$lib/helpers/constants'; |
| 25 | + import { TIME_RANGE_OPTIONS, CUSTOM_DATE_RANGE } from '$lib/helpers/constants'; |
26 | 26 | import { clickoutsideDirective } from '$lib/helpers/directives'; |
27 | 27 | import { |
28 | 28 | getConversations, |
|
63 | 63 |
|
64 | 64 | // Get time range display text |
65 | 65 | const getTimeRangeDisplayText = () => { |
66 | | - if (searchOption.timeRange === TimeRange.SpecificDay) { |
| 66 | + if (searchOption.timeRange === CUSTOM_DATE_RANGE) { |
67 | 67 | if (searchOption.startDate && searchOption.endDate) { |
68 | 68 | const start = formatDateForDisplay(searchOption.startDate); |
69 | 69 | const end = formatDateForDisplay(searchOption.endDate); |
|
96 | 96 |
|
97 | 97 | // Update time range display text reactively |
98 | 98 | $: { |
99 | | - if (searchOption.timeRange === TimeRange.SpecificDay && searchOption.startDate && searchOption.endDate) { |
| 99 | + if (searchOption.timeRange === CUSTOM_DATE_RANGE && searchOption.startDate && searchOption.endDate) { |
100 | 100 | const start = formatDateForDisplay(searchOption.startDate); |
101 | 101 | const end = formatDateForDisplay(searchOption.endDate); |
102 | 102 | if (start === end) { |
103 | 103 | timeRangeDisplayText = start; |
104 | 104 | } else { |
105 | 105 | timeRangeDisplayText = `${start} - ${end}`; |
106 | 106 | } |
107 | | - } else if (searchOption.timeRange === TimeRange.SpecificDay) { |
| 107 | + } else if (searchOption.timeRange === CUSTOM_DATE_RANGE) { |
108 | 108 | timeRangeDisplayText = 'Custom'; |
109 | 109 | } else { |
110 | 110 | const selected = presetTimeRangeOptions.find(x => x.value === searchOption.timeRange); |
|
143 | 143 | { value: k.toLowerCase(), label: v } |
144 | 144 | )); |
145 | 145 |
|
146 | | - // Preset time range options (excluding SpecificDay) |
| 146 | + // Preset time range options (excluding custom date) |
147 | 147 | const presetTimeRangeOptions = TIME_RANGE_OPTIONS |
148 | | - .filter(x => x.value !== TimeRange.SpecificDay) |
| 148 | + .filter(x => x.value !== CUSTOM_DATE_RANGE) |
149 | 149 | .map(x => ({ |
150 | 150 | label: x.label, |
151 | 151 | value: x.value |
|
586 | 586 | on:click={() => { |
587 | 587 | showDatePicker = !showDatePicker; |
588 | 588 | if (showDatePicker) { |
589 | | - datePickerTab = 'relative'; |
| 589 | + // If custom date is selected, switch to custom tab; otherwise use relative tab |
| 590 | + datePickerTab = searchOption.timeRange === CUSTOM_DATE_RANGE ? 'custom' : 'relative'; |
590 | 591 | } |
591 | 592 | }} |
592 | 593 | style="cursor: pointer;" |
|
710 | 711 | // Force reactivity by reassigning the object |
711 | 712 | searchOption = { |
712 | 713 | ...searchOption, |
713 | | - timeRange: TimeRange.SpecificDay |
| 714 | + timeRange: CUSTOM_DATE_RANGE |
714 | 715 | }; |
715 | 716 | } |
716 | 717 | showDatePicker = false; |
|
0 commit comments