"use client"; import { useEffect, useRef, useState } from "react"; import { GearIcon } from "@radix-ui/react-icons"; import { SettingsIcon, Volume2 } from "lucide-react"; import MicVolumeBar from "_components/MicVolumeIndication"; import { useMutation, useQuery } from "@tanstack/react-query"; import { editUserAPI, getUserAPI } from "_querys/user"; import { useSession } from "next-auth/react"; import { useAudioStore } from "_store/audioStore"; import toast from "react-hot-toast"; export const SettingsBtn = () => { const session = useSession(); const { data: user } = useQuery({ queryKey: ["user", session.data?.user.id], queryFn: () => getUserAPI(session.data!.user.id), }); const testSoundRef = useRef(null); const editUserMutation = useMutation({ mutationFn: editUserAPI, }); useEffect(() => { if (typeof window !== "undefined") { testSoundRef.current = new Audio("/sounds/Melder3.wav"); } }, []); const modalRef = useRef(null); const [inputDevices, setInputDevices] = useState([]); const [selectedDevice, setSelectedDevice] = useState( user?.settingsMicDevice || null, ); const [showIndication, setShowIndication] = useState(false); const [micVol, setMicVol] = useState(1); const [funkVolume, setFunkVol] = useState(0.8); const [dmeVolume, setDmeVol] = useState(0.8); const setMic = useAudioStore((state) => state.setMic); useEffect(() => { if (user) { setSelectedDevice(user.settingsMicDevice); setMic(user.settingsMicDevice, user.settingsMicVolume || 1); setMicVol(user.settingsMicVolume || 1); setFunkVol(user.settingsRadioVolume || 0.8); setDmeVol(user.settingsDmeVolume || 0.8); } }, [user, setMic]); useEffect(() => { if (typeof navigator !== "undefined" && navigator.mediaDevices?.enumerateDevices) { navigator.mediaDevices.enumerateDevices().then((devices) => { setInputDevices(devices.filter((d) => d.kind === "audioinput")); }); } }, []); return (

Einstellungen

Eingabelautstärke

{ const value = parseFloat(e.target.value); setMicVol(value); setShowIndication(true); }} value={micVol} className="range range-xs range-accent w-full" />
0% 25% 50% 75% 100%
{showIndication && ( )}

Funk Lautstärke

{ const value = parseFloat(e.target.value); setFunkVol(value); }} value={funkVolume} className="range range-xs range-primary w-full" />
0% 25% 50% 75% 100%

Melder Lautstärke

{ const value = parseFloat(e.target.value); setDmeVol(value); if (!testSoundRef.current) return; testSoundRef.current.volume = value; testSoundRef.current.play(); }} value={dmeVolume} className="range range-xs range-primary w-full" />
0% 25% 50% 75% 100%
); }; export const Settings = () => { return (
); };