조민지

feat: react hook 세팅

...@@ -6,12 +6,13 @@ import { tdArray } from "variables/Variables.jsx"; ...@@ -6,12 +6,13 @@ import { tdArray } from "variables/Variables.jsx";
6 6
7 const thArray = ['유저ID', '대여 시각', '반납 시각', '대여 시간', '이동 거리', '대여 금액']; 7 const thArray = ['유저ID', '대여 시각', '반납 시각', '대여 시간', '이동 거리', '대여 금액'];
8 8
9 -const KickboardHistoryTable = () => { 9 +const KickboardHistoryTable = (props) => {
10 + const {kbId} = props;
10 11
11 // category="Here is a subtitle for this table" 12 // category="Here is a subtitle for this table"
12 return ( 13 return (
13 <Card 14 <Card
14 - title="000000번 킥보드 사용자 히스토리" 15 + title={`${kbId}번 킥보드 사용자 히스토리`}
15 ctTableFullWidth 16 ctTableFullWidth
16 ctTableResponsive 17 ctTableResponsive
17 content={ 18 content={
......
...@@ -6,7 +6,7 @@ import moment from "moment"; ...@@ -6,7 +6,7 @@ import moment from "moment";
6 6
7 // border: 1px solid #E3E3E3; 7 // border: 1px solid #E3E3E3;
8 const KickboardButton = styled.div` 8 const KickboardButton = styled.div`
9 - font-size: 16px; 9 + font-size: 15px;
10 background-color: #e7e7e7; 10 background-color: #e7e7e7;
11 border-radius: 4px; 11 border-radius: 4px;
12 color: #565656; 12 color: #565656;
...@@ -47,12 +47,13 @@ const kickboardDataKey = { ...@@ -47,12 +47,13 @@ const kickboardDataKey = {
47 l: '최근 업데이트 시각', 47 l: '최근 업데이트 시각',
48 }; 48 };
49 49
50 -const KickboardStatusCard = () => { 50 +const KickboardStatusCard = (props) => {
51 + const {kbId} = props;
51 const getStats = `마지막 업데이트 ${moment().format("YYYY/MM/DD hh:mm")}`; 52 const getStats = `마지막 업데이트 ${moment().format("YYYY/MM/DD hh:mm")}`;
52 53
53 return ( 54 return (
54 <Card 55 <Card
55 - title={'000000번 킥보드'} 56 + title={`${kbId}번 킥보드`}
56 stats={getStats} 57 stats={getStats}
57 statsIcon="fa fa-history" 58 statsIcon="fa fa-history"
58 content={ 59 content={
......
...@@ -9,12 +9,13 @@ const UserData = styled.div` ...@@ -9,12 +9,13 @@ const UserData = styled.div`
9 font-size: 15px; 9 font-size: 15px;
10 `; 10 `;
11 11
12 -const UserDataCard = () => { 12 +const UserDataCard = (props) => {
13 const getStats = `마지막 업데이트 ${moment().format("YYYY/MM/DD hh:mm")}`; 13 const getStats = `마지막 업데이트 ${moment().format("YYYY/MM/DD hh:mm")}`;
14 + const {userId} = props;
14 15
15 return ( 16 return (
16 <Card 17 <Card
17 - title={'000000번 사용자'} 18 + title={`${userId}번 사용자`}
18 stats={getStats} 19 stats={getStats}
19 statsIcon="fa fa-history" 20 statsIcon="fa fa-history"
20 content={ 21 content={
......
1 import React, { Component } from "react"; 1 import React, { Component } from "react";
2 import { Grid, Row, Col, Table } from "react-bootstrap"; 2 import { Grid, Row, Col, Table } from "react-bootstrap";
3 - 3 +import styled from "styled-components";
4 import Card from "components/Card/Card.jsx"; 4 import Card from "components/Card/Card.jsx";
5 import { tdArray } from "variables/Variables.jsx"; 5 import { tdArray } from "variables/Variables.jsx";
6 6
7 const thArray = ['킥보드 시리얼 번호', '대여 시각', '반납 시각', '대여 시간', '이동 거리', '대여 금액']; 7 const thArray = ['킥보드 시리얼 번호', '대여 시각', '반납 시각', '대여 시간', '이동 거리', '대여 금액'];
8 8
9 -class UserHistoryCard extends Component { 9 +const UserHistoryCard = (props) => {
10 - render() { 10 + const {userId} = props;
11 - return ( 11 +
12 - <Card 12 + return (
13 - title="Striped Table with Hover" 13 + <Card
14 - category="Here is a subtitle for this table" 14 + title={`${userId}번 사용자 킥보드 사용 히스토리`}
15 - ctTableFullWidth 15 + ctTableFullWidth
16 - ctTableResponsive 16 + ctTableResponsive
17 - content={ 17 + content={
18 - <Table striped hover> 18 + <Table striped hover>
19 - <thead> 19 + <thead>
20 - <tr> 20 + <tr>
21 - {thArray.map((prop, key) => { 21 + {thArray.map((prop, key) => {
22 - return <th key={key}>{prop}</th>; 22 + return <th key={key}>{prop}</th>;
23 - })}
24 - </tr>
25 - </thead>
26 - <tbody>
27 - {tdArray.map((prop, key) => {
28 - return (
29 - <tr key={key}>
30 - {prop.map((prop, key) => {
31 - return <td key={key}>{prop}</td>;
32 - })}
33 - </tr>
34 - );
35 })} 23 })}
36 - </tbody> 24 + </tr>
37 - </Table> 25 + </thead>
38 - } 26 + <tbody>
39 - /> 27 + {tdArray.map((prop, key) => {
40 - ); 28 + return (
41 - } 29 + <tr key={key}>
42 -} 30 + {prop.map((prop, key) => {
31 + return <td key={key}>{prop}</td>;
32 + })}
33 + </tr>
34 + );
35 + })}
36 + </tbody>
37 + </Table>
38 + }
39 + />
40 + );
41 +};
43 42
44 export default UserHistoryCard; 43 export default UserHistoryCard;
......
1 -import React from "react"; 1 +import React, {useState, useEffect} from "react";
2 import {Grid, Row, Col} from "react-bootstrap"; 2 import {Grid, Row, Col} from "react-bootstrap";
3 3
4 import GoogleMapCard from '../components/Kickboard/GoogleMapCard'; 4 import GoogleMapCard from '../components/Kickboard/GoogleMapCard';
...@@ -7,6 +7,8 @@ import KickboardHistoryTable from '../components/Kickboard/KickboardHistoryTable ...@@ -7,6 +7,8 @@ import KickboardHistoryTable from '../components/Kickboard/KickboardHistoryTable
7 import SearchButton from '../components/Kickboard/SearchButton'; 7 import SearchButton from '../components/Kickboard/SearchButton';
8 8
9 const Kickboard = () => { 9 const Kickboard = () => {
10 + const [kbId, setKbId] = useState('000000');
11 +
10 // 여기 API 요청 12 // 여기 API 요청
11 return ( 13 return (
12 <div className="content"> 14 <div className="content">
...@@ -21,17 +23,17 @@ const Kickboard = () => { ...@@ -21,17 +23,17 @@ const Kickboard = () => {
21 <GoogleMapCard/> 23 <GoogleMapCard/>
22 </Col> 24 </Col>
23 <Col md={6}> 25 <Col md={6}>
24 - <KickboardStatusCard/> 26 + <KickboardStatusCard kbId={kbId}/>
25 </Col> 27 </Col>
26 </Row> 28 </Row>
27 <Row> 29 <Row>
28 <Col md={12}> 30 <Col md={12}>
29 - <KickboardHistoryTable/> 31 + <KickboardHistoryTable kbId={kbId}/>
30 </Col> 32 </Col>
31 </Row> 33 </Row>
32 </Grid> 34 </Grid>
33 </div> 35 </div>
34 ); 36 );
35 -} 37 +};
36 38
37 export default Kickboard; 39 export default Kickboard;
......
...@@ -4,8 +4,8 @@ import UserDataCard from '../components/UserHistory/UserDataCard'; ...@@ -4,8 +4,8 @@ import UserDataCard from '../components/UserHistory/UserDataCard';
4 import UserHistoryCard from '../components/UserHistory/UserHistoryCard'; 4 import UserHistoryCard from '../components/UserHistory/UserHistoryCard';
5 import SearchButton from "../components/UserHistory/SearchButton"; 5 import SearchButton from "../components/UserHistory/SearchButton";
6 6
7 -const UserHistory = (props) => { 7 +const UserHistory = () => {
8 - const [userId, setUserId] = useState('0'); 8 + const [userId, setUserId] = useState(0);
9 9
10 useEffect(() => { 10 useEffect(() => {
11 // componentDidMount > 쿼리 검사하기 11 // componentDidMount > 쿼리 검사하기
...@@ -21,10 +21,10 @@ const UserHistory = (props) => { ...@@ -21,10 +21,10 @@ const UserHistory = (props) => {
21 </Row> 21 </Row>
22 <Row> 22 <Row>
23 <Col md={12}> 23 <Col md={12}>
24 - <UserDataCard/> 24 + <UserDataCard userId={userId}/>
25 </Col> 25 </Col>
26 <Col md={12}> 26 <Col md={12}>
27 - <UserHistoryCard/> 27 + <UserHistoryCard userId={userId}/>
28 </Col> 28 </Col>
29 </Row> 29 </Row>
30 </Grid> 30 </Grid>
......