Skip to content
Open
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 pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ const noShowNav = ["/login", "/", "/privacy", "/letter"];

function MyApp({ Component, pageProps }) {
const router = useRouter();
const [districtURL, setDistrictURL] = useState(
"https://md-mcps-psv.edupoint.com"
);
const [districtURL, setDistrictURL] = useState(() => {
if (typeof window !== 'undefined') {
return localStorage.getItem("lastSelectedDistrict") || "https://md-mcps-psv.edupoint.com";
}
return "https://md-mcps-psv.edupoint.com";
});
const [client, setClient] = useState(undefined);
const [studentInfo, setStudentInfo] = useState(undefined);
const [toasts, setToasts] = useState<Toast[]>([]);
Expand Down
12 changes: 10 additions & 2 deletions pages/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ export default function Login({
if (localStorage.getItem("remember") === "true") {
setCheckbox(true);
}
}, []);

const cachedDistrict = localStorage.getItem("lastSelectedDistrict");
if (cachedDistrict) {
setDistrictURL(cachedDistrict);
}
}, [setDistrictURL]);

const findDistricts = async () => {
StudentVue.findDistricts(zipCode)
Expand Down Expand Up @@ -118,7 +123,10 @@ export default function Login({
<select
id="districts"
value={districtURL}
onChange={(e) => setDistrictURL(e.target.value)}
onChange={(e) => {
setDistrictURL(e.target.value);
localStorage.setItem("lastSelectedDistrict", e.target.value);
}}
className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500"
>
{districts.map((district, i) => (
Expand Down