Я хочу go открыть страницу сообщения со своей панели инструментов на моем веб-сайте, но она не удалась, и когда я пробую ее с другой страницы, она полностью отобразится.
Вот мой исходный код:
...
import { withRouter } from 'react-router';
import LoadingIndicator from '../widgets/loadingIndicator.jsx';
import SystemStore from '../../stores/SystemStore';
import ProfileStore from '../../stores/ProfileStore';
import ProfileActions from '../../actions/ProfileActions';
import Formatter from '../../utils/formatter';
import Layout from '../layout.jsx';
import { isNull } from 'util';
class MessagePage extends React.Component{
constructor(props){
super(props);
this.state={
systemUser: SystemStore.systemUser(),
profile: ProfileStore.getProfile(),
message: "",
};
this.handleProfileChange = this.handleProfileChange.bind(this);
this.handleSystemUserChange = this.handleSystemUserChange.bind(this);
this.renderForm = this.renderForm.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
ComponentDidMout(){
ProfileStore.addProfileChangeListener(this.handleProfileChange);
if (!this.state.profile) {
ProfileActions.reload();
}
SystemStore.addSystemUserChangeListener(this.hancleSystemUserChange);
}
ComponentWillUnmount(){
SystemStore.removeSystemUserChangeListener(this.handleSystemUserChange);
ProfileStore.removeProfileChangeListener(this.handleProfileChange);
}
render(){
if (this.state.profile) {
if (this.state.systemUser.membershipId.match("^(33).+") ||
this.state.profile.currentMembership.category === 'PARTICIPANT') {
return this.props.router.push('/');
}
return this.renderForm();
} else {
return <LoadingIndicator />;
}
}
renderForm(){
var styles = {fontWeight: "bold", fontSize: '20px'};
return(
<Layout>
....
<div className="col hs-message-form-logo-container" style={styles}>
</div>
<div className="hs-message-form-label text-center">
{T.translate('message.title')}
</div>
<div className="hs-message-form-label-1 text-center">
{T.translate('message.subtitle')}
</div>
</div>
<div className="row hs-message-form-body">
<form className="hs-message-form-body-content">
{T.translate('profile.fullName')}
<input
type="text"
ref="inputFullName"
className="form-control"
defaultValue={this.state.profile.fullName}
placeholder={ T.translate('placeholder.fullName') }
/>
{T.translate('profile.memberId')}
<input
type="text"
ref="inputMemberId"
className="form-control"
defaultValue={this.state.profile.currentMembership.memberId}
placeholder={ T.translate('profile.memberId') }
/>
{T.translate('profile.primarySite')}
<input
type="text"
ref="inputSite"
className="form-control"
defaultValue={_.get(this.state.profile,'primarySite.name')}/>
{T.translate('message.message')}
<textarea
type="text"
ref="inputMessage"
className="form-control"
placeholder={ T.translate('placeholder.message') }
onChange={this.onChange}
/>
<LaddaButton
loading={ this.state.submitting }
onClick={ this.handleSubmit }>
{ T.translate('action.send') }
</LaddaButton>
</form>
</div>
</div>
</div>
</div>
</div>
</Layout>
)
}
handleProfileChange() {
this.setState({
profile: ProfileStore.getProfile(),
profileMetadata: ProfileStore.getMetadata()
});
if(_.isNil(ProfileStore.getCurrentEditRef())){
ProfileActions.checkProfileEdits();
}
}
handleSystemUserChange() {
this.setState({ systemUser: SystemStore.systemUser() });
}
}
export default withRouter(MessagePage);
Можете ли вы сказать мне, что может быть не так с моим кодом здесь? Спасибо за вашу помощь, я спрашивал моего друга, и он сказал, что нет лога c для установки профиля, но если это правда, страница не будет отображаться. Я не знаю, потому что я могу получить к нему доступ с другой страницы.