From 19aa76e55d64ef59ef3728952356cb082dcc2665 Mon Sep 17 00:00:00 2001 From: dekzter Date: Wed, 19 Mar 2025 17:05:22 -0400 Subject: [PATCH] Frontend updates with new stream group changes --- frontend/src/components/forms/Stream.jsx | 31 ++-- .../src/components/tables/StreamsTable.jsx | 9 +- frontend/src/pages/Stats.jsx | 158 ++++++++++-------- 3 files changed, 115 insertions(+), 83 deletions(-) diff --git a/frontend/src/components/forms/Stream.jsx b/frontend/src/components/forms/Stream.jsx index 6c058345..05720b34 100644 --- a/frontend/src/components/forms/Stream.jsx +++ b/frontend/src/components/forms/Stream.jsx @@ -5,16 +5,18 @@ import * as Yup from 'yup'; import API from '../../api'; import useStreamProfilesStore from '../../store/streamProfiles'; import { Modal, TextInput, Select, Button, Flex } from '@mantine/core'; +import useChannelsStore from '../../store/channels'; const Stream = ({ stream = null, isOpen, onClose }) => { const streamProfiles = useStreamProfilesStore((state) => state.profiles); + const { channelGroups } = useChannelsStore(); const [selectedStreamProfile, setSelectedStreamProfile] = useState(''); const formik = useFormik({ initialValues: { name: '', url: '', - group_name: '', + channel_group: null, stream_profile_id: '', }, validationSchema: Yup.object({ @@ -23,6 +25,7 @@ const Stream = ({ stream = null, isOpen, onClose }) => { // stream_profile_id: Yup.string().required('Stream profile is required'), }), onSubmit: async (values, { setSubmitting, resetForm }) => { + console.log(values); if (stream?.id) { await API.updateStream({ id: stream.id, ...values }); } else { @@ -40,7 +43,7 @@ const Stream = ({ stream = null, isOpen, onClose }) => { formik.setValues({ name: stream.name, url: stream.url, - group_name: stream.group_name, + channel_group: stream.channel_group, stream_profile_id: stream.stream_profile_id, }); } else { @@ -73,13 +76,19 @@ const Stream = ({ stream = null, isOpen, onClose }) => { error={formik.errors.url} /> - { + formik.setFieldValue('channel_group', value); // Update Formik's state with the new value + }} + error={formik.errors.channel_group} + data={channelGroups.map((group) => ({ + label: group.name, + value: `${group.id}`, + }))} />