From 5abe69c1d3ff779d2c2c734727bfdd3a1a63d320 Mon Sep 17 00:00:00 2001 From: dabby9734 <62941997+dabby9734@users.noreply.github.com> Date: Sat, 30 Mar 2024 12:07:55 +0800 Subject: [PATCH 1/3] Adjust the Industries filter to be an "OR" filter --- pages/mentors/[id].tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/mentors/[id].tsx b/pages/mentors/[id].tsx index 8348542e..52026d0d 100644 --- a/pages/mentors/[id].tsx +++ b/pages/mentors/[id].tsx @@ -103,7 +103,7 @@ const App = () => { values: [WAVES[currentTabId].waveId], }, ], - disjunctiveFacets: ["organisation", "course_of_study"], + disjunctiveFacets: ["organisation", "course_of_study", "industries"], facets: { industries: { type: "value", size: 100 }, organisation: { type: "value", size: 100 }, @@ -183,7 +183,7 @@ const App = () => { { name: "Name", value: "name", direction: "asc" }, ]} /> - + Date: Sun, 31 Mar 2024 00:11:02 +0800 Subject: [PATCH 2/3] add modal for user to select preferred industries --- components/PersonalisationModal.tsx | 95 +++++++++++++++++++++++++++++ pages/mentors/[id].tsx | 25 +++++++- 2 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 components/PersonalisationModal.tsx diff --git a/components/PersonalisationModal.tsx b/components/PersonalisationModal.tsx new file mode 100644 index 00000000..72c87811 --- /dev/null +++ b/components/PersonalisationModal.tsx @@ -0,0 +1,95 @@ +import { Box, Button, Chip, Modal } from "@mui/material"; +import React from "react"; +import { useState, useEffect } from "react"; + +const modalStyle = { + position: "absolute" as "absolute", + top: "50%", + left: "50%", + transform: "translate(-50%, -50%)", + width: 800, + bgcolor: "background.paper", + boxShadow: 24, + borderRadius: 2, + p: 2, +}; + +const modalHeaderStyle = { + fontSize: "1.5rem", + fontWeight: "bold", + margin: 0, +}; + +const modalTextStyle = {}; + +const PersonalisationModal = ({ industries, clearFilters, addFilter }) => { + const [open, setOpen] = useState(false); + + // handles toggling of the selected industries + const [selectedIndustries, setSelectedIndustries] = useState([]); + const handleIndustryChipToggle = (industry: string) => { + if (selectedIndustries.includes(industry)) { + setSelectedIndustries(selectedIndustries.filter((i) => i !== industry)); + } else { + setSelectedIndustries([...selectedIndustries, industry]); + } + }; + + const IsChipSelected = (industry: string) => { + return selectedIndustries.includes(industry); + }; + + const handleContinueButtonClick = () => { + clearFilters(); + selectedIndustries.forEach((industry) => { + addFilter("industries", industry, "any"); + }); + setOpen(false); + localStorage.setItem("ModalClosed", "true"); + }; + + // only open the modal if the user hasn't closed it before + useEffect(() => { + if (localStorage.getItem("ModalClosed") === null) { + setOpen(true); + } + }); + + return ( + setOpen(false)}> + + Hello there! + + Select some industries you're interested in to help us personalise + your experience. + + + {industries === undefined && Loading...} + {industries !== undefined && + industries[0].data.map( + (industry: { count: number; value: string }) => ( + handleIndustryChipToggle(industry.value)} + color="primary" + variant={ + IsChipSelected(industry.value) ? "filled" : "outlined" + } + /> + ) + )} + + Continue + + + ); +}; + +export default PersonalisationModal; diff --git a/pages/mentors/[id].tsx b/pages/mentors/[id].tsx index 52026d0d..ebbe6d0c 100644 --- a/pages/mentors/[id].tsx +++ b/pages/mentors/[id].tsx @@ -11,6 +11,7 @@ import { Results, SearchBox, Sorting, + WithSearch, } from "@elastic/react-search-ui"; import { FilterType, SortDirection } from "@elastic/search-ui"; import useMediaQuery from "@mui/material/useMediaQuery"; @@ -31,6 +32,7 @@ import type { GetStaticProps, GetStaticPaths } from "next"; import { useRouter } from "next/router"; import ClearFacets from "../../components/ResetButton"; +import PersonalisationModal from "../../components/PersonalisationModal"; // This also gets called at build time export const getStaticProps: GetStaticProps = async (context) => { @@ -170,9 +172,11 @@ const App = () => { } bodyContent={ - } - /> + + } + /> + } sideContent={ @@ -208,6 +212,21 @@ const App = () => { bodyFooter={} /> + ({ + facets, + clearFilters, + addFilter, + })} + > + {({ facets, clearFilters, addFilter }) => ( + + )} + From c4e4a6e2e367a722f953457960504f0591dbe32f Mon Sep 17 00:00:00 2001 From: dabby9734 <62941997+dabby9734@users.noreply.github.com> Date: Tue, 9 Apr 2024 16:32:59 +0800 Subject: [PATCH 3/3] disable behaviour to not show modal after first appearance --- components/PersonalisationModal.tsx | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/components/PersonalisationModal.tsx b/components/PersonalisationModal.tsx index 72c87811..28d5efd3 100644 --- a/components/PersonalisationModal.tsx +++ b/components/PersonalisationModal.tsx @@ -23,7 +23,7 @@ const modalHeaderStyle = { const modalTextStyle = {}; const PersonalisationModal = ({ industries, clearFilters, addFilter }) => { - const [open, setOpen] = useState(false); + const [open, setOpen] = useState(true); // handles toggling of the selected industries const [selectedIndustries, setSelectedIndustries] = useState([]); @@ -45,16 +45,8 @@ const PersonalisationModal = ({ industries, clearFilters, addFilter }) => { addFilter("industries", industry, "any"); }); setOpen(false); - localStorage.setItem("ModalClosed", "true"); }; - // only open the modal if the user hasn't closed it before - useEffect(() => { - if (localStorage.getItem("ModalClosed") === null) { - setOpen(true); - } - }); - return ( setOpen(false)}>
Hello there!
+ Select some industries you're interested in to help us personalise + your experience. +
Loading...