From df6d672df85ff3fdf24a98e3d6f766c5381d9a8e Mon Sep 17 00:00:00 2001 From: dank074 Date: Fri, 17 Jun 2022 20:55:29 -0500 Subject: [PATCH 1/6] updated packets --- src/api/navigator/TryVisitRoom.ts | 4 +- src/api/utils/PlaySound.ts | 3 +- .../page/layout/CatalogLayoutRoomAdsView.tsx | 71 +++++++++++++++++++ .../views/page/layout/GetCatalogLayout.tsx | 3 + .../navigator/NavigatorMessageHandler.tsx | 22 +++--- .../views/NavigatorRoomCreatorView.tsx | 4 +- .../navigator/views/NavigatorRoomInfoView.tsx | 6 +- .../room-tools/RoomToolsWidgetView.tsx | 4 +- 8 files changed, 95 insertions(+), 22 deletions(-) create mode 100644 src/components/catalog/views/page/layout/CatalogLayoutRoomAdsView.tsx diff --git a/src/api/navigator/TryVisitRoom.ts b/src/api/navigator/TryVisitRoom.ts index 94d8e6fc..81138d6c 100644 --- a/src/api/navigator/TryVisitRoom.ts +++ b/src/api/navigator/TryVisitRoom.ts @@ -1,7 +1,7 @@ -import { RoomInfoComposer } from '@nitrots/nitro-renderer'; +import { GetGuestRoomMessageComposer } from '@nitrots/nitro-renderer'; import { SendMessageComposer } from '../nitro'; export function TryVisitRoom(roomId: number): void { - SendMessageComposer(new RoomInfoComposer(roomId, false, true)); + SendMessageComposer(new GetGuestRoomMessageComposer(roomId, false, true)); } diff --git a/src/api/utils/PlaySound.ts b/src/api/utils/PlaySound.ts index 94c50ee9..70f6aad7 100644 --- a/src/api/utils/PlaySound.ts +++ b/src/api/utils/PlaySound.ts @@ -1,5 +1,4 @@ -import { MouseEventType } from '@nitrots/nitro-renderer'; -import { NitroSoundEvent } from '@nitrots/nitro-renderer/src/nitro/events/NitroSoundEvent'; +import { MouseEventType, NitroSoundEvent } from '@nitrots/nitro-renderer'; import { DispatchMainEvent } from '../../hooks'; let canPlaySound = false; diff --git a/src/components/catalog/views/page/layout/CatalogLayoutRoomAdsView.tsx b/src/components/catalog/views/page/layout/CatalogLayoutRoomAdsView.tsx new file mode 100644 index 00000000..cbc4e497 --- /dev/null +++ b/src/components/catalog/views/page/layout/CatalogLayoutRoomAdsView.tsx @@ -0,0 +1,71 @@ +import { GetRoomAdPurchaseInfoComposer, PurchaseRoomAdMessageComposer, RoomAdPurchaseInfoEvent, RoomEntryData } from '@nitrots/nitro-renderer'; +import { FC, useCallback, useEffect, useState } from 'react'; +import { LocalizeText, SendMessageComposer } from '../../../../../api'; +import { Base, Column, Text } from '../../../../../common'; +import { UseMessageEventHook } from '../../../../../hooks'; +import { CatalogLayoutProps } from './CatalogLayout.types'; + +export const CatalogLayoutRoomAdsView: FC = props => +{ + const { page = null } = props; + const [ eventName, setEventName ] = useState(''); + const [ eventDesc, setEventDesc ] = useState(''); + const [ roomId, setRoomId ] = useState(null); + const [ availableRooms, setAvailableRooms ] = useState([]); + const [ extended, setExtended ] = useState(false); + const [ categories, setCategories ] = useState(null); + + const onRoomAdPurchaseInfoEvent = useCallback((event: RoomAdPurchaseInfoEvent) => + { + const parser = event.getParser(); + + if(!parser) return; + + setAvailableRooms(parser.rooms); + }, []); + + UseMessageEventHook(RoomAdPurchaseInfoEvent, onRoomAdPurchaseInfoEvent); + + const purchaseAd = useCallback(() => + { + const pageId = page.pageId; + const offerId = page.offers.length >= 1 ? page.offers[0].offerId : -1; + const flatId = roomId; + const name = eventName; + const desc = eventDesc; + const categoryId = -1; + + SendMessageComposer(new PurchaseRoomAdMessageComposer(pageId, offerId, flatId, name, extended, desc, categoryId)) + }, [eventDesc, eventName, extended, page.offers, page.pageId, roomId]); + + useEffect(() => + { + SendMessageComposer(new GetRoomAdPurchaseInfoComposer()); + //SendMessageComposer(new GetUserEventCatsMessageComposer()); + }, []); + + return (<> + {LocalizeText('roomad.catalog_header')} + + {LocalizeText('roomad.catalog_text')} + + + { LocalizeText('roomad.catalog_name') } + setEventName(event.target.value) } /> + + + < Text bold>{LocalizeText('roomad.catalog_description')} +