From 4603e5271d6708b6f365f661bd33abfbf70918cd Mon Sep 17 00:00:00 2001 From: dank074 Date: Sun, 24 Oct 2021 21:54:54 -0500 Subject: [PATCH] added help center --- src/assets/images/help/help_index.png | Bin 0 -> 2569 bytes src/events/help/HelpEvent.ts | 8 ++ src/events/help/HelpReportUserEvent.ts | 27 ++++++ src/views/Styles.scss | 1 + .../ChatHistoryMessageHandler.tsx | 4 +- src/views/chat-history/ChatHistoryView.tsx | 9 +- .../{utils => common}/ChatHistoryState.ts | 0 .../chat-history/common/GetChatHistory.ts | 7 ++ .../{utils => common}/RoomHistoryState.ts | 0 .../context/ChatHistoryContext.types.ts | 2 + src/views/help/HelpMessageHandler.tsx | 4 +- src/views/help/HelpView.scss | 10 +++ src/views/help/HelpView.tsx | 74 ++++++++++++++++- src/views/help/common/IUser.ts | 5 ++ src/views/help/context/HelpContext.tsx | 14 ++++ src/views/help/context/HelpContext.types.ts | 33 ++++++++ src/views/help/views/DescribeReportView.tsx | 50 +++++++++++ src/views/help/views/HelpIndexView.tsx | 36 ++++++++ .../help/views/SelectReportedChatsView.tsx | 73 ++++++++++++++++ .../help/views/SelectReportedUserView.tsx | 78 ++++++++++++++++++ src/views/help/views/SelectTopicView.tsx | 53 ++++++++++++ .../mod-tools/ModToolsMessageHandler.tsx | 4 + src/views/mod-tools/ModToolsView.scss | 12 +++ .../mod-tools/common/GetCFHCategories.ts | 7 ++ .../views/tickets/ModToolsTicketsView.tsx | 1 + .../my-issues/ModToolsMyIssuesTabView.tsx | 2 +- .../open-issues/ModToolsOpenIssuesTabView.tsx | 2 +- .../ModToolsPickedIssuesTabView.tsx | 2 +- .../ModToolsUserModActionView.tsx | 2 +- src/views/purse/PurseView.tsx | 8 +- 30 files changed, 513 insertions(+), 15 deletions(-) create mode 100644 src/assets/images/help/help_index.png create mode 100644 src/events/help/HelpEvent.ts create mode 100644 src/events/help/HelpReportUserEvent.ts rename src/views/chat-history/{utils => common}/ChatHistoryState.ts (100%) create mode 100644 src/views/chat-history/common/GetChatHistory.ts rename src/views/chat-history/{utils => common}/RoomHistoryState.ts (100%) create mode 100644 src/views/help/HelpView.scss create mode 100644 src/views/help/common/IUser.ts create mode 100644 src/views/help/context/HelpContext.tsx create mode 100644 src/views/help/context/HelpContext.types.ts create mode 100644 src/views/help/views/DescribeReportView.tsx create mode 100644 src/views/help/views/HelpIndexView.tsx create mode 100644 src/views/help/views/SelectReportedChatsView.tsx create mode 100644 src/views/help/views/SelectReportedUserView.tsx create mode 100644 src/views/help/views/SelectTopicView.tsx create mode 100644 src/views/mod-tools/common/GetCFHCategories.ts diff --git a/src/assets/images/help/help_index.png b/src/assets/images/help/help_index.png new file mode 100644 index 0000000000000000000000000000000000000000..2844f41e11f70f4f07c486f4221b242c15aac4bb GIT binary patch literal 2569 zcmV+k3ikDhP)waCoe|^~H>Kcaijw@mPIPh@?`TBTiT>uA$K7oGm*3#wz z=*KCbBLQ^yM+5%`?CtICvZ+V4zQaFQZHLfrK6o(dwGRGB%{&17)7uY5z23ne419t+ z*8b6+K7Bf?>Eqv{b?^rQpWu$bheyxuEH(f5^$z|d;L{kOgFi6%u_;eYJ?!gY7tq0P z5aeJBxrzfj*uTTqhaT457IX-TaKEmaQ9TBpv+mb#1U%)Q5dxUm6sUPj*LDed2fsC+ z97Ws4zoix-y$AQ}5^yK7dOD{pbQ9{cLi8hx>X5d{1H5a_1}pJfZ;D zAj<->Mid3$bA=cQT|3q|vH)h#sqii9=NpXzZz;Um;5{O62w=zXoy|Q2Zz-@y_*$3E zB7i-^=bQUL_!fVDE8w*PI0yW~KHdwy6n^Qoa{|~ad~r6d7=8ixpI`nq+4%WCKl0i5 zS$M7p0eEHxcLSdlffhdU5IqQFZxs|6knUMqms z;70~6;V+<5rUh@gSuOBd;Bx|K1%55~cNa|kp!Y^SD%S$94W1K#wmeG9B9+I;pjDIq zzsl~dC3p;lOS9ko5eKHTY^vUt@lv^9ggf<)%r#3*b6?L$1_va z0=fmhb}|X)2POfO%pSJL++6_hz=yy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ob)303V*JlKu3LXYs((jai4Q;CJiY?l58#_gUXVb5{2p+&E&{WtJ z4wNTX3z`%? z`r{(GpJqexa}hoxh=LJ!hh11;McxCs9l8`o<}4PFugVYU72e$)|w3}4aY zckuf>7D1R^<2!s+Ki|RcyQ`4l=b`t}_?}%vD*jIS@N0)u`%x)A&_k-{^$dDQwY!Er f%GO1&Vc7ox%|VtsUkD)j00000NkvXXu0mjfTyEtL literal 0 HcmV?d00001 diff --git a/src/events/help/HelpEvent.ts b/src/events/help/HelpEvent.ts new file mode 100644 index 00000000..1403f20f --- /dev/null +++ b/src/events/help/HelpEvent.ts @@ -0,0 +1,8 @@ +import { NitroEvent } from '@nitrots/nitro-renderer'; + +export class HelpEvent extends NitroEvent +{ + public static SHOW_HELP_CENTER: string = 'HCE_SHOW_HELP_CENTER'; + public static HIDE_HELP_CENTER: string = 'HCE_HIDE_HELP_CENTER'; + public static TOGGLE_HELP_CENTER: string = 'HCE_TOGGLE_HELP_CENTER'; +} diff --git a/src/events/help/HelpReportUserEvent.ts b/src/events/help/HelpReportUserEvent.ts new file mode 100644 index 00000000..4af418af --- /dev/null +++ b/src/events/help/HelpReportUserEvent.ts @@ -0,0 +1,27 @@ +import { HelpEvent } from './HelpEvent'; + +export class HelpReportUserEvent extends HelpEvent +{ + public static REPORT_USER: string = 'HCE_HELP_CENTER_REPORT_USER'; + + private _reportedUserId: number; + private _reportedUsername: string; + + constructor(userId: number, username: string) + { + super(HelpReportUserEvent.REPORT_USER); + + this._reportedUserId = userId; + this._reportedUsername = username; + } + + public get reportedUserId(): number + { + return this._reportedUserId; + } + + public get reportedUsername(): string + { + return this._reportedUsername; + } +} diff --git a/src/views/Styles.scss b/src/views/Styles.scss index f66d2a1a..77dc121f 100644 --- a/src/views/Styles.scss +++ b/src/views/Styles.scss @@ -21,3 +21,4 @@ @import './user-settings/UserSettingsView'; @import './user-profile/UserProfileVew'; @import './chat-history/ChatHistoryView'; +@import './help/HelpView'; diff --git a/src/views/chat-history/ChatHistoryMessageHandler.tsx b/src/views/chat-history/ChatHistoryMessageHandler.tsx index f56702a4..d1165d39 100644 --- a/src/views/chat-history/ChatHistoryMessageHandler.tsx +++ b/src/views/chat-history/ChatHistoryMessageHandler.tsx @@ -54,7 +54,7 @@ export const ChatHistoryMessageHandler: FC<{}> = props => const timeString = currentDate(); - const entry: IChatEntry = { id: -1, entityId: userData.webID, name: userData.name, look: userData.figure, message: event.message, timestamp: timeString, type: ChatEntryType.TYPE_CHAT }; + const entry: IChatEntry = { id: -1, entityId: userData.webID, name: userData.name, look: userData.figure, entityType: userData.type, message: event.message, timestamp: timeString, type: ChatEntryType.TYPE_CHAT, roomId: roomSession.roomId }; addChatEntry(entry); }, [addChatEntry]); @@ -89,7 +89,7 @@ export const ChatHistoryMessageHandler: FC<{}> = props => if(needsRoomInsert) { - const chatEntry: IChatEntry = { id: -1, entityId: parser.data.roomId, name: parser.data.roomName, timestamp: currentDate(), type: ChatEntryType.TYPE_ROOM_INFO }; + const chatEntry: IChatEntry = { id: -1, entityId: parser.data.roomId, name: parser.data.roomName, timestamp: currentDate(), type: ChatEntryType.TYPE_ROOM_INFO, roomId: parser.data.roomId }; addChatEntry(chatEntry); diff --git a/src/views/chat-history/ChatHistoryView.tsx b/src/views/chat-history/ChatHistoryView.tsx index d1121e9e..2a29cdd8 100644 --- a/src/views/chat-history/ChatHistoryView.tsx +++ b/src/views/chat-history/ChatHistoryView.tsx @@ -5,10 +5,13 @@ import { ChatHistoryEvent } from '../../events/chat-history/ChatHistoryEvent'; import { useUiEvent } from '../../hooks'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../layout'; import { ChatHistoryMessageHandler } from './ChatHistoryMessageHandler'; +import { ChatHistoryState } from './common/ChatHistoryState'; +import { SetChatHistory } from './common/GetChatHistory'; +import { RoomHistoryState } from './common/RoomHistoryState'; import { ChatHistoryContextProvider } from './context/ChatHistoryContext'; import { ChatEntryType } from './context/ChatHistoryContext.types'; -import { ChatHistoryState } from './utils/ChatHistoryState'; -import { RoomHistoryState } from './utils/RoomHistoryState'; + + export const ChatHistoryView: FC<{}> = props => { @@ -25,6 +28,8 @@ export const ChatHistoryView: FC<{}> = props => const chatState = new ChatHistoryState(); const roomState = new RoomHistoryState(); + SetChatHistory(chatState); + chatState.notifier = () => setChatHistoryUpdateId(prevValue => (prevValue + 1)); roomState.notifier = () => setRoomHistoryUpdateId(prevValue => (prevValue + 1)); diff --git a/src/views/chat-history/utils/ChatHistoryState.ts b/src/views/chat-history/common/ChatHistoryState.ts similarity index 100% rename from src/views/chat-history/utils/ChatHistoryState.ts rename to src/views/chat-history/common/ChatHistoryState.ts diff --git a/src/views/chat-history/common/GetChatHistory.ts b/src/views/chat-history/common/GetChatHistory.ts new file mode 100644 index 00000000..d39ef584 --- /dev/null +++ b/src/views/chat-history/common/GetChatHistory.ts @@ -0,0 +1,7 @@ +import { IChatHistoryState } from '../context/ChatHistoryContext.types'; + +let GLOBAL_CHATS: IChatHistoryState = null; + +export const SetChatHistory = (chatHistory: IChatHistoryState) => (GLOBAL_CHATS = chatHistory); + +export const GetChatHistory = () => GLOBAL_CHATS; diff --git a/src/views/chat-history/utils/RoomHistoryState.ts b/src/views/chat-history/common/RoomHistoryState.ts similarity index 100% rename from src/views/chat-history/utils/RoomHistoryState.ts rename to src/views/chat-history/common/RoomHistoryState.ts diff --git a/src/views/chat-history/context/ChatHistoryContext.types.ts b/src/views/chat-history/context/ChatHistoryContext.types.ts index e691d471..51cd19cf 100644 --- a/src/views/chat-history/context/ChatHistoryContext.types.ts +++ b/src/views/chat-history/context/ChatHistoryContext.types.ts @@ -24,6 +24,8 @@ export interface IChatEntry { name: string; look?: string; message?: string; + entityType?: number; + roomId: number; timestamp: string; type: number; } diff --git a/src/views/help/HelpMessageHandler.tsx b/src/views/help/HelpMessageHandler.tsx index f71634b7..959abdb9 100644 --- a/src/views/help/HelpMessageHandler.tsx +++ b/src/views/help/HelpMessageHandler.tsx @@ -1,12 +1,10 @@ -import { CallForHelpResultMessageEvent, FurnitureListItemParser, PetData } from '@nitrots/nitro-renderer'; +import { CallForHelpResultMessageEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback } from 'react'; import { LocalizeText } from '../../api'; import { CreateMessageHook } from '../../hooks/messages/message-event'; import { NotificationAlertType } from '../notification-center/common/NotificationAlertType'; import { NotificationUtilities } from '../notification-center/common/NotificationUtilities'; import { GetCloseReasonKey } from './common/GetCloseReasonKey'; -let furniMsgFragments: Map[] = null; -let petMsgFragments: Map[] = null; export const HelpMessageHandler: FC<{}> = props => { diff --git a/src/views/help/HelpView.scss b/src/views/help/HelpView.scss new file mode 100644 index 00000000..927c1cdc --- /dev/null +++ b/src/views/help/HelpView.scss @@ -0,0 +1,10 @@ +.nitro-help { + height: 400px; + width: 300px; + + .index-image { + background: url('../../assets/images/help/help_index.png'); + width: 126px; + height: 105px; + } +} diff --git a/src/views/help/HelpView.tsx b/src/views/help/HelpView.tsx index 4917c713..630d41d1 100644 --- a/src/views/help/HelpView.tsx +++ b/src/views/help/HelpView.tsx @@ -1,11 +1,79 @@ -import { FC } from 'react'; +import { FC, useCallback, useState } from 'react'; +import { LocalizeText } from '../../api'; +import { HelpEvent } from '../../events/help/HelpEvent'; +import { HelpReportUserEvent } from '../../events/help/HelpReportUserEvent'; +import { useUiEvent } from '../../hooks'; +import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../layout'; +import { HelpContextProvider } from './context/HelpContext'; +import { IHelpReportState, initialReportState } from './context/HelpContext.types'; import { HelpMessageHandler } from './HelpMessageHandler'; +import { DescribeReportView } from './views/DescribeReportView'; +import { HelpIndexView } from './views/HelpIndexView'; +import { SelectReportedChatsView } from './views/SelectReportedChatsView'; +import { SelectReportedUserView } from './views/SelectReportedUserView'; +import { SelectTopicView } from './views/SelectTopicView'; export const HelpView: FC<{}> = props => { + const [isVisible, setIsVisible] = useState(false); + const [ helpReportState, setHelpReportState ] = useState(initialReportState); + + const onHelpEvent = useCallback((event: HelpEvent) => + { + setHelpReportState(initialReportState); + + switch(event.type) + { + case HelpEvent.SHOW_HELP_CENTER: + setIsVisible(true); + break; + case HelpEvent.HIDE_HELP_CENTER: + setIsVisible(false); + break; + case HelpEvent.TOGGLE_HELP_CENTER: + setIsVisible(!isVisible); + break; + case HelpReportUserEvent.REPORT_USER: + const reportEvent = event as HelpReportUserEvent; + const reportState = Object.assign({}, helpReportState ); + reportState.reportedUserId = reportEvent.reportedUserId; + reportState.currentStep = 2; + setHelpReportState(reportState); + setIsVisible(true); + break; + } + }, [helpReportState, isVisible]); + + useUiEvent(HelpEvent.TOGGLE_HELP_CENTER, onHelpEvent); + useUiEvent(HelpEvent.SHOW_HELP_CENTER, onHelpEvent); + useUiEvent(HelpEvent.HIDE_HELP_CENTER, onHelpEvent); + useUiEvent(HelpReportUserEvent.REPORT_USER, onHelpEvent); + + const CurrentStepView = useCallback(() => + { + switch(helpReportState.currentStep) + { + case 0: return + case 1: return + case 2: return + case 3: return + case 4: return + } + + return null; + }, [helpReportState.currentStep]); + return ( - <> + - + {isVisible && + + setIsVisible(false)} /> + + + + + } + ); } diff --git a/src/views/help/common/IUser.ts b/src/views/help/common/IUser.ts new file mode 100644 index 00000000..bd3852ab --- /dev/null +++ b/src/views/help/common/IUser.ts @@ -0,0 +1,5 @@ +export interface IUser +{ + id: number; + username: string; +} diff --git a/src/views/help/context/HelpContext.tsx b/src/views/help/context/HelpContext.tsx new file mode 100644 index 00000000..2cad4a52 --- /dev/null +++ b/src/views/help/context/HelpContext.tsx @@ -0,0 +1,14 @@ +import { createContext, FC, useContext } from 'react'; +import { HelpContextProps, IHelpContext } from './HelpContext.types'; + +const HelpContext = createContext({ + helpReportState: null, + setHelpReportState: null +}); + +export const HelpContextProvider: FC = props => +{ + return { props.children } +} + +export const useHelpContext = () => useContext(HelpContext); diff --git a/src/views/help/context/HelpContext.types.ts b/src/views/help/context/HelpContext.types.ts new file mode 100644 index 00000000..9368308b --- /dev/null +++ b/src/views/help/context/HelpContext.types.ts @@ -0,0 +1,33 @@ +import { ProviderProps } from 'react'; +import { IChatEntry } from '../../chat-history/context/ChatHistoryContext.types'; + +export interface IHelpContext +{ + helpReportState: IHelpReportState; + setHelpReportState: React.Dispatch>; +} + +export interface IHelpReportState { + reportedUserId: number; + reportedChats: IChatEntry[]; + cfhCategory: number; + cfhTopic: number; + roomId: number; + message: string; + currentStep: number; +} + +export const initialReportState: IHelpReportState = { + reportedUserId: -1, + reportedChats: [], + cfhCategory: -1, + cfhTopic: -1, + roomId: -1, + message: '', + currentStep: 0 +} + +export interface HelpContextProps extends ProviderProps +{ + +} diff --git a/src/views/help/views/DescribeReportView.tsx b/src/views/help/views/DescribeReportView.tsx new file mode 100644 index 00000000..f936d225 --- /dev/null +++ b/src/views/help/views/DescribeReportView.tsx @@ -0,0 +1,50 @@ +import { CallForHelpMessageComposer } from '@nitrots/nitro-renderer'; +import { FC, useCallback, useState } from 'react'; +import { LocalizeText } from '../../../api'; +import { HelpEvent } from '../../../events/help/HelpEvent'; +import { dispatchUiEvent, SendMessageHook } from '../../../hooks'; +import { useHelpContext } from '../context/HelpContext'; + +export const DescribeReportView: FC<{}> = props => +{ + const { helpReportState = null, setHelpReportState = null } = useHelpContext(); + const [message, setMessage] = useState(''); + + const submitReport = useCallback(() => + { + if(message.length < 15) return; + + const reportState = Object.assign({}, helpReportState); + + reportState.message = message; + + setHelpReportState(reportState); + + const roomId = reportState.reportedChats[0].roomId; + const chats: (string | number )[] = []; + reportState.reportedChats.forEach(entry => + { + chats.push(entry.entityId); + chats.push(entry.message); + }); + + SendMessageHook(new CallForHelpMessageComposer(message, reportState.cfhTopic, reportState.reportedUserId, roomId, chats)); + + dispatchUiEvent(new HelpEvent(HelpEvent.HIDE_HELP_CENTER)); + }, [helpReportState, message, setHelpReportState]); + + return ( + <> +
+

{LocalizeText('help.emergency.chat_report.subtitle')}

+
{LocalizeText('help.cfh.input.text')}
+
+ +
+