import React from 'react'; import { DefaultBtn } from '../DefaultBtn/DefaultBtn'; import { useAttribute } from '@threekit-tools/treble'; import { SetActiveItem } from '../../store/actions/Settings'; import { useStoreDispatch, useStoreSelector } from '../../App'; import s from './ShopItem.module.scss'; import { getActualAttributes, getActualAttributesByName, } from './../../store/selectors/selectors'; import { warningShopInfo } from '../../utils/constants'; import { pathImage } from '../StandardItem/StandardItem'; export const ShopItem = ({ name, quantity, label, info, type, setConfigActiveMenu, actualPrice, }: any) => { const [attribute, setAttribute]: any = useAttribute(name); const actualAttributes: any = useStoreSelector(getActualAttributes); const dispatch = useStoreDispatch(); const { defaultItem, activeItem, price, img, assetType } = info; function toDefault(e: any, value: any) { e.stopPropagation(); dispatch( SetActiveItem({ name: name, data: { activeItem: defaultItem, activeItemId: undefined, price: 0, shopInfo: { quantity: 1 }, }, }) ); setAttribute(value); const checkTotalPrice = Number(actualPrice) - price; if (checkTotalPrice === 0) { setConfigActiveMenu(true); } } function changeQuantity(number: any) { if (number >= 1) { dispatch( SetActiveItem({ name: name, data: { activeItem: activeItem, shopInfo: { quantity: number } }, }) ); } } return ( <> {type === 'asset' ? (