File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -128,6 +128,7 @@ export function SchedulerWrapper({
128128 onToggleFavorite = { ( ) => {
129129 if ( currentScheduleKey ) toggleFavorite ( currentScheduleKey ) ;
130130 } }
131+ isLoggedIn = { isLoggedIn }
131132 />
132133 </ div >
133134 < ScheduleSidebar
@@ -138,6 +139,7 @@ export function SchedulerWrapper({
138139 colorMap = { colorMap }
139140 onSelectSchedule = { setSelectedScheduleKey }
140141 onToggleFavorite = { toggleFavorite }
142+ isLoggedIn = { isLoggedIn }
141143 />
142144 </ div >
143145 </ div >
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ interface SchedulerViewProps {
1717 colorMap : Map < string , CourseColor > ;
1818 isFavorited : boolean ;
1919 onToggleFavorite : ( ) => void ;
20+ isLoggedIn : boolean ;
2021}
2122
2223export function SchedulerView ( {
@@ -26,6 +27,7 @@ export function SchedulerView({
2627 colorMap,
2728 isFavorited,
2829 onToggleFavorite,
30+ isLoggedIn,
2931} : SchedulerViewProps ) {
3032 const currentSchedule = useMemo ( ( ) => {
3133 if ( ! selectedScheduleKey ) return schedules [ 0 ] ?? allSchedules [ 0 ] ?? null ;
@@ -82,20 +84,22 @@ export function SchedulerView({
8284 < h1 className = "text-neu8 text-2xl font-bold" >
8385 Schedule { currentScheduleIndex + 1 }
8486 </ h1 >
85- < button onClick = { onToggleFavorite } className = "cursor-pointer" >
86- < svg
87- width = "19"
88- height = "19"
89- viewBox = "0 0 24 24"
90- fill = { isFavorited ? "#E63946" : "none" }
91- stroke = { isFavorited ? "#E63946" : "#858585" }
92- strokeWidth = "2"
93- strokeLinejoin = "round"
94- strokeLinecap = "round"
95- >
96- < polygon points = "12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" />
97- </ svg >
98- </ button >
87+ { isLoggedIn && (
88+ < button onClick = { onToggleFavorite } className = "cursor-pointer" >
89+ < svg
90+ width = "19"
91+ height = "19"
92+ viewBox = "0 0 24 24"
93+ fill = { isFavorited ? "#E63946" : "none" }
94+ stroke = { isFavorited ? "#E63946" : "#858585" }
95+ strokeWidth = "2"
96+ strokeLinejoin = "round"
97+ strokeLinecap = "round"
98+ >
99+ < polygon points = "12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" />
100+ </ svg >
101+ </ button >
102+ ) }
99103 </ div >
100104 </ div >
101105 ) }
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ interface ScheduleSidebarProps {
1717 colorMap : Map < string , CourseColor > ;
1818 onSelectSchedule : ( scheduleKey : string ) => void ;
1919 onToggleFavorite : ( scheduleKey : string ) => void ;
20+ isLoggedIn : boolean ;
2021}
2122
2223export function ScheduleSidebar ( {
@@ -27,6 +28,7 @@ export function ScheduleSidebar({
2728 colorMap,
2829 onSelectSchedule,
2930 onToggleFavorite,
31+ isLoggedIn,
3032} : ScheduleSidebarProps ) {
3133 const [ activeTab , setActiveTab ] = useState < SidebarTab > ( "filters" ) ;
3234 const scrollRef = useRef < HTMLDivElement > ( null ) ;
@@ -151,6 +153,7 @@ export function ScheduleSidebar({
151153 scheduleIndex = { virtualItem . index }
152154 onClick = { ( ) => handleSelect ( key ) }
153155 onToggleFavorite = { ( ) => handleToggleFav ( key ) }
156+ isLoggedIn = { isLoggedIn }
154157 />
155158 </ div >
156159 ) ;
@@ -159,7 +162,7 @@ export function ScheduleSidebar({
159162 ) : (
160163 < div className = "text-neu6 py-8 text-center text-sm" >
161164 { activeTab === "favorites"
162- ? "No favorited schedules yet."
165+ ? ( isLoggedIn ? "No favorited schedules yet." : "Log in to favorite schedules." )
163166 : "No schedules found." }
164167 </ div >
165168 ) }
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ interface MiniCalendarProps {
1616 scheduleIndex : number ;
1717 onClick : ( ) => void ;
1818 onToggleFavorite : ( ) => void ;
19+ isLoggedIn : boolean ;
1920}
2021
2122const MINI_START_HOUR = 7 ;
@@ -56,6 +57,7 @@ export const MiniCalendar = memo(function MiniCalendar({
5657 scheduleIndex,
5758 onClick,
5859 onToggleFavorite,
60+ isLoggedIn,
5961} : MiniCalendarProps ) {
6062 const asyncCourses = schedule . filter (
6163 ( section ) =>
@@ -159,26 +161,28 @@ export const MiniCalendar = memo(function MiniCalendar({
159161 < span className = "text-neu7 text-[14px] font-semibold" >
160162 Schedule { scheduleIndex + 1 }
161163 </ span >
162- < button
163- onClick = { ( e ) => {
164- e . stopPropagation ( ) ;
165- onToggleFavorite ( ) ;
166- } }
167- className = "cursor-pointer p-0.5"
168- >
169- < svg
170- width = "18"
171- height = "18"
172- viewBox = "0 0 24 24"
173- fill = { isFavorited ? "#E63946" : "none" }
174- stroke = { isFavorited ? "#E63946" : "#858585" }
175- strokeWidth = "2"
176- strokeLinejoin = "round"
177- strokeLinecap = "round"
164+ { isLoggedIn && (
165+ < button
166+ onClick = { ( e ) => {
167+ e . stopPropagation ( ) ;
168+ onToggleFavorite ( ) ;
169+ } }
170+ className = "cursor-pointer p-0.5"
178171 >
179- < polygon points = "12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" />
180- </ svg >
181- </ button >
172+ < svg
173+ width = "18"
174+ height = "18"
175+ viewBox = "0 0 24 24"
176+ fill = { isFavorited ? "#E63946" : "none" }
177+ stroke = { isFavorited ? "#E63946" : "#858585" }
178+ strokeWidth = "2"
179+ strokeLinejoin = "round"
180+ strokeLinecap = "round"
181+ >
182+ < polygon points = "12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" />
183+ </ svg >
184+ </ button >
185+ ) }
182186 </ div >
183187 </ div >
184188 ) ;
Original file line number Diff line number Diff line change @@ -41,6 +41,8 @@ export function useSchedulerFavorites({
4141
4242 const toggleFavorite = useCallback (
4343 ( key : string ) => {
44+ if ( ! isLoggedIn || ! planId ) return ;
45+
4446 const currentlyFavorited = favoritedSchedules . has ( key ) ;
4547
4648 if ( debounceRef . current ) clearTimeout ( debounceRef . current ) ;
@@ -88,7 +90,6 @@ export function useSchedulerFavorites({
8890 return ;
8991 }
9092
91- if ( ! isLoggedIn || ! planId ) return ;
9293
9394 const sectionIds = schedule . map ( ( s ) => s . id ) ;
9495
You can’t perform that action at this time.
0 commit comments