Skip to content

Commit

Permalink
fix(web): use getItemUrl for currency and crafting
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed May 9, 2023
1 parent 4206132 commit d42d65b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion web/src/components/inventory/InventoryHotbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const InventoryHotbar: React.FC = () => {
<div
className="hotbar-item-slot"
style={{
backgroundImage: getItemUrl(item as SlotWithItem) || 'none',
backgroundImage: `url(${item?.name ? getItemUrl(item as SlotWithItem) : 'none'}`,
}}
key={`hotbar-${item.slot}`}
>
Expand Down
12 changes: 4 additions & 8 deletions web/src/components/inventory/InventorySlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { Locale } from '../../store/locale';
import { Tooltip } from '@mui/material';
import SlotTooltip from './SlotTooltip';
import { setContextMenu } from '../../store/inventory';
import { imagepath } from '../../store/imagepath';
import { onCraft } from '../../dnd/onCraft';
import useNuiEvent from '../../hooks/useNuiEvent';
import { ItemsPayload } from '../../reducers/refreshSlots';
Expand Down Expand Up @@ -46,7 +45,7 @@ const InventorySlot: React.FC<SlotProps> = ({ inventory, item }) => {
name: item.name,
slot: item.slot,
},
image: item?.name ? getItemUrl(item as SlotWithItem) : 'none',
image: item?.name && `url(${getItemUrl(item) || 'none'}`,
}
: null,
canDrag,
Expand Down Expand Up @@ -147,7 +146,7 @@ const InventorySlot: React.FC<SlotProps> = ({ inventory, item }) => {
? 'brightness(80%) grayscale(100%)'
: undefined,
opacity: isDragging ? 0.4 : 1.0,
backgroundImage: getItemUrl(item as SlotWithItem) || 'none',
backgroundImage: `url(${item?.name ? getItemUrl(item as SlotWithItem) : 'none'}`,
border: isOver ? '1px dashed rgba(255,255,255,0.4)' : '',
}}
>
Expand Down Expand Up @@ -184,13 +183,10 @@ const InventorySlot: React.FC<SlotProps> = ({ inventory, item }) => {
)}
{inventory.type === 'shop' && item?.price !== undefined && (
<>
{item?.currency !== 'money' &&
item?.currency !== 'black_money' &&
item.price > 0 &&
item?.currency ? (
{item?.currency !== 'money' && item.currency !== 'black_money' && item.price > 0 && item.currency ? (
<div className="item-slot-currency-wrapper">
<img
src={item?.currency ? `${`${imagepath}/${item?.currency}.png`}` : ''}
src={item.currency ? getItemUrl(item.currency) : 'none'}
alt="item-image"
style={{
imageRendering: '-webkit-optimize-contrast',
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/inventory/SlotTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { Items } from '../../store/items';
import { Locale } from '../../store/locale';
import ReactMarkdown from 'react-markdown';
import { useAppSelector } from '../../store';
import { imagepath } from '../../store/imagepath';
import ClockIcon from '../utils/icons/ClockIcon';
import { getItemUrl } from '../../helpers';

const SlotTooltip: React.FC<{ item: SlotWithItem; inventory: Inventory }> = ({ item, inventory }) => {
const additionalMetadata = useAppSelector((state) => state.inventory.additionalMetadata);
Expand Down Expand Up @@ -98,7 +98,7 @@ const SlotTooltip: React.FC<{ item: SlotWithItem; inventory: Inventory }> = ({ i
const [item, count] = [ingredient[0], ingredient[1]];
return (
<div className="tooltip-ingredient" key={`ingredient-${item}`}>
<img src={`${imagepath}/${item}.png`} />
<img src={item ? getItemUrl(item) : 'none'} alt="item-image" />
<p>
{count >= 1
? `${count}x ${Items[item]?.label || item}`
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/utils/ItemNotifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const ItemNotification = React.forwardRef(
<div
className="item-notification-item-box"
style={{
backgroundImage: getItemUrl(slotItem) || 'none',
backgroundImage: `url(${getItemUrl(slotItem) || 'none'}`,
...props.style,
}}
ref={ref}
Expand Down

0 comments on commit d42d65b

Please sign in to comment.