Skip to content

Commit

Permalink
Fix banner condition
Browse files Browse the repository at this point in the history
  • Loading branch information
juniusfree committed Mar 26, 2024
1 parent 4daf0f1 commit 5a265af
Showing 1 changed file with 41 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ const CommandBanner = ({
const bannerImageInputField = useRef(null);
const topImageInputField = useRef(null);

const customBannerImage = customBanner?.find((customBanner) => customBanner.purpose === banner.purpose);
const customBannerImage = customBanner?.find((customBanner) => customBanner.purpose === banner?.purpose);
const customTopImage = customBanner?.find((customBanner) => customBanner.purpose === thumbnail?.purpose);
const customBannerImageUrl = customBannerImage?.publicUrl;
const customTopImageUrl = customTopImage?.publicUrl;
Expand Down Expand Up @@ -254,39 +254,46 @@ const CommandBanner = ({
</StyledInformationTooltip>
</HeaderContainer>
<CommandBannerUploadContainer>
<BannerUploadContainer>
<BannerUploadHeader>Banner</BannerUploadHeader>
<BannerUploadImageContainer>
{customBannerImageUrl ? (
<SafeImage
src={customBannerImageUrl}
alt={`${title} banner`}
style={{
height: "auto",
objectFit: "cover",
width: "100%",
maxHeight: "100%",
}}
/>
) : (
<img src={banner.image} alt={`${title} banner`} />
)}
</BannerUploadImageContainer>
<BannerUploadTextButtonContainer>
<BannerUploadText>Optimal size: 640 x 140px</BannerUploadText>
<BannerUploadButtonContainer>
<ButtonIconWrapper onClick={handleSetBannerImageAvatarProps}>
<ReplaceIcon />
</ButtonIconWrapper>
<ButtonInputContainer>
<input type="file" accept="image/*" ref={bannerImageInputField} onChange={handleBannerImageOnChange} />
</ButtonInputContainer>
<ButtonIconWrapper onClick={handleDeleteBannerImage}>
<DeleteIcon />
</ButtonIconWrapper>
</BannerUploadButtonContainer>
</BannerUploadTextButtonContainer>
</BannerUploadContainer>
{banner !== undefined && (
<BannerUploadContainer>
<BannerUploadHeader>Banner</BannerUploadHeader>
<BannerUploadImageContainer>
{customBannerImageUrl ? (
<SafeImage
src={customBannerImageUrl}
alt={`${title} banner`}
style={{
height: "auto",
objectFit: "cover",
width: "100%",
maxHeight: "100%",
}}
/>
) : (
<img src={banner.image} alt={`${title} banner`} />
)}
</BannerUploadImageContainer>
<BannerUploadTextButtonContainer>
<BannerUploadText>Optimal size: 640 x 140px</BannerUploadText>
<BannerUploadButtonContainer>
<ButtonIconWrapper onClick={handleSetBannerImageAvatarProps}>
<ReplaceIcon />
</ButtonIconWrapper>
<ButtonInputContainer>
<input
type="file"
accept="image/*"
ref={bannerImageInputField}
onChange={handleBannerImageOnChange}
/>
</ButtonInputContainer>
<ButtonIconWrapper onClick={handleDeleteBannerImage}>
<DeleteIcon />
</ButtonIconWrapper>
</BannerUploadButtonContainer>
</BannerUploadTextButtonContainer>
</BannerUploadContainer>
)}
<SectionDivider />
{thumbnail !== undefined && (
<TopImageSectionContainer>
Expand Down

0 comments on commit 5a265af

Please sign in to comment.