From 8ad2874387e87c196eb1166cff4bb0e84d7933cc Mon Sep 17 00:00:00 2001 From: Swathi Vutukuri Date: Fri, 20 Mar 2026 18:14:54 +0530 Subject: [PATCH 1/2] fix: prevent crash and handle missing organizationInformation --- src/components/SupportUsButton.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/SupportUsButton.tsx b/src/components/SupportUsButton.tsx index c9b7278..d5dd986 100644 --- a/src/components/SupportUsButton.tsx +++ b/src/components/SupportUsButton.tsx @@ -70,11 +70,14 @@ function SupportUsButton({ }, buttonVariant = "AOSSIE", }: supportUsButtonProps): React.JSX.Element { + + return ( // Container for the support us button, with dynamic classes based on the selected theme and custom class names
+ {/* Hero section with optional background image*/}
{hero.Image && ( @@ -128,7 +131,9 @@ function SupportUsButton({
{/* Organization information section */} -
+ {/* Avoid rendering empty organization section when data is not provided */} +{organizationInformation ? ( +
+) : ( +

+ Organization details are not available. +

+)} {/* Sponsors section */}
Date: Fri, 20 Mar 2026 20:37:03 +0530 Subject: [PATCH 2/2] cta and org errors resolved --- src/components/SupportUsButton.tsx | 60 +++++++++++++++++++----------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/src/components/SupportUsButton.tsx b/src/components/SupportUsButton.tsx index d5dd986..fe4b907 100644 --- a/src/components/SupportUsButton.tsx +++ b/src/components/SupportUsButton.tsx @@ -49,7 +49,9 @@ function getButtonClasses(buttonVariant: ButtonVariant): string { } // Main component function that renders the support us button, taking in various props for customization and rendering different sections such as hero, organization information, sponsors, and call-to-action based on the provided data and selected theme and button variant -function SupportUsButton({ +function SupportUsButton( + + { Theme = "AOSSIE", pattern = "AOSSIE", hero = { @@ -70,8 +72,23 @@ function SupportUsButton({ }, buttonVariant = "AOSSIE", }: supportUsButtonProps): React.JSX.Element { + // Ensure required props are provided to prevent runtime crashes + if (!organizationInformation) { + console.warn( + "SupportUsButton: 'organizationInformation' is required." + ); + } + + if (!ctaSection) { + console.warn( + "SupportUsButton: 'ctaSection' is required." + ); + } + // Defensive fallback to handle unexpected missing props at runtime + const org = organizationInformation ?? null; + const cta = ctaSection ?? null; return ( // Container for the support us button, with dynamic classes based on the selected theme and custom class names
- {typeof organizationInformation.logo === "string" ? ( + {typeof org.logo === "string" ? ( - {organizationInformation.logo} + {org.logo} ) : ( {organizationInformation.logo?.alt} )} @@ -190,15 +207,15 @@ function SupportUsButton({ {/* Organization name and description */}

- {organizationInformation.name} + {org.name}

- {organizationInformation.description} + {org.description}

{/* Line */} - {organizationInformation.projectInformation && ( + {org.projectInformation && (

ABOUT PROJECT:{" "} - {organizationInformation.projectInformation.name} + {org.projectInformation.name}

- "{organizationInformation.projectInformation.description}" + "{org.projectInformation.description}"

)}
-) : ( -

- Organization details are not available. -

+ )} {/* Sponsors section */} @@ -427,21 +441,23 @@ function SupportUsButton({
{/* Call-to-action section with title, description, and sponsor links */} + {cta && ( +

- {ctaSection.title} + {cta.title}

- {ctaSection.description} + {cta.description}

- {ctaSection.sponsorLink.map((link, index) => ( + {cta.sponsorLink.map((link, index) => (
-
+
)}
); }