2
2
* No Matching Profiles Result Card
3
3
* Card that appears when there are no matching profiles after searching.
4
4
*/
5
- import React from "react" ;
5
+ import React , { useCallback , useMemo } from "react" ;
6
6
import { Link } from "@reach/router" ;
7
7
import PT from "prop-types" ;
8
+ import { useDispatch , useSelector } from "react-redux" ;
9
+ import { addSearchedRole } from "../../actions" ;
8
10
import "./styles.module.scss" ;
9
11
import IconEarthX from "../../../../assets/images/icon-earth-x.svg" ;
10
12
import Curve from "../../../../assets/images/curve.svg" ;
11
13
import Button from "components/Button" ;
12
14
import { formatMoney } from "utils/format" ;
13
15
14
16
function NoMatchingProfilesResultCard ( { role } ) {
17
+ const { addedRoles } = useSelector ( ( state ) => state . searchedRoles ) ;
18
+
19
+ const alreadyAdded = useMemo ( ( ) => {
20
+ if (
21
+ addedRoles . find (
22
+ ( addedRole ) => addedRole . searchId === role . roleSearchRequestId
23
+ )
24
+ ) {
25
+ return true ;
26
+ }
27
+ return false ;
28
+ } , [ addedRoles , role ] ) ;
29
+
30
+ const dispatch = useDispatch ( ) ;
31
+
32
+ const addRole = useCallback ( ( ) => {
33
+ const searchId = role . roleSearchRequestId ;
34
+ let name = "Custom Role" ;
35
+ if ( role . jobTitle && role . jobTitle . length ) {
36
+ name = role . jobTitle ;
37
+ }
38
+ dispatch ( addSearchedRole ( { searchId, name } ) ) ;
39
+ } , [ dispatch , role ] ) ;
40
+
15
41
return (
16
42
< div styleName = "result-card" >
17
43
< div styleName = "heading" >
@@ -21,6 +47,11 @@ function NoMatchingProfilesResultCard({ role }) {
21
47
< IconEarthX styleName = "transparent-icon" />
22
48
</ div >
23
49
< div styleName = "content" >
50
+ < h4 styleName = "job-title" >
51
+ { role . jobTitle && role . jobTitle . length
52
+ ? role . jobTitle
53
+ : "Custom Role" }
54
+ </ h4 >
24
55
< p styleName = "info-txt" >
25
56
We will be looking internally for members matching your requirements
26
57
and be back at them in about 2 weeks.
@@ -38,11 +69,20 @@ function NoMatchingProfilesResultCard({ role }) {
38
69
< p > /Week</ p >
39
70
</ div >
40
71
) }
41
- < Link to = "/taas/createnewteam" >
42
- < Button type = "secondary" styleName = "button" >
43
- Modify Search Criteria
72
+ < div styleName = "button-group" >
73
+ < Link to = "/taas/createnewteam" >
74
+ < Button styleName = "left" type = "secondary" >
75
+ Modify Search Criteria
76
+ </ Button >
77
+ </ Link >
78
+ < Button
79
+ onClick = { addRole }
80
+ disabled = { ! role . roleSearchRequestId || alreadyAdded }
81
+ type = "primary"
82
+ >
83
+ { alreadyAdded ? "Added" : "Add Custom Role" }
44
84
</ Button >
45
- </ Link >
85
+ </ div >
46
86
</ div >
47
87
</ div >
48
88
) ;
0 commit comments