Skip to content

Commit

Permalink
feat: using own backend api
Browse files Browse the repository at this point in the history
  • Loading branch information
kaustubhxd committed May 23, 2023
1 parent a763ae4 commit d83706b
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 39 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/deploy_github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ jobs:
run: |
yarn install
CI='' yarn build
env:
CI: false
REACT_APP_API_URL: ${{ secrets.REACT_APP_API_URL }}
REACT_APP_API_VERSION: ${{ secrets.REACT_APP_API_VERSION }}

- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@4.1.5
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

.env
.env.development
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
},
"scripts": {
"start": "react-scripts start",
"dev": "PUBLIC_URL='.' env-cmd -f .env.development react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
Expand Down
88 changes: 52 additions & 36 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,52 +72,68 @@ function App() {
limit = ( starlinkData?.limit || 10 ),
status = ( dataFilters?.status || 0),
type = ( dataFilters?.type || undefined ),
search = ( dataFilters?.search || undefined ),
// search = ( dataFilters?.search || undefined ),
dateRange = ( dataFilters?.dateRange || undefined )
}, actionType) => {
setDataLoading(true)

const resetPage = actionType !== 'page'
console.log("resetPage: ", actionType, resetPage)

client.post('https://api.spacexdata.com/v4/starlink/query', {
"query": {
"latitude": getDecayValue(status),
"version": getTypeValue(type),
"spaceTrack.LAUNCH_DATE": getDateRangeValue(dateRange)
},
"options": {
"limit": limit,
"page": resetPage ? 1 : page,
"pagination": true,
"populate": [
"launch"
],
"sort": {
"spaceTrack.LAUNCH_DATE":"desc"
},
"select": [
"height_km",
"latitude",
"longitude",
"velocity_kms",
"version",
"id",
"spaceTrack.OBJECT_NAME",
"spaceTrack.LAUNCH_DATE",
"spaceTrack.DECAYED",
"spaceTrack.DECAY_DATE"
]
}
client.post('http://localhost:4000/v1/starlink/query', {
page : resetPage ? 1 : page,
limit,
status,
type,
dateRange
}).then(res => {
console.log(res.data)
const data = res.data
console.log(data)
console.log(res.data)
const data = res.data
console.log(data)

setStarlinkData(data)
}).finally(() => {
setStarlinkData(data)
}).finally(() => {
setDataLoading(false)
})
})

// client.post('https://api.spacexdata.com/v4/starlink/query', {
// "query": {
// "latitude": getDecayValue(status),
// "version": getTypeValue(type),
// "spaceTrack.LAUNCH_DATE": getDateRangeValue(dateRange)
// },
// "options": {
// "limit": limit,
// "page": resetPage ? 1 : page,
// "pagination": true,
// "populate": [
// "launch"
// ],
// "sort": {
// "spaceTrack.LAUNCH_DATE":"desc"
// },
// "select": [
// "height_km",
// "latitude",
// "longitude",
// "velocity_kms",
// "version",
// "id",
// "spaceTrack.OBJECT_NAME",
// "spaceTrack.LAUNCH_DATE",
// "spaceTrack.DECAYED",
// "spaceTrack.DECAY_DATE"
// ]
// }
// }).then(res => {
// console.log(res.data)
// const data = res.data
// console.log(data)

// setStarlinkData(data)
// }).finally(() => {
// setDataLoading(false)
// })
}

useEffect(() => {
Expand Down
3 changes: 2 additions & 1 deletion src/components/CustomModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ const CustomModal = ({ open, id, closeModal }) => {
useEffect(() => {
if(!id) return
setDataLoading(true)
client.get(`https://api.spacexdata.com/v4/starlink/${id}`)
client.get(`http://localhost:4000/v1/starlink/${id}`)
.then(res => {
console.log(res)
console.log(res.data)
setData(res.data)

Expand Down
2 changes: 1 addition & 1 deletion src/components/CustomTiltCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const CustomTiltCard = ({ selectedSat, handleSatSelect, loading, handleModal })
<div className='mt-4 flex flex-col gap-y-1'>
<CustomDataStrip label='Latitude' value={latitude?.toFixed(4)} />
<CustomDataStrip label='Longitude' value={longitude?.toFixed(4)} />
<CustomDataStrip label='Height' value={height_km?.toFixed(4)} />
<CustomDataStrip label='Height' value={height_km ? `${height_km?.toFixed(4)} km` : undefined} />
<CustomDataStrip label='Velocity' value={velocity_kms && `${velocity_kms?.toFixed(4)} km/s`} />
</div>
<div
Expand Down
5 changes: 4 additions & 1 deletion src/helpers/axiosClient.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import axios from "axios";

const URL = process.env.REACT_APP_API_URL
const VERSION = process.env.REACT_APP_API_VERSION

const client = axios.create({
baseURL: process.env.REACT_APP_API_URL,
baseURL: `${URL}/${VERSION}`,
});


Expand Down

0 comments on commit d83706b

Please sign in to comment.