11import { Box , Grid } from '@mui/material' ;
22import { styled } from '@mui/material/styles' ;
3- import React from 'react' ;
3+ import React , { useMemo } from 'react' ;
4+ import { useLocation } from 'react-router' ;
45
56import { ControlsProps } from '../../interfaces/PropTypes' ;
7+ import UserProfile from '../sidebar/friends/UserProfile' ;
68import Autotimetabler from './Autotimetabler' ;
79import CourseSelect from './CourseSelect' ;
810import CustomEvents from './CustomEvent' ;
@@ -18,6 +20,20 @@ const TermSelectWrapper = styled(Box)`
1820 align-items: flex-start;
1921` ;
2022
23+ const FriendTimetableLabelContainer = styled ( Box ) `
24+ display: flex;
25+ justify-content: center;
26+ align-items: center;
27+ width: 100%;
28+ background-color: ${ ( { theme } ) => theme . palette . secondary . light } ;
29+ border: 0.75px solid;
30+ border-color: ${ ( { theme } ) => theme . palette . text . primary } ;
31+ padding: 10px 0;
32+ border-top-left-radius: ${ ( { theme } ) => theme . shape . borderRadius } px;
33+ border-top-right-radius: ${ ( { theme } ) => theme . shape . borderRadius } px;
34+ font-weight: 700;
35+ ` ;
36+
2137const SelectWrapper = styled ( Box ) `
2238 display: flex;
2339 flex-direction: row;
@@ -52,50 +68,71 @@ const Controls: React.FC<ControlsProps> = ({
5268 handleSelectCourse,
5369 handleRemoveCourse,
5470} ) => {
71+ const location = useLocation ( ) ;
72+ const additionalControlsDisplay = useMemo ( ( ) => {
73+ if ( location . pathname !== '/home' ) {
74+ return (
75+ < >
76+ < TermSelectWrapper >
77+ < TermSelect />
78+ </ TermSelectWrapper >
79+ < FriendTimetableLabelContainer >
80+ < UserProfile firstName = "Sunny" lastName = "Chen" overrideCollapse = { true } />
81+ </ FriendTimetableLabelContainer >
82+ </ >
83+ ) ;
84+ }
85+ return (
86+ < >
87+ < Grid
88+ container
89+ direction = "row"
90+ size = { {
91+ xs : 12 ,
92+ md : 6.5 ,
93+ } }
94+ >
95+ < TermSelectWrapper >
96+ < TermSelect />
97+ </ TermSelectWrapper >
98+
99+ < SelectWrapper minWidth = { '296px' } >
100+ < CourseSelect
101+ assignedColors = { assignedColors }
102+ handleSelect = { handleSelectCourse }
103+ handleRemove = { handleRemoveCourse }
104+ />
105+ </ SelectWrapper >
106+ </ Grid >
107+ < Grid
108+ container
109+ direction = "row"
110+ sx = { {
111+ alignItems : 'center' ,
112+ justifyContent : 'space-between' ,
113+ } }
114+ size = { {
115+ xs : 12 ,
116+ md : 5.5 ,
117+ } }
118+ >
119+ < CustomEventsWrapper >
120+ < CustomEvents />
121+ </ CustomEventsWrapper >
122+ < AutotimetablerWrapper >
123+ < Autotimetabler handleSelectClass = { handleSelectClass } />
124+ </ AutotimetablerWrapper >
125+ < HistoryWrapper >
126+ < History />
127+ </ HistoryWrapper >
128+ </ Grid >
129+ </ >
130+ ) ;
131+ } , [ location . pathname , assignedColors , handleSelectCourse , handleRemoveCourse , handleSelectClass ] ) ;
132+
55133 return (
56134 < Grid container sx = { { paddingLeft : '66px' } } spacing = { 2 } >
57- < Grid
58- container
59- direction = "row"
60- size = { {
61- xs : 12 ,
62- md : 6.5 ,
63- } }
64- >
65- < TermSelectWrapper >
66- < TermSelect />
67- </ TermSelectWrapper >
68-
69- < SelectWrapper minWidth = { '296px' } >
70- < CourseSelect
71- assignedColors = { assignedColors }
72- handleSelect = { handleSelectCourse }
73- handleRemove = { handleRemoveCourse }
74- />
75- </ SelectWrapper >
76- </ Grid >
77- < Grid
78- container
79- direction = "row"
80- sx = { {
81- alignItems : 'center' ,
82- justifyContent : 'space-between' ,
83- } }
84- size = { {
85- xs : 12 ,
86- md : 5.5 ,
87- } }
88- >
89- < CustomEventsWrapper >
90- < CustomEvents />
91- </ CustomEventsWrapper >
92- < AutotimetablerWrapper >
93- < Autotimetabler handleSelectClass = { handleSelectClass } />
94- </ AutotimetablerWrapper >
95- < HistoryWrapper >
96- < History />
97- </ HistoryWrapper >
98- </ Grid >
135+ { additionalControlsDisplay }
99136 </ Grid >
100137 ) ;
101138} ;
0 commit comments