From 9e1e93972d9594f9c24d2aebd736ec177d0b8be8 Mon Sep 17 00:00:00 2001 From: Achyuth Mohan Date: Sat, 3 Dec 2022 17:54:03 +0530 Subject: [PATCH] reviews added --- src/components/ReviewDialog/ReviewDialog.css | 12 ++++ src/components/ReviewDialog/ReviewDialog.js | 59 ++++++++++++++++++++ src/pages/ReviewPage/ReviewCards.js | 6 +- src/pages/ReviewPage/ReviewPage.css | 4 ++ src/pages/ReviewPage/ReviewPage.js | 18 +++++- src/utils/axios.js | 2 +- 6 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 src/components/ReviewDialog/ReviewDialog.css create mode 100644 src/components/ReviewDialog/ReviewDialog.js diff --git a/src/components/ReviewDialog/ReviewDialog.css b/src/components/ReviewDialog/ReviewDialog.css new file mode 100644 index 0000000..3e20a3f --- /dev/null +++ b/src/components/ReviewDialog/ReviewDialog.css @@ -0,0 +1,12 @@ +.review_form__container{ + width: 100%; + display: flex; + justify-content: center; + align-items: center; + padding: 3rem; +} +.review_main_form{ + display: flex; + flex-direction: column; + gap: 2rem; +} \ No newline at end of file diff --git a/src/components/ReviewDialog/ReviewDialog.js b/src/components/ReviewDialog/ReviewDialog.js new file mode 100644 index 0000000..ee72d40 --- /dev/null +++ b/src/components/ReviewDialog/ReviewDialog.js @@ -0,0 +1,59 @@ +import React, { useState } from 'react' +import './ReviewDialog.css' +import Dialog from '@mui/material/Dialog'; +import axiosInstance from '../../utils/axios'; +import { useEffect } from 'react'; +import baseUrl from '../../utils/Urls'; +const ReviewDialog = ({open,handleClose}) => { + const[description,setDescription]=useState('') + const[rate,setRate]=useState(0) + const[currUser,setCurrUser]=useState('') + const[currUserId,setCurrUserId]=useState() + + useEffect(()=>{ + axiosInstance.get(`${baseUrl}/current-user/`).then((response)=>{ + setCurrUser(response.data.username) + setCurrUserId(response.data.id) + },(error)=>{ + + }) + },[]) + const handleSubmit=()=>{ + axiosInstance.post(`${baseUrl}/reviews/`,{ + desc: description, + rate: rate, + user_name: currUser, + user_foreign: currUserId + }).then((response)=>{ + console.log(response) + },(error)=>{ + + }) + } + return ( +
+ +
+
+ {setDescription(e.target.value)}}/> + {setRate(e.target.value)}}/> + +
+
+ + +
+
+ ) +} + +export default ReviewDialog \ No newline at end of file diff --git a/src/pages/ReviewPage/ReviewCards.js b/src/pages/ReviewPage/ReviewCards.js index 44245be..88c2f4e 100644 --- a/src/pages/ReviewPage/ReviewCards.js +++ b/src/pages/ReviewPage/ReviewCards.js @@ -1,6 +1,6 @@ import React from 'react' import './ReviewPage.css' -function ReviewCards({ desc,rate }) { +function ReviewCards({ desc,rate,name }) { return (
@@ -17,8 +17,8 @@ function ReviewCards({ desc,rate }) {
-
Strugatsky Brothers
-
Rating {rate}
+
{name}
+
Rating {rate}
diff --git a/src/pages/ReviewPage/ReviewPage.css b/src/pages/ReviewPage/ReviewPage.css index 172772d..a147c87 100644 --- a/src/pages/ReviewPage/ReviewPage.css +++ b/src/pages/ReviewPage/ReviewPage.css @@ -8,6 +8,10 @@ section.t-bq-section { padding: 30px; margin-bottom: 60px; } +.rating__text{ + font-size: 1rem; + color: cornflowerblue; +} .t-bq-wrapper.t-bq-wrapper-boxed { max-width: 576px; diff --git a/src/pages/ReviewPage/ReviewPage.js b/src/pages/ReviewPage/ReviewPage.js index 2ce575b..dbb1b8d 100644 --- a/src/pages/ReviewPage/ReviewPage.js +++ b/src/pages/ReviewPage/ReviewPage.js @@ -4,22 +4,36 @@ import './ReviewPage.css' import axios from 'axios' import baseUrl from '../../utils/Urls' import ReviewCards from './ReviewCards' +import ReviewDialog from '../../components/ReviewDialog/ReviewDialog' function ReviewPage() { const[reviews,setReviews]=useState([]) +const[open,setOpen]=useState(false) + +const handleClose=()=>{ + setOpen(false) +} +const handleClickOpen = () => { + setOpen(true); +} useEffect(()=>{ axios.get(`${baseUrl}/reviews/`).then((response)=>{ setReviews(response.data) }) },[]) - return ( +
+ { + (localStorage.getItem('refresh_token'))?(( )):(( null)) + } { reviews.map((item)=>{ return( - + ) }) } diff --git a/src/utils/axios.js b/src/utils/axios.js index 0f8e8f7..310c7a9 100644 --- a/src/utils/axios.js +++ b/src/utils/axios.js @@ -3,7 +3,7 @@ import baseUrl from "./Urls"; const axiosInstance= axios.create({ baseURL: "http://127.0.0.1:8000", - timeout:5000, + timeout:30000, headers:{ Authorization: localStorage.getItem('access_token') ? 'Bearer ' + localStorage.getItem('access_token')