forked from dev-triangle/Wanderlust-frontend
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5739302
commit 9e1e939
Showing
6 changed files
with
95 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<div> | ||
<Dialog | ||
fullWidth={true} | ||
maxWidth={"md"} | ||
PaperProps={{ | ||
sx: { width: "100%", borderRadius: 5, m: 2, minHeight: "60vh" }, | ||
}} | ||
open={open} | ||
onClose={handleClose} | ||
aria-labelledby="alert-dialog-title" | ||
aria-describedby="alert-dialog-description"> | ||
<div className="review_form__container"> | ||
<form className='review_main_form' onSubmit={handleSubmit}> | ||
<input type='text' placeholder='Description'value={description} onChange={(e)=>{setDescription(e.target.value)}}/> | ||
<input type="number" placeholder='Enter your rating out of 10' value={rate} onChange={(e)=>{setRate(e.target.value)}}/> | ||
<button type='submit'>Submit</button> | ||
</form> | ||
</div> | ||
|
||
|
||
</Dialog> | ||
</div> | ||
) | ||
} | ||
|
||
export default ReviewDialog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters