From 70de6ad919f3116963a21ec30a6df9f7f787f38e Mon Sep 17 00:00:00 2001 From: JSC Date: Fri, 29 Aug 2025 03:02:15 +0200 Subject: [PATCH] feat: implement combobox for timezone, sound, and playlist selection in CreateTaskDialog --- .../schedulers/CreateTaskDialog.tsx | 229 ++++++++++++++---- 1 file changed, 176 insertions(+), 53 deletions(-) diff --git a/src/components/schedulers/CreateTaskDialog.tsx b/src/components/schedulers/CreateTaskDialog.tsx index d15ba00..4fdab76 100644 --- a/src/components/schedulers/CreateTaskDialog.tsx +++ b/src/components/schedulers/CreateTaskDialog.tsx @@ -1,4 +1,12 @@ import { Button } from '@/components/ui/button' +import { + Command, + CommandEmpty, + CommandGroup, + CommandInput, + CommandItem, + CommandList, +} from '@/components/ui/command' import { Dialog, DialogContent, @@ -7,6 +15,11 @@ import { } from '@/components/ui/dialog' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' +import { + Popover, + PopoverContent, + PopoverTrigger, +} from '@/components/ui/popover' import { Select, SelectContent, @@ -26,7 +39,7 @@ import { soundsService } from '@/lib/api/services/sounds' import { playlistsService } from '@/lib/api/services/playlists' import { getSupportedTimezones } from '@/utils/locale' import { useLocale } from '@/hooks/use-locale' -import { CalendarPlus, Loader2, Music, PlayCircle } from 'lucide-react' +import { CalendarPlus, Check, ChevronsUpDown, Loader2, Music, PlayCircle } from 'lucide-react' import { useState, useEffect } from 'react' interface CreateTaskDialogProps { @@ -75,6 +88,11 @@ export function CreateTaskDialog({ const [playlists, setPlaylists] = useState>([]) const [loadingSounds, setLoadingSounds] = useState(false) const [loadingPlaylists, setLoadingPlaylists] = useState(false) + + // Combobox state + const [soundComboOpen, setSoundComboOpen] = useState(false) + const [playlistComboOpen, setPlaylistComboOpen] = useState(false) + const [timezoneComboOpen, setTimezoneComboOpen] = useState(false) // Load sounds and playlists when dialog opens useEffect(() => { @@ -191,6 +209,9 @@ export function CreateTaskDialog({ setSelectedPlaylistId('') setPlayMode('continuous') setShuffle(false) + setSoundComboOpen(false) + setPlaylistComboOpen(false) + setTimezoneComboOpen(false) onCancel() } @@ -276,22 +297,61 @@ export function CreateTaskDialog({
- + + + + + + e.stopPropagation()}> + + + No timezone found. + + { + setFormData(prev => ({ ...prev, timezone: 'UTC' })) + setTimezoneComboOpen(false) + }} + > + UTC + + + {getSupportedTimezones().map((tz) => ( + { + setFormData(prev => ({ ...prev, timezone: tz })) + setTimezoneComboOpen(false) + }} + > + {tz.replace('_', ' ')} + + + ))} + + + + +
@@ -358,24 +418,56 @@ export function CreateTaskDialog({ {formData.task_type === 'play_sound' && (
- + + + + + + e.stopPropagation()}> + + + No sound found. + + {sounds.map((sound) => ( + { + setSelectedSoundId(sound.id.toString()) + setSoundComboOpen(false) + }} + > +
+ + {sound.name || sound.filename} +
+ +
+ ))} +
+
+
+
+
{parametersError && (

{parametersError}

)} @@ -386,24 +478,55 @@ export function CreateTaskDialog({
- + + + + + + e.stopPropagation()}> + + + No playlist found. + + {playlists.map((playlist) => ( + { + setSelectedPlaylistId(playlist.id.toString()) + setPlaylistComboOpen(false) + }} + > +
+ + {playlist.name} +
+ +
+ ))} +
+
+
+
+