5
5
} from 'antd' ;
6
6
import LoadingErrorMessage from '../../LoadingErrorMessage/LoadingErrorMessage' ;
7
7
import './TeamProjectModal.css' ;
8
+ import { useHistory } from 'react-router-dom' ;
8
9
9
10
const TeamProjectModal = ( {
10
11
isModalOpen,
@@ -15,32 +16,18 @@ const TeamProjectModal = ({
15
16
selectedTeamProject,
16
17
setSelectedTeamProject,
17
18
} ) => {
19
+ const history = useHistory ( ) ;
18
20
const closeAndUpdateTeamProject = ( ) => {
19
21
setIsModalOpen ( false ) ;
20
22
setBannerText ( selectedTeamProject ) ;
21
23
localStorage . setItem ( 'teamProject' , selectedTeamProject ) ;
22
24
} ;
23
-
24
- let modalContent = (
25
- < Modal
26
- open = { isModalOpen }
27
- className = 'team-project-modal'
28
- title = 'Team Projects'
29
- closable = { false }
30
- maskClosable = { false }
31
- keyboard = { false }
32
- footer = { false }
33
- >
34
- < div className = 'spinner-container' >
35
- < Spin /> Retrieving the list of team projects.
36
- < br />
37
- Please wait...
38
- </ div >
39
- </ Modal >
40
- ) ;
25
+ const redirectToHomepage = ( ) => {
26
+ history . push ( '/' ) ;
27
+ } ;
41
28
42
29
if ( status === 'error' ) {
43
- modalContent = (
30
+ return (
44
31
< Modal
45
32
open = { isModalOpen }
46
33
className = 'team-project-modal'
@@ -57,43 +44,84 @@ const TeamProjectModal = ({
57
44
) ;
58
45
}
59
46
if ( data ) {
60
- modalContent = (
47
+ if ( data . teams . length > 0 ) {
48
+ return (
49
+ < Modal
50
+ className = 'team-project-modal'
51
+ title = 'Team Projects'
52
+ open = { isModalOpen }
53
+ onCancel = { ( ) => setIsModalOpen ( false ) }
54
+ closable = { localStorage . getItem ( 'teamProject' ) }
55
+ maskClosable = { localStorage . getItem ( 'teamProject' ) }
56
+ keyboard = { localStorage . getItem ( 'teamProject' ) }
57
+ footer = { [
58
+ < Button
59
+ key = 'submit'
60
+ type = 'primary'
61
+ disabled = { ! selectedTeamProject }
62
+ onClick = { ( ) => closeAndUpdateTeamProject ( ) }
63
+ >
64
+ Submit
65
+ </ Button > ,
66
+ ] }
67
+ >
68
+ < div className = 'team-project-modal_modal-description' >
69
+ Please select your team.
70
+ </ div >
71
+ < Select
72
+ id = 'input-selectTeamProjectDropDown'
73
+ labelInValue
74
+ defaultValue = { selectedTeamProject }
75
+ onChange = { ( e ) => setSelectedTeamProject ( e . value ) }
76
+ placeholder = '-select one of the team projects below-'
77
+ fieldNames = { { label : 'teamName' , value : 'teamName' } }
78
+ options = { data . teams }
79
+ dropdownStyle = { { width : '100%' } }
80
+ />
81
+ </ Modal >
82
+ ) ;
83
+ }
84
+ return (
61
85
< Modal
86
+ open = { isModalOpen }
62
87
className = 'team-project-modal'
63
88
title = 'Team Projects'
64
- open = { isModalOpen }
65
- onCancel = { ( ) => setIsModalOpen ( false ) }
66
- closable = { localStorage . getItem ( 'teamProject' ) }
67
- maskClosable = { localStorage . getItem ( 'teamProject' ) }
68
- keyboard = { localStorage . getItem ( 'teamProject' ) }
89
+ closable = { false }
90
+ maskClosable = { false }
91
+ keyboard = { false }
69
92
footer = { [
70
93
< Button
71
94
key = 'submit'
72
95
type = 'primary'
73
- disabled = { ! selectedTeamProject }
74
- onClick = { ( ) => closeAndUpdateTeamProject ( ) }
96
+ onClick = { redirectToHomepage }
75
97
>
76
- Submit
98
+ Ok
77
99
</ Button > ,
78
100
] }
79
101
>
80
102
< div className = 'team-project-modal_modal-description' >
81
- Please select your team.
103
+ Please reach out to < a href = 'mailto:[email protected] ' > [email protected] </ a > to gain access to the system
82
104
</ div >
83
- < Select
84
- id = 'input-selectTeamProjectDropDown'
85
- labelInValue
86
- defaultValue = { selectedTeamProject }
87
- onChange = { ( e ) => setSelectedTeamProject ( e . value ) }
88
- placeholder = '-select one of the team projects below-'
89
- fieldNames = { { label : 'teamName' , value : 'teamName' } }
90
- options = { data . teams }
91
- dropdownStyle = { { width : '100%' } }
92
- />
93
105
</ Modal >
94
106
) ;
95
107
}
96
- return < React . Fragment > { modalContent } </ React . Fragment > ;
108
+ return (
109
+ < Modal
110
+ open = { isModalOpen }
111
+ className = 'team-project-modal'
112
+ title = 'Team Projects'
113
+ closable = { false }
114
+ maskClosable = { false }
115
+ keyboard = { false }
116
+ footer = { false }
117
+ >
118
+ < div className = 'spinner-container' >
119
+ < Spin /> Retrieving the list of team projects.
120
+ < br />
121
+ Please wait...
122
+ </ div >
123
+ </ Modal >
124
+ ) ;
97
125
} ;
98
126
99
127
TeamProjectModal . propTypes = {
0 commit comments