Skip to content

Commit

Permalink
Initial version.
Browse files Browse the repository at this point in the history
  • Loading branch information
tuliofaria committed Apr 14, 2020
0 parents commit 930b287
Show file tree
Hide file tree
Showing 28 changed files with 9,277 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .env-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
AUTH0_CLIENT_ID=
AUTH0_CLIENT_SECRET=
AUTH0_SCOPE=
AUTH0_DOMAIN=
AUTH0_REDIRECT_URI=
AUTH0_LOGOUT_REDIRECT_URI=
AUTH0_SESSION_SECRET=
AUTH0_SESSION_COOKIE_TIME=
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.now
.env
now.json
firebase-secret.json
.next
.now
node_modules
13 changes: 13 additions & 0 deletions components/Footer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react'

const Footer = () => {
return (
<div className='py-4 text-center bg-gray-400'>
MyDailyStatus é um projeto criado durante o Fullstack Lab do DevPleno.
<br />
Implementado por:{' '}
<a href='https://linkedin.com/in/tuliofaria'>Tulio Faria</a>
</div>
)
}
export default Footer
19 changes: 19 additions & 0 deletions components/Header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react'
import NavBar from './NavBar'

const Header = () => {
return (
<div className='bg-gray-200'>
<h1>
<img
className='h-24 mx-auto py-4'
src='/logo.png'
alt='Olá FSL!'
height='60'
/>
</h1>
<NavBar />
</div>
)
}
export default Header
21 changes: 21 additions & 0 deletions components/NavBar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react'
import Link from 'next/link'

const NavLink = ({ href, children }) => {
return (
<Link href={href}>
<a className='p-2 hover:underline hover:text-red-800'>{children}</a>
</Link>
)
}

const NavBar = () => {
return (
<div className='bg-gray-500 py-4 text-center'>
<NavLink href='/sobre'>Sobre</NavLink>
<NavLink href='/cadastro'>Cadastro</NavLink>
<NavLink href='/entrar'>Entrar</NavLink>
</div>
)
}
export default NavBar
14 changes: 14 additions & 0 deletions lib/auth0.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { initAuth0 } from '@auth0/nextjs-auth0'
console.log(process.env)
export default initAuth0({
clientId: process.env.AUTH0_CLIENT_ID,
clientSecret: process.env.AUTH0_CLIENT_SECRET,
scope: process.env.AUTH0_SCOPE,
domain: process.env.AUTH0_DOMAIN,
redirectUri: process.env.AUTH0_REDIRECT_URI,
postLogoutRedirectUri: process.env.AUTH0_LOGOUT_REDIRECT_URI,
session: {
cookieSecret: process.env.AUTH0_SESSION_SECRET,
cookieLifetime: process.env.AUTH0_SESSION_COOKIE_TIME
}
})
16 changes: 16 additions & 0 deletions lib/db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const admin = require('firebase-admin')
const secret = require('../firebase-secret.json')
const { GeoFirestore } = require('geofirestore')

if (!admin.apps.length) {
admin.initializeApp({
credential: admin.credential.cert(secret)
})
}

const firestore = admin.firestore()
const db = new GeoFirestore(firestore)

module.exports = {
db
}
22 changes: 22 additions & 0 deletions lib/geo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//alert(calcCrow(59.3293371,13.4877472,59.3225525,13.4619422).toFixed(1));

// Converts numeric degrees to radians
function toRad (Value) {
return (Value * Math.PI) / 180
}

//This function takes in latitude and longitude of two location and returns the distance between them as the crow flies (in km)
export function distance (lat1, lon1, lat2, lon2) {
var R = 6371 // km
var dLat = toRad(lat2 - lat1)
var dLon = toRad(lon2 - lon1)
var lat1 = toRad(lat1)
var lat2 = toRad(lat2)

var a =
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(lat1) * Math.cos(lat2)
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a))
var d = R * c
return d
}
3 changes: 3 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require('dotenv').config()

module.exports = {}
Loading

0 comments on commit 930b287

Please sign in to comment.