mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-26 23:50:52 +01:00
Fix gift place in inventory
This commit is contained in:
parent
5e7bd29e97
commit
cfebf32679
@ -71,7 +71,7 @@ export const CatalogPurchaseView: FC<CatalogPurchaseViewProps> = props =>
|
||||
</div>
|
||||
<div className="d-flex flex-column mt-1">
|
||||
<CatalogPurchaseButtonView className="btn-sm w-100" offer={ offer } pageId={ pageId } extra={ extraData } quantity={ quantity } disabled={ disabled } />
|
||||
{ offer.giftable && <CatalogPurchaseGiftButtonView className="btn-sm w-100 mt-1" offer={ offer } pageId={ pageId } extra={ extraData } quantity={ quantity } /> }
|
||||
{ offer.giftable && <CatalogPurchaseGiftButtonView className="btn-sm w-100 mt-1" offer={ offer } pageId={ pageId } extra={ extraData } disabled={ disabled } /> }
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
@ -6,7 +6,7 @@ import { CatalogPurchaseGiftButtonViewProps } from './CatalogPurchaseGiftButtonV
|
||||
|
||||
export const CatalogPurchaseGiftButtonView: FC<CatalogPurchaseGiftButtonViewProps> = props =>
|
||||
{
|
||||
const { className = '', offer = null, pageId = -1, extra = null, quantity = 1, isPurchaseAllowed = true, beforePurchase = null } = props;
|
||||
const { className = '', offer = null, pageId = -1, extra = null, disabled = false } = props;
|
||||
|
||||
const initGift = useCallback(() =>
|
||||
{
|
||||
@ -14,6 +14,6 @@ export const CatalogPurchaseGiftButtonView: FC<CatalogPurchaseGiftButtonViewProp
|
||||
}, [ extra, offer, pageId ]);
|
||||
|
||||
return (
|
||||
<button type="button" className={ 'btn btn-secondary ' + className } onClick={ initGift }>{ LocalizeText('catalog.purchase_confirmation.gift') }</button>
|
||||
<button type="button" className={ 'btn btn-secondary ' + className } onClick={ initGift } disabled={ disabled }>{ LocalizeText('catalog.purchase_confirmation.gift') }</button>
|
||||
);
|
||||
}
|
||||
|
@ -6,7 +6,5 @@ export interface CatalogPurchaseGiftButtonViewProps
|
||||
offer: CatalogPageMessageOfferData;
|
||||
pageId: number;
|
||||
extra?: string;
|
||||
quantity?: number;
|
||||
isPurchaseAllowed?: boolean;
|
||||
beforePurchase?: () => void;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { RoomObjectCategory, RoomObjectOperationType } from '@nitrots/nitro-renderer';
|
||||
import { FC, useCallback, useMemo, useState } from 'react';
|
||||
import { CreateLinkEvent, GetSessionDataManager, LocalizeText, RoomWidgetPresentOpenMessage, RoomWidgetRoomObjectUpdateEvent, RoomWidgetUpdatePresentDataEvent } from '../../../../../api';
|
||||
import { CreateLinkEvent, GetRoomEngine, GetSessionDataManager, LocalizeText, RoomWidgetPresentOpenMessage, RoomWidgetRoomObjectUpdateEvent, RoomWidgetUpdatePresentDataEvent } from '../../../../../api';
|
||||
import { CreateEventDispatcherHook } from '../../../../../hooks/events/event-dispatcher.base';
|
||||
import { NitroCardContentView, NitroCardHeaderView, NitroCardView, NitroLayoutGiftCardView } from '../../../../../layout';
|
||||
import { ProductTypeEnum } from '../../../../catalog/common/ProductTypeEnum';
|
||||
@ -11,7 +12,6 @@ const LANDSCAPE: string = 'landscape';
|
||||
|
||||
export const FurnitureGiftOpeningView: FC<{}> = props =>
|
||||
{
|
||||
const { eventDispatcher = null, widgetHandler = null } = useRoomContext();
|
||||
const [ objectId, setObjectId ] = useState(-1);
|
||||
const [ classId, setClassId ] = useState(-1);
|
||||
const [ itemType, setItemType ] = useState<string>(null);
|
||||
@ -24,6 +24,7 @@ export const FurnitureGiftOpeningView: FC<{}> = props =>
|
||||
const [ placedInRoom, setPlacedInRoom ] = useState(false);
|
||||
const [ imageUrl, setImageUrl ] = useState<string>(null);
|
||||
const [ openRequested, setOpenRequested ] = useState(false);
|
||||
const { roomSession = null, eventDispatcher = null, widgetHandler = null } = useRoomContext();
|
||||
|
||||
const clearGift = useCallback(() =>
|
||||
{
|
||||
@ -127,7 +128,12 @@ export const FurnitureGiftOpeningView: FC<{}> = props =>
|
||||
const close = useCallback(() =>
|
||||
{
|
||||
setObjectId(-1);
|
||||
}, []);
|
||||
setOpenRequested(false);
|
||||
setPlacedItemId(-1);
|
||||
setPlacedInRoom(false);
|
||||
setText(null);
|
||||
setIsOwnerOfFurniture(false);
|
||||
}, [ clearGift ]);
|
||||
|
||||
const isSpaces = useMemo(() =>
|
||||
{
|
||||
@ -166,9 +172,24 @@ export const FurnitureGiftOpeningView: FC<{}> = props =>
|
||||
case 'room':
|
||||
return;
|
||||
case 'inventory':
|
||||
if((placedItemId > 0) && placedInRoom)
|
||||
{
|
||||
if(placedItemType === ProductTypeEnum.PET)
|
||||
{
|
||||
roomSession.pickupPet(placedItemId);
|
||||
}
|
||||
else
|
||||
{
|
||||
const roomObject = GetRoomEngine().getRoomObject(roomSession.roomId, placedItemId, RoomObjectCategory.FLOOR);
|
||||
|
||||
if(roomObject) GetRoomEngine().processRoomObjectOperation(roomObject.id, RoomObjectCategory.FLOOR, RoomObjectOperationType.OBJECT_PICKUP);
|
||||
}
|
||||
}
|
||||
|
||||
close();
|
||||
return;
|
||||
}
|
||||
}, [ widgetHandler, objectId ]);
|
||||
}, [ roomSession, widgetHandler, objectId, placedInRoom, placedItemId, placedItemType, close ]);
|
||||
|
||||
if(objectId === -1) return null;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user