diff --git a/components/GridRep/index.tsx b/components/GridRep/index.tsx index a9281b65..9448bcde 100644 --- a/components/GridRep/index.tsx +++ b/components/GridRep/index.tsx @@ -1,25 +1,35 @@ import React, { useEffect, useState } from 'react' +import { useSnapshot } from 'valtio' import classNames from 'classnames' +import { accountState } from '~utils/accountState' import { formatTimeAgo } from '~utils/timeAgo' +import Button from '~components/Button' +import { ButtonType } from '~utils/enums' + import './index.scss' interface Props { shortcode: string + id: string name: string raid: Raid grid: GridWeapon[] user?: User + favorited: boolean createdAt: Date displayUser?: boolean | false onClick: (shortcode: string) => void + onSave: (partyId: string, favorited: boolean) => void } const GridRep = (props: Props) => { const numWeapons: number = 9 + const { account } = useSnapshot(accountState) + const [mainhand, setMainhand] = useState() const [weapons, setWeapons] = useState>({}) @@ -64,6 +74,10 @@ const GridRep = (props: Props) => { {weapons[position]?.name.en} : '' } + function sendSaveData() { + props.onSave(props.id, props.favorited) + } + const userImage = () => { if (props.user) return ( @@ -80,7 +94,7 @@ const GridRep = (props: Props) => { const details = (
-

{ (props.name) ? props.name : 'Untitled' }

+

{ (props.name) ? props.name : 'Untitled' }

{ (props.raid) ? props.raid.name.en : 'No raid set' }
@@ -90,8 +104,19 @@ const GridRep = (props: Props) => { const detailsWithUsername = (
-

{ (props.name) ? props.name : 'Untitled' }

-
{ (props.raid) ? props.raid.name.en : 'No raid set' }
+
+
+

{ (props.name) ? props.name : 'Untitled' }

+
{ (props.raid) ? props.raid.name.en : 'No raid set' }
+
+ { (!props.user || (account.user && account.user.id !== props.user.id)) ? +
{ userImage() } @@ -103,9 +128,9 @@ const GridRep = (props: Props) => { ) return ( -
+
{ (props.displayUser) ? detailsWithUsername : details} -
+
{generateMainhandImage()}