mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-30 00:50:50 +01:00
Merge branch 'fix-place-furni-gift' into '@fix/fixes'
Fix placing furni when is a gift - Issue #248 See merge request nitro/nitro-react!82
This commit is contained in:
commit
5b6e33e58f
@ -1,14 +1,23 @@
|
|||||||
import { FC } from 'react';
|
import { FC } from 'react';
|
||||||
import { CreateLinkEvent, LocalizeText } from '../../../../api';
|
import { attemptItemPlacement, CreateLinkEvent, LocalizeText } from '../../../../api';
|
||||||
import { Button, Column, Flex, LayoutGiftTagView, LayoutImage, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../common';
|
import { Button, Column, Flex, LayoutGiftTagView, LayoutImage, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../common';
|
||||||
import { useFurniturePresentWidget } from '../../../../hooks';
|
import { useFurniturePresentWidget, useInventoryFurni } from '../../../../hooks';
|
||||||
|
|
||||||
export const FurnitureGiftOpeningView: FC<{}> = props =>
|
export const FurnitureGiftOpeningView: FC<{}> = props =>
|
||||||
{
|
{
|
||||||
const { objectId = -1, classId = -1, itemType = null, text = null, isOwnerOfFurniture = false, senderName = null, senderFigure = null, placedItemId = -1, placedItemType = null, placedInRoom = false, imageUrl = null, openPresent = null, onClose = null } = useFurniturePresentWidget();
|
const { objectId = -1, classId = -1, itemType = null, text = null, isOwnerOfFurniture = false, senderName = null, senderFigure = null, placedItemId = -1, placedItemType = null, placedInRoom = false, imageUrl = null, openPresent = null, onClose = null } = useFurniturePresentWidget();
|
||||||
|
const { groupItems = null } = useInventoryFurni();
|
||||||
|
|
||||||
if(objectId === -1) return null;
|
if(objectId === -1) return null;
|
||||||
|
|
||||||
|
const putFurni = (itemId: number) =>
|
||||||
|
{
|
||||||
|
const furni = groupItems?.filter(group => group.items[0].ref == itemId);
|
||||||
|
|
||||||
|
attemptItemPlacement(furni[0]);
|
||||||
|
onClose();
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NitroCardView className="nitro-gift-opening" theme="primary-slim">
|
<NitroCardView className="nitro-gift-opening" theme="primary-slim">
|
||||||
<NitroCardHeaderView headerText={ LocalizeText(senderName ? 'widget.furni.present.window.title_from' : 'widget.furni.present.window.title', [ 'name' ], [ senderName ]) } onCloseClick={ onClose } />
|
<NitroCardHeaderView headerText={ LocalizeText(senderName ? 'widget.furni.present.window.title_from' : 'widget.furni.present.window.title', [ 'name' ], [ senderName ]) } onCloseClick={ onClose } />
|
||||||
@ -45,7 +54,7 @@ export const FurnitureGiftOpeningView: FC<{}> = props =>
|
|||||||
<Button fullWidth onClick={ null }>
|
<Button fullWidth onClick={ null }>
|
||||||
{ LocalizeText('widget.furni.present.put_in_inventory') }
|
{ LocalizeText('widget.furni.present.put_in_inventory') }
|
||||||
</Button> }
|
</Button> }
|
||||||
<Button fullWidth variant="success" onClick={ null }>
|
<Button fullWidth variant="success" onClick={ event => putFurni(placedItemId) }>
|
||||||
{ LocalizeText(placedInRoom ? 'widget.furni.present.keep_in_room' : 'widget.furni.present.place_in_room') }
|
{ LocalizeText(placedInRoom ? 'widget.furni.present.keep_in_room' : 'widget.furni.present.place_in_room') }
|
||||||
</Button>
|
</Button>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
Loading…
Reference in New Issue
Block a user