mirror of
https://github.com/System-End/site.git
synced 2026-04-19 22:05:11 +00:00
* initial migration
* port landing and feature components
* Features section
* Add event cards in Testimonials (no styles)
* add everything section
* everything but no styling
* fFix some styles in Everything.js
* Add Start section without the form yet
* Fix testimonials section grid
* Fix styles on Landing
* Styles on Everything section
* Fix testimonials cards
* Fix console error and testimonial cards
* Fix landing and style bugs
* Fix styles
* Add selection color
* Fix Grid on everything section
* Fetch transaction data from api
* Style stats
* Fix landing on mobile
* Fix some bugs and responsiveness
* Fix 🐛 so the form exists now
* Fix bugs & add timeline
* Fix Laptop in Grid
* Switch to Dark Laptop
* Fix Stat Text Size
* Form -> Airtable
* Change to hred to primary, align ModuleDetails card
* Remove dates
* Fix Event card to align items center
* Add mtop margin to transparency button
* Fix Run.js icon styles
* Make fiscal sponsor note more readable
* Add 2 tone colors btwn Start and Everything
* Flashing green dot
* Confusion
* Update components/bank/Timeline.js
Co-authored-by: Sam Poder <39828164+sampoder@users.noreply.github.com>
* Fix remaining style bugs
* small fix
* small fix
* Fix Form
* Fixes
- fix timeline horizontal
- green to hack club theme green
- more horizontal margin on everything section
- attempt to fix testimonial grid
* center 7 (percentage)
* Fix testimonial grid layout
* Fix landing
* Fix horizontal scroll on mobile
* Fix styles on event card
* Decrease font size and padding
* Actually fix it this time
* Fix styles
* Responsiveness and mobile styling
* Slight styles changes
* Fix Margins
* Neutralize
Co-authored-by: Sam Poder <39828164+sampoder@users.noreply.github.com>
78 lines
2.1 KiB
JavaScript
78 lines
2.1 KiB
JavaScript
import storage from './storage'
|
|
|
|
export const url = 'https://api.hackclub.com/'
|
|
const methods = ['GET', 'PUT', 'POST', 'PATCH', 'DELETE']
|
|
|
|
const generateMethod =
|
|
method =>
|
|
(path, options = {}, fetchOptions = {}) => {
|
|
let filteredOptions = {}
|
|
const authToken = storage.get('authToken')
|
|
if (authToken) {
|
|
options.authToken = authToken
|
|
}
|
|
|
|
for (let [key, value] of Object.entries(options)) {
|
|
switch (key) {
|
|
case 'authToken':
|
|
filteredOptions.headers = filteredOptions.headers || {}
|
|
filteredOptions.headers['Authorization'] = `Bearer ${value}`
|
|
break
|
|
case 'data':
|
|
if (value instanceof FormData) {
|
|
filteredOptions.body = value
|
|
} else {
|
|
filteredOptions.body = JSON.stringify(value)
|
|
filteredOptions.headers = filteredOptions.headers || {}
|
|
filteredOptions.headers['Content-Type'] = 'application/json'
|
|
}
|
|
break
|
|
default:
|
|
filteredOptions[key] = value
|
|
break
|
|
}
|
|
}
|
|
|
|
if (fetchOptions.noAuth) {
|
|
if (filteredOptions.headers && filteredOptions.headers['Authorization']) {
|
|
delete filteredOptions.headers['Authorization']
|
|
}
|
|
}
|
|
|
|
const foreignUrl = path.startsWith('http')
|
|
const urlPath = foreignUrl ? path : url + path
|
|
|
|
return fetch(urlPath, { method, ...filteredOptions })
|
|
.then(res => {
|
|
if (res.ok) {
|
|
const contentType = res.headers.get('content-type')
|
|
if (contentType && contentType.indexOf('application/json') !== -1) {
|
|
return res.json()
|
|
} else {
|
|
return res.text()
|
|
}
|
|
} else {
|
|
if (res.status === 422) {
|
|
return res.json().then(json => {
|
|
// eslint-disable-next-line
|
|
throw { ...res, errors: json.errors }
|
|
})
|
|
} else {
|
|
throw res
|
|
}
|
|
}
|
|
})
|
|
.catch(err => {
|
|
throw err
|
|
})
|
|
}
|
|
|
|
let api = {}
|
|
|
|
methods.forEach(method => {
|
|
api[method.toLowerCase()] = generateMethod(method)
|
|
})
|
|
|
|
api.currentUser = () => api.get(`v1/users/current`)
|
|
|
|
export default api
|