Skip to content

Commit

Permalink
πŸš‘ Hotfix - Fix blank presenter on user group page (#3068)
Browse files Browse the repository at this point in the history
* πŸš‘ Fixed netug page attempting to render presenters when there are no presenters

* πŸ› Added fallback logic to ensure the image for user groups will not attempt to render if not provided

* πŸ› Added fallback logic so presenter name will be sourced from the event if presenter list is empty

* ✨ Added fallback so that the presenter image will default to the profile avatar image if not provided

---------

Co-authored-by: Calinator444 <[email protected]>
  • Loading branch information
Calinator444 and Calinator444 authored Sep 5, 2024
1 parent d31a9e9 commit 3568715
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 6 additions & 1 deletion components/usergroup/organizer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Image from "next/image";
import { useState } from "react";
import type { Template } from "tinacms";
import { tinaField } from "tinacms/dist/react";
import type { TinaMarkdownContent } from "tinacms/dist/rich-text";
Expand All @@ -21,6 +22,7 @@ export const Organizer = ({
data: OrganizerType;
stringContent?: string;
}) => {
const [image, setFallbackImage] = useState<string>(data.profileImg ?? "");
return (
<div className="flex flex-col gap-5">
<div className="flex flex-row items-center gap-2">
Expand All @@ -30,9 +32,12 @@ export const Organizer = ({
>
<Image
alt={`Picture of ${data?.name ?? "Organizer"}`}
src={data?.profileImg ?? ""}
src={image}
height={68}
width={68}
onError={() =>
setFallbackImage("/images/thumbs/avatar-thumbnail.png")
}
className="w-17"
/>
</div>
Expand Down
10 changes: 6 additions & 4 deletions pages/netug/[[...filename]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export default function NETUGPage(
const speaker = props.event?.presenterList
? props.event.presenterList[0]
: null;

// Converting element to string to render in presenter block
const aboutDescription = ReactDomServer.renderToString(
<TinaMarkdown content={speaker?.presenter?.about} />
Expand Down Expand Up @@ -189,7 +188,7 @@ export default function NETUGPage(
))}
</div>
</div>
{speaker && (
{(speaker || props.event.presenterName) && (
<div className="col-span-1 py-4 md:py-0">
<h2 className="text-4xl font-medium text-sswRed">
Presenter
Expand All @@ -198,9 +197,12 @@ export default function NETUGPage(
<Organizer
data={{
profileImg: speaker?.presenter?.profileImg,
name: speaker?.presenter?.presenter?.name,
name:
speaker?.presenter?.presenter?.name ||
props.event.presenterName,
profileLink:
speaker?.presenter?.presenter?.peopleProfileURL,
speaker?.presenter?.presenter?.peopleProfileURL ||
props.event.presenterProfileUrl,
}}
stringContent={aboutDescription}
/>
Expand Down

0 comments on commit 3568715

Please sign in to comment.