Change CSV handling - fixed group delete

This commit is contained in:
Luke Berndt
2023-11-10 07:28:27 -05:00
parent b21f214e74
commit 2647c75733
7 changed files with 109 additions and 100 deletions

View File

@@ -13,9 +13,9 @@ import {
Icon,
Form,
TextArea,
Message,
Header,
Container,
Message,
List,
Segment,
Tab,
@@ -31,7 +31,7 @@ const System = () => {
//const { data: systemErrorData, isSuccess: isErrorsSuccess } = useGetErrorsQuery(shortName);
const [deleteGroupAPI] = useDeleteGroupMutation();
const [reorderGroupsAPI] = useSaveGroupOrderMutation();
const [importTalkgroupsAPI] = useImportTalkgroupsMutation();
const [importTalkgroupsAPI, { error: importError }] = useImportTalkgroupsMutation();
const [deleteSystemAPI ] = useDeleteSystemMutation();
const [openSystemDeleteConfirm, setOpenSystemDeleteConfirm] = useState(false);
const [openMessage, setOpenMessage] = useState(false);
@@ -401,22 +401,13 @@ const System = () => {
<List ordered celled>
<List.Item>
<List.Content>
<List.Header>Number</List.Header>
<List.Description>The talkgroup number</List.Description>
<List.Header>Decimal</List.Header>
<List.Description>The talkgroup number in decimal</List.Description>
</List.Content>
</List.Item>
<List.Item>
<List.Content>
<List.Header>Mode</List.Header>
<List.Description>
The mode for the talkgroup, it can be: 'A' = analog, 'D' =
P25 Digital, 'E' = Encrypted
</List.Description>
</List.Content>
</List.Item>
<List.Item>
<List.Content>
<List.Header>Alpha</List.Header>
<List.Header>Alpha Tag</List.Header>
<List.Description>
Up to 12 charecter description of the talkgroup
</List.Description>
@@ -430,31 +421,6 @@ const System = () => {
</List.Description>
</List.Content>
</List.Item>
<List.Item>
<List.Content>
<List.Header>Tag</List.Header>
<List.Description>
The type of talkgroup, eg: Dispatch, Fireground
</List.Description>
</List.Content>
</List.Item>
<List.Item>
<List.Content>
<List.Header>Group</List.Header>
<List.Description>
The department that uses this talkgroup
</List.Description>
</List.Content>
</List.Item>
<List.Item>
<List.Content>
<List.Header>Priority</List.Header>
<List.Description>
The priority for recording this talkgroup, 100 or over
will be skipped
</List.Description>
</List.Content>
</List.Item>
</List>
</Container>
<Divider />
@@ -483,6 +449,12 @@ const System = () => {
Export Talkgroups
</Button>
</a>
{importError ? (
<div>
<Message color='red'>{importError.data}</Message>
</div>
) : (<div></div>)}
<ListTalkgroups talkgroups={talkgroupsData} />
</div>
)

View File

@@ -20,16 +20,15 @@ class ListTalkgroups extends Component {
<Table celled>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Mode</Table.HeaderCell>
<Table.HeaderCell>Number</Table.HeaderCell>
<Table.HeaderCell>Alpha</Table.HeaderCell>
<Table.HeaderCell>Decimal</Table.HeaderCell>
<Table.HeaderCell>Alpha Tag</Table.HeaderCell>
<Table.HeaderCell>Description</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
{talkgroups.map((talkgroup, i) => (
<Table.Row key={talkgroup.num + "-" + i}>
<Table.Cell>{talkgroup.mode}</Table.Cell>
<Table.Cell>{talkgroup.num}</Table.Cell>
<Table.Cell>{talkgroup.alpha}</Table.Cell>
<Table.Cell>{talkgroup.description}</Table.Cell>

View File

@@ -94,7 +94,7 @@ export const apiSlice = createApi({
await queryFulfilled
dispatch(
apiSlice.util.updateQueryData('getGroups', group.shortName, (groups) => {
const groupIndex = groups.findIndex((obj => obj.groupId === group.groupId));
const groupIndex = groups.findIndex((obj => obj._id === group._id));
groups.splice(groupIndex,1);
})
)