File tree Expand file tree Collapse file tree 4 files changed +63
-10
lines changed
client/src/screens/browse Expand file tree Collapse file tree 4 files changed +63
-10
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ const ConfirmDialog = ({
30
30
confirmText = "Confirm" ,
31
31
cancelText = "Cancel" ,
32
32
} ) => {
33
- const [ submitEnabled , setSubmitEnabled ] = useState ( true ) ;
33
+ const [ submitEnabled , setSubmitEnabled ] = useState ( false ) ;
34
34
if ( ! show ) return null ;
35
35
36
36
return (
@@ -50,7 +50,11 @@ const ConfirmDialog = ({
50
50
name = "section"
51
51
className = "select_section"
52
52
value = { yearName }
53
- onChange = { ( e ) => onYearNameChange ( e . target . value ) }
53
+ onChange = { ( e ) => {
54
+ if ( e . target . value ) setSubmitEnabled ( true ) ;
55
+ else setSubmitEnabled ( false ) ;
56
+ onYearNameChange ( e . target . value ) ;
57
+ } }
54
58
>
55
59
< option value = "" disabled >
56
60
Select year
Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ const YearInfo = ({
28
28
const handleConfirmAddYear = async ( ) => {
29
29
const yearName = newYearName . trim ( ) ;
30
30
31
+ if ( ! yearName ) return ;
32
+ console . log ( yearName ) ;
31
33
if ( ! courseCode ) {
32
34
toast . error ( "No course selected." ) ;
33
35
return ;
@@ -94,7 +96,11 @@ const YearInfo = ({
94
96
key = { idx }
95
97
>
96
98
{ year . name }
97
- < div className = "delete" onClick = { handleDeleteYear } > </ div >
99
+ < div
100
+ className = "delete"
101
+ onClick = { handleDeleteYear }
102
+ title = "Delete Year"
103
+ > </ div >
98
104
99
105
</ span >
100
106
< ConfirmDelDialog
@@ -112,7 +118,7 @@ const YearInfo = ({
112
118
< div >
113
119
< div className = "" >
114
120
< span className = "" onClick = { handleAddYear } >
115
- < span className = "text" > Add Year</ span >
121
+ < span className = "text" > New Year</ span >
116
122
</ span >
117
123
</ div >
118
124
< ConfirmDialog
Original file line number Diff line number Diff line change 1
1
const presentYears = [ ] ;
2
2
const options = [ ] ;
3
- const currYear = new Date ( ) . getFullYear ( ) ;
3
+ const currentDate = new Date ( ) ;
4
+ const currentMonth = currentDate . getMonth ( ) + 1 ; // getMonth() returns 0-11, so add 1 for 1-12
5
+ const acadYear = ( currentMonth >= 1 && currentMonth <= 5 ) ? currentDate . getFullYear ( ) - 1 : currentDate . getFullYear ( ) ;
4
6
for ( let i = 0 ; i < 5 ; i ++ ) {
5
- let yr = ( currYear - i ) . toString ( ) ;
7
+ let yr = ( acadYear - i ) . toString ( ) ;
6
8
if ( ! presentYears . includes ( yr ) )
7
9
options . push ( yr ) ;
8
10
}
Original file line number Diff line number Diff line change 55
55
font-size : 1.2rem ;
56
56
}
57
57
.year {
58
+ cursor : pointer ;
58
59
padding : 10px 20px ;
59
60
font-size : 1.14rem ;
61
+ position : relative ;
62
+ display : flex ;
63
+ align-items : center ;
64
+ justify-content : space-between ;
60
65
& .selected {
61
66
color : #000 ;
62
67
background-color : #fff ;
63
68
.delete {
64
- background-color : red ;
65
- height :15px ;
66
- width : 15px ;
67
- border-radius : 50% ;
69
+ background : url (./components/browsefolder/Delete.svg ), none ;
70
+
71
+ position : absolute ;
72
+ top : 50% ;
73
+ right : 10px ;
74
+ transform : translateY (-50% );
75
+ width : 16px ;
76
+ height : 16px ;
77
+ background-size : contain ;
78
+ background-repeat : no-repeat ;
79
+ background-position : center ;
80
+ cursor : pointer ;
81
+ opacity : 0 ;
82
+ transition : opacity 0.2s ease-in-out ;
83
+ z-index : 3 ;
84
+ border-radius : 2px ;
85
+ }
86
+ }
87
+ & .selected :hover .delete {opacity : 1 ;}
88
+ }
89
+ & .add-year {
90
+ border-top : 1px solid #333 ;
91
+ margin-top : 10px ;
92
+ padding : 10px 20px ;
93
+
94
+ span {
95
+ color : #888 ;
96
+ font-size : 0.9rem ;
97
+ cursor : pointer ;
98
+ transition : color 0.2s ease-in-out ;
99
+
100
+ & :hover {
101
+ color : #bbb ;
102
+ }
103
+
104
+ .text {
105
+ & ::before {
106
+ content : " + " ;
107
+ margin-right : 4px ;
108
+ }
68
109
}
69
110
}
70
111
}
You can’t perform that action at this time.
0 commit comments