diff --git a/src/components/UpcomingDates/index.js b/src/components/UpcomingDates/index.js index cb8567f42..3d67a86ea 100644 --- a/src/components/UpcomingDates/index.js +++ b/src/components/UpcomingDates/index.js @@ -139,7 +139,10 @@ const UpcomingDates = ({ useEffect(() => { const getData = async () => { - const cohorts = await getCohorts({ academy: location }); + const academySlug = session.academyAliasDictionary[location] + ? session.academyAliasDictionary[location] + : location; + const cohorts = await getCohorts({ academy: academySlug }); console.log("cohorts upcoming", cohorts); let syllabus = []; for (let i in cohorts) { @@ -166,8 +169,8 @@ const UpcomingDates = ({ }, })); }; - getData(); - }, []); + if (session?.academyAliasDictionary) getData(); + }, [session]); const formIsValid = (formData = null) => { if (!formData) return null; diff --git a/src/templates/calendar.js b/src/templates/calendar.js index dbaf11f79..f500b2867 100644 --- a/src/templates/calendar.js +++ b/src/templates/calendar.js @@ -370,11 +370,13 @@ const Calendar = (props) => { value={academy} onChange={(opt) => { setAcademy(opt); + const academySlug = + session.academyAliasDictionary[opt.value] || opt.value; let filtered = opt.label !== "All Locations" ? datas[filterType.value].all.filter( - (elm) => elm.academy.slug === opt.value + (elm) => elm.academy.slug === academySlug ) : datas[filterType.value].all; // if no cohorts on location, try to include online @@ -751,9 +753,6 @@ export const query = graphql` width: 400 placeholder: NONE # --> NONE || DOMINANT_COLOR || BLURRED | TRACED_SVG ) - # fluid(maxWidth: 400) { - # ...GatsbyImageSharpFluid_withWebp - # } } } } diff --git a/src/templates/outcomes.js b/src/templates/outcomes.js index f9c14202c..fb3d5c919 100644 --- a/src/templates/outcomes.js +++ b/src/templates/outcomes.js @@ -157,7 +157,6 @@ const Outcomes = ({ data, pageContext, yml }) => {
{ } if (!language) language = location.defaultLanguage; + + //construct the academy alias dictionary + let academyAlias = await fetch( + `${process.env.GATSBY_BREATHECODE_HOST}/marketing/alias?academy=2,4,5,6,7,8,9,10,11`, + { + method: "GET", + } + ); + academyAlias = await academyAlias.json(); + + const academyAliasDictionary = {}; + academyAlias.map((alias) => { + const key = alias.slug; + academyAliasDictionary[key] = alias.academy.slug; + }); + const _session = { ...defaultSession, ...storedSession, @@ -266,6 +282,7 @@ const initSession = async (locationsArray, storedSession, seed = {}) => { language, latitude, longitude, + academyAliasDictionary, pathsDictionary, // marketing utm info