File tree Expand file tree Collapse file tree 6 files changed +100
-18
lines changed Expand file tree Collapse file tree 6 files changed +100
-18
lines changed Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
1
2
import Container from 'react-bootstrap/Container' ;
2
- import Row from 'react-bootstrap/Row' ;
3
3
import JoinedMissions from './JoinedMissions' ;
4
4
import ReservedRockets from './ReservedRockets' ;
5
5
import ReservedDragons from './ReservedDragons' ;
6
+ import '../styles/Profile.css' ;
6
7
7
8
const ProfileComponent = ( ) => (
8
9
< Container >
9
- < Row >
10
- < table >
10
+ < div className = "profile-table-container" >
11
+ < table className = "profile-table" >
11
12
< thead >
12
13
< tr >
13
14
< th > My Missions</ th >
14
- < th > My Rockets</ th >
15
- < th > My Dragons</ th >
16
15
</ tr >
17
16
</ thead >
18
17
< tbody >
19
18
< tr >
20
19
< td >
21
20
< JoinedMissions />
22
21
</ td >
22
+ </ tr >
23
+ </ tbody >
24
+ </ table >
25
+
26
+ < table className = "profile-table" >
27
+ < thead >
28
+ < tr >
29
+ < th > My Rockets</ th >
30
+ </ tr >
31
+ </ thead >
32
+ < tbody >
33
+ < tr >
23
34
< td >
24
35
< ReservedRockets />
25
36
</ td >
37
+ </ tr >
38
+ </ tbody >
39
+ </ table >
40
+
41
+ < table className = "profile-table" >
42
+ < thead >
43
+ < tr >
44
+ < th > My Dragons</ th >
45
+ </ tr >
46
+ </ thead >
47
+ < tbody >
48
+ < tr >
26
49
< td >
27
50
< ReservedDragons />
28
51
</ td >
29
52
</ tr >
30
53
</ tbody >
31
54
</ table >
32
- </ Row >
33
-
55
+ </ div >
34
56
</ Container >
35
57
) ;
58
+
36
59
export default ProfileComponent ;
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
+ import { useSelector } from 'react-redux' ;
2
3
3
- const ReservedRockets = ( ) => (
4
- < div > ReservedRockets</ div >
5
- ) ;
4
+ const ReservedRockets = ( ) => {
5
+ const rockets = useSelector ( ( state ) => state . rockets . rockets ) ;
6
+ const reservedRockets = rockets . filter ( ( rocket ) => rocket . reserved === true ) ;
7
+
8
+ if ( reservedRockets . length === 0 ) {
9
+ return < div > You have no reserved rockets.</ div > ;
10
+ }
11
+
12
+ return (
13
+ < ul className = "reserved-rockets" >
14
+ { reservedRockets . map ( ( rocket ) => (
15
+ < li className = "reserved-rocket" key = { rocket . id } > { rocket . name } </ li >
16
+ ) ) }
17
+ </ ul >
18
+ ) ;
19
+ } ;
6
20
7
21
export default ReservedRockets ;
Original file line number Diff line number Diff line change @@ -29,12 +29,15 @@ const Rocket = ({ rocket }) => {
29
29
{ rocket . description }
30
30
</ p >
31
31
</ div >
32
- < button className = "reserve-button" type = "submit" onClick = { handleReserveRocket } >
33
- Reserve Rocket
34
- </ button >
35
- < button className = "cancel-button" type = "submit" onClick = { handleCancelRocket } >
36
- Cancel Reservation
37
- </ button >
32
+ { ! rocket . reserved ? (
33
+ < button className = "reserve-button" type = "submit" onClick = { handleReserveRocket } >
34
+ Reserve Rocket
35
+ </ button >
36
+ ) : (
37
+ < button className = "cancel-button" type = "submit" onClick = { handleCancelRocket } >
38
+ Cancel Reservation
39
+ </ button >
40
+ ) }
38
41
</ div >
39
42
</ li >
40
43
) ;
Original file line number Diff line number Diff line change @@ -11,8 +11,10 @@ const RocketsComponent = () => {
11
11
const error = useSelector ( ( state ) => state . rockets . error ) ;
12
12
13
13
useEffect ( ( ) => {
14
- dispatch ( fetchRockets ( ) ) ;
15
- } , [ dispatch ] ) ;
14
+ if ( rockets . length === 0 ) {
15
+ dispatch ( fetchRockets ( ) ) ;
16
+ }
17
+ } , [ dispatch , rockets . length ] ) ;
16
18
17
19
if ( loading ) {
18
20
return (
Original file line number Diff line number Diff line change
1
+ .profile-table-container {
2
+ display : flex;
3
+ justify-content : space-between;
4
+ }
5
+
6
+ .profile-table {
7
+ border-collapse : collapse;
8
+ width : 30% ; /* Adjust the width as needed */
9
+ }
10
+
11
+ .profile-table th {
12
+ padding : 10px ;
13
+ }
14
+
15
+ .profile-row {
16
+ border-bottom : 1px solid # ccc ;
17
+ padding-bottom : 10px ;
18
+ margin-bottom : 10px ;
19
+ }
20
+
21
+ .profile-table tbody tr : nth-child (odd) {
22
+ background-color : # f8f8f8 ;
23
+ }
24
+
25
+ .profile-table tbody tr : hover {
26
+ background-color : # f0f0f0 ;
27
+ }
Original file line number Diff line number Diff line change
1
+ .reserved-rockets {
2
+ margin : 0 ;
3
+ padding : 0 ;
4
+ display : flex;
5
+ flex-direction : column;
6
+ align-items : flex-start;
7
+ }
8
+
9
+ .reserved-rocket {
10
+ padding : 3% 5% ;
11
+ border : 1px solid;
12
+ width : 100% ;
13
+ }
You can’t perform that action at this time.
0 commit comments