From ca2bff4e6eae229c9013122efc34bf6f7438bb14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roc=C3=ADo=20Llanes?= Date: Fri, 7 Jun 2024 09:30:10 -0300 Subject: [PATCH 1/2] SBIT-316: footer's subscription component's redirection issues fixed --- .../Footer/Subscription/subscription.js | 50 ++++++++++++------- src/hooks/useFooter.js | 1 + src/schema/layoutSchema.js | 1 + 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/components/Footer/Subscription/subscription.js b/src/components/Footer/Subscription/subscription.js index 6305d1af..ff9806b2 100644 --- a/src/components/Footer/Subscription/subscription.js +++ b/src/components/Footer/Subscription/subscription.js @@ -1,15 +1,41 @@ import { Link } from "gatsby" import React from "react" -import { useFooter } from "../../../hooks" +import { useFooter, useLandingUrl } from "../../../hooks" import "./subscription.scss" export default function Subscription() { const data = useFooter() + const getUrl = useLandingUrl() + const dataSubscription = data?.allStrapiLayout?.nodes[0]?.footer?.subscription + const subscriptionUrl = dataSubscription?.url - const subscriptionLanding = dataSubscription?.landing_page?.slug + const landing = getUrl(dataSubscription?.landing_page?.slug) + + if(!dataSubscription?.landing_page && !subscriptionUrl) return <> + + const SubscriptionLink = ({ children }) => { + const isExternalLink = subscriptionUrl?.startsWith('http') - const isExternalLink = subscriptionUrl?.startsWith('http') + if (landing) return ( + + {children} + + ) + else if (isExternalLink) return ( + + {children} + + ) + else { + + {children} + + } + } return (
@@ -17,26 +43,12 @@ export default function Subscription() {
) diff --git a/src/hooks/useFooter.js b/src/hooks/useFooter.js index 49a5d00b..b8097518 100644 --- a/src/hooks/useFooter.js +++ b/src/hooks/useFooter.js @@ -92,6 +92,7 @@ const useFooter = () => { subscription { title url + callToAction landing_page { slug } diff --git a/src/schema/layoutSchema.js b/src/schema/layoutSchema.js index 1f8f85b9..8fb0ef12 100644 --- a/src/schema/layoutSchema.js +++ b/src/schema/layoutSchema.js @@ -118,6 +118,7 @@ type StrapiLayoutNavbarNavButtonLanding_page { id: Int title: String url: String + callToAction: String landing_page: StrapiLayoutFooterSubscriptionLanding } From 0ff2b1b7dcc3503cb40ce4a2133c04768dca0cb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roc=C3=ADo=20Llanes?= Date: Fri, 7 Jun 2024 09:47:24 -0300 Subject: [PATCH 2/2] SBIT-316: fixes --- .../Footer/Subscription/subscription.js | 58 ++++++++++--------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/src/components/Footer/Subscription/subscription.js b/src/components/Footer/Subscription/subscription.js index ff9806b2..d23e78d5 100644 --- a/src/components/Footer/Subscription/subscription.js +++ b/src/components/Footer/Subscription/subscription.js @@ -1,8 +1,31 @@ import { Link } from "gatsby" +import PropTypes from "prop-types" import React from "react" import { useFooter, useLandingUrl } from "../../../hooks" import "./subscription.scss" +const SubscriptionLink = ({ children, subscriptionUrl, landing }) => { + const isExternalLink = subscriptionUrl?.startsWith('http') + + if (landing) { + return {children} + } else if (isExternalLink) { + return ( + + {children} + + ) + } else { + return {children} + } +} + +SubscriptionLink.propTypes = { + children: PropTypes.node.isRequired, + subscriptionUrl: PropTypes.string, + landing: PropTypes.string, +} + export default function Subscription() { const data = useFooter() const getUrl = useLandingUrl() @@ -12,30 +35,7 @@ export default function Subscription() { const subscriptionUrl = dataSubscription?.url const landing = getUrl(dataSubscription?.landing_page?.slug) - if(!dataSubscription?.landing_page && !subscriptionUrl) return <> - - const SubscriptionLink = ({ children }) => { - const isExternalLink = subscriptionUrl?.startsWith('http') - - if (landing) return ( - - {children} - - ) - else if (isExternalLink) return ( - - {children} - - ) - else { - - {children} - - } - } + if (!dataSubscription?.landing_page && !subscriptionUrl) return null return (
@@ -43,13 +43,17 @@ export default function Subscription() {
) -} \ No newline at end of file +}