11import React from 'react'
22import PT from 'prop-types'
33import _ from 'lodash'
4- import { withRouter , Link } from 'react-router-dom'
4+ import { withRouter } from 'react-router-dom'
55import { getProjectRoleForCurrentUser } from '../../../helpers/projectHelper'
66import ProjectCardHeader from './ProjectCardHeader'
77import ProjectCardBody from './ProjectCardBody'
88import ProjectManagerAvatars from '../../list/components/Projects/ProjectManagerAvatars'
9+ import LoadingIndicator from '../../../components/LoadingIndicator/LoadingIndicator'
910import './ProjectCard.scss'
1011
11- function ProjectCard ( { project, duration, disabled, currentUser, history, onChangeStatus, projectTemplates, unreadMentionsCount } ) {
12+ function ProjectCard ( { project, duration, disabled, currentUser, history, onChangeStatus, projectTemplates, unreadMentionsCount, callInviteRequest , isAcceptingInvite } ) {
1213 const className = `ProjectCard ${ disabled ? 'disabled' : 'enabled' } `
1314 if ( ! project ) return null
1415 const currentMemberRole = getProjectRoleForCurrentUser ( { project, currentUserId : currentUser . userId } )
@@ -41,11 +42,27 @@ function ProjectCard({ project, duration, disabled, currentUser, history, onChan
4142 < ProjectManagerAvatars managers = { project . members } maxShownNum = { 10 } />
4243 < div >
4344 { ( ! isMember && isInvited ) &&
44- < Link to = { `/projects/${ project . id } ` } className = "spacing" >
45- < div className = "join-btn" style = { { margin : '5px' } } >
46- Join project
47- </ div >
48- </ Link >
45+ < div className = "spacing join-btn-container" >
46+ { ( ! isAcceptingInvite ) && (
47+ < button
48+ onClick = { ( event ) => {
49+ event . stopPropagation ( )
50+ callInviteRequest ( project , true )
51+ } }
52+ className = { 'tc-btn tc-btn-primary tc-btn-md blue accept-btn' }
53+ >
54+ Join project
55+ </ button > ) }
56+ { ( ! isAcceptingInvite ) && (
57+ < button
58+ onClick = { ( event ) => {
59+ event . stopPropagation ( )
60+ callInviteRequest ( project , false )
61+ } }
62+ className = "decline-btn"
63+ > Decline</ button > ) }
64+ { isAcceptingInvite && ( < LoadingIndicator isSmall /> ) }
65+ </ div >
4966 }
5067 </ div >
5168 </ div >
@@ -54,13 +71,17 @@ function ProjectCard({ project, duration, disabled, currentUser, history, onChan
5471}
5572
5673ProjectCard . defaultTypes = {
74+ callInviteRequest : ( ) => { } ,
75+ isAcceptingInvite : false ,
5776}
5877
5978ProjectCard . propTypes = {
6079 project : PT . object . isRequired ,
6180 currentMemberRole : PT . string ,
6281 projectTemplates : PT . array . isRequired ,
63- unreadMentionsCount : PT . number . isRequired
82+ unreadMentionsCount : PT . number . isRequired ,
83+ callInviteRequest : PT . func ,
84+ isAcceptingInvite : PT . bool
6485 // duration: PT.object.isRequired,
6586}
6687
0 commit comments