import React from 'react'; import API from '../../api'; import { Button, Modal, Text, Group, Flex, NumberInput } from '@mantine/core'; import { ListOrdered } from 'lucide-react'; import { useForm } from '@mantine/form'; import { showNotification } from '../../utils/notificationUtils.js'; const assignChannelNumbers = (channelIds, starting_number) => { return API.assignChannelNumbers(channelIds, starting_number); }; const requeryChannels = () => { API.requeryChannels(); }; const AssignChannelNumbers = ({ channelIds, isOpen, onClose }) => { const form = useForm({ mode: 'uncontrolled', initialValues: { starting_number: 1, }, }); const onSubmit = async () => { const { starting_number } = form.getValues(); try { const result = await assignChannelNumbers(channelIds, starting_number); showNotification({ title: result.message || 'Channels assigned', color: 'green.5', }); requeryChannels(); onClose(); } catch (err) { console.error(err); showNotification({ title: 'Failed to assign channels', color: 'red.5', }); } }; if (!isOpen) { return <>; } return ( Assign Channel #s } styles={{ hannontent: { '--mantine-color-body': '#27272A' } }} >
); }; export default AssignChannelNumbers;