[go: nahoru, domu]

Skip to content

Commit

Permalink
#2 add passwordChange for individualStudentTeacherEdit and update onB…
Browse files Browse the repository at this point in the history
…lur being passed to render
  • Loading branch information
MirTalpur committed Aug 29, 2020
1 parent 4c9a945 commit 333a98e
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 35 deletions.
80 changes: 49 additions & 31 deletions components/individualStudentTeacherEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,6 @@ export default class TeacherEditStudentComponent extends React.Component {
console.log("in TeacherEditStudentComponent class....");
console.log(this.props.individualEditStudentInformation);
console.log(this.props.individualEditStudentInformation.data.data.displayName);

}

backButtonComponent = () => {
return(
<Button style={{ float: 'left' }}>
Back
</Button>
)
}

updateButtonComponent = () => {
return(
<Button type="primary" size="large"
style={{ float: 'right' }}
>
Update
</Button>
)
}

nameFormItemComponent = () => {
Expand Down Expand Up @@ -74,7 +55,7 @@ export default class TeacherEditStudentComponent extends React.Component {
Email
<Form.Item
validateStatus="error"
help="Please insert a valid insert">
help="Please insert a valid Email">
<Input size="medium"
defaultValue={this.props.individualEditStudentInformation.data.data.email}
onChange={(event)=>this.props.handleIndividualStudentTeacherEditEmailChange(event)}
Expand All @@ -90,7 +71,7 @@ export default class TeacherEditStudentComponent extends React.Component {
<Form.Item>
<Input size="medium"
defaultValue={this.props.individualEditStudentInformation.data.data.email}
onChange={(event)=>this.props.handleIndividualStudentTeacherEditNameChange(event)}
onChange={(event)=>this.props.handleIndividualStudentTeacherEditEmailChange(event)}
onBlur={(event)=>this.props.onBlurhandleIndividualStudentTeacherEditEmailChange(event)}
/>
</Form.Item>
Expand All @@ -109,7 +90,7 @@ export default class TeacherEditStudentComponent extends React.Component {
help="Current grade can't be empty">
<Input size="medium"
defaultValue={this.props.individualEditStudentInformation.data.data.currentGradeLevel}
onChange={(event)=>this.props.handleIndividualStudentTeacherEditNameChange(event)}
onChange={(event)=>this.props.handleIndividualStudentTeacherEditGradeChange(event)}
onBlur={(event)=>this.props.onBlurhandleIndividualStudentTeacherEditGradeChange(event)}
/>
</Form.Item>
Expand All @@ -122,7 +103,7 @@ export default class TeacherEditStudentComponent extends React.Component {
<Form.Item>
<Input size="medium"
defaultValue={this.props.individualEditStudentInformation.data.data.currentGradeLevel}
onChange={(event)=>this.props.handleIndividualStudentTeacherEditNameChange(event)}
onChange={(event)=>this.props.handleIndividualStudentTeacherEditGradeChange(event)}
onBlur={(event)=>this.props.onBlurhandleIndividualStudentTeacherEditGradeChange(event)}
/>
</Form.Item>
Expand All @@ -132,15 +113,52 @@ export default class TeacherEditStudentComponent extends React.Component {
}

passwordFormItemComponent = () => {
if(this.props.teacherStudentComponent.individualStudentTeacherEditPasswordError) {
return(
<div>
New Password
<Form.Item
validateStatus="error"
help="Password needs to be at least 6 characters">
<Input size="medium" type="password"
onChange={(event)=>this.props.handleIndividualStudentTeacherEditPasswordChange(event)}
onBlur={(event)=>this.props.onBlurhandleIndividualStudentTeacherEditPasswordChange(event)}
value={this.props.teacherStudentComponent.individualStudentTeacherEditPassword}
/>
</Form.Item>
</div>
)
} else {
return(
<div>
New Password
<Form.Item>
<Input size="medium" type="password"
onChange={(event)=>this.props.handleIndividualStudentTeacherEditPasswordChange(event)}
onBlur={(event)=>this.props.onBlurhandleIndividualStudentTeacherEditPasswordChange(event)}
value={this.props.teacherStudentComponent.individualStudentTeacherEditPassword}
/>
</Form.Item>
</div>
)
}
}

backButtonComponent = () => {
return(
<Button style={{ float: 'left' }}>
Back
</Button>
)
}

updateButtonComponent = () => {
return(
<div>
New Password
<Form.Item>
<Input size="medium" type="password"
onChange={(event)=>this.props.handleIndividualStudentTeacherEditNameChange(event)}
/>
</Form.Item>
</div>
<Button type="primary" size="large"
style={{ float: 'right' }}
>
Update
</Button>
)
}

Expand Down
2 changes: 2 additions & 0 deletions components/nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ export default class Nav extends React.Component {
onBlurhandleIndividualStudentTeacherEditEmailChange={this.props.onBlurhandleIndividualStudentTeacherEditEmailChange}
handleIndividualStudentTeacherEditGradeChange={this.props.handleIndividualStudentTeacherEditGradeChange}
onBlurhandleIndividualStudentTeacherEditGradeChange={this.props.onBlurhandleIndividualStudentTeacherEditGradeChange}
handleIndividualStudentTeacherEditPasswordChange={this.props.handleIndividualStudentTeacherEditPasswordChange}
onBlurhandleIndividualStudentTeacherEditPasswordChange={this.props.onBlurhandleIndividualStudentTeacherEditPasswordChange}
/>
}
}
Expand Down
67 changes: 63 additions & 4 deletions components/teacherDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ export class TeacherDashboard extends React.Component {
individualStudentEditLoading: false,
individualStudentTeacherEditName: null,
individualStudentTeacherEditNameError: null,
individualStudentTeacherEditEmail: null,
individualStudentTeacherEditEmail: "",
individualStudentTeacherEditEmailError: null,
individualStudentTeacherEditEmailPristine: true,
individualStudentTeacherEditGrade: null,
individualStudentTeacherEditGradeError: null,
individualStudentTeacherEditPassword: "",
individualStudentTeacherEditPasswordError: null,
individualStudentTeacherEditPasswordPristine: true,
},
}
this.handleMenuClick = this.handleMenuClick.bind(this);
Expand All @@ -61,6 +64,8 @@ export class TeacherDashboard extends React.Component {
this.onBlurhandleIndividualStudentTeacherEditEmailChange = this.onBlurhandleIndividualStudentTeacherEditEmailChange.bind(this);
this.handleIndividualStudentTeacherEditGradeChange = this.handleIndividualStudentTeacherEditGradeChange.bind(this);
this.onBlurhandleIndividualStudentTeacherEditGradeChange = this.onBlurhandleIndividualStudentTeacherEditGradeChange.bind(this);
this.handleIndividualStudentTeacherEditPasswordChange = this.handleIndividualStudentTeacherEditPasswordChange.bind(this);
this.onBlurhandleIndividualStudentTeacherEditPasswordChange = this.onBlurhandleIndividualStudentTeacherEditPasswordChange.bind(this);
}

componentDidMount() {
Expand All @@ -81,8 +86,8 @@ export class TeacherDashboard extends React.Component {
const target = e.target;
const value = target.value;
console.log("value being set for handleIndividualStudentTeacherEditEmailChange" + value);

if(this.state.individualStudentTeacherEditEmailPristine) {
console.log("this.state.teacherStudentComponent.individualStudentTeacherEditEmailPristine " + this.state.teacherStudentComponent.individualStudentTeacherEditEmailPristine);
if(this.state.teacherStudentComponent.individualStudentTeacherEditEmailPristine) {
this.setState(prevState => ({
teacherStudentComponent: {
...prevState.teacherStudentComponent,
Expand Down Expand Up @@ -111,6 +116,8 @@ export class TeacherDashboard extends React.Component {
}

onBlurhandleIndividualStudentTeacherEditEmailChange = (e) => {
console.log("in onBlurhandleIndividualStudentTeacherEditEmailChange ");
console.log("this.state.teacherStudentComponent.individualStudentTeacherEditEmail " + this.state.teacherStudentComponent.individualStudentTeacherEditEmail);
if(!this.validateEmail(this.state.teacherStudentComponent.individualStudentTeacherEditEmail)) {
this.setState(prevState => ({
teacherStudentComponent: {
Expand Down Expand Up @@ -164,6 +171,56 @@ export class TeacherDashboard extends React.Component {
}
/* End Grade Level */

/* Password */
handleIndividualStudentTeacherEditPasswordChange = (e) => {
console.log("in handleIndividualStudentTeacherPasswordChange");
const target = e.target;
const value = target.value;
console.log("value being set for handleIndividualStudentTeacherPasswordChange" + value);
console.log("this.state.individualStudentTeacherEditPasswordPristine: " + this.state.individualStudentTeacherEditPasswordPristine);
if(this.state.teacherStudentComponent.individualStudentTeacherEditPasswordPristine) {
console.log("in conditional for individualStudentTeacherEditPasswordPristine");
this.setState(prevState => ({
teacherStudentComponent: {
...prevState.teacherStudentComponent,
individualStudentTeacherEditPassword: value,
}
}));
} else {
if(value.length >= 6) {
this.setState(prevState => ({
teacherStudentComponent: {
...prevState.teacherStudentComponent,
individualStudentTeacherEditPassword: value,
individualStudentTeacherEditPasswordError: null,
}
}));
} else {
this.setState(prevState => ({
teacherStudentComponent: {
...prevState.teacherStudentComponent,
individualStudentTeacherEditPassword: value,
individualStudentTeacherEditPasswordError: true,
}
}));
}
}
}

onBlurhandleIndividualStudentTeacherEditPasswordChange = (e) => {
console.log("I'm in this biatch..");
if(this.state.teacherStudentComponent.individualStudentTeacherEditPassword.length < 6) {
this.setState(prevState => ({
teacherStudentComponent: {
...prevState.teacherStudentComponent,
individualStudentTeacherEditPasswordError: true,
individualStudentTeacherEditPasswordPristine: false,
}
}));
}
}

/* End Password */
/* Name */
handleIndividualStudentTeacherEditNameChange = (e) => {
console.log("in handleIndividualStudentTeacherEditNameChange");
Expand Down Expand Up @@ -478,9 +535,11 @@ export class TeacherDashboard extends React.Component {
handleIndividualStudentTeacherEditNameChange={this.handleIndividualStudentTeacherEditNameChange}
onBlurhandleIndividualStudentTeacherEditNameChange={this.onBlurhandleIndividualStudentTeacherEditNameChange}
handleIndividualStudentTeacherEditEmailChange={this.handleIndividualStudentTeacherEditEmailChange}
onBlurhandleIndividualStudentTeacherEditEmailChange={this.handleIndividualStudentTeacherEditEmailChange}
onBlurhandleIndividualStudentTeacherEditEmailChange={this.onBlurhandleIndividualStudentTeacherEditEmailChange}
handleIndividualStudentTeacherEditGradeChange={this.handleIndividualStudentTeacherEditGradeChange}
onBlurhandleIndividualStudentTeacherEditGradeChange={this.onBlurhandleIndividualStudentTeacherEditGradeChange}
handleIndividualStudentTeacherEditPasswordChange={this.handleIndividualStudentTeacherEditPasswordChange}
onBlurhandleIndividualStudentTeacherEditPasswordChange={this.onBlurhandleIndividualStudentTeacherEditPasswordChange}
/>
</div>
</React.Fragment>
Expand Down
2 changes: 2 additions & 0 deletions components/teacherStudentComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ export default class TeacherStudentComponent extends React.Component {
onBlurhandleIndividualStudentTeacherEditEmailChange={this.props.onBlurhandleIndividualStudentTeacherEditEmailChange}
handleIndividualStudentTeacherEditGradeChange={this.props.handleIndividualStudentTeacherEditGradeChange}
onBlurhandleIndividualStudentTeacherEditGradeChange={this.props.onBlurhandleIndividualStudentTeacherEditGradeChange}
handleIndividualStudentTeacherEditPasswordChange={this.props.handleIndividualStudentTeacherEditPasswordChange}
onBlurhandleIndividualStudentTeacherEditPasswordChange={this.props.onBlurhandleIndividualStudentTeacherEditPasswordChange}
/>
// displayName: "asdlkfj 89234"
// email: "alskdjf@gmail.com"
Expand Down

0 comments on commit 333a98e

Please sign in to comment.