import { ModalBody } from '@chakra-ui/modal'; import { FormLabel, FormControl, Input, Button } from '@chakra-ui/react'; import { getOSC, oscPlaceholderSettings, postOSC } from 'app/api/ontimeApi'; import { useEffect, useState } from 'react'; import { useFetch } from 'app/hooks/useFetch'; import { OSC_SETTINGS } from 'app/api/apiConstants'; import { showErrorToast } from 'common/helpers/toastManager'; import style from './Modals.module.scss'; export default function AppSettingsModal() { const { data, status } = useFetch(OSC_SETTINGS, getOSC); const [formData, setFormData] = useState(oscPlaceholderSettings); const [changed, setChanged] = useState(false); const [submitting, setSubmitting] = useState(false); useEffect(() => { if (data == null) return; setFormData({ ...data }); }, [data]); const submitHandler = async (event) => { event.preventDefault(); const f = formData; let e = { status: false, message: '' }; // Validate fields if (f.port < 1024 || f.port > 65535) { // Port in incorrect range e.status = true; e.message += 'OSC IN Port in incorrect range (1024 - 65535)'; } else if (f.portOut < 1024 || f.portOut > 65535) { // Port in incorrect range e.status = true; e.message += 'OSC OUT Port in incorrect range (1024 - 65535)'; } else if (f.port === f.portOut) { // Cant use the same port e.status = true; e.message += 'OSC IN and OUT Ports cant be the same'; } // set fields with error if (e.status) { showErrorToast('Invalid Input', e.message); return; } // Post here postOSC(formData); setChanged(false); setSubmitting(false); }; return ( <>
{status === 'success' && ( <>

Options related to the application
🔥 Changes take effect after app restart 🔥

Viewer Port Port to access viewers (Read Only Value) OSC In Port
App Control - Default 8888
{ setChanged(true); setFormData({ ...formData, port: parseInt(event.target.value), }); }} isDisabled={submitting} style={{ width: '6em', textAlign: 'center' }} />
OSC Out Target IP
App Feedback - Default 127.0.0.1
{ setChanged(true); setFormData({ ...formData, targetIP: event.target.value, }); }} isDisabled={submitting} style={{ width: '12em', textAlign: 'right' }} />
OSC Out Port
Default 9999
{ setChanged(true); setFormData({ ...formData, portOut: parseInt(event.target.value), }); }} isDisabled={submitting} style={{ width: '6em', textAlign: 'left' }} />
)}
); }