Skip to content

Commit

Permalink
fix map
Browse files Browse the repository at this point in the history
  • Loading branch information
JavaRip committed Sep 19, 2024
1 parent d7c3f4f commit 15a42e5
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 8 deletions.
10 changes: 7 additions & 3 deletions app/client/src/pages/Map/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ export default function Map() {
throw new Error(`Failed to fetch well data:, ${res}`);
}

const wells = await res.json();
setWells(wells.data);
const data = await res.json();
setWells(data.wells);
}

async function getRegionTranslations() {
const translations = await RegionTranslationsFetcher();
setRegionTranslations(translations);
}

useEffect(() => {
async function fetchToken() {
const token = await AccessToken.get();
Expand All @@ -58,9 +59,12 @@ export default function Map() {
fetchToken();
getRegionTranslations();
getInteractiveMap();
getPredictionPinData();
}, []);

useEffect(() => {
getPredictionPinData();
}, [token]);

if (!interactiveMap || !wells || !regionTranslations) return (
<Stack alignItems='center' justifyContent='center'>
<CircularProgress />
Expand Down
4 changes: 4 additions & 0 deletions app/client/src/pages/Map/markers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ export default function Markers({ wells, regionTranslations }: props): JSX.Eleme
}
}

console.log('================================');
console.log(wells);
console.log(wells.filter);

return (
<>
{wells.filter(
Expand Down
6 changes: 5 additions & 1 deletion app/client/src/utils/AccessToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ export default class AccessToken {
if (!accessToken) return null;

const parsedAccessToken = JSON.parse(accessToken);
const tokenValidationRes = TokenSchema.safeParse(parsedAccessToken);
const tokenValidationRes = TokenSchema.safeParse({
...parsedAccessToken,
createdAt: parsedAccessToken.createdAt = new Date(parsedAccessToken.createdAt),
expiresAt: parsedAccessToken.expiresAt = new Date(parsedAccessToken.expiresAt),
});

if (!tokenValidationRes.success) {
console.error('Failed to validate access token:', tokenValidationRes.error);
Expand Down
2 changes: 1 addition & 1 deletion app/client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default defineConfig({
},
resolve: {
alias: {
'shared': './node_modules/shared/dist/index.js',
'shared': './node_modules/shared/src/index.ts',
}
}
});
2 changes: 1 addition & 1 deletion app/server/iArsenic API/environments/localhost.bru
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ vars {
base_url: http://127.0.0.1:5001/iarsenic-staging/us-central1/default
}
vars:secret [
test_password,
access_token,
test_password,
well_id
]
15 changes: 15 additions & 0 deletions app/server/iArsenic API/get wells.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
meta {
name: get wells
type: http
seq: 14
}

get {
url: {{base_url}}/api/v1/well/
body: none
auth: none
}

headers {
authorization: Bearer {{access_token}}
}
2 changes: 1 addition & 1 deletion app/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.ts",
"scripts": {
"build": "rm -rf dist && tsc && ../client/ run build && cp -r ../client/static/ dist/static/",
"build:firebase": "npm --prefix ../shared run build && npm --prefix ../client/ run build && rm -rf dist && tsc && rm -rf ../../firebase-functions/dist && cp -r dist/* ../../firebase-functions"
"build:firebase": "npm --prefix ../shared run build && npm --prefix ../client run build && rm -rf dist && tsc && rm -rf ../../firebase-functions/dist && cp -r dist/* ../../firebase-functions && cp -r ../client/static ../../firebase-functions"
},
"keywords": [],
"author": "",
Expand Down
2 changes: 2 additions & 0 deletions app/server/src/server/routes/v1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import healthcheck from './healthcheck'
import Router from '@koa/router'
import self from './self'
import user from './user'
import well from './well'

const routes = new Router({ prefix: '/api/v1' })

Expand All @@ -13,5 +14,6 @@ routes.use(errorHandler)
routes.use(healthcheck.routes())
routes.use(user.routes())
routes.use(self.routes())
routes.use(well.routes())

export default routes
2 changes: 1 addition & 1 deletion app/server/src/server/routes/v1/well.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Router from '@koa/router'
import { adminOnly } from '../../middleware'
import { WellController } from 'src/server/controllers';
import { WellController } from '../../controllers';

const well = new Router({ prefix: '/well' })

Expand Down

0 comments on commit 15a42e5

Please sign in to comment.