Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Edit.js #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions client/src/components/Edit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React, { Component } from 'react';
import Editform from './Editform';
import Modal from 'react-responsive-modal';
import './Product/Product.css'
import axios from 'axios';

class Edit extends Component {
state = {
open: false,
};
formdata=[]; //get products data from props from Edit button from Products page
formdata=this.props.item;

onOpenModal = () => {
this.setState({ open: true });
};

onCloseModal = () => {
this.setState({ open: false });
};

categories=[];

componentDidMount() {
axios.get('/admin/getcategories')
.then(res => {
this.categories=res.data;
})
}

render() {

return (
<div className="container">
<button className="btn btn-primary btn-lg edit-item-btn box-shadow--8dp" onClick={this.onOpenModal}>Edit product</button>
<Modal open={this.state.open} onClose={this.onCloseModal} center>
<Editform categories={this.categories} formdata={this.formdata}/>
</Modal>
</div>
)
}
}
export default Edit;