Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Fix 'find a mentor' flow #58

Merged
merged 4 commits into from
Sep 13, 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
106 changes: 53 additions & 53 deletions app/controllers/mentor-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ exports.list_mentors_results_get = (req, res) => {
items: as.map((a) => {
return {
text: utilsHelper.getFilterALabel(a),
href: `/organisations/${req.params.organisationId}/mentors/remove-a-filter/${a}`
href: `/find/organisations/${req.params.organisationId}/mentors/remove-a-filter/${a}`
}
})
})
Expand All @@ -109,7 +109,7 @@ exports.list_mentors_results_get = (req, res) => {
items: bs.map((b) => {
return {
text: utilsHelper.getFilterBLabel(b),
href: `/organisations/${req.params.organisationId}/mentors/remove-b-filter/${b}`
href: `/find/organisations/${req.params.organisationId}/mentors/remove-b-filter/${b}`
}
})
})
Expand All @@ -121,7 +121,7 @@ exports.list_mentors_results_get = (req, res) => {
items: cs.map((c) => {
return {
text: utilsHelper.getFilterCLabel(c),
href: `/organisations/${req.params.organisationId}/mentors/remove-c-filter/${c}`
href: `/find/organisations/${req.params.organisationId}/mentors/remove-c-filter/${c}`
}
})
})
Expand All @@ -133,7 +133,7 @@ exports.list_mentors_results_get = (req, res) => {
items: ds.map((d) => {
return {
text: utilsHelper.getFilterDLabel(d),
href: `/organisations/${req.params.organisationId}/mentors/remove-d-filter/${d}`
href: `/find/organisations/${req.params.organisationId}/mentors/remove-d-filter/${d}`
}
})
})
Expand All @@ -145,7 +145,7 @@ exports.list_mentors_results_get = (req, res) => {
items: es.map((e) => {
return {
text: utilsHelper.getFilterELabel(e),
href: `/organisations/${req.params.organisationId}/mentors/remove-e-filter/${e}`
href: `/find/organisations/${req.params.organisationId}/mentors/remove-e-filter/${e}`
}
})
})
Expand All @@ -157,7 +157,7 @@ exports.list_mentors_results_get = (req, res) => {
items: fs.map((f) => {
return {
text: utilsHelper.getFilterFLabel(f),
href: `/organisations/${req.params.organisationId}/mentors/remove-f-filter/${f}`
href: `/find/organisations/${req.params.organisationId}/mentors/remove-f-filter/${f}`
}
})
})
Expand All @@ -169,7 +169,7 @@ exports.list_mentors_results_get = (req, res) => {
items: gs.map((g) => {
return {
text: utilsHelper.getFilterGLabel(g),
href: `/organisations/${req.params.organisationId}/mentors/remove-g-filter/${g}`
href: `/find/organisations/${req.params.organisationId}/mentors/remove-g-filter/${g}`
}
})
})
Expand All @@ -181,7 +181,7 @@ exports.list_mentors_results_get = (req, res) => {
items: hs.map((h) => {
return {
text: utilsHelper.getFilterHLabel(h),
href: `/organisations/${req.params.organisationId}/mentors/remove-h-filter/${h}`
href: `/find/organisations/${req.params.organisationId}/mentors/remove-h-filter/${h}`
}
})
})
Expand All @@ -193,7 +193,7 @@ exports.list_mentors_results_get = (req, res) => {
items: is.map((i) => {
return {
text: utilsHelper.getFilterILabel(i),
href: `/organisations/${req.params.organisationId}/mentors/remove-i-filter/${i}`
href: `/find/organisations/${req.params.organisationId}/mentors/remove-i-filter/${i}`
}
})
})
Expand All @@ -205,7 +205,7 @@ exports.list_mentors_results_get = (req, res) => {
items: js.map((j) => {
return {
text: utilsHelper.getFilterJLabel(j),
href: `/organisations/${req.params.organisationId}/mentors/remove-j-filter/${j}`
href: `/find/organisations/${req.params.organisationId}/mentors/remove-j-filter/${j}`
}
})
})
Expand Down Expand Up @@ -320,78 +320,78 @@ exports.list_mentors_results_get = (req, res) => {
// selectedE,
// selectedF,
actions: {
view: `/organisations/${req.params.organisationId}/mentors`,
view: `/find/organisations/${req.params.organisationId}/mentors`,
filters: {
apply: `/organisations/${req.params.organisationId}/mentors`,
remove: `/organisations/${req.params.organisationId}/mentors/remove-all-filters`
apply: `/find/organisations/${req.params.organisationId}/mentors`,
remove: `/find/organisations/${req.params.organisationId}/mentors/remove-all-filters`
},
search: {
find: `/organisations/${req.params.organisationId}/mentors`,
remove: `/organisations/${req.params.organisationId}/mentors/remove-keyword-search`,
change: `/organisations/${req.params.organisationId}/mentors/search`
find: `/find/organisations/${req.params.organisationId}/mentors`,
remove: `/find/organisations/${req.params.organisationId}/mentors/remove-keyword-search`,
change: `/find/organisations/${req.params.organisationId}/mentors/search`
}
}
})
}

exports.removeKeywordSearch = (req, res) => {
delete req.session.data.keywords
res.redirect(`/organisations/${req.params.organisationId}/mentors`)
res.redirect(`/find/organisations/${req.params.organisationId}/mentors`)
}

exports.removeFilterA = (req, res) => {
req.session.data.filter.a = utilsHelper.removeFilter(req.params.a, req.session.data.filter.a)
res.redirect(`/organisations/${req.params.organisationId}/mentors`)
res.redirect(`/find/organisations/${req.params.organisationId}/mentors`)
}

exports.removeFilterB = (req, res) => {
req.session.data.filter.b = utilsHelper.removeFilter(req.params.b, req.session.data.filter.b)
res.redirect(`/organisations/${req.params.organisationId}/mentors`)
res.redirect(`/find/organisations/${req.params.organisationId}/mentors`)
}

exports.removeFilterC = (req, res) => {
req.session.data.filter.c = utilsHelper.removeFilter(req.params.c, req.session.data.filter.c)
res.redirect(`/organisations/${req.params.organisationId}/mentors`)
res.redirect(`/find/organisations/${req.params.organisationId}/mentors`)
}

exports.removeFilterD = (req, res) => {
req.session.data.filter.d = utilsHelper.removeFilter(req.params.d, req.session.data.filter.d)
res.redirect(`/organisations/${req.params.organisationId}/mentors`)
res.redirect(`/find/organisations/${req.params.organisationId}/mentors`)
}

exports.removeFilterE = (req, res) => {
req.session.data.filter.e = utilsHelper.removeFilter(req.params.e, req.session.data.filter.e)
res.redirect(`/organisations/${req.params.organisationId}/mentors`)
res.redirect(`/find/organisations/${req.params.organisationId}/mentors`)
}

exports.removeFilterF = (req, res) => {
req.session.data.filter.f = utilsHelper.removeFilter(req.params.f, req.session.data.filter.f)
res.redirect(`/organisations/${req.params.organisationId}/mentors`)
res.redirect(`/find/organisations/${req.params.organisationId}/mentors`)
}

exports.removeFilterG = (req, res) => {
req.session.data.filter.g = utilsHelper.removeFilter(req.params.g, req.session.data.filter.g)
res.redirect(`/organisations/${req.params.organisationId}/mentors`)
res.redirect(`/find/organisations/${req.params.organisationId}/mentors`)
}

exports.removeFilterH = (req, res) => {
req.session.data.filter.h = utilsHelper.removeFilter(req.params.h, req.session.data.filter.h)
res.redirect(`/organisations/${req.params.organisationId}/mentors`)
res.redirect(`/find/organisations/${req.params.organisationId}/mentors`)
}

exports.removeFilterI = (req, res) => {
req.session.data.filter.i = utilsHelper.removeFilter(req.params.i, req.session.data.filter.i)
res.redirect(`/organisations/${req.params.organisationId}/mentors`)
res.redirect(`/find/organisations/${req.params.organisationId}/mentors`)
}

exports.removeFilterJ = (req, res) => {
req.session.data.filter.j = utilsHelper.removeFilter(req.params.j, req.session.data.filter.j)
res.redirect(`/organisations/${req.params.organisationId}/mentors`)
res.redirect(`/find/organisations/${req.params.organisationId}/mentors`)
}

exports.removeAllFilters = (req, res) => {
delete req.session.data.filter
res.redirect(`/organisations/${req.params.organisationId}/mentors`)
res.redirect(`/find/organisations/${req.params.organisationId}/mentors`)
}


Expand All @@ -405,8 +405,8 @@ exports.search_get = (req, res) => {

res.render('mentors/search/index', {
actions: {
back: `/organisations/${req.params.organisationId}/mentors`,
save: `/organisations/${req.params.organisationId}/mentors/search`
back: `/find/organisations/${req.params.organisationId}/mentors`,
save: `/find/organisations/${req.params.organisationId}/mentors/search`
}
})
}
Expand Down Expand Up @@ -445,20 +445,20 @@ exports.search_post = (req, res) => {
res.render('mentors/search/index', {
errors,
actions: {
back: `/organisations/${req.params.organisationId}/mentors`,
save: `/organisations/${req.params.organisationId}/mentors/search`
back: `/find/organisations/${req.params.organisationId}/mentors`,
save: `/find/organisations/${req.params.organisationId}/mentors/search`
}
})
} else {
res.redirect(`/organisations/${req.params.organisationId}/mentors/age-groups`)
res.redirect(`/find/organisations/${req.params.organisationId}/mentors/age-groups`)
}
}

exports.age_groups_get = (req, res) => {
res.render('mentors/search/age-groups', {
actions: {
back: `/organisations/${req.params.organisationId}/mentors/search`,
save: `/organisations/${req.params.organisationId}/mentors/age-groups`
back: `/find/organisations/${req.params.organisationId}/mentors/search`,
save: `/find/organisations/${req.params.organisationId}/mentors/age-groups`
}
})
}
Expand All @@ -480,17 +480,17 @@ exports.age_groups_post = (req, res) => {
res.render('mentors/search/age-groups', {
errors,
actions: {
back: `/organisations/${req.params.organisationId}/mentors/search`,
save: `/organisations/${req.params.organisationId}/mentors/age-groups`
back: `/find/organisations/${req.params.organisationId}/mentors/search`,
save: `/find/organisations/${req.params.organisationId}/mentors/age-groups`
}
})
} else {
if (ageGroup === 'primary') {
res.redirect(`/organisations/${req.params.organisationId}/mentors/primary-subjects`)
res.redirect(`/find/organisations/${req.params.organisationId}/mentors/primary-subjects`)
} else if (ageGroup === 'secondary') {
res.redirect(`/organisations/${req.params.organisationId}/mentors/secondary-subjects`)
res.redirect(`/find/organisations/${req.params.organisationId}/mentors/secondary-subjects`)
} else {
res.redirect(`/organisations/${req.params.organisationId}/mentors/results`)
res.redirect(`/find/organisations/${req.params.organisationId}/mentors/results`)
}
}
}
Expand All @@ -506,8 +506,8 @@ exports.primary_subjects_get = (req, res) => {
res.render('mentors/search/primary-subjects', {
subjectOptions,
actions: {
back: `/organisations/${req.params.organisationId}/mentors/age-groups`,
save: `/organisations/${req.params.organisationId}/mentors/primary-subjects`
back: `/find/organisations/${req.params.organisationId}/mentors/age-groups`,
save: `/find/organisations/${req.params.organisationId}/mentors/primary-subjects`
}
})
}
Expand Down Expand Up @@ -535,12 +535,12 @@ exports.primary_subjects_post = (req, res) => {
subjectOptions,
errors,
actions: {
back: `/organisations/${req.params.organisationId}/mentors/age-groups`,
save: `/organisations/${req.params.organisationId}/mentors/primary-subjects`
back: `/find/organisations/${req.params.organisationId}/mentors/age-groups`,
save: `/find/organisations/${req.params.organisationId}/mentors/primary-subjects`
}
})
} else {
res.redirect(`/organisations/${req.params.organisationId}/mentors/results`)
res.redirect(`/find/organisations/${req.params.organisationId}/mentors/results`)
}
}

Expand All @@ -555,8 +555,8 @@ exports.secondary_subjects_get = (req, res) => {
res.render('mentors/search/secondary-subjects', {
subjectOptions,
actions: {
back: `/organisations/${req.params.organisationId}/mentors/age-groups`,
save: `/organisations/${req.params.organisationId}/mentors/secondary-subjects`
back: `/find/organisations/${req.params.organisationId}/mentors/age-groups`,
save: `/find/organisations/${req.params.organisationId}/mentors/secondary-subjects`
}
})
}
Expand Down Expand Up @@ -584,30 +584,30 @@ exports.secondary_subjects_post = (req, res) => {
subjectOptions,
errors,
actions: {
back: `/organisations/${req.params.organisationId}/mentors/age-groups`,
save: `/organisations/${req.params.organisationId}/mentors/secondary-subjects`
back: `/find/organisations/${req.params.organisationId}/mentors/age-groups`,
save: `/find/organisations/${req.params.organisationId}/mentors/secondary-subjects`
}
})
} else {
res.redirect(`/organisations/${req.params.organisationId}/mentors/results`)
res.redirect(`/find/organisations/${req.params.organisationId}/mentors/results`)
}
}

/// ------------------------------------------------------------------------ ///
/// SHOW mentor
/// ------------------------------------------------------------------------ ///

exports.show_mentors_get = (req, res) => {
exports.show_mentor_get = (req, res) => {
const mentors = require('../data/temp/mentors-sprint6')
const mentor = mentors.find(mentor => mentor.id === req.params.mentorId)

const school = schoolModel.findOne({ schoolId: mentor.urn })

res.render('../views/mentors/show', {
res.render('../views/mentors/results/show', {
school,
mentor,
actions: {
back: `/organisations/${req.params.organisationId}/mentors/results`
back: `/find/organisations/${req.params.organisationId}/mentors/results`
}
})
}
2 changes: 1 addition & 1 deletion app/controllers/mentors.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ exports.list_mentors_get = (req, res) => {
mentors,
actions: {
new: `/organisations/${req.params.organisationId}/mentors/new`,
find: `/organisations/${req.params.organisationId}/mentors/search`,
find: `/find/organisations/${req.params.organisationId}/mentors/search`,
view: `/organisations/${req.params.organisationId}/mentors`
}
})
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ exports.getAgeRangeFilterItems = (subjectLevel = 'secondary', selectedItems) =>

let options = require('../data/age-ranges')
if (subjectLevel) {
options = options.filter(range => range.level === subjectLevel)
options = options.filter(range => range.levels.includes(subjectLevel))
}

options.forEach((option, i) => {
Expand Down Expand Up @@ -181,7 +181,7 @@ exports.getKeyStageFilterItems = (subjectLevel = 'secondary', selectedItems) =>

let options = require('../data/key-stages')
if (subjectLevel) {
options = options.filter(stage => stage.level === subjectLevel)
options = options.filter(stage => stage.levels.includes(subjectLevel))
}

options.forEach((option, i) => {
Expand Down
Loading
Loading