update page after submit review
This commit is contained in:
parent
788610292e
commit
9c4fc6ddcd
@ -31,6 +31,7 @@ function LocationDetail() {
|
||||
const [locationImages, setLocationImages] = useState<LocationResponse>(emptyLocationResponse())
|
||||
const [currentUserReview, setCurrentUserReview] = useState<CurrentUserLocationReviews>()
|
||||
const [lightboxOpen, setLightboxOpen] = useState<boolean>(false)
|
||||
const[updatePage, setUpdatePage] = useState<boolean>(true)
|
||||
const [pageState, setPageState] = useState({
|
||||
critic_filter_name: 'highest rated',
|
||||
critic_filter_type: 0,
|
||||
@ -74,13 +75,14 @@ function LocationDetail() {
|
||||
const res = await getImagesByLocationService({ page: 1, page_size: 15, location_id: Number(id) })
|
||||
res.data.images.push({ src: thumbnail })
|
||||
setLocationImages(res.data)
|
||||
setUpdatePage(false)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
setIsLoading(false)
|
||||
}
|
||||
|
||||
async function getCurrentUserLocationReview() {
|
||||
async function getCurrentUserLocationReview(): Promise<void> {
|
||||
try {
|
||||
const res = await getCurrentUserLocationReviewService(Number(id))
|
||||
setCurrentUserReview(res.data)
|
||||
@ -165,6 +167,7 @@ function LocationDetail() {
|
||||
created_at: data.created_at,
|
||||
updated_at: data.updated_at
|
||||
})
|
||||
setUpdatePage(true)
|
||||
} catch (error) {
|
||||
let err = error as AxiosError;
|
||||
console.log(err)
|
||||
@ -184,8 +187,13 @@ function LocationDetail() {
|
||||
|
||||
useEffect(() => {
|
||||
getCurrentUserLocationReview()
|
||||
getLocationDetail()
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if(updatePage) {
|
||||
getLocationDetail()
|
||||
}
|
||||
}, [updatePage])
|
||||
|
||||
return (
|
||||
<>
|
||||
|
Loading…
Reference in New Issue
Block a user