Skip to content

Instantly share code, notes, and snippets.

@ertanuj96
Last active May 20, 2019 22:12
Show Gist options
  • Select an option

  • Save ertanuj96/a388454a3100e446e13f26228194f340 to your computer and use it in GitHub Desktop.

Select an option

Save ertanuj96/a388454a3100e446e13f26228194f340 to your computer and use it in GitHub Desktop.
two functions on a single onClick event is not working
//Modify course
import React, { Component } from 'react';
import reactFeature from '../../assets/images/react-feature.svg';
import sassFeature from '../../assets/images/sass-feature.svg';
import bootstrapFeature from '../../assets/images/bootstrap-feature.svg';
import responsiveFeature from '../../assets/images/responsive-feature.svg';
import {
Row,
FormGroup,
Label,
Input,
Col,
Card,
ListGroup,
ListGroupItem,
CardHeader,
CardFooter,
CardBody,
Progress,
Button,
Modal,
ModalHeader,
ModalBody,
ModalFooter
} from 'reactstrap';
import { Switch } from '../../vibe';
import { Doughnut, Line } from 'react-chartjs-2';
import LinkButton from 'C:/Users/Dell/Desktop/scholarsbook/ebook/src/vibe/components/LinkButton/LinkButton';
import axios from 'axios';
class modifycourse extends React.Component {
constructor(props) {
super(props);
this.state = {
course_name:'',
modal: false,
course_description:'',
books_list: '',
syllabus_entry_list: '',
syllabus_pdf: '',
course_content_list: '',
course_modules_list: ''
};
this.toggle =this.toggle.bind(this);
this.modifydescription = this.modifydescription.bind(this);
this.modifyname = this.modifyname.bind(this);
this.modifybooks = this.modifybooks.bind(this);
this.modifysyllabus = this.modifysyllabus.bind(this);
this.modifycontent = this.modifycontent.bind(this);
this.modifymodules = this.modifymodules.bind(this);
}
modifydescription=(e)=>{
e.preventDefault();
const {course_description} = this.state;
axios.put('http://ec2-13-233-162-214.ap-south-1.compute.amazonaws.com:8085/scholarsbook/course/fVGHy2oBo3oYpNg-gBkt',{course_description},
{headers: {
"Accept": "application/json",
"from_user_id" : "DVC0T2oBo3oYpNg-Uq2t"
}
}
)
.then(
(response)=> {
console.log(response);
//access the results here....
});
}
modifyname=(e)=>{
e.preventDefault();
const {course_name} = this.state;
axios.put('http://ec2-13-233-162-214.ap-south-1.compute.amazonaws.com:8085/scholarsbook/course/fVGHy2oBo3oYpNg-gBkt',{course_name},
{headers: {
"Accept": "application/json",
"from_user_id" : "DVC0T2oBo3oYpNg-Uq2t"
}
}
)
.then(
(response)=> {
console.log(response);
//access the results here....
});
}
modifybooks=(e)=>{
e.preventDefault();
const {books_list} = this.state;
axios.put('http://ec2-13-233-162-214.ap-south-1.compute.amazonaws.com:8085/scholarsbook/course/fVGHy2oBo3oYpNg-gBkt',{books_list},
{headers: {
"Accept": "application/json",
"from_user_id" : "DVC0T2oBo3oYpNg-Uq2t"
}
}
)
.then(
(response)=> {
console.log(response);
//access the results here....
});
}
modifysyllabus=(e)=>{
e.preventDefault();
const {syllabus_entry_list} = this.state;
axios.put('http://ec2-13-233-162-214.ap-south-1.compute.amazonaws.com:8085/scholarsbook/course/fVGHy2oBo3oYpNg-gBkt',{syllabus_entry_list},
{headers: {
"Accept": "application/json",
"from_user_id" : "DVC0T2oBo3oYpNg-Uq2t"
}
}
)
.then(
(response)=> {
console.log(response);
//access the results here....
});
}
modifycontent=(e)=>{
e.preventDefault();
const {course_content_list} = this.state;
axios.put('http://ec2-13-233-162-214.ap-south-1.compute.amazonaws.com:8085/scholarsbook/ext_video_data/',{course_content_list},
{headers: {
"Accept": "application/json",
"from_user_id" : "DVC0T2oBo3oYpNg-Uq2t"
}
}
)
.then(
(response)=> {
console.log(response);
//access the results here....
});
}
modifymodules=(e)=>{
e.preventDefault();
const {course_modules_list} = this.state;
axios.put('http://ec2-13-233-162-214.ap-south-1.compute.amazonaws.com:8085/scholarsbook/course/fVGHy2oBo3oYpNg-gBkt',{course_modules_list},
{headers: {
"Accept": "application/json",
"from_user_id" : "DVC0T2oBo3oYpNg-Uq2t"
}
}
)
.then(
(response)=> {
console.log(response);
//access the results here....
});
}
toggle() {
this.setState({
modal: !this.state.modal
});
}
function1(){
modifyname();
toggle();
}
render(){
var cardstyle = {
display:'block',
height: '300px'
};
var cardstyle2 = {
display: 'block',
height: '500px'
};
var buttonstyle ={
margin: '10px',
float:'right'
};
const heroStyles = {
padding: '50px 0 70px'
};
return (
<div>
<Row>
<Col md={12}>
<div className="home-hero" style={heroStyles} align="center">
<h1 align="center">How Technology Reveals God to Us</h1>
</div>
</Col>
<Col md={6} xs={8}>
<Card style={cardstyle} >
<CardHeader >
Update Course Name
<Button size="sm" className="pull-right" >
Update
</Button>
</CardHeader>
<CardBody >
<FormGroup>
<Label for="course_name">Enter New Course Name</Label>
<Input type="textarea" name="course_name" id="course_name" style={{height: 100}} />
<br />
<Button size="sm" className="pull-right" onClick={this.function1} >
Update
</Button>
<Modal isOpen={this.state.modal} toggle={this.toggle}>
<ModalBody>
Course Name
</ModalBody>
<ModalFooter>
<Button color="secondary" onClick={this.toggle}>Cancel</Button>
</ModalFooter>
</Modal>
</FormGroup>
</CardBody>
</Card>
</Col>
<Col md={6} xs={8}>
<Card style={cardstyle} >
<CardHeader >
Update Course_Description
<Button size="sm" className="pull-right" >
Update
</Button>
</CardHeader>
<CardBody>
<FormGroup>
<Label for="course_description">Enter New Course_Description</Label>
<Input type="textarea" name="course_description" id="course_description" style={{height: 100}} />
<Button size="sm" className="pull-right" onClick={this.toggle}>
Update
</Button>
<Modal isOpen={this.state.modal} toggle={this.toggle}>
<ModalBody>
Course Description is Updated!!
</ModalBody>
</Modal>
</FormGroup>
</CardBody>
</Card>
</Col>
<Col md={6} xs={8}>
<Card style={cardstyle2} >
<CardHeader >
Update Book list
<Button size="sm" className="pull-right">
Update
</Button>
</CardHeader>
<CardBody>
<ListGroupItem>Complete Data structures</ListGroupItem>
<ListGroupItem>A refrence Book of Data Structures</ListGroupItem>
<ListGroupItem>Sample Papers of Data Structures</ListGroupItem>
<br/>
<br/>
<br/>
<FormGroup>
<Label for="books_list">Enter New Book</Label>
<Input type="textarea" name="books_list" id="books_list" style={{height: 100}} />
<Button size="sm" className="pull-right" onClick={this.toggle}>
Update
</Button>
<Modal isOpen={this.state.modal} toggle={this.toggle}>
<ModalBody>
Books_list is Updated!!
</ModalBody>
<ModalFooter>
<Button color="secondary" onClick={this.toggle}>Cancel</Button>
</ModalFooter>
</Modal>
</FormGroup>
</CardBody>
</Card>
</Col>
<Col md={6} xs={8}>
<Card style={cardstyle2} >
<CardHeader >
Update Syllabus_list
<Button size="sm" className="pull-right">
Update
</Button>
</CardHeader>
<CardBody>
<ListGroupItem>Setting up your development environment</ListGroupItem>
<ListGroupItem>Building Product</ListGroupItem>
<ListGroupItem>Applying the criteria</ListGroupItem>
<br/>
<FormGroup>
<Label for="syllabus_entry_list">Enter New Syllabus</Label>
<Input type="textarea" name="syllabus_entry_list" id="syllabus_entry_list" style={{height: 100}} />
<Button size="sm" className="pull-right" onClick={this.toggle}>Update
</Button>
</FormGroup>
</CardBody>
</Card>
</Col>
<Col md={6} xs={8}>
<Card style={cardstyle2} >
<CardHeader >
Update Content_list
<Button size="sm" className="pull-right">
Update
</Button>
</CardHeader>
<CardBody>
<ListGroupItem>Setting up your development environment</ListGroupItem>
<ListGroupItem>Building Product</ListGroupItem>
<ListGroupItem>Applying the criteria</ListGroupItem>
<br/>
<br/>
<br/>
<FormGroup>
<Label for="course_content_list">Enter New Content</Label>
<Input type="textarea" name="course_content_list" id="course_content_list" style={{height: 100}} />
<Button size="sm" className="pull-right" onClick={this.toggle}>
Update
</Button>
<Modal isOpen={this.state.modal} toggle={this.toggle}>
<ModalBody>
Successfully Updated!!
</ModalBody>
<ModalFooter>
<Button color="secondary" onClick={this.toggle}>Cancel</Button>
</ModalFooter>
</Modal>
</FormGroup>
</CardBody>
</Card>
</Col> <Col md={6} xs={8}>
<Card style={cardstyle2} >
<CardHeader >
Update Module_list
<Button size="sm" className="pull-right">
Update
</Button>
</CardHeader>
<CardBody>
<ListGroupItem>Module1</ListGroupItem>
<ListGroupItem>Module2</ListGroupItem>
<ListGroupItem>Module3</ListGroupItem>
<br/>
<br/>
<br/>
<FormGroup>
<Label for="course_description">Enter New Module Name</Label>
<Input type="textarea" name="course_modules_list" id="course_modules_list" style={{height: 100}} />
<Button size="sm" className="pull-right" onClick={this.toggle}>
Update
</Button>
<Modal isOpen={this.state.modal} toggle={this.toggle}>
<ModalBody>
Successfully Updated!!
</ModalBody>
<ModalFooter>
<Button color="secondary" onClick={this.toggle}>Cancel</Button>
</ModalFooter>
</Modal>
</FormGroup>
</CardBody>
</Card>
</Col>
</Row>
</div>
)
}
}
export default modifycourse;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment