From 81d1a2910a57474ee663c9d6ad10e2a4151082e3 Mon Sep 17 00:00:00 2001 From: dank074 Date: Wed, 20 Oct 2021 20:31:26 -0500 Subject: [PATCH] bill fix this --- src/views/mod-tools/ModToolsView.tsx | 7 ++++-- .../tickets/ModToolsOpenIssuesTabView.tsx | 6 ----- .../views/tickets/ModToolsTicketsView.tsx | 24 ++++++++++++++----- .../open-issues/ModToolsOpenIssuesTabView.tsx | 11 +++++++++ .../ModToolsOpenIssuesTabView.types.ts | 6 +++++ 5 files changed, 40 insertions(+), 14 deletions(-) delete mode 100644 src/views/mod-tools/views/tickets/ModToolsOpenIssuesTabView.tsx create mode 100644 src/views/mod-tools/views/tickets/open-issues/ModToolsOpenIssuesTabView.tsx create mode 100644 src/views/mod-tools/views/tickets/open-issues/ModToolsOpenIssuesTabView.types.ts diff --git a/src/views/mod-tools/ModToolsView.tsx b/src/views/mod-tools/ModToolsView.tsx index 45ea7b46..4f73d340 100644 --- a/src/views/mod-tools/ModToolsView.tsx +++ b/src/views/mod-tools/ModToolsView.tsx @@ -161,12 +161,15 @@ export const ModToolsView: FC = props => if(!parser) return; + const data = parser.data; + dispatchModToolsState({ type: ModToolsActions.SET_INIT_DATA, payload: { - settings: parser.data + settings: data } - }); + }); + console.log(parser); }, []); CreateMessageHook(ModeratorInitMessageEvent, onModeratorInitMessageEvent); diff --git a/src/views/mod-tools/views/tickets/ModToolsOpenIssuesTabView.tsx b/src/views/mod-tools/views/tickets/ModToolsOpenIssuesTabView.tsx deleted file mode 100644 index 6d4392b7..00000000 --- a/src/views/mod-tools/views/tickets/ModToolsOpenIssuesTabView.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import { FC } from 'react'; - -export const ModToolsOpenIssuesTabView: FC<{}> = props => -{ - return null; -} diff --git a/src/views/mod-tools/views/tickets/ModToolsTicketsView.tsx b/src/views/mod-tools/views/tickets/ModToolsTicketsView.tsx index 60651532..6f9471ae 100644 --- a/src/views/mod-tools/views/tickets/ModToolsTicketsView.tsx +++ b/src/views/mod-tools/views/tickets/ModToolsTicketsView.tsx @@ -1,7 +1,9 @@ -import { FC, useCallback, useState } from 'react'; +import { IssueMessageData } from '@nitrots/nitro-renderer'; +import { FC, useCallback, useMemo, useState } from 'react'; import { NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../../../layout'; -import { ModToolsOpenIssuesTabView } from './ModToolsOpenIssuesTabView'; +import { useModToolsContext } from '../../context/ModToolsContext'; import { ModToolsTicketsViewProps } from './ModToolsTicketsView.types'; +import { ModToolsOpenIssuesTabView } from './open-issues/ModToolsOpenIssuesTabView'; const TABS: string[] = [ 'Open Issues', @@ -12,17 +14,27 @@ const TABS: string[] = [ export const ModToolsTicketsView: FC = props => { const { onCloseClick = null } = props; - + const { modToolsState = null } = useModToolsContext(); + const { settings = null } = modToolsState; const [ currentTab, setCurrentTab ] = useState(0); + const openIssues = useMemo(() => + { + if(!settings) return []; + + return settings.issues.filter(issue => issue.state === IssueMessageData.STATE_OPEN) + }, [settings]); + const CurrentTabComponent = useCallback(() => { switch(currentTab) { - case 0: return ; + case 0: return ; default: return null; } - }, [currentTab]); + }, [currentTab, openIssues]); + + console.log(settings); return ( @@ -37,7 +49,7 @@ export const ModToolsTicketsView: FC = props => }) }
- + {settings && }
diff --git a/src/views/mod-tools/views/tickets/open-issues/ModToolsOpenIssuesTabView.tsx b/src/views/mod-tools/views/tickets/open-issues/ModToolsOpenIssuesTabView.tsx new file mode 100644 index 00000000..d6ebe1bc --- /dev/null +++ b/src/views/mod-tools/views/tickets/open-issues/ModToolsOpenIssuesTabView.tsx @@ -0,0 +1,11 @@ +import { FC } from 'react'; +import { ModToolsOpenIssuesTabViewProps } from './ModToolsOpenIssuesTabView.types'; + +export const ModToolsOpenIssuesTabView: FC = props => +{ + const { openIssues = null } = props; + + return ( +
{openIssues.length}
+ ); +} diff --git a/src/views/mod-tools/views/tickets/open-issues/ModToolsOpenIssuesTabView.types.ts b/src/views/mod-tools/views/tickets/open-issues/ModToolsOpenIssuesTabView.types.ts new file mode 100644 index 00000000..45a80d7d --- /dev/null +++ b/src/views/mod-tools/views/tickets/open-issues/ModToolsOpenIssuesTabView.types.ts @@ -0,0 +1,6 @@ +import { IssueMessageData } from '@nitrots/nitro-renderer'; + +export interface ModToolsOpenIssuesTabViewProps +{ + openIssues: IssueMessageData[]; +}