11import React from 'react' ;
22import Popup from 'reactjs-popup' ;
33
4+ class CourseDetailsPanel extends React . Component {
5+ render ( ) {
6+ const course = this . props . course ;
7+ return (
8+ < div className = { 'content' } >
9+ < p > { 'Instructor: ' } { course . instructor } </ p >
10+ < p > { 'Time: ' } { course . time } </ p >
11+ < p > { 'Location: ' } { course . location } </ p >
12+ </ div >
13+ ) ;
14+ }
15+ }
16+
17+ class CourseDetailsWindow extends React . Component {
18+ render ( ) {
19+ const course = this . props . course ;
20+ return (
21+ < div className = "modal" >
22+ < a className = "close" onClick = { this . props . onClose } > ×</ a >
23+ < button onClick = { this . props . onSelectDefTag ( 'N/A' ) } > N/A</ button >
24+ < button onClick = { this . props . onSelectDefTag ( 'In Progress' ) } > In Progress</ button >
25+ < button onClick = { this . props . onSelectDefTag ( 'Finished' ) } > Finished</ button >
26+ < div className = "header" > { course . course_number } </ div >
27+ < CourseDetailsPanel course = { course } />
28+ </ div >
29+ ) ;
30+ }
31+ }
432
533class Popups extends React . Component {
634 constructor ( props ) {
735 super ( props ) ;
8- this . handleClick = this . handleClick . bind ( this ) ;
36+ this . removeDefTags = this . removeDefTags . bind ( this ) ;
37+ this . selectDefTag = this . selectDefTag . bind ( this ) ;
938 this . state = {
10- tags : [ ] || props . tags ,
39+ deftags : [ ] || props . tags ,
1140 } ;
1241 }
1342
@@ -21,36 +50,37 @@ class Popups extends React.Component {
2150 } ) ,
2251 } ;
2352
24- handleClick ( e ) {
53+ removeDefTags ( ) {
54+ if ( this . state . deftags === 'N/A'
55+ || this . state . deftags === 'In Progress'
56+ || this . state . deftags === 'Finished' ) {
57+ this . state . deftags = '' ;
58+ }
59+ }
60+
61+ selectDefTag ( e ) {
62+ this . removeDefTags ( ) ;
2563 if ( e === 'N/A' ) {
26- this . state . tags = 'N/A' ;
64+ this . state . deftags = 'N/A' ;
2765 }
2866 if ( e === 'In Progress' ) {
29- this . state . tags = 'In Progress' ;
67+ this . state . deftags = 'In Progress' ;
3068 }
3169 if ( e === 'Finished' ) {
32- this . state . tags = 'Finished' ;
70+ this . state . deftags = 'Finished' ;
3371 }
34- console . log ( `get tags: ${ this . state . tags } ` ) ;
3572 }
3673
3774 render ( ) {
3875 return < div >
39- < Popup trigger = { < a className = "button" > { this . props . myLists . course_title } </ a > } modal >
40- { close => (
41- < div className = "modal" >
42- < a className = "close" onClick = { close } > ×</ a >
43- < button onClick = { ( ) => this . handleClick ( 'N/A' ) } > N/A</ button >
44- < button onClick = { ( ) => this . handleClick ( 'In Progress' ) } > In Progress</ button >
45- < button onClick = { ( ) => this . handleClick ( 'Finished' ) } > Finished</ button >
46- < div className = "header" > { this . props . myLists . course_number } </ div >
47- < div className = { 'content' } >
48- < p > { 'Instructor: ' } { this . props . myLists . instructor } </ p >
49- < p > { 'Time: ' } { this . props . myLists . time } </ p >
50- < p > { 'Location: ' } { this . props . myLists . location } </ p >
51- </ div >
52- </ div >
53- ) }
76+ < Popup
77+ trigger = { < a className = "button" > { this . props . myLists . course_title } </ a > } modal >
78+ { close =>
79+ < CourseDetailsWindow
80+ course = { this . props . myLists }
81+ onClose = { close }
82+ onSelectDefTag = { ( tag ) => this . selectDefTag ( tag ) } />
83+ }
5484 </ Popup >
5585 </ div > ;
5686 }
0 commit comments