mirror of
https://github.com/duckietm/Nitro-Cool-UI.git
synced 2025-06-21 22:36:58 +00:00
🐟 We don't need to destructure the key in the child component at all
This commit is contained in:
parent
5ffc133721
commit
10dd5c3f62
@ -11,12 +11,12 @@ export const GetBubbleLayout = (
|
||||
) => {
|
||||
if (!item) return null;
|
||||
|
||||
const props = { key: item.id, item, onClose };
|
||||
const props = { item, onClose };
|
||||
|
||||
switch (item.notificationType) {
|
||||
case NotificationBubbleType.CLUBGIFT:
|
||||
return <NotificationClubGiftBubbleView {...props} />;
|
||||
return <NotificationClubGiftBubbleView key={ item.id } {...props} />;
|
||||
default:
|
||||
return <NotificationDefaultBubbleView {...props} />;
|
||||
return <NotificationDefaultBubbleView key={ item.id } {...props} />;
|
||||
}
|
||||
};
|
||||
|
@ -2,25 +2,28 @@ import { FC } from 'react';
|
||||
import { LocalizeText, NotificationBubbleItem, OpenUrl } from '../../../../api';
|
||||
import { LayoutCurrencyIcon, LayoutNotificationBubbleView, LayoutNotificationBubbleViewProps } from '../../../../common';
|
||||
|
||||
export interface NotificationClubGiftBubbleViewProps extends LayoutNotificationBubbleViewProps
|
||||
{
|
||||
export interface NotificationClubGiftBubbleViewProps extends LayoutNotificationBubbleViewProps {
|
||||
item: NotificationBubbleItem;
|
||||
}
|
||||
|
||||
export const NotificationClubGiftBubbleView: FC<NotificationClubGiftBubbleViewProps> = props =>
|
||||
{
|
||||
const { item = null, onClose = null, ...rest } = props;
|
||||
export const NotificationClubGiftBubbleView: FC<NotificationClubGiftBubbleViewProps> = props => {
|
||||
// Don't try to destructure key from props!
|
||||
const { item = null, onClose = null, ...restProps } = props;
|
||||
|
||||
return (
|
||||
<LayoutNotificationBubbleView fadesOut={ false } className="flex-column club-gift" onClose={ onClose } { ...rest }>
|
||||
<LayoutNotificationBubbleView fadesOut={ false } className="flex-column club-gift" onClose={ onClose } { ...restProps }>
|
||||
<div className="d-flex align-items-center gap-2 mb-2">
|
||||
<LayoutCurrencyIcon type="hc" className="flex-shrink-0" />
|
||||
<span className="ms-1">{ LocalizeText('notifications.text.club_gift') }</span>
|
||||
</div>
|
||||
<div className="d-flex align-items-center justify-content-end gap-2">
|
||||
<button type="button" className="btn btn-success w-100 btn-sm" onClick={ () => OpenUrl(item.linkUrl) }>{ LocalizeText('notifications.button.show_gift_list') }</button>
|
||||
<span className="text-decoration-underline cursor-pointer text-nowrap" onClick={ onClose }>{ LocalizeText('notifications.button.later') }</span>
|
||||
<button type="button" className="btn btn-success w-100 btn-sm" onClick={ () => OpenUrl(item.linkUrl) }>
|
||||
{ LocalizeText('notifications.button.show_gift_list') }
|
||||
</button>
|
||||
<span className="text-decoration-underline cursor-pointer text-nowrap" onClick={ onClose }>
|
||||
{ LocalizeText('notifications.button.later') }
|
||||
</span>
|
||||
</div>
|
||||
</LayoutNotificationBubbleView>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
@ -2,19 +2,20 @@ import { FC } from 'react';
|
||||
import { NotificationBubbleItem, OpenUrl } from '../../../../api';
|
||||
import { Flex, LayoutNotificationBubbleView, LayoutNotificationBubbleViewProps, Text } from '../../../../common';
|
||||
|
||||
export interface NotificationDefaultBubbleViewProps extends LayoutNotificationBubbleViewProps
|
||||
{
|
||||
export interface NotificationDefaultBubbleViewProps extends LayoutNotificationBubbleViewProps {
|
||||
item: NotificationBubbleItem;
|
||||
}
|
||||
|
||||
export const NotificationDefaultBubbleView: FC<NotificationDefaultBubbleViewProps> = props =>
|
||||
{
|
||||
const { item = null, onClose = null, ...rest } = props;
|
||||
export const NotificationDefaultBubbleView: FC<NotificationDefaultBubbleViewProps> = props => {
|
||||
// Do not destructure key!
|
||||
const { item = null, onClose = null, ...restProps } = props;
|
||||
|
||||
const htmlText = item.message.replace(/\r\n|\r|\n/g, '<br />');
|
||||
|
||||
return (
|
||||
<LayoutNotificationBubbleView onClose={ onClose } gap={ 2 } alignItems="center" onClick={ event => (item.linkUrl && item.linkUrl.length && OpenUrl(item.linkUrl)) } { ...rest }>
|
||||
<LayoutNotificationBubbleView onClose={ onClose } gap={ 2 } alignItems="center"
|
||||
onClick={ event => (item.linkUrl && item.linkUrl.length && OpenUrl(item.linkUrl)) }
|
||||
{ ...restProps }>
|
||||
<Flex center className="bubble-image-container">
|
||||
{ (item.iconUrl && item.iconUrl.length) &&
|
||||
<img className="no-select" src={ item.iconUrl } alt="" /> }
|
||||
@ -22,4 +23,4 @@ export const NotificationDefaultBubbleView: FC<NotificationDefaultBubbleViewProp
|
||||
<Text wrap variant="white" dangerouslySetInnerHTML={ { __html: htmlText } } />
|
||||
</LayoutNotificationBubbleView>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user