From 57a0ce62c29e3e3a4919fe671c85bc9a0cdfc5e7 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Mon, 26 Dec 2022 00:22:30 -0800 Subject: [PATCH] Fix party details when new --- components/Party/index.tsx | 2 ++ components/PartyDetails/index.tsx | 57 +++++++++++++++++++++---------- utils/appState.tsx | 4 +-- 3 files changed, 43 insertions(+), 20 deletions(-) diff --git a/components/Party/index.tsx b/components/Party/index.tsx index d2dd91e7..05fb6547 100644 --- a/components/Party/index.tsx +++ b/components/Party/index.tsx @@ -238,6 +238,8 @@ const Party = (props: Props) => { {navigation}
{currentGrid()}
void deleteCallback: ( @@ -116,34 +119,38 @@ const PartyDetails = (props: Props) => { toggleDetails() } - const userImage = () => { - if (party.user) + const userImage = (picture?: string, element?: string) => { + if (picture && element) return ( {party.user.avatar.picture} ) else return
} - const userBlock = () => { + const userBlock = (username?: string, picture?: string, element?: string) => { return (
- {userImage()} - {party.user ? party.user.username : t('no_user')} + {userImage(picture, element)} + {username ? username : t('no_user')}
) } - const linkedUserBlock = (user: User) => { + const linkedUserBlock = ( + username?: string, + picture?: string, + element?: string + ) => { return (
- - {userBlock()} + + {userBlock(username, picture, element)}
) @@ -203,7 +210,7 @@ const PartyDetails = (props: Props) => { { /> { placeholder={ 'Write your notes here\n\n\nWatch out for the 50% trigger!\nMake sure to click Fediel’s 1 first\nGood luck with RNG!' } - value={party.description} + value={props.party?.description} onChange={handleTextAreaChange} error={errors.description} ref={descriptionInput} @@ -249,9 +256,23 @@ const PartyDetails = (props: Props) => { {party.name ? party.name : 'Untitled'}
- {party.user ? linkedUserBlock(party.user) : userBlock()} + {accountState.account.authorized && props.new + ? linkedUserBlock( + accountState.account.user?.username, + accountState.account.user?.picture, + accountState.account.user?.element + ) + : userBlock()} + {party.user && !props.new + ? linkedUserBlock( + party.user.username, + party.user.avatar.picture, + party.user.avatar.element + ) + : ''} + {!party.user && !props.new ? userBlock() : ''} {party.raid ? linkedRaidBlock(party.raid) : ''} - {party.created_at != undefined ? ( + {party.created_at != '' ? (