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

update modal diary

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