This repository has been archived by the owner on Oct 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
matheus motizuki
authored and
matheus motizuki
committed
Oct 8, 2023
1 parent
99d561b
commit baabb0c
Showing
16 changed files
with
192 additions
and
12 deletions.
There are no files selected for viewing
Submodule hackathon_front
added at
e70029
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import {get} from "svelte/store"; | ||
import {userStore} from "../../stores.js"; | ||
import axios from "axios"; | ||
import {backendUrl} from "$lib/server/constants.js"; | ||
import {redirect} from "@sveltejs/kit"; | ||
|
||
export async function load({ params }) { | ||
const user = get(userStore); | ||
|
||
async function getSchools() { | ||
let config = { | ||
method: 'get', | ||
maxBodyLength: Infinity, | ||
url: backendUrl + 'school/distance/' + user.Id + '?distance=100', | ||
headers: { | ||
'Authorization': 'Bearer ' + user.token, | ||
'Content-Type': 'application/json' | ||
}, | ||
}; | ||
|
||
let result = await axios.request(config).catch((error) => { | ||
throw redirect(302, "/logout") | ||
}); | ||
|
||
return result.data; | ||
} | ||
async function getUserCoords() { | ||
let config = { | ||
method: 'get', | ||
maxBodyLength: Infinity, | ||
url: backendUrl + 'users/' + user.Id, | ||
headers: { | ||
'Authorization': 'Bearer ' + user.token, | ||
'Content-Type': 'application/json' | ||
}, | ||
}; | ||
|
||
let result = await axios.request(config).catch((error) => { | ||
throw redirect(302, "/logout") | ||
}); | ||
|
||
return { latitude: result.data.latitude, longitude: result.data.longitude} | ||
} | ||
|
||
return { | ||
userCoords: getUserCoords(), | ||
schools: getSchools() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<script> | ||
import Map from "$lib/components/Map.svelte" | ||
import Sidebar from "$lib/components/Sidebar.svelte"; | ||
import {dashboardSelected} from "../../stores.js"; | ||
import ContactGrid from "$lib/components/ContactGrid.svelte"; | ||
export let data; | ||
</script> | ||
|
||
<Sidebar> | ||
<span slot="main"> | ||
{#if $dashboardSelected === 'Maps'} | ||
<Map userCoords={data.userCoords} schools={data.schools}/> | ||
{/if} | ||
{#if $dashboardSelected === 'List'} | ||
<ContactGrid/> | ||
{/if} | ||
</span> | ||
</Sidebar> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import axios from "axios"; | ||
import {userStore} from "../../stores.js"; | ||
import {redirect} from "@sveltejs/kit"; | ||
import {backendUrl} from "$lib/server/constants.js"; | ||
|
||
export const actions = { | ||
default: async ({ request }) => { | ||
const formData = await request.formData(); | ||
const email = formData.get('email'); | ||
const password = formData.get('password') | ||
|
||
let config = { | ||
method: 'post', | ||
maxBodyLength: Infinity, | ||
url: backendUrl + 'auth/login', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
data : JSON.stringify({ | ||
email: email, | ||
password: password | ||
}) | ||
}; | ||
|
||
let user = await axios.request(config).catch((error) => { | ||
console.log(error.message) | ||
return { success: false, error: error.message} | ||
}) | ||
|
||
if (user?.data) { | ||
userStore.set(user.data); | ||
throw redirect(302, '/dashboard') | ||
} | ||
|
||
return { success: false, error: "Credenciais Invalidas"} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
import LoginPage from "$lib/components/LoginPage.svelte"; | ||
</script> | ||
|
||
<LoginPage/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {userStore} from "../../stores.js"; | ||
import {redirect} from "@sveltejs/kit"; | ||
|
||
export function GET({ url }) { | ||
userStore.set({}) | ||
throw redirect(302, "/") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import axios from "axios"; | ||
import {userStore} from "../../stores.js"; | ||
import {redirect} from "@sveltejs/kit"; | ||
import {backendUrl} from "$lib/server/constants.js"; | ||
|
||
export const actions = { | ||
default: async ({ request }) => { | ||
const formData = await request.formData(); | ||
|
||
const name = formData.get('name'); | ||
const email = formData.get('email') | ||
const password = formData.get('password') | ||
const cep = formData.get('cep') | ||
const phoneNumber = formData.get('phone-number') | ||
|
||
let config = { | ||
method: 'post', | ||
maxBodyLength: Infinity, | ||
url: backendUrl + 'auth/register', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
data : JSON.stringify({ | ||
name: name, | ||
email: email, | ||
password: password, | ||
cep: cep, | ||
phoneNumber: phoneNumber | ||
}) | ||
}; | ||
|
||
let user = await axios.request(config).catch((error) => { | ||
console.log(error.message) | ||
return { success: false, error: error.message} | ||
}) | ||
|
||
if (user?.data) { | ||
userStore.set(user.data); | ||
throw redirect(302, '/dashboard') | ||
} | ||
|
||
|
||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
import RegisterPage from "$lib/components/RegisterPage.svelte"; | ||
</script> | ||
|
||
<RegisterPage/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
import SchoolLogin from "$lib/components/SchoolLogin.svelte"; | ||
</script> | ||
|
||
<SchoolLogin/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
import SchoolRegister from "$lib/components/SchoolRegister.svelte"; | ||
</script> | ||
|
||
<SchoolRegister/> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
import Sobre from "$lib/components/Sobre.svelte"; | ||
</script> | ||
|
||
<Sobre/> |