Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Academy alias #1732

Merged
merged 5 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading