Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Use apigo endpoints #30

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .DS_Store
Binary file not shown.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build/
node_modules/
.env
.DS_*
.DS_*
.idea
71 changes: 71 additions & 0 deletions src/API.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// TODO: bu list `reasonsUrl`den cekilmeli
const reasons = ["enkaz","erzak","guvenli-noktalar","hayvanlar-icin-tedavi","giysi","konaklama","kurtarma","lojistik","su","yemek","elektronik","barinma"]

// TODO: API endpoint'ler environment variable ile aktarilmali
// TODO: query string'de bulunan lokasyon, locations drop down component'dan gelmeli
const areasUrl = "https://apigo.afetharita.com/feeds/areas?ne_lat=39.91618777305531&ne_lng=47.85149904303703&sw_lat=36.07272886939253&sw_lng=23.872389299415502&is_location_verified=0&is_need_verified=0"
const feedsUrl = "https://apigo.afetharita.com/feeds"
const reasonsUrl = "https://apigo.afetharita.com/reasons"

const IS_LOCATION_VERIFIED = 'is_location_verified'
const IS_NEED_VERIFIED = 'is_need_verified'
const EXTRA_PARAMS = 'extraParams'

const Areas = {
url: new URL(areasUrl),
reasons: [], // selected reasons

locationVerified() {
this.url.searchParams.set(IS_LOCATION_VERIFIED, "1")
return this
},

locationNotVerified() {
this.url.searchParams.set(IS_LOCATION_VERIFIED, "0")
return this
},


needVerified() {
this.url.searchParams.set(IS_NEED_VERIFIED, "1")
return this
},

needNotVerified() {
this.url.searchParams.set(IS_NEED_VERIFIED, "0")
return this
},

withExtraParams() {
this.url.searchParams.set(EXTRA_PARAMS, "1")
return this
},

withoutExtraParams() {
this.url.searchParams.set(EXTRA_PARAMS, "0")
return this
},

getURL() {
return this.url.toString()
},

getUpdateURL() {
// return `${this.url.origin}${this.url.pathname}`
return `/blabla`
}
}

const Feeds = {
url: new URL(feedsUrl),

getURL(id) {
return `${this.url.toString()}/${id}`
}
}

const API = {
Areas, Feeds,
reasons: reasons,
}
export default API
5 changes: 1 addition & 4 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ const App = () => {
<BrowserRouter>
<Routes>
{agreed && (
<>
<Route path="/" element={<Home />} />
<Route path="/dogrula" element={<Verify />} />
</>
<Route path="/" element={<Home />} />
)}

{!agreed && <Route path="*" element={<Agreement />} />}
Expand Down
37 changes: 37 additions & 0 deletions src/components/Loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React, { Component } from "react";

class Loader extends Component {
render() {
return (
<div
className={`absolute z-10 h-full bg-zinc-900/60 w-full flex items-center justify-center transition-all ${
this.props.isLoading ? "opacity-100 visible" : "opacity-0 invisible"
}`}
>
<svg
className="animate-spin h-8 w-8"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
>
<circle
className="opacity-25"
cx="12"
cy="12"
r="10"
stroke="currentColor"
strokeWidth="4"
/>

<path
className="opacity-75"
fill="currentColor"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
/>
</svg>
</div>
);
}
}

export default Loader;
17 changes: 17 additions & 0 deletions src/components/ReasonSelector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React, { Component } from "react";

class ReasonSelector extends Component {
render() {
return (
<div className={"mt-4 mx-auto max-w-2xl text-left"}>
{this.props.reasons.map(r => {
return <span className={"mr-2"}>
<input className={"reasonList"} type="checkbox" value={r} /> {r}
</span>
})}
</div>
);
}
}

export default ReasonSelector;
Loading