forked from SiegeEngineers/aoe2cm2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add direct links for joining as a host/guest
Closes SiegeEngineers#129
- Loading branch information
Showing
7 changed files
with
113 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import * as React from "react"; | ||
import Player from "../../constants/Player"; | ||
import "../../types/DraftEvent"; | ||
import {WithTranslation, withTranslation} from "react-i18next"; | ||
import {Redirect} from "react-router"; | ||
import {Util} from "../../util/Util"; | ||
|
||
interface IProps extends WithTranslation { | ||
setOwnRole: (role: Player) => void; | ||
} | ||
|
||
|
||
class GuestDraft extends React.Component<IProps, object> { | ||
|
||
componentDidMount(): void { | ||
this.props.setOwnRole(Player.GUEST); | ||
} | ||
|
||
public render() { | ||
const draftId = Util.getIdFromUrl(); | ||
return ( | ||
<Redirect to={`/draft/${draftId}`}/> | ||
); | ||
} | ||
} | ||
|
||
export default withTranslation()(GuestDraft); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import * as React from "react"; | ||
import Player from "../../constants/Player"; | ||
import "../../types/DraftEvent"; | ||
import {WithTranslation, withTranslation} from "react-i18next"; | ||
import {Redirect} from "react-router"; | ||
import {Util} from "../../util/Util"; | ||
|
||
interface IProps extends WithTranslation { | ||
setOwnRole: (role: Player) => void; | ||
} | ||
|
||
|
||
class HostDraft extends React.Component<IProps, object> { | ||
|
||
componentDidMount(): void { | ||
this.props.setOwnRole(Player.HOST); | ||
} | ||
|
||
public render() { | ||
const draftId = Util.getIdFromUrl(); | ||
return ( | ||
<Redirect to={`/draft/${draftId}`}/> | ||
); | ||
} | ||
} | ||
|
||
export default withTranslation()(HostDraft); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import * as actions from '../actions/'; | ||
import {ApplicationState} from '../types'; | ||
import {connect} from 'react-redux'; | ||
import {Dispatch} from 'redux'; | ||
import Player from "../constants/Player"; | ||
import DraftGuest from "../components/draft/GuestDraft"; | ||
|
||
export function mapStateToProps(state: ApplicationState) { | ||
return {} | ||
} | ||
|
||
export function mapDispatchToProps(dispatch: Dispatch<actions.Action>) { | ||
return { | ||
setOwnRole: (role: Player) => dispatch(actions.setOwnRole(role)), | ||
triggerConnect: () => dispatch(actions.connect()), | ||
triggerSetRole: (name: string, role: Player) => dispatch(actions.setRole(name, role)), | ||
} | ||
} | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(DraftGuest); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import * as actions from '../actions/'; | ||
import {ApplicationState} from '../types'; | ||
import {connect} from 'react-redux'; | ||
import {Dispatch} from 'redux'; | ||
import Player from "../constants/Player"; | ||
import DraftHost from "../components/draft/HostDraft"; | ||
|
||
export function mapStateToProps(state: ApplicationState) { | ||
return {} | ||
} | ||
|
||
export function mapDispatchToProps(dispatch: Dispatch<actions.Action>) { | ||
return { | ||
setOwnRole: (role: Player) => dispatch(actions.setOwnRole(role)), | ||
triggerConnect: () => dispatch(actions.connect()), | ||
triggerSetRole: (name: string, role: Player) => dispatch(actions.setRole(name, role)), | ||
} | ||
} | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(DraftHost); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters