Commit 4371fd59 authored by Mai Thanh Cong's avatar Mai Thanh Cong

update modal diary

parent 54c48d51
......@@ -56,12 +56,6 @@ const AddProduct = () => {
history.push("/profile/add");
}
const onHandleClickAddProductDiary = () => {
history.push({
pathname: "/profile/add-product-diary",
state: { profileId }
});
}
return (
<>
......@@ -139,14 +133,9 @@ const AddProduct = () => {
<FormGroup>
<Label for="product-name">Mô t</Label>
<InputGroup className="mb-4">
<InputGroupAddon addonType="prepend">
<InputGroupText>
<i className="fa fa-product-hunt" />
</InputGroupText>
</InputGroupAddon>
<Input
placeholder="Mô tả"
type="text"
type="textarea"
value={description}
onChange={(e) => setDescription(e.target.value)}
/>
......@@ -155,14 +144,9 @@ const AddProduct = () => {
<FormGroup>
<Label for="product-name">Điu kin nuôi trng</Label>
<InputGroup className="mb-4">
<InputGroupAddon addonType="prepend">
<InputGroupText>
<i className="fa fa-product-hunt" />
</InputGroupText>
</InputGroupAddon>
<Input
placeholder="Điều kiện nuôi trồng"
type="text"
type="textarea"
value={growingConditions}
onChange={(e) => setGrowingConditions(e.target.value)}
/>
......
......@@ -56,7 +56,7 @@ const AddProfile = () => {
}
console.log("params", params);
dummyData.data.push(params);
history.push("/");
history.push("/profile");
setValidPhoneNumber(false);
}else {
setValidPhoneNumber(true);
......@@ -127,23 +127,15 @@ const AddProfile = () => {
<FormGroup className="mb-4">
<Label for="address" >Địa ch</Label>
<InputGroup className="mb-4">
<InputGroupAddon addonType="prepend">
<InputGroupText>
<i className="fa fa-location-arrow" />
</InputGroupText>
</InputGroupAddon>
<Input
placeholder="Địa chỉ"
type="text"
type="textarea"
value={profileAddress}
onChange={(e) => setProfileAddress(e.target.value)}
/>
</InputGroup>
</FormGroup>
<FormGroup row>
{/* <Col>
<Label for="file-logo" sm={2}>Logo</Label>
</Col> */}
<Col sm={10}>
<Input type="file" name="file" id="file-logo" />
<FormText color="muted">
......
......@@ -67,13 +67,8 @@ const DetailProfile = (props) => {
</Col>
</Row>
<Row className="row-grid">
{/* <div className="icon icon-lg icon-shape icon-shape-warning shadow rounded-circle mb-5">
<i className="ni ni-settings" />
</div> */}
{data.profile_product && data.profile_product.length > 0 ? data.profile_product.map(product => {
const onHandleTraceCode = () => {
console.log("product", product);
console.log("click");
history.push({
pathname: `/trace-code/${product.trace_code}`,
state: { product }
......@@ -87,7 +82,6 @@ const DetailProfile = (props) => {
<div className="d-flex justify-content-around">
<QRCode
size={250}
// fgColor="#7f0000"
includeMargin
value={`http://trace.aqbits.net/trace-code/${product.trace_code}`}
imageSettings={{
......
......@@ -12,24 +12,20 @@ import MainBanner from "components/Generals/MainBanner.js";
import DemoNavbar from "components/Navbars/DemoNavbar.js";
import SimpleFooter from "components/Footers/SimpleFooter.js";
import { formatDateTime } from '../../constans/index.js';
import dummyData from '../../data/index.json';
const Tracecode = () => {
const [plainTabs, setPlainTabs] = useState(1);
const history = useHistory();
let state = { ...history.location.state };
const product = state.product;
const toggleNavs = (e, index) => {
e.preventDefault();
setPlainTabs(index);
};
const history = useHistory();
let state = { ...history.location.state };
const product = state.product;
const renderProductInfo = (product) => {
// let product = dummyData.data[0].profile_product;
// product = product[0];
return (
<>
<section className="section bg-secondary">
......
......@@ -174,12 +174,7 @@ export const ProductTable = (props) => {
console.log("props", props);
const onHandleClickAdd = () => {
history.push("/profile/add");
};
const onHandleClickEdit = (productId) => {
console.log("productId", productId);
let detailProduct = props.listProduct.filter(item => item.product_id === productId);
history.push({
pathname: "/profile/add-product",
......@@ -191,7 +186,7 @@ export const ProductTable = (props) => {
// dispatch(props.onDeleteProfile(profileId));
}
const onHandleClickAddProduct = () => {
const onHandleClickAdd = () => {
history.push({
pathname: "/profile/add-product",
// state: { profileId }
......@@ -249,7 +244,7 @@ export const ProductTable = (props) => {
<DropdownItem onClick={() => onHandleClickEdit(product_id)} >
<i className="fa fa-pencil mr-3" />{"Sửa"}
</DropdownItem>
<DropdownItem className="text-danger" onClick={() => console.log('This will fire!')}>
<DropdownItem className="text-danger" onClick={() => onHandleClickDelete(product_id)}>
<i className="fa fa-trash mr-3" />{"Xóa"}
</DropdownItem>
</DropdownMenu>
......@@ -268,7 +263,7 @@ export const ProductTable = (props) => {
<h5 className="mb-3">{"Danh sách sản phẩm"}</h5>
</Col>
<Col className="text-right">
<Button className="btn-1 ml-1" color="success" size="sm" type="button" onClick={() => onHandleClickAddProduct()}>{"Thêm mới sản phẩm"}</Button>
<Button className="btn-1 ml-1" color="success" size="sm" type="button" onClick={() => onHandleClickAdd()}>{"Thêm mới sản phẩm"}</Button>
</Col>
</Row>
</CardHeader>
......@@ -327,23 +322,29 @@ export const ProductDiaryTable = (props) => {
const [modal, setModal] = useState(false);
const [company, setCompany] = useState("");
const [description, setDescription] = useState("");
const [createDate, setCreateDate] = useState("");
const history = useHistory();
// const dispatch = useDispatch();
console.log("props", props);
const toggle = () => setModal(!modal);
const onHandleClickEdit = (id) => {
console.log("id", id);
const toggleModal = (id) => {
let detailProductDiary = props.listProductDiary.filter(item => item.id === id);
history.push({
// pathname: "/profile/add-product",
state: { id, detailProductDiary }
});
if(detailProductDiary.length > 0){
setCompany(detailProductDiary[0].company);
setDescription(detailProductDiary[0].description);
setCreateDate(profileFormatDateTime(detailProductDiary[0].date))
}else {
setCompany("");
setDescription("");
}
setModal(!modal);
};
const onHandleClickDelete = (profileId) => {
const onHandleClickAdd = () => {
}
const onHandleClickDelete = (id) => {
// dispatch(props.onDeleteProfile(profileId));
}
......@@ -389,10 +390,10 @@ export const ProductDiaryTable = (props) => {
<i className="fa fa-ellipsis-h" />
</DropdownToggle>
<DropdownMenu>
<DropdownItem onClick={() => toggle()} >
<DropdownItem onClick={() => toggleModal(id)} >
<i className="fa fa-pencil mr-3" />{"Sửa"}
</DropdownItem>
<DropdownItem className="text-danger" onClick={() => console.log('This will fire!')}>
<DropdownItem className="text-danger" onClick={() => onHandleClickDelete(id)}>
<i className="fa fa-trash mr-3" />{"Xóa"}
</DropdownItem>
</DropdownMenu>
......@@ -412,9 +413,9 @@ export const ProductDiaryTable = (props) => {
</Col>
<Col className="text-right">
<div>
<Button className="btn-1 ml-1" color="success" size="sm" type="button" onClick={() => toggle()}>{"Tạo mới nhật kí"}</Button>
<Modal isOpen={modal} toggle={toggle}>
<ModalHeader toggle={toggle}>Thêm nht kí</ModalHeader>
<Button className="btn-1 ml-1" color="success" size="sm" type="button" onClick={() => toggleModal()}>{"Tạo mới nhật kí"}</Button>
<Modal isOpen={modal} toggle={() => toggleModal()}>
<ModalHeader toggle={() => toggleModal()}>{company ? "Sửa nhật kí" : "Thêm nhật kí"}</ModalHeader>
<ModalBody>
<Form>
<FormGroup>
......@@ -436,11 +437,6 @@ export const ProductDiaryTable = (props) => {
<FormGroup>
<Label for="diary-description">Mô t</Label>
<InputGroup className="mb-4">
{/* <InputGroupAddon addonType="prepend">
<InputGroupText>
<i className="fa fa-book" />
</InputGroupText>
</InputGroupAddon> */}
<Input
placeholder="Mô tả"
type="textarea"
......@@ -449,11 +445,21 @@ export const ProductDiaryTable = (props) => {
/>
</InputGroup>
</FormGroup>
{company ? <FormGroup>
<Label for="diary-date">Thi gian to</Label>
<InputGroup className="mb-4">
<Input
placeholder="Thời gian tạo"
type="text"
value={createDate}
disabled
/>
</InputGroup>
</FormGroup> : <div></div>}
</Form>
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={toggle}>Thêm</Button>
{/* <Button color="secondary" onClick={toggle}>Quay lại</Button> */}
<Button color="primary" size="sm" onClick={onHandleClickAdd}>{company ? "Sửa" : "Thêm mới"}</Button>
</ModalFooter>
</Modal>
</div>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment