From 789aa3c183e253f63da31b557deda491b980a20f Mon Sep 17 00:00:00 2001 From: Dank074 Date: Fri, 23 Jul 2021 18:22:07 -0500 Subject: [PATCH] added widget slots --- src/views/hotel-view/HotelView.scss | 44 ++++++++++--------- src/views/hotel-view/HotelView.tsx | 41 +++++++++-------- .../views/widget-slot/WidgetSlotView.tsx | 2 +- .../views/widget-slot/WidgetSlotView.types.ts | 1 + .../views/widgets/GetWidgetLayout.tsx | 13 +++--- .../views/widgets/GetWidgetLayout.types.ts | 2 + .../bonus-rare/BonusRareWidgetView.tsx | 32 ++++++++++++++ .../bonus-rare/BonusRareWidgetView.types.ts | 2 + .../hall-of-fame/HallOfFameWidgetView.tsx | 25 ++++++++++- .../HallOfFameWidgetView.types.ts | 5 ++- .../promo-article/PromoArticleWidgetView.scss | 4 +- .../promo-article/PromoArticleWidgetView.tsx | 32 +++++++------- 12 files changed, 138 insertions(+), 65 deletions(-) create mode 100644 src/views/hotel-view/views/widgets/bonus-rare/BonusRareWidgetView.tsx create mode 100644 src/views/hotel-view/views/widgets/bonus-rare/BonusRareWidgetView.types.ts diff --git a/src/views/hotel-view/HotelView.scss b/src/views/hotel-view/HotelView.scss index 4d3ae78f..607bcec1 100644 --- a/src/views/hotel-view/HotelView.scss +++ b/src/views/hotel-view/HotelView.scss @@ -80,49 +80,51 @@ overflow: hidden; } - .slot-0 { - top: 5px; - width: 600px; - height: 100px; - } - .slot-1 { - top: 100px; - left: 100px; - width: 100px; - height:100px; + top: 5px; + left: 10px; + width: 100%; + height: 100px; } .slot-2 { - top: 300px; + top: 100px; left: 100px; - width: 100px; - height: 100px; + width: 200px; + height:100px; } .slot-3 { - top: 100px; - left: 600px; - width: 100px; + top: 300px; + left: 100px; + width: 200px; height: 100px; } .slot-4 { - top: 300px; + top: 100px; left: 600px; - width: 100px; + width: 200px; height: 100px; } .slot-5 { - bottom: 5px; - width: 600px; + top: 300px; + left: 600px; + width: 200px; height: 100px; } .slot-6 { + left: 10px; + bottom: 5px; + width: 100%; + height: 100px; + } + + .slot-7 { width: 100px; - height: 600px; + height: 100%; right: 5px; } } diff --git a/src/views/hotel-view/HotelView.tsx b/src/views/hotel-view/HotelView.tsx index 74da6863..dc8b2683 100644 --- a/src/views/hotel-view/HotelView.tsx +++ b/src/views/hotel-view/HotelView.tsx @@ -7,12 +7,12 @@ import { WidgetSlotView } from './views/widget-slot/WidgetSlotView'; export const HotelView: FC = props => { - const [ isVisible, setIsVisible ] = useState(true); + const [isVisible, setIsVisible] = useState(true); const widgetSlotCount = 7; const onRoomSessionEvent = useCallback((event: RoomSessionEvent) => { - switch(event.type) + switch (event.type) { case RoomSessionEvent.CREATED: setIsVisible(false); @@ -26,26 +26,31 @@ export const HotelView: FC = props => useRoomSessionManagerEvent(RoomSessionEvent.CREATED, onRoomSessionEvent); useRoomSessionManagerEvent(RoomSessionEvent.ENDED, onRoomSessionEvent); - if(!isVisible) return null; + if (!isVisible) return null; const backgroundColor = GetConfiguration('hotelview')['images']['background.colour']; - const background = Nitro.instance.core.configuration.interpolate(GetConfiguration('hotelview')['images']['background']); - const sun = Nitro.instance.core.configuration.interpolate(GetConfiguration('hotelview')['images']['sun']); - const drape = Nitro.instance.core.configuration.interpolate(GetConfiguration('hotelview')['images']['drape']); - const left = Nitro.instance.core.configuration.interpolate(GetConfiguration('hotelview')['images']['left']); - const rightRepeat = Nitro.instance.core.configuration.interpolate(GetConfiguration('hotelview')['images']['right.repeat']); - const right = Nitro.instance.core.configuration.interpolate(GetConfiguration('hotelview')['images']['right']); + const background = Nitro.instance.core.configuration.interpolate(GetConfiguration('hotelview')['images']['background']); + const sun = Nitro.instance.core.configuration.interpolate(GetConfiguration('hotelview')['images']['sun']); + const drape = Nitro.instance.core.configuration.interpolate(GetConfiguration('hotelview')['images']['drape']); + const left = Nitro.instance.core.configuration.interpolate(GetConfiguration('hotelview')['images']['left']); + const rightRepeat = Nitro.instance.core.configuration.interpolate(GetConfiguration('hotelview')['images']['right.repeat']); + const right = Nitro.instance.core.configuration.interpolate(GetConfiguration('hotelview')['images']['right']); return ( -
- {Array.from(Array(widgetSlotCount)).map((x, index) => )} -
-
-
-
-
-
+
+ {Array.from(Array(widgetSlotCount)).map((x, index) => + )} +
+
+
+
+
+
); } diff --git a/src/views/hotel-view/views/widget-slot/WidgetSlotView.tsx b/src/views/hotel-view/views/widget-slot/WidgetSlotView.tsx index 639cb0e3..d03e1a05 100644 --- a/src/views/hotel-view/views/widget-slot/WidgetSlotView.tsx +++ b/src/views/hotel-view/views/widget-slot/WidgetSlotView.tsx @@ -6,7 +6,7 @@ export const WidgetSlotView: FC = props => { return (
- +
); } diff --git a/src/views/hotel-view/views/widget-slot/WidgetSlotView.types.ts b/src/views/hotel-view/views/widget-slot/WidgetSlotView.types.ts index cbbefc31..ab1d6c8d 100644 --- a/src/views/hotel-view/views/widget-slot/WidgetSlotView.types.ts +++ b/src/views/hotel-view/views/widget-slot/WidgetSlotView.types.ts @@ -2,4 +2,5 @@ export interface WidgetSlotViewProps { widgetType: string; slot: number; + widgetConf: string; } diff --git a/src/views/hotel-view/views/widgets/GetWidgetLayout.tsx b/src/views/hotel-view/views/widgets/GetWidgetLayout.tsx index bd8d4b60..84351f3e 100644 --- a/src/views/hotel-view/views/widgets/GetWidgetLayout.tsx +++ b/src/views/hotel-view/views/widgets/GetWidgetLayout.tsx @@ -1,16 +1,19 @@ import { FC } from 'react'; +import { BonusRareWidgetView } from './bonus-rare/BonusRareWidgetView'; import { GetWidgetLayoutProps } from './GetWidgetLayout.types'; import { HallOfFameWidgetView } from './hall-of-fame/HallOfFameWidgetView'; import { PromoArticleWidgetView } from './promo-article/PromoArticleWidgetView'; export const GetWidgetLayout: FC = props => { - switch(props.widgetType) + switch (props.widgetType) { - case "news": - return ; - case "hof": - return ; + case "promoarticle": + return ; + case "achievementcompetition_hall_of_fame": + return ; + case "bonusrare": + return ; default: return null; } diff --git a/src/views/hotel-view/views/widgets/GetWidgetLayout.types.ts b/src/views/hotel-view/views/widgets/GetWidgetLayout.types.ts index 42ca0053..b06d5e7a 100644 --- a/src/views/hotel-view/views/widgets/GetWidgetLayout.types.ts +++ b/src/views/hotel-view/views/widgets/GetWidgetLayout.types.ts @@ -1,4 +1,6 @@ export interface GetWidgetLayoutProps { widgetType: string; + slot: number; + widgetConf: string; } diff --git a/src/views/hotel-view/views/widgets/bonus-rare/BonusRareWidgetView.tsx b/src/views/hotel-view/views/widgets/bonus-rare/BonusRareWidgetView.tsx new file mode 100644 index 00000000..6f135bd2 --- /dev/null +++ b/src/views/hotel-view/views/widgets/bonus-rare/BonusRareWidgetView.tsx @@ -0,0 +1,32 @@ +import { BonusRareInfoMessageEvent, GetBonusRareInfoMessageComposer } from 'nitro-renderer'; +import { FC, useCallback, useEffect, useState } from 'react'; +import { CreateMessageHook, SendMessageHook } from '../../../../../hooks/messages/message-event'; +import { BonusRareWidgetViewProps } from './BonusRareWidgetView.types'; + +export const BonusRareWidgetView: FC = props => +{ + const [productType, setProductType] = useState(null); + const [productClassId, setProductClassId] = useState(null); + const [totalCoinsForBonus, setTotalCoinsForBonus] = useState(null); + const [coinsStillRequiredToBuy, setCoinsStillRequiredToBuy] = useState(null); + + useEffect(() => + { + SendMessageHook(new GetBonusRareInfoMessageComposer()); + }, []); + + const onBonusRareInfoMessageEvent = useCallback((event: BonusRareInfoMessageEvent) => + { + const parser = event.getParser(); + setProductType(parser.productType); + setProductClassId(parser.productClassId); + setTotalCoinsForBonus(parser.totalCoinsForBonus); + setCoinsStillRequiredToBuy(parser.coinsStillRequiredToBuy); + }, []); + + CreateMessageHook(BonusRareInfoMessageEvent, onBonusRareInfoMessageEvent); + + if(!productType) return (null); + + return (
{productType}
); +} diff --git a/src/views/hotel-view/views/widgets/bonus-rare/BonusRareWidgetView.types.ts b/src/views/hotel-view/views/widgets/bonus-rare/BonusRareWidgetView.types.ts new file mode 100644 index 00000000..9157b7b2 --- /dev/null +++ b/src/views/hotel-view/views/widgets/bonus-rare/BonusRareWidgetView.types.ts @@ -0,0 +1,2 @@ +export interface BonusRareWidgetViewProps +{} diff --git a/src/views/hotel-view/views/widgets/hall-of-fame/HallOfFameWidgetView.tsx b/src/views/hotel-view/views/widgets/hall-of-fame/HallOfFameWidgetView.tsx index d60ade22..82300041 100644 --- a/src/views/hotel-view/views/widgets/hall-of-fame/HallOfFameWidgetView.tsx +++ b/src/views/hotel-view/views/widgets/hall-of-fame/HallOfFameWidgetView.tsx @@ -1,9 +1,30 @@ -import { FC } from 'react'; +import { CommunityGoalHallOfFameData, CommunityGoalHallOfFameMessageEvent, GetCommunityGoalHallOfFameMessageComposer } from 'nitro-renderer'; +import { FC, useCallback, useEffect, useState } from 'react'; +import { CreateMessageHook, SendMessageHook } from '../../../../../hooks/messages/message-event'; import { HallOfFameWidgetViewProps } from './HallOfFameWidgetView.types'; export const HallOfFameWidgetView: FC = props => { + const [data, setData] = useState(null); + + useEffect(() => + { + SendMessageHook(new GetCommunityGoalHallOfFameMessageComposer(props.conf)); + }, [props.conf]); + + const onCommunityGoalHallOfFameMessageEvent = useCallback((event: CommunityGoalHallOfFameMessageEvent) => + { + const parser = event.getParser(); + setData(parser.data); + }, []); + + CreateMessageHook(CommunityGoalHallOfFameMessageEvent, onCommunityGoalHallOfFameMessageEvent); + + if(!data) return null; + return ( -
+
+

showing hall of fame for event: {data ? data.goalCode : 'empty'}

+
); } diff --git a/src/views/hotel-view/views/widgets/hall-of-fame/HallOfFameWidgetView.types.ts b/src/views/hotel-view/views/widgets/hall-of-fame/HallOfFameWidgetView.types.ts index c03c84a8..955af179 100644 --- a/src/views/hotel-view/views/widgets/hall-of-fame/HallOfFameWidgetView.types.ts +++ b/src/views/hotel-view/views/widgets/hall-of-fame/HallOfFameWidgetView.types.ts @@ -1,2 +1,5 @@ export interface HallOfFameWidgetViewProps -{} +{ + slot: number; + conf: string; +} diff --git a/src/views/hotel-view/views/widgets/promo-article/PromoArticleWidgetView.scss b/src/views/hotel-view/views/widgets/promo-article/PromoArticleWidgetView.scss index b0521c2a..77dc0cb3 100644 --- a/src/views/hotel-view/views/widgets/promo-article/PromoArticleWidgetView.scss +++ b/src/views/hotel-view/views/widgets/promo-article/PromoArticleWidgetView.scss @@ -1,4 +1,4 @@ .promo-article { - top: 50px; - left: 50px; + width: 100%; + height: 100%; } diff --git a/src/views/hotel-view/views/widgets/promo-article/PromoArticleWidgetView.tsx b/src/views/hotel-view/views/widgets/promo-article/PromoArticleWidgetView.tsx index e32ebbe3..a17257ee 100644 --- a/src/views/hotel-view/views/widgets/promo-article/PromoArticleWidgetView.tsx +++ b/src/views/hotel-view/views/widgets/promo-article/PromoArticleWidgetView.tsx @@ -6,14 +6,14 @@ import { PromoArticleWidgetViewProps } from './PromoArticleWidgetView.types'; export const PromoArticleWidgetView: FC = props => { - const [ articles, setArticles ] = useState(null); + const [articles, setArticles] = useState(null); const [index, setIndex] = useState(0); const handleSelect = (selectedIndex, e) => { setIndex(selectedIndex); }; - + useEffect(() => { SendMessageHook(new GetPromoArticlesComposer()); @@ -27,22 +27,24 @@ export const PromoArticleWidgetView: FC = props => CreateMessageHook(PromoArticlesMessageEvent, onPromoArticlesMessageEvent); + if (!articles) return null; + return (
- { articles && (articles.length > 0) && articles.map(article => - - {article.title} - -

{article.title}

-

{article.bodyText}

-
-
- ) } + {articles && (articles.length > 0) && articles.map(article => + + {article.title} + +

{article.title}

+

{article.bodyText}

+
+
+ )}
);