diff --git a/src/api/guide-tool/GuideSessionState.ts b/src/api/guide-tool/GuideSessionState.ts index 02d225f0..c5e24f37 100644 --- a/src/api/guide-tool/GuideSessionState.ts +++ b/src/api/guide-tool/GuideSessionState.ts @@ -7,6 +7,8 @@ export class GuideSessionState public static readonly USER_PENDING: string = 'USER_PENDING'; public static readonly USER_ONGOING: string = 'USER_ONGOING'; public static readonly USER_FEEDBACK: string = 'USER_FEEDBACK'; + public static readonly USER_NO_HELPERS: string = 'USER_NO_HELPERS'; + public static readonly USER_SOMETHING_WRONG: string = 'USER_SOMETHING_WRONG'; public static readonly USER_THANKS: string = 'USER_THANKS'; public static readonly USER_GUIDE_DISCONNECTED: string = 'USER_GUIDE_DISCONNECTED'; public static readonly GUIDE_TOOL_MENU: string = 'GUIDE_TOOL_MENU'; diff --git a/src/components/guide-tool/GuideToolView.tsx b/src/components/guide-tool/GuideToolView.tsx index cec4f5f7..5e85f46d 100644 --- a/src/components/guide-tool/GuideToolView.tsx +++ b/src/components/guide-tool/GuideToolView.tsx @@ -1,4 +1,4 @@ -import { GuideOnDutyStatusMessageEvent, GuideSessionAttachedMessageEvent, GuideSessionDetachedMessageEvent, GuideSessionEndedMessageEvent, GuideSessionInvitedToGuideRoomMessageEvent, GuideSessionMessageMessageEvent, GuideSessionOnDutyUpdateMessageComposer, GuideSessionPartnerIsTypingMessageEvent, GuideSessionStartedMessageEvent, ILinkEventTracker, PerkAllowancesMessageEvent, PerkEnum } from '@nitrots/nitro-renderer'; +import { GuideOnDutyStatusMessageEvent, GuideSessionAttachedMessageEvent, GuideSessionDetachedMessageEvent, GuideSessionEndedMessageEvent, GuideSessionErrorMessageEvent, GuideSessionInvitedToGuideRoomMessageEvent, GuideSessionMessageMessageEvent, GuideSessionOnDutyUpdateMessageComposer, GuideSessionPartnerIsTypingMessageEvent, GuideSessionStartedMessageEvent, ILinkEventTracker, PerkAllowancesMessageEvent, PerkEnum } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; import { AddEventLinkTracker, GetConfiguration, GetSessionDataManager, GuideSessionState, GuideToolMessage, GuideToolMessageGroup, LocalizeText, RemoveLinkEventTracker, SendMessageComposer } from '../../api'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../common'; @@ -9,7 +9,9 @@ import { GuideToolMenuView } from './views/GuideToolMenuView'; import { GuideToolOngoingView } from './views/GuideToolOngoingView'; import { GuideToolUserCreateRequestView } from './views/GuideToolUserCreateRequestView'; import { GuideToolUserFeedbackView } from './views/GuideToolUserFeedbackView'; +import { GuideToolUserNoHelpersView } from './views/GuideToolUserNoHelpersView'; import { GuideToolUserPendingView } from './views/GuideToolUserPendingView'; +import { GuideToolUserSomethingWrogView } from './views/GuideToolUserSomethingWrogView'; import { GuideToolUserThanksView } from './views/GuideToolUserThanksView'; export const GuideToolView: FC<{}> = props => @@ -77,6 +79,14 @@ export const GuideToolView: FC<{}> = props => setHeaderText(LocalizeText('guide.help.request.user.thanks.title')); setNoCloseButton(false); break; + case GuideSessionState.USER_NO_HELPERS: + setHeaderText(LocalizeText('guide.help.request.no_tour_guides.heading')); + setNoCloseButton(false); + break; + case GuideSessionState.USER_SOMETHING_WRONG: + setHeaderText(LocalizeText('guide.help.request.user.guide.disconnected.error.heading')); + setNoCloseButton(false); + break; } setSessionState(newState); @@ -92,7 +102,7 @@ export const GuideToolView: FC<{}> = props => return; case GuideToolEvent.HIDE_GUIDE_TOOL: setIsVisible(false); - return; + return; case GuideToolEvent.TOGGLE_GUIDE_TOOL: setIsVisible(value => !value); return; @@ -136,7 +146,7 @@ export const GuideToolView: FC<{}> = props => setHelpRequestAverageTime(parser.roleSpecificWaitTime); if(parser.asGuide && isOnDuty) updateSessionState(GuideSessionState.GUIDE_ACCEPT); - + if(!parser.asGuide) updateSessionState(GuideSessionState.USER_PENDING); }); @@ -222,6 +232,24 @@ export const GuideToolView: FC<{}> = props => } }); + useMessageEvent(GuideSessionErrorMessageEvent, event => + { + const parser = event.getParser(); + + // SOMETHING_WRONG_REQUEST = 0, NO_HELPERS_AVAILABLE = 1, NO_GUARDIANS_AVAILABLE = 2 + + switch (parser['errorCode']) + { + case 0: + updateSessionState(GuideSessionState.USER_SOMETHING_WRONG); + break; + case 1: + case 2: + updateSessionState(GuideSessionState.USER_NO_HELPERS); + break; + } + }); + useMessageEvent(GuideSessionDetachedMessageEvent, event => { setOngoingUserId(0); @@ -232,7 +260,7 @@ export const GuideToolView: FC<{}> = props => if(isOnDuty) { - + updateSessionState(GuideSessionState.GUIDE_TOOL_MENU); } else @@ -247,9 +275,9 @@ export const GuideToolView: FC<{}> = props => linkReceived: (url: string) => { const parts = url.split('/'); - + if(parts.length < 2) return; - + switch(parts[1]) { case 'tour': @@ -286,7 +314,7 @@ export const GuideToolView: FC<{}> = props => SendMessageComposer(new GuideSessionOnDutyUpdateMessageComposer(!v, v ? false : isHandlingGuideRequests, v ? false : isHandlingHelpRequests, v ? false : isHandlingBullyReports)); return !v; }); - + return; case 'forum_link': const url: string = GetConfiguration('group.homepage.url', '').replace('%groupid%', GetConfiguration('guide.help.alpha.groupid', '0')); @@ -302,7 +330,7 @@ export const GuideToolView: FC<{}> = props => processAction('close') } noCloseButton={ noCloseButton } /> { (sessionState === GuideSessionState.GUIDE_TOOL_MENU) && - } + } { (sessionState === GuideSessionState.GUIDE_ACCEPT) && } { [ GuideSessionState.GUIDE_ONGOING, GuideSessionState.USER_ONGOING ].includes(sessionState) && @@ -315,6 +343,10 @@ export const GuideToolView: FC<{}> = props => } { (sessionState === GuideSessionState.USER_THANKS) && } + { (sessionState === GuideSessionState.USER_NO_HELPERS) && + } + { (sessionState === GuideSessionState.USER_SOMETHING_WRONG) && + } ); diff --git a/src/components/guide-tool/views/GuideToolUserNoHelpersView.tsx b/src/components/guide-tool/views/GuideToolUserNoHelpersView.tsx new file mode 100644 index 00000000..6fcbfd51 --- /dev/null +++ b/src/components/guide-tool/views/GuideToolUserNoHelpersView.tsx @@ -0,0 +1,13 @@ +import { FC } from 'react'; +import { LocalizeText } from '../../../api'; +import { Column, Text } from '../../../common'; + +export const GuideToolUserNoHelpersView: FC<{}> = props => +{ + return ( + + { LocalizeText('guide.help.request.no_tour_guides.title') } + { LocalizeText('guide.help.request.no_tour_guides.message') } + + ); +}; \ No newline at end of file diff --git a/src/components/guide-tool/views/GuideToolUserSomethingWrogView.tsx b/src/components/guide-tool/views/GuideToolUserSomethingWrogView.tsx new file mode 100644 index 00000000..1e8ec5ea --- /dev/null +++ b/src/components/guide-tool/views/GuideToolUserSomethingWrogView.tsx @@ -0,0 +1,12 @@ +import { FC } from 'react'; +import { LocalizeText } from '../../../api'; +import { Column, Text } from '../../../common'; + +export const GuideToolUserSomethingWrogView: FC<{}> = props => +{ + return ( + + { LocalizeText('guide.help.request.user.guide.disconnected.error.desc') } + + ); +}; \ No newline at end of file