diff --git a/src/layout/gift-card/NitroLayoutGiftCardView.tsx b/src/layout/gift-card/NitroLayoutGiftCardView.tsx index f9a1f3c6..30a575b6 100644 --- a/src/layout/gift-card/NitroLayoutGiftCardView.tsx +++ b/src/layout/gift-card/NitroLayoutGiftCardView.tsx @@ -8,7 +8,7 @@ export const NitroLayoutGiftCardView: FC = props = const { figure = null, userName = null, message = null, editable = false, onChange = null } = props; return ( -
+
{ !userName &&
} { figure &&
diff --git a/src/views/catalog/views/gift/CatalogPageGiftView.tsx b/src/views/catalog/views/gift/CatalogPageGiftView.tsx index 769f81a1..3cf7f616 100644 --- a/src/views/catalog/views/gift/CatalogPageGiftView.tsx +++ b/src/views/catalog/views/gift/CatalogPageGiftView.tsx @@ -150,7 +150,7 @@ export const CatalogPageGiftView: FC<{}> = props => }); return; case 'buy': - SendMessageHook(new PurchaseFromCatalogAsGiftComposer(pageId, offerId, extraData, receiverName, message, selectedColorId, selectedBoxIndex, selectedRibbonIndex, !showMyFace)); + SendMessageHook(new PurchaseFromCatalogAsGiftComposer(pageId, offerId, extraData, receiverName, message, selectedColorId, selectedBoxIndex, selectedRibbonIndex, showMyFace)); return; } }, [ extraData, maxBoxIndex, maxRibbonIndex, message, offerId, pageId, receiverName, selectedBoxIndex, selectedColorId, selectedRibbonIndex, showMyFace ]); diff --git a/src/views/room/widgets/furniture/FurnitureWidgets.scss b/src/views/room/widgets/furniture/FurnitureWidgets.scss index 688d0e6a..0fe453bc 100644 --- a/src/views/room/widgets/furniture/FurnitureWidgets.scss +++ b/src/views/room/widgets/furniture/FurnitureWidgets.scss @@ -6,3 +6,4 @@ @import './mannequin/FurnitureMannequinView'; @import './stickie/FurnitureStickieView'; @import './high-score/FurnitureHighScoreView'; +@import './gift-opening/FurnitureGiftOpeningView'; diff --git a/src/views/room/widgets/furniture/gift-opening/FurnitureGiftOpeningView.scss b/src/views/room/widgets/furniture/gift-opening/FurnitureGiftOpeningView.scss index e69de29b..5c1630f7 100644 --- a/src/views/room/widgets/furniture/gift-opening/FurnitureGiftOpeningView.scss +++ b/src/views/room/widgets/furniture/gift-opening/FurnitureGiftOpeningView.scss @@ -0,0 +1,3 @@ +.nitro-gift-opening { + width: 340px; +} diff --git a/src/views/room/widgets/furniture/gift-opening/FurnitureGiftOpeningView.tsx b/src/views/room/widgets/furniture/gift-opening/FurnitureGiftOpeningView.tsx index 8af7befb..55c19667 100644 --- a/src/views/room/widgets/furniture/gift-opening/FurnitureGiftOpeningView.tsx +++ b/src/views/room/widgets/furniture/gift-opening/FurnitureGiftOpeningView.tsx @@ -1,9 +1,14 @@ -import { FC, useCallback, useState } from 'react'; -import { LocalizeText, RoomWidgetRoomObjectUpdateEvent, RoomWidgetUpdatePresentDataEvent } from '../../../../../api'; +import { FC, useCallback, useMemo, useState } from 'react'; +import { CreateLinkEvent, GetSessionDataManager, LocalizeText, RoomWidgetPresentOpenMessage, RoomWidgetRoomObjectUpdateEvent, RoomWidgetUpdatePresentDataEvent } from '../../../../../api'; import { CreateEventDispatcherHook } from '../../../../../hooks/events/event-dispatcher.base'; -import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../layout'; +import { NitroCardContentView, NitroCardHeaderView, NitroCardView, NitroLayoutGiftCardView } from '../../../../../layout'; +import { ProductTypeEnum } from '../../../../catalog/common/ProductTypeEnum'; import { useRoomContext } from '../../../context/RoomContext'; +const FLOOR: string = 'floor'; +const WALLPAPER: string = 'wallpaper'; +const LANDSCAPE: string = 'landscape'; + export const FurnitureGiftOpeningView: FC<{}> = props => { const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); @@ -124,13 +129,77 @@ export const FurnitureGiftOpeningView: FC<{}> = props => setObjectId(-1); }, []); + const isSpaces = useMemo(() => + { + if(itemType !== ProductTypeEnum.WALL) return false; + + const furniData = GetSessionDataManager().getWallItemData(classId); + + if(!furniData) return false; + + const className = furniData.className; + + return (className === FLOOR || className === LANDSCAPE || className === WALLPAPER); + }, [ classId, itemType ]); + + const productName = useMemo(() => + { + if(objectId === -1) return ''; + + if(isSpaces) + return 'widget.furni.present.spaces.message_opened'; + + return 'widget.furni.present.message_opened'; + }, [ objectId, isSpaces ]); + + const handleAction = useCallback((action: string) => + { + switch(action) + { + case 'give_gift': + CreateLinkEvent('catalog/open'); + return; + case 'open': + setOpenRequested(true); + widgetHandler.processWidgetMessage(new RoomWidgetPresentOpenMessage(RoomWidgetPresentOpenMessage.OPEN_PRESENT, objectId)); + return; + case 'room': + return; + case 'inventory': + return; + } + }, [ widgetHandler, objectId ]); + if(objectId === -1) return null; return ( - - + + - plz + { placedItemId === -1 && <> + +
+ { senderName && } + +
+ } + { placedItemId !== -1 && <> +
+
+ +
+
+ { LocalizeText(productName, ['product'], [text]) } +
+
+
+ + +
+ { senderName && <> + + } + }
);