-
-
{x.critic_rating}
-
-
+ { x.critic_score !== -1 &&
+
+
+
{x.critic_score === -1 ? "NR" : x.critic_score}
+
+
critic score ({x.critic_count})
-
critic score ({x.critic_voters})
-
-
-
-
{x.user_rating}
-
-
+ }
+ { x.user_score !== -1 &&
+
+
+
{x.user_score === -1 ? "NR" : x.user_score}
+
+
user score ({x.user_count})
-
user score ({x.user_voters})
-
+ }
))}
@@ -187,7 +206,7 @@ function Home() {
-
+ >
)
}
diff --git a/src/routes/index.tsx b/src/routes/index.tsx
new file mode 100644
index 0000000..a734fd9
--- /dev/null
+++ b/src/routes/index.tsx
@@ -0,0 +1,13 @@
+import {
+ Home
+} from '../pages';
+
+const routes = [
+ {
+ path: "/",
+ name: "Home",
+ element:
+ }
+]
+
+export default routes;
\ No newline at end of file
diff --git a/src/services/config.ts b/src/services/config.ts
new file mode 100644
index 0000000..1752435
--- /dev/null
+++ b/src/services/config.ts
@@ -0,0 +1,19 @@
+import axios, { AxiosPromise, AxiosRequestConfig } from "axios";
+import {BASE_URL} from '../constants/api'
+
+export const client = (props: AxiosRequestConfig): AxiosPromise => axios({
+ method: props.method,
+ baseURL: `${BASE_URL}`,
+ url: props.url,
+ headers: props.headers,
+ data: props.data
+})
+
+// export const authClient = (props: AxiosRequestConfig) => axios({
+// method: props.method,
+// baseURL: `${BASE_URL}`,
+// url: props.url,
+// headers: {
+// 'Authorization':
+// }
+// })
\ No newline at end of file
diff --git a/src/services/index.ts b/src/services/index.ts
new file mode 100644
index 0000000..984f465
--- /dev/null
+++ b/src/services/index.ts
@@ -0,0 +1,6 @@
+import { getListLocations, getListRecentLocationsRatings } from "./locations";
+
+export {
+ getListLocations,
+ getListRecentLocationsRatings
+}
\ No newline at end of file
diff --git a/src/services/locations.ts b/src/services/locations.ts
new file mode 100644
index 0000000..8f13375
--- /dev/null
+++ b/src/services/locations.ts
@@ -0,0 +1,54 @@
+import { GET_LIST_LOCATIONS_URI, GET_LIST_RECENT_LOCATIONS_RATING_URI } from "../constants/api";
+import { client } from "./config";
+import statusCode from "./status-code";
+
+const initialState: any = {
+ data: null,
+ error: null
+}
+
+type getListLocationsArg = {
+ page: number,
+ page_size: number
+}
+
+async function getListLocations ({ page, page_size}: getListLocationsArg) {
+ const newState = {...initialState};
+ const url = `${GET_LIST_LOCATIONS_URI}?page=${page}&page_size=${page_size}`
+ try {
+ const response = await client({method: 'GET', url: url})
+ switch (response.request.status) {
+ case statusCode.OK:
+ newState.data = response.data;
+ return newState;
+ default:
+ newState.error = response.data;
+ return newState
+ }
+ } catch (error) {
+ console.log(error)
+ }
+}
+
+async function getListRecentLocationsRatings (page_size: Number) {
+ const newState = {...initialState};
+ const url = `${GET_LIST_RECENT_LOCATIONS_RATING_URI}?page_size=${page_size}`
+ try {
+ const response = await client({method: 'GET', url: url})
+ switch (response.request.status) {
+ case statusCode.OK:
+ newState.data = response.data;
+ return newState;
+ default:
+ newState.error = response.data;
+ return newState
+ }
+ } catch (error) {
+ console.log(error)
+ }
+}
+
+export {
+ getListLocations,
+ getListRecentLocationsRatings
+}
\ No newline at end of file
diff --git a/src/services/status-code.ts b/src/services/status-code.ts
new file mode 100644
index 0000000..a44f393
--- /dev/null
+++ b/src/services/status-code.ts
@@ -0,0 +1,10 @@
+export default {
+ OK: 200,
+ CREATED: 201,
+ ACCEPTED: 202,
+ BAD_REQUEST: 400,
+ UNAUTHORIZED: 401,
+ NOT_ALLOWED: 405,
+ NOT_FOUND: 404,
+ SERVER_ERROR: 500,
+};
diff --git a/src/types/common.ts b/src/types/common.ts
new file mode 100644
index 0000000..14092c2
--- /dev/null
+++ b/src/types/common.ts
@@ -0,0 +1,3 @@
+type BaseNullValueRes = { valid: boolean };
+type NullValueRes
= BaseNullValueRes & Record
+
diff --git a/yarn.lock b/yarn.lock
index a775479..fe752a1 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -434,6 +434,11 @@
"@prefresh/utils" "^1.2.0"
"@rollup/pluginutils" "^4.2.1"
+"@remix-run/router@1.9.0":
+ version "1.9.0"
+ resolved "https://registry.yarnpkg.com/@remix-run/router/-/router-1.9.0.tgz#9033238b41c4cbe1e961eccb3f79e2c588328cf6"
+ integrity sha512-bV63itrKBC0zdT27qYm6SDZHlkXwFL1xMBuhkn+X7l0+IIhNaH5wuuvZKp6eKhCD4KFhujhfhCT1YxXW6esUIA==
+
"@rollup/pluginutils@^4.1.1", "@rollup/pluginutils@^4.2.1":
version "4.2.1"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-4.2.1.tgz#e6c6c3aba0744edce3fb2074922d3776c0af2a6d"
@@ -1050,6 +1055,21 @@ queue-microtask@^1.2.2:
resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243"
integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==
+react-router-dom@^6.16.0:
+ version "6.16.0"
+ resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-6.16.0.tgz#86f24658da35eb66727e75ecbb1a029e33ee39d9"
+ integrity sha512-aTfBLv3mk/gaKLxgRDUPbPw+s4Y/O+ma3rEN1u8EgEpLpPe6gNjIsWt9rxushMHHMb7mSwxRGdGlGdvmFsyPIg==
+ dependencies:
+ "@remix-run/router" "1.9.0"
+ react-router "6.16.0"
+
+react-router@6.16.0:
+ version "6.16.0"
+ resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.16.0.tgz#abbf3d5bdc9c108c9b822a18be10ee004096fb81"
+ integrity sha512-VT4Mmc4jj5YyjpOi5jOf0I+TYzGpvzERy4ckNSvSh2RArv8LLoCxlsZ2D+tc7zgjxcY34oTz2hZaeX5RVprKqA==
+ dependencies:
+ "@remix-run/router" "1.9.0"
+
read-cache@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/read-cache/-/read-cache-1.0.0.tgz#e664ef31161166c9751cdbe8dbcf86b5fb58f774"