mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-23 14:40:50 +01:00
Fix alert
This commit is contained in:
parent
157f687170
commit
60fe9fe265
@ -1,6 +1,5 @@
|
|||||||
import { HabboWebTools, RoomEnterEffect } from '@nitrots/nitro-renderer';
|
import { HabboWebTools, RoomEnterEffect } from '@nitrots/nitro-renderer';
|
||||||
import { CreateLinkEvent, GetConfiguration, GetNitroInstance, LocalizeText } from '..';
|
import { CreateLinkEvent, GetConfiguration, GetNitroInstance, LocalizeText } from '..';
|
||||||
import { CatalogPageName } from '../../components/catalog/common/CatalogPageName';
|
|
||||||
import { NotificationAlertEvent, NotificationConfirmEvent } from '../../events';
|
import { NotificationAlertEvent, NotificationConfirmEvent } from '../../events';
|
||||||
import { NotificationBubbleEvent } from '../../events/notification-center/NotificationBubbleEvent';
|
import { NotificationBubbleEvent } from '../../events/notification-center/NotificationBubbleEvent';
|
||||||
import { DispatchUiEvent } from '../../hooks';
|
import { DispatchUiEvent } from '../../hooks';
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { NotificationAlertItem, NotificationAlertType } from '../../../../api';
|
import { NotificationAlertItem } from '../../../../api';
|
||||||
import { NotificationDefaultAlertView } from './NotificationDefaultAlertView';
|
import { NotificationDefaultAlertView } from './NotificationDefaultAlertView';
|
||||||
import { NotificationEventAlertView } from './NotificationEventAlertView';
|
|
||||||
|
|
||||||
export const GetAlertLayout = (item: NotificationAlertItem, close: () => void) =>
|
export const GetAlertLayout = (item: NotificationAlertItem, close: () => void) =>
|
||||||
{
|
{
|
||||||
@ -8,11 +7,5 @@ export const GetAlertLayout = (item: NotificationAlertItem, close: () => void) =
|
|||||||
|
|
||||||
const props = { key: item.id, item, close };
|
const props = { key: item.id, item, close };
|
||||||
|
|
||||||
switch(item.alertType)
|
return <NotificationDefaultAlertView { ...props } />
|
||||||
{
|
|
||||||
case NotificationAlertType.EVENT:
|
|
||||||
return <NotificationEventAlertView { ...props } />
|
|
||||||
default:
|
|
||||||
return <NotificationDefaultAlertView { ...props } />
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,8 @@ export const NotificationDefaultAlertView: FC<NotificationDefaultAlertViewProps>
|
|||||||
close();
|
close();
|
||||||
}, [ item, close ]);
|
}, [ item, close ]);
|
||||||
|
|
||||||
|
const isAction = (item.clickUrl && item.clickUrl.startsWith('event:'));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LayoutNotificationAlertView title={ title } close={ close } { ...rest }>
|
<LayoutNotificationAlertView title={ title } close={ close } { ...rest }>
|
||||||
{ (item.messages.length > 0) && item.messages.map((message, index) =>
|
{ (item.messages.length > 0) && item.messages.map((message, index) =>
|
||||||
@ -27,9 +29,12 @@ export const NotificationDefaultAlertView: FC<NotificationDefaultAlertViewProps>
|
|||||||
return <Base grow fullHeight overflow="auto" key={ index } dangerouslySetInnerHTML={ { __html: htmlText } } />;
|
return <Base grow fullHeight overflow="auto" key={ index } dangerouslySetInnerHTML={ { __html: htmlText } } />;
|
||||||
}) }
|
}) }
|
||||||
<Column alignItems="center" center gap={ 1 }>
|
<Column alignItems="center" center gap={ 1 }>
|
||||||
<Button onClick={ close }>{ LocalizeText('generic.close') }</Button>
|
{ !isAction &&
|
||||||
{ item.clickUrl && item.clickUrl.length &&
|
<Button onClick={ close }>{ LocalizeText('generic.close') }</Button> }
|
||||||
|
{ !isAction && item.clickUrl && (item.clickUrl.length > 0) &&
|
||||||
<Button variant="link" onClick={ visitUrl }>{ LocalizeText(item.clickUrlText) }</Button> }
|
<Button variant="link" onClick={ visitUrl }>{ LocalizeText(item.clickUrlText) }</Button> }
|
||||||
|
{ isAction && item.clickUrl && (item.clickUrl.length > 0) &&
|
||||||
|
<Button onClick={ visitUrl }>{ LocalizeText(item.clickUrlText) }</Button> }
|
||||||
</Column>
|
</Column>
|
||||||
</LayoutNotificationAlertView>
|
</LayoutNotificationAlertView>
|
||||||
);
|
);
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
import { FC, useCallback } from 'react';
|
|
||||||
import { LocalizeText, NotificationAlertItem, NotificationUtilities } from '../../../../api';
|
|
||||||
import { LayoutNotificationAlertView, LayoutNotificationAlertViewProps } from '../../../../common';
|
|
||||||
|
|
||||||
export interface NotificationEventAlertViewProps extends LayoutNotificationAlertViewProps
|
|
||||||
{
|
|
||||||
item: NotificationAlertItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const NotificationEventAlertView: FC<NotificationEventAlertViewProps> = props =>
|
|
||||||
{
|
|
||||||
const { item = null, title = ((props.item && props.item.title) || ''), close = null, ...rest } = props;
|
|
||||||
|
|
||||||
const visitUrl = useCallback(() =>
|
|
||||||
{
|
|
||||||
NotificationUtilities.openUrl(item.clickUrl);
|
|
||||||
|
|
||||||
close();
|
|
||||||
}, [ item, close ]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<LayoutNotificationAlertView title={ item.title } close={ close } { ...rest }>
|
|
||||||
{ (item.messages.length > 0) && item.messages.map((message, index) =>
|
|
||||||
{
|
|
||||||
const htmlText = message.replace(/\r\n|\r|\n/g, '<br />');
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div key={ index } dangerouslySetInnerHTML={ { __html: htmlText } } />
|
|
||||||
);
|
|
||||||
}) }
|
|
||||||
<div className="d-flex justify-content-center align-items-center mt-1">
|
|
||||||
<button type="button" className="btn btn-primary" onClick={ visitUrl }>{ LocalizeText(item.clickUrlText) }</button>
|
|
||||||
</div>
|
|
||||||
</LayoutNotificationAlertView>
|
|
||||||
);
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user