Changeset 63f5ced for frontend/src/Dashboard
- Timestamp:
- 08/24/22 17:11:52 (2 years ago)
- Branches:
- master
- Children:
- d86edb7
- Parents:
- a569b7c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
frontend/src/Dashboard/Review.js
ra569b7c r63f5ced 1 1 import React, {useEffect, useState} from 'react' 2 import {Button, Card, Input, List, notification, Rate, Spin, Tooltip} from "antd";2 import {Button, Card, Input, List, notification, Pagination, Rate, Spin, Tooltip} from "antd"; 3 3 import axios from "axios"; 4 4 import env from "../env"; … … 6 6 7 7 const Review = props => { 8 const [restaurant, setRestaurant] = useState({}); 8 const [reviews, setReviews] = useState([]); 9 const [restaurant, setRestaurant] = useState({}) 9 10 const [loading, setLoading] = useState(true); 11 const [reviewSize, setReviewSize] = useState(0) 12 10 13 11 14 useEffect(()=> { … … 18 21 },[props.refresh]) 19 22 20 const getRestaurant = () => { 23 24 const getRestaurant = (pg = 1, size = 5) => { 25 axios.get(env.api + 'Reviews/count',).then(res=>{ 26 setReviewSize(res.data); 27 }); 21 28 axios.get(env.api + 'Restaurants').then(res=>{ 22 29 setRestaurant(res.data); 23 setLoading(false); 30 console.log(pg, size) 31 axios.get(env.api + 'Reviews',{params:{page:pg-1, pageSize: size}}).then(res=>{ 32 setReviews(res.data); 33 setLoading(false); 34 }); 24 35 }); 25 36 } … … 45 56 <div> 46 57 <div style={{backgroundColor: 'white',padding:'10px', border:'1px solid lightgray', borderTop: 'none'}}> 47 <h3>Средна оценка: <Rate disabled allowHalf value={restaurant.averageReview}/> од вкупно {re staurant.reviews.length} оценки</h3>58 <h3>Средна оценка: <Rate disabled allowHalf value={restaurant.averageReview}/> од вкупно {reviewSize} оценки</h3> 48 59 </div> 49 <List dataSource={re staurant.reviews} itemLayout={'horizontal'} locale={{emptyText:'Нема оставени оценки за овој ресторан'}}60 <List dataSource={reviews} itemLayout={'horizontal'} locale={{emptyText:'Нема оставени оценки за овој ресторан'}} 50 61 renderItem={item => ( 51 62 <Card title={item.title} style={{width:'98%',backgroundColor:'white',margin:'1%'}}> … … 55 66 </Card> 56 67 )}/> 68 <div style={{paddingBottom:'20px', textAlign:'center'}}> 69 <Pagination defaultPageSize={5} total={reviewSize} onChange={(pg,size)=>getRestaurant(pg,size)} showSizeChanger pageSizeOptions={[5,10,20,50]}/> 70 </div> 57 71 </div> 58 59 72 } 60 73 </div>
Note:
See TracChangeset
for help on using the changeset viewer.