diff --git a/tutify/src/components/Resources/AddResource.js b/tutify/src/components/Resources/AddResource.js index 87d779ac..deea7c61 100644 --- a/tutify/src/components/Resources/AddResource.js +++ b/tutify/src/components/Resources/AddResource.js @@ -10,6 +10,8 @@ import DialogActions from '@material-ui/core/DialogActions'; import DialogContentText from '@material-ui/core/DialogContentText'; import DialogTitle from '@material-ui/core/DialogTitle'; import Avatar from '@material-ui/core/Avatar'; +import axios from 'axios'; +import swal from 'sweetalert'; class AddResource extends Component { constructor(props) { @@ -21,6 +23,21 @@ class AddResource extends Component { }; } + addResourceToDB = () => { + axios.post('/api/addResource', { + title: this.state.title, + description: this.state.description, + image: this.state.image, + link: this.state.link, + category: this.state.category, + educationLevel: this.state.educationLevel + }).then((res) => { + console.info("Successfully added the resource"); + swal("Resource successfully added!", "", "success") + }) + .catch(err => console.error("Could not add the resource to the database: "+err)); + } + render() { const { open, handleClose } = this.props