diff --git a/src/pages/LocationDetail/index.tsx b/src/pages/LocationDetail/index.tsx index 9862b94..9c15187 100644 --- a/src/pages/LocationDetail/index.tsx +++ b/src/pages/LocationDetail/index.tsx @@ -86,7 +86,12 @@ function LocationDetail() { setCurrentUserReview(res.data) setPageState({ ...pageState, enable_post: false}) } catch (error) { - alert(error) + console.log(error) + let err = error as IHttpResponse; + if(err.status == 404) { + return + } + alert(err.error.response.data.message) } } @@ -390,67 +395,77 @@ function LocationDetail() { }
-
-
Sort by:
- setPageState({ ...pageState, show_sort: !pageState.show_sort })}> -

{pageState.critic_filter_name}

- -
-
- {SORT_TYPE.map((x, index) => ( - onChangeCriticsSort(e, x, index)} className={'block pt-1 capitalize'}>{x} - ))} -
-
-
- - {locationDetail.critics_review.map(x => ( -
-
-
- {x.score} -
-
-
-
-
-
- - + {locationDetail.critics_review.length > 0 ? + <> + -
- -
- -
-
-
- - -
Video
-
+
+ + {locationDetail.critics_review.map(x => ( +
+
+
+ {x.score} +
+
+
+
+
+
+ + + +
+ +
+ +
+
- -
-
- ))} + ))} + + + : + <> + No Critics review to display + + + }
diff --git a/src/services/auth.ts b/src/services/auth.ts index c678ac2..9221e5a 100644 --- a/src/services/auth.ts +++ b/src/services/auth.ts @@ -2,7 +2,7 @@ import { AxiosError } from "axios"; import { LOGIN_URI, SIGNUP_URI } from "../constants/api"; import { client } from "./config"; -const initialState: IEmptyResponseState = { +const initialState: IHttpResponse = { data: null, error: AxiosError } diff --git a/src/services/review.ts b/src/services/review.ts index 7102a49..5810f3e 100644 --- a/src/services/review.ts +++ b/src/services/review.ts @@ -2,9 +2,10 @@ import { AxiosError } from "axios" import { client } from "./config"; import { GET_CURRENT_USER_REVIEW_LOCATION_URI, POST_REVIEW_LOCATION_URI } from "../constants/api"; -const initialState: IEmptyResponseState = { +const initialState: IHttpResponse = { data: null, - error: AxiosError + error: AxiosError, + status: 0, } interface postReviewLocationReq { @@ -29,7 +30,7 @@ async function postReviewLocation(req: postReviewLocationReq) { } } -async function getCurrentUserLocationReviewService(location_id: number) { +async function getCurrentUserLocationReviewService(location_id: number): Promise { const newState = { ...initialState }; try { const response = await client({ method: 'GET', url: `${GET_CURRENT_USER_REVIEW_LOCATION_URI}/${location_id}`, withCredentials: true}) @@ -37,7 +38,10 @@ async function getCurrentUserLocationReviewService(location_id: number) { newState.error = null return newState } catch (err) { - throw err; + let error = err as AxiosError; + newState.error = error + newState.status = error.response?.status; + throw(newState) } } diff --git a/src/types/common.ts b/src/types/common.ts index 9d0fc2e..1ae1d49 100644 --- a/src/types/common.ts +++ b/src/types/common.ts @@ -7,7 +7,8 @@ interface GetRequestPagination { } -interface IEmptyResponseState { +interface IHttpResponse { data: any, error: any, + status?: number, }; \ No newline at end of file