Merge branch 'fix-if-guardian-is-not-available' into 'dev'

Fix issue #78 - Show alert if no one is available Guardian/Helper

See merge request nitro/nitro-react!92
This commit is contained in:
skeletor 2022-11-08 00:03:33 +00:00
commit f13eb1fed4
4 changed files with 67 additions and 8 deletions

View File

@ -7,6 +7,8 @@ export class GuideSessionState
public static readonly USER_PENDING: string = 'USER_PENDING'; public static readonly USER_PENDING: string = 'USER_PENDING';
public static readonly USER_ONGOING: string = 'USER_ONGOING'; public static readonly USER_ONGOING: string = 'USER_ONGOING';
public static readonly USER_FEEDBACK: string = 'USER_FEEDBACK'; 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_THANKS: string = 'USER_THANKS';
public static readonly USER_GUIDE_DISCONNECTED: string = 'USER_GUIDE_DISCONNECTED'; public static readonly USER_GUIDE_DISCONNECTED: string = 'USER_GUIDE_DISCONNECTED';
public static readonly GUIDE_TOOL_MENU: string = 'GUIDE_TOOL_MENU'; public static readonly GUIDE_TOOL_MENU: string = 'GUIDE_TOOL_MENU';

View File

@ -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 { FC, useCallback, useEffect, useState } from 'react';
import { AddEventLinkTracker, GetConfiguration, GetSessionDataManager, GuideSessionState, GuideToolMessage, GuideToolMessageGroup, LocalizeText, RemoveLinkEventTracker, SendMessageComposer } from '../../api'; import { AddEventLinkTracker, GetConfiguration, GetSessionDataManager, GuideSessionState, GuideToolMessage, GuideToolMessageGroup, LocalizeText, RemoveLinkEventTracker, SendMessageComposer } from '../../api';
import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../common'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../common';
@ -9,7 +9,9 @@ import { GuideToolMenuView } from './views/GuideToolMenuView';
import { GuideToolOngoingView } from './views/GuideToolOngoingView'; import { GuideToolOngoingView } from './views/GuideToolOngoingView';
import { GuideToolUserCreateRequestView } from './views/GuideToolUserCreateRequestView'; import { GuideToolUserCreateRequestView } from './views/GuideToolUserCreateRequestView';
import { GuideToolUserFeedbackView } from './views/GuideToolUserFeedbackView'; import { GuideToolUserFeedbackView } from './views/GuideToolUserFeedbackView';
import { GuideToolUserNoHelpersView } from './views/GuideToolUserNoHelpersView';
import { GuideToolUserPendingView } from './views/GuideToolUserPendingView'; import { GuideToolUserPendingView } from './views/GuideToolUserPendingView';
import { GuideToolUserSomethingWrogView } from './views/GuideToolUserSomethingWrogView';
import { GuideToolUserThanksView } from './views/GuideToolUserThanksView'; import { GuideToolUserThanksView } from './views/GuideToolUserThanksView';
export const GuideToolView: FC<{}> = props => export const GuideToolView: FC<{}> = props =>
@ -77,6 +79,14 @@ export const GuideToolView: FC<{}> = props =>
setHeaderText(LocalizeText('guide.help.request.user.thanks.title')); setHeaderText(LocalizeText('guide.help.request.user.thanks.title'));
setNoCloseButton(false); setNoCloseButton(false);
break; 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); setSessionState(newState);
@ -222,6 +232,24 @@ export const GuideToolView: FC<{}> = props =>
} }
}); });
useMessageEvent<GuideSessionErrorMessageEvent>(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>(GuideSessionDetachedMessageEvent, event => useMessageEvent<GuideSessionDetachedMessageEvent>(GuideSessionDetachedMessageEvent, event =>
{ {
setOngoingUserId(0); setOngoingUserId(0);
@ -315,6 +343,10 @@ export const GuideToolView: FC<{}> = props =>
<GuideToolUserFeedbackView userName={ ongoingUsername } /> } <GuideToolUserFeedbackView userName={ ongoingUsername } /> }
{ (sessionState === GuideSessionState.USER_THANKS) && { (sessionState === GuideSessionState.USER_THANKS) &&
<GuideToolUserThanksView /> } <GuideToolUserThanksView /> }
{ (sessionState === GuideSessionState.USER_NO_HELPERS) &&
<GuideToolUserNoHelpersView /> }
{ (sessionState === GuideSessionState.USER_SOMETHING_WRONG) &&
<GuideToolUserSomethingWrogView /> }
</NitroCardContentView> </NitroCardContentView>
</NitroCardView> </NitroCardView>
); );

View File

@ -0,0 +1,13 @@
import { FC } from 'react';
import { LocalizeText } from '../../../api';
import { Column, Text } from '../../../common';
export const GuideToolUserNoHelpersView: FC<{}> = props =>
{
return (
<Column gap={ 1 }>
<Text bold>{ LocalizeText('guide.help.request.no_tour_guides.title') }</Text>
<Text>{ LocalizeText('guide.help.request.no_tour_guides.message') }</Text>
</Column>
);
};

View File

@ -0,0 +1,12 @@
import { FC } from 'react';
import { LocalizeText } from '../../../api';
import { Column, Text } from '../../../common';
export const GuideToolUserSomethingWrogView: FC<{}> = props =>
{
return (
<Column gap={ 1 }>
<Text>{ LocalizeText('guide.help.request.user.guide.disconnected.error.desc') }</Text>
</Column>
);
};