From 9beebe58ba4dfd3fc74e9636633ab9a839de7008 Mon Sep 17 00:00:00 2001 From: brenoepics <59066707+brenoepics@users.noreply.github.com> Date: Tue, 15 Mar 2022 23:52:25 -0300 Subject: [PATCH] Fix calendar --- src/components/campaign/CalendarItemView.tsx | 11 +++---- src/components/campaign/CalendarView.tsx | 5 ++-- src/components/campaign/CampaignView.tsx | 5 ++-- .../campaign/common/CalendarItem.ts | 30 +++++++++++++++++++ .../campaign/common/ICalendarItem.ts | 6 ++++ 5 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 src/components/campaign/common/CalendarItem.ts create mode 100644 src/components/campaign/common/ICalendarItem.ts diff --git a/src/components/campaign/CalendarItemView.tsx b/src/components/campaign/CalendarItemView.tsx index bd61d3e7..7ca4cb66 100644 --- a/src/components/campaign/CalendarItemView.tsx +++ b/src/components/campaign/CalendarItemView.tsx @@ -1,6 +1,7 @@ import { FC } from 'react'; -import { GetRoomEngine, GetSessionDataManager } from '../../api'; +import { GetConfiguration, GetRoomEngine, GetSessionDataManager } from '../../api'; import { Base, Column, Flex, LayoutImage } from '../../common'; +import { CalendarItem } from './common/CalendarItem'; import { CalendarItemState } from './common/CalendarItemState'; interface CalendarItemViewProps @@ -8,13 +9,13 @@ interface CalendarItemViewProps itemId: number; state: number; active?: boolean; - productName?: string; + product?: CalendarItem; onClick: (itemId: number) => void; } export const CalendarItemView: FC = props => { - const { itemId = -1, state = null, productName = null, active = false, onClick = null } = props; + const { itemId = -1, state = null, product = null, active = false, onClick = null } = props; const getFurnitureIcon = (name: string) => { @@ -37,8 +38,8 @@ export const CalendarItemView: FC = props => { (state === CalendarItemState.STATE_UNLOCKED) && - { productName && - } + { product && + ('image.library.url') + product.customImage : getFurnitureIcon(product.productName) } /> } } { (state !== CalendarItemState.STATE_UNLOCKED) && diff --git a/src/components/campaign/CalendarView.tsx b/src/components/campaign/CalendarView.tsx index b36d5669..5afbd1a6 100644 --- a/src/components/campaign/CalendarView.tsx +++ b/src/components/campaign/CalendarView.tsx @@ -2,13 +2,14 @@ import { FC, useState } from 'react'; import { GetSessionDataManager, LocalizeText } from '../../api'; import { Base, Button, Column, Flex, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../common'; import { CalendarItemView } from './CalendarItemView'; +import { CalendarItem } from './common/CalendarItem'; import { CalendarItemState } from './common/CalendarItemState'; interface CalendarViewProps { close(): void; openPackage(id: number, asStaff: boolean): void; - receivedProducts: Map; + receivedProducts: Map; campaignName: string; currentDay: number; numDays: number; @@ -128,7 +129,7 @@ export const CalendarView: FC = props => return ( - + ); }) } diff --git a/src/components/campaign/CampaignView.tsx b/src/components/campaign/CampaignView.tsx index 1a7cf339..3464f29f 100644 --- a/src/components/campaign/CampaignView.tsx +++ b/src/components/campaign/CampaignView.tsx @@ -3,12 +3,13 @@ import { FC, useCallback, useEffect, useState } from 'react'; import { AddEventLinkTracker, RemoveLinkEventTracker, SendMessageComposer } from '../../api'; import { BatchUpdates, UseMessageEventHook } from '../../hooks'; import { CalendarView } from './CalendarView'; +import { CalendarItem } from './common/CalendarItem'; export const CampaignView: FC<{}> = props => { const [ calendarData, setCalendarData ] = useState(null); const [ lastOpenAttempt, setLastOpenAttempt ] = useState(-1); - const [ receivedProducts, setReceivedProducts ] = useState>(new Map()); + const [ receivedProducts, setReceivedProducts ] = useState>(new Map()); const [ isCalendarOpen, setCalendarOpen ] = useState(false); const onCampaignCalendarDataMessageEvent = useCallback((event: CampaignCalendarDataMessageEvent) => @@ -44,7 +45,7 @@ export const CampaignView: FC<{}> = props => setReceivedProducts(prev => { const copy = new Map(prev); - copy.set(lastAttempt, parser.furnitureClassName); + copy.set(lastAttempt, new CalendarItem(parser.productName, parser.customImage,parser.furnitureClassName)); return copy; }); diff --git a/src/components/campaign/common/CalendarItem.ts b/src/components/campaign/common/CalendarItem.ts new file mode 100644 index 00000000..d3634b3d --- /dev/null +++ b/src/components/campaign/common/CalendarItem.ts @@ -0,0 +1,30 @@ +import { ICalendarItem } from './ICalendarItem'; + +export class CalendarItem implements ICalendarItem +{ + private _productName: string; + private _customImage: string; + private _furnitureClassName: string; + + constructor(productName: string, customImage: string, furnitureClassName: string) + { + this._productName = productName; + this._customImage = customImage; + this._furnitureClassName = furnitureClassName; + } + + public get productName(): string + { + return this._productName; + } + + public get customImage(): string + { + return this._customImage; + } + + public get furnitureClassName(): string + { + return this._furnitureClassName; + } +} diff --git a/src/components/campaign/common/ICalendarItem.ts b/src/components/campaign/common/ICalendarItem.ts new file mode 100644 index 00000000..87dfbd6d --- /dev/null +++ b/src/components/campaign/common/ICalendarItem.ts @@ -0,0 +1,6 @@ +export interface ICalendarItem +{ + readonly productName: string; + readonly customImage: string; + readonly furnitureClassName: string; +}