mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-22 09:37:57 +00:00
Fixes channel creation form resetting if also creating a group.
Also fixes group creation form not closing when saving.
This commit is contained in:
parent
693d33e18d
commit
a387130d23
2 changed files with 21 additions and 4 deletions
|
|
@ -339,6 +339,20 @@ const Channel = ({ channel = null, isOpen, onClose }) => {
|
|||
// },
|
||||
// });
|
||||
|
||||
// Update the handler for when channel group modal is closed
|
||||
const handleChannelGroupModalClose = (newGroup) => {
|
||||
setChannelGroupModalOpen(false);
|
||||
|
||||
// If a new group was created and returned, update the form with it
|
||||
if (newGroup && newGroup.id) {
|
||||
// Preserve all current form values while updating just the channel_group_id
|
||||
formik.setValues({
|
||||
...formik.values,
|
||||
channel_group_id: `${newGroup.id}`
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (!isOpen) {
|
||||
return <></>;
|
||||
}
|
||||
|
|
@ -804,7 +818,7 @@ const Channel = ({ channel = null, isOpen, onClose }) => {
|
|||
|
||||
<ChannelGroupForm
|
||||
isOpen={channelGroupModelOpen}
|
||||
onClose={() => setChannelGroupModalOpen(false)}
|
||||
onClose={handleChannelGroupModalClose}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -18,13 +18,16 @@ const ChannelGroup = ({ channelGroup = null, isOpen, onClose }) => {
|
|||
|
||||
const onSubmit = async () => {
|
||||
const values = form.getValues();
|
||||
let newGroup;
|
||||
|
||||
if (channelGroup) {
|
||||
await API.updateChannelGroup({ id: channelGroup.id, ...values });
|
||||
newGroup = await API.updateChannelGroup({ id: channelGroup.id, ...values });
|
||||
} else {
|
||||
await API.addChannelGroup(values);
|
||||
newGroup = await API.addChannelGroup(values);
|
||||
}
|
||||
|
||||
return form.reset();
|
||||
form.reset();
|
||||
onClose(newGroup); // Pass the new/updated group back to parent
|
||||
};
|
||||
|
||||
if (!isOpen) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue