Commit ce269b19 authored by Mai Thanh Cong's avatar Mai Thanh Cong

update UI profile, trace-code

parent 4ddc8971
import React from 'react'; import React from 'react';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { Routes } from '../../routes'; import { Routes } from '../../routes';
import dummyData from '../../data/index.json';
const Home = () => { const Home = () => {
return ( return (
<ul> <ul>
<Link to={Routes.Profile.path}>Profile</Link> <Link to={Routes.Profile.path + `/${dummyData.data.map(data => data.code)}` }>Profile</Link>
</ul> </ul>
); );
} }
......
...@@ -10,7 +10,7 @@ const Profile = () => { ...@@ -10,7 +10,7 @@ const Profile = () => {
dummyData.data && dummyData.data.length > 0 ? dummyData.data && dummyData.data.length > 0 ?
dummyData.data.map((data, key) => { dummyData.data.map((data, key) => {
return ( return (
<Card className="px-0 px-md-4 py-0 border-0"> <Card className="px-0 px-md-4 py-0 border-0" key={key}>
<Card.Body> <Card.Body>
<Row className="mb-2"> <Row className="mb-2">
<Col xs={8}> <Col xs={8}>
...@@ -36,7 +36,7 @@ const Profile = () => { ...@@ -36,7 +36,7 @@ const Profile = () => {
<div>{data.profile_product && data.profile_product.length > 0 ? data.profile_product.map(product => { <div>{data.profile_product && data.profile_product.length > 0 ? data.profile_product.map(product => {
const onHandleTraceCode = () => { const onHandleTraceCode = () => {
history.push({ history.push({
pathname: Routes.TraceCode.path, pathname: Routes.TraceCode.path + `/${product.trace_code}`,
state: { product } state: { product }
}); });
} }
......
...@@ -8,21 +8,20 @@ const TraceCode = () => { ...@@ -8,21 +8,20 @@ const TraceCode = () => {
const history = useHistory(); const history = useHistory();
let state = { ...history.location.state }; let state = { ...history.location.state };
const product = state.product; const product = state.product;
console.log("product", product);
return ( return (
<Card className="px-0 px-md-4 py-0 border-0"> <Card className="px-0 px-md-4 py-0 border-0" key={product.product_id}>
<Card.Header> <Card.Header>
<div className="text-center"> <div className="text-center">
<img className="mb-3" src={window.location.origin + product.image} alt="product" /> <img className="mb-3" src={window.location.origin + product.image} alt="product" />
<div className="h4 font-weight-bold mb-3">{product.name}</div> <div className="h4 font-weight-bold mb-3">{product.name}</div>
<div className="mb-3">Mã sn phm {product.trace_code}</div> <div className="mb-3">Mã sn phm <span className="font-weight-bold">{product.trace_code}</span></div>
<div className="mb-3">Xut x {product.origin}</div> <div className="mb-3">Xut x <span className="font-weight-bold">{product.origin}</span></div>
<div className="h5 mb-3" style={{ color: '#33CC66' }}>Giá: {product.cost}</div> <div className="h5 mb-3" style={{ color: '#33CC66' }}>Giá: {product.cost}</div>
</div> </div>
</Card.Header> </Card.Header>
<Card.Body> <Card.Body>
<div className="main-container"> <div className="main-container">
<Row className="wrapper-search py-4"> <div className="wrapper-search py-4">
<Tab.Container defaultActiveKey="general-information"> <Tab.Container defaultActiveKey="general-information">
<Row> <Row>
<Col xs={12}> <Col xs={12}>
...@@ -59,16 +58,20 @@ const TraceCode = () => { ...@@ -59,16 +58,20 @@ const TraceCode = () => {
<Tab.Pane eventKey="product-chain-diary"> <Tab.Pane eventKey="product-chain-diary">
{product.product_chain_diary.map(diary => ( {product.product_chain_diary.map(diary => (
<div> <div>
<Row className="h6 mt-3">{diary.company}</Row> <div className="h6 mt-3">{diary.company}</div>
<Row className="mb-3"> <Row className="mb-3">
<Col>{formatDateTime(diary.date)}</Col> <Col>{formatDateTime(diary.date)}</Col>
<Col>{diary.description}</Col> <Col>{diary.description}</Col>
<Col></Col>
<Col></Col>
<Col></Col>
<Col></Col>
</Row> </Row>
</div> </div>
))} ))}
</Tab.Pane> </Tab.Pane>
<Tab.Pane eventKey="product-certification"> <Tab.Pane eventKey="product-certification">
{product.product_certification.map(certificate => ( {product.product_certification.map((certificate) => (
<div> <div>
<div className="h6 mt-3 mb-3">{certificate.certification_information}</div> <div className="h6 mt-3 mb-3">{certificate.certification_information}</div>
<img src={window.location.origin + certificate.image} alt="certificate" height="250px" /> <img src={window.location.origin + certificate.image} alt="certificate" height="250px" />
...@@ -79,7 +82,7 @@ const TraceCode = () => { ...@@ -79,7 +82,7 @@ const TraceCode = () => {
</Col> </Col>
</Row> </Row>
</Tab.Container> </Tab.Container>
</Row> </div>
</div> </div>
</Card.Body> </Card.Body>
</Card> </Card>
......
export const Routes = { export const Routes = {
Profile: { path: "/profile" }, Profile: { path: "/profile" },
TraceCode: { path: `/trace-code/` } TraceCode: { path: "/trace-code" }
}; };
\ No newline at end of file
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