Compare commits

..

No commits in common. "655618877809dd3cd7b08c342de26b32567ce610" and "aff0c03ad2f47e47981dfdc4d4f0a26f883c93dc" have entirely different histories.

7 changed files with 19 additions and 38 deletions

View file

@ -8,7 +8,6 @@ export async function handleFetch({ request, fetch }) {
}
export async function handleError({ error, event, status, message }) {
console.error(error)
return {
status,
message

View file

@ -1,37 +1,21 @@
<script lang="ts">
import {PUBLIC_BACKEND_URL} from '$env/static/public'
export let name: string;
export let id: number;
export let id: string;
export let color: string;
export const path = `/paths/${id}`;
export let src: string;
console.log(id)
let image = '/archi.png'
switch (id) {
case 1:
image = '/archi.png';
break;
case 2:
image = '/montagne.png';
break;
case 3:
image = '/bibbito.png';
break;
}
</script>
<a href={path} class="route-card">
<div class="route-card-left" style="background-color: {color}">
<img src={image} alt="logo" />
<img {src} alt="logo" />
</div>
<div class="route-card-center">
<div class="name">
<div class="bold">{name}</div>
</div>
</div>
<div class="route-card-right" style:background-image='url({PUBLIC_BACKEND_URL}{src}' />
<div class="route-card-right" />
</a>
<style>
@ -50,6 +34,7 @@
.route-card-right {
border-top-right-radius: 45px;
border-bottom-right-radius: 45px;
background-image: url('/images/test-1.jpg');
background-position: center;
background-size: cover;
}
@ -63,7 +48,6 @@
.route-card-left img {
width: 100%;
max-width: 120px;
}
.route-card-center {

View file

@ -1,8 +1,6 @@
import {PUBLIC_BACKEND_URL} from '$env/static/public'
const API_URL = "https://ale-dev.teck-developer.com/api";
const API_URL = `${PUBLIC_BACKEND_URL}/api`
const getAllRoutes = async () => {
const getAllRoutes = async (fetch) => {
let data = [];
const response = await fetch(`${API_URL}/all-routes`);
@ -12,7 +10,7 @@ const getAllRoutes = async () => {
return data;
}
const getRouteCategories = async () => {
const getRouteCategories = async (fetch) => {
let data = [];
const response = await fetch(`${API_URL}/route-categories`);
@ -22,7 +20,7 @@ const getRouteCategories = async () => {
return data;
}
const getRouteByCategory = async (categoryId: number) => {
const getRouteByCategory = async (fetch,categoryId: number) => {
let data = [];
const response = await fetch(`${API_URL}/route-by-category/${categoryId}`);
const json = await response.json();
@ -31,7 +29,7 @@ const getRouteByCategory = async (categoryId: number) => {
return data;
}
const getRoute = async (routeId: number) => {
const getRoute = async (fetch,routeId: number) => {
let data = {};
const response = await fetch(`${API_URL}/route/${routeId}`);
const json = await response.json();
@ -41,7 +39,7 @@ const getRoute = async (routeId: number) => {
}
const getSport = async (routeId: number, sportId: number) => {
const getSport = async (fetch,routeId: number, sportId: number) => {
let data = {};
const response = await fetch(`${API_URL}/route/${routeId}/${sportId}`);
const json = await response.json();
@ -50,7 +48,7 @@ const getSport = async (routeId: number, sportId: number) => {
return data;
}
const getPlacemarks = async (routeId: number, sportId: number) => {
const getPlacemarks = async (fetch,routeId: number, sportId: number) => {
let data = {};
const response = await fetch(`${API_URL}/getPlacemarks/${routeId}/${sportId}`);
const json = await response.json();

View file

@ -14,7 +14,7 @@
<div id="welcome-message">Benvenuti a <span class="bold">Pianello Val Tidone</span></div>
<div id="route-cards">
{#each categories as category}
<Path src={category.cover} color={category.color} name="{category.name_it}" id={category.id} />
<Path src={category.cover} color={category.color} name="{category.name_it}" id={String(category.id)} />
{/each}
</div>
</main>

View file

@ -2,10 +2,10 @@
import { getRouteCategories } from '$lib/repo.js';
import { error } from '@sveltejs/kit';
export async function load() {
export async function load({fetch}) {
let categories = [];
try {
categories = await getRouteCategories();
categories = await getRouteCategories(fetch);
} catch (ex) {
error(500);
}

View file

@ -1,8 +1,8 @@
import { getRouteByCategory, getRouteCategories } from '$lib/repo.js';
import { error } from '@sveltejs/kit';
export async function load({ params }) {
const categories: App.Category[] = await getRouteCategories();
export async function load({ fetch, params }) {
const categories: App.Category[] = await getRouteCategories(fetch);
const categoryId = Number(params.slug);
const category: App.Category = categories.find(c => c.id === categoryId) as App.Category;
@ -13,7 +13,7 @@ export async function load({ params }) {
const toReturn = {
category: category.name_it,
routes: await getRouteByCategory(categoryId),
routes: await getRouteByCategory(fetch, categoryId),
}
return toReturn;

View file

@ -1,9 +1,9 @@
import { getRoute } from '$lib/repo.js';
import { error } from '@sveltejs/kit';
export async function load({ params }) {
export async function load({ fetch, params }) {
const routeId = Number(params.slug);
const route = await getRoute(routeId);
const route = await getRoute(fetch, routeId);
if (!route) {
error(404);