Skip to content

Commit

Permalink
Merge pull request #1732 from gustavomm19/academy-alias
Browse files Browse the repository at this point in the history
Academy alias
  • Loading branch information
alesanchezr authored Aug 29, 2023
2 parents 22e3b05 + 0a15c27 commit 10cb0c0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
9 changes: 6 additions & 3 deletions src/components/UpcomingDates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -166,8 +169,8 @@ const UpcomingDates = ({
},
}));
};
getData();
}, []);
if (session?.academyAliasDictionary) getData();
}, [session]);

const formIsValid = (formData = null) => {
if (!formData) return null;
Expand Down
7 changes: 3 additions & 4 deletions src/templates/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -751,9 +753,6 @@ export const query = graphql`
width: 400
placeholder: NONE # --> NONE || DOMINANT_COLOR || BLURRED | TRACED_SVG
)
# fluid(maxWidth: 400) {
# ...GatsbyImageSharpFluid_withWebp
# }
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/templates/outcomes.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ const Outcomes = ({ data, pageContext, yml }) => {
<Div
display="flex"
display_tablet="none"
width="auto"
margin="0 0 0 -17px"
background={Colors.white}
style={{
Expand Down
17 changes: 17 additions & 0 deletions src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,22 @@ const initSession = async (locationsArray, storedSession, seed = {}) => {
}

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,
Expand All @@ -266,6 +282,7 @@ const initSession = async (locationsArray, storedSession, seed = {}) => {
language,
latitude,
longitude,
academyAliasDictionary,
pathsDictionary,

// marketing utm info
Expand Down

0 comments on commit 10cb0c0

Please sign in to comment.