Skip to content

Commit

Permalink
Change banner to be clearer about winter terms (#483)
Browse files Browse the repository at this point in the history
* change banner

* fix update selected term on url change too
  • Loading branch information
szeckirjr authored Jun 18, 2023
1 parent 230ddf9 commit bfa6967
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/common/header/containers/HeaderContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,13 @@ export function HeaderContainer({ onSearchChange }: HeaderProps): JSX.Element {
<Text>
📅 The{' '}
<Text as={Link} to="/calendar/202309" textDecoration="underline">
Winter 2023
Fall 2023
</Text>{' '}
calendar is now available. Happy scheduling!
and{' '}
<Text as={Link} to="/calendar/202401" textDecoration="underline">
Spring 2024
</Text>{' '}
calendars are now available. Happy scheduling!
</Text>,
];
return (
Expand Down
8 changes: 7 additions & 1 deletion src/lib/hooks/useTerm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMemo } from 'react';
import { useEffect, useMemo } from 'react';

import { useParams } from 'react-router';

Expand All @@ -13,5 +13,11 @@ export const useTerm = (): [Term, (term: string) => void] => {
const defaultTerm = useMemo(() => termParam || getCurrentTerm(), [termParam]);
const [term, setTerm] = useLocalStorage<string>('user:term', defaultTerm) as [Term, (term: string) => void];

useEffect(() => {
if (termParam && termParam !== term) {
setTerm(termParam);
}
}, [termParam, term, setTerm]);

return [term, setTerm];
};

0 comments on commit bfa6967

Please sign in to comment.