Commit 083630ad authored by Mai Thanh Cong's avatar Mai Thanh Cong

refactor class DemoNavbar to function component

parent da26ae66
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/ */
import React from "react"; import React, { useState, useEffect } from "react";
import { Link } from "react-router-dom"; import { Link, useHistory } from "react-router-dom";
// JavaScript plugin that hides or shows a component based on your scroll // JavaScript plugin that hides or shows a component based on your scroll
import Headroom from "headroom.js"; import Headroom from "headroom.js";
// reactstrap components // reactstrap components
...@@ -39,30 +39,44 @@ import { ...@@ -39,30 +39,44 @@ import {
UncontrolledTooltip UncontrolledTooltip
} from "reactstrap"; } from "reactstrap";
class DemoNavbar extends React.Component { const DemoNavbar = () => {
componentDidMount() { // componentDidMount() {
let headroom = new Headroom(document.getElementById("navbar-main")); // let headroom = new Headroom(document.getElementById("navbar-main"));
// initialise // // initialise
headroom.init(); // headroom.init();
} // }
state = { // state = {
collapseClasses: "", // collapseClasses: "",
collapseOpen: false // collapseOpen: false
}; // };
const [collapseClasses, setCollapseClasses] = useState("");
const history = useHistory();
onExiting = () => { const onExiting = () => {
this.setState({ setCollapseClasses("collapsing-out");
collapseClasses: "collapsing-out" // this.setState({
}); // collapseClasses: "collapsing-out"
// });
}; };
onExited = () => { const onExited = () => {
this.setState({ setCollapseClasses("");
collapseClasses: "" // this.setState({
}); // collapseClasses: ""
// });
}; };
render() { const onHandleGoToHome = () => {
history.push("/");
}
useEffect(() => {
let headroom = new Headroom(document.getElementById("navbar-main"));
headroom.init();
}, []);
// render() {
return ( return (
<> <>
<header className="header-global"> <header className="header-global">
...@@ -84,9 +98,9 @@ class DemoNavbar extends React.Component { ...@@ -84,9 +98,9 @@ class DemoNavbar extends React.Component {
<UncontrolledCollapse <UncontrolledCollapse
toggler="#navbar_global" toggler="#navbar_global"
navbar navbar
className={this.state.collapseClasses} className={collapseClasses}
onExiting={this.onExiting} onExiting={onExiting}
onExited={this.onExited} onExited={onExited}
> >
<div className="navbar-collapse-header"> <div className="navbar-collapse-header">
<Row> <Row>
...@@ -110,7 +124,7 @@ class DemoNavbar extends React.Component { ...@@ -110,7 +124,7 @@ class DemoNavbar extends React.Component {
<UncontrolledDropdown nav> <UncontrolledDropdown nav>
<DropdownToggle nav> <DropdownToggle nav>
<i className="ni ni-ui-04 d-lg-none mr-1" /> <i className="ni ni-ui-04 d-lg-none mr-1" />
<span className="nav-link-inner--text">Trang ch</span> <span className="nav-link-inner--text" onClick={onHandleGoToHome}>Trang ch</span>
</DropdownToggle> </DropdownToggle>
{/* <DropdownMenu className="dropdown-menu-xl"> {/* <DropdownMenu className="dropdown-menu-xl">
<div className="dropdown-menu-inner"> <div className="dropdown-menu-inner">
...@@ -264,7 +278,7 @@ class DemoNavbar extends React.Component { ...@@ -264,7 +278,7 @@ class DemoNavbar extends React.Component {
</header> </header>
</> </>
); );
} // }
} }
export default DemoNavbar; export default DemoNavbar;
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
"code": "KIS", "code": "KIS",
"name": "Công ty TNHH sáng tạo KIS", "name": "Công ty TNHH sáng tạo KIS",
"logo": "/image/logo/kis-academy.jpg", "logo": "/image/logo/kis-academy.jpg",
"address": "Technosoft Số 8 ngõ 15 Duy Tân, Cầu Giấy, Hà Nội", "address": "Tầng 5 - Technosoft Số 8 ngõ 15 Duy Tân, Dịch Vọng Hậu, Cầu Giấy, Hà Nội",
"phone_number": "024 3795 5218", "phone_number": "024 3795 5218",
"qr_code": "/image/qrcode/qr-code.png", "qr_code": "/image/qrcode/qr-code.png",
"created_at": 1624870109921, "created_at": 1624870109921,
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
"cost": "Liên hệ", "cost": "Liên hệ",
"origin": "Việt Nam", "origin": "Việt Nam",
"image": "/image/product/tom-su.jpg", "image": "/image/product/tom-su.jpg",
"description": "Tôm nước ngọt", "description": "Tôm càng xanh là loại thủy sản sống được cả ở vùng nước lợ và nước ngọt",
"growing_conditions": "Nuôi trồng tại vùng nguyên liệu tôm, cơ sở chế biến: Tỉnh Trà Vinh", "growing_conditions": "Nuôi trồng tại vùng nguyên liệu tôm, cơ sở chế biến: Tỉnh Trà Vinh",
"product_chain_diary": [ "product_chain_diary": [
{ {
......
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