-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: frontend fixes and improvements (#29)
* deps: downgrade to fix sveltejs/kit#11317 * fix: fixed the api problems on frontend * feat: improvements to +page.server.ts and moved backend api host to localhost
- Loading branch information
1 parent
e6b0a46
commit fd19f8a
Showing
15 changed files
with
201 additions
and
121 deletions.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 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,9 @@ | ||
<script lang="ts"> | ||
import { page } from '$app/stores'; | ||
</script> | ||
|
||
<div class="flex flex-col items-center justify-center w-full h-full font-primary"> | ||
<h1 class="text-4xl font-bold text-center">Something went wrong</h1> | ||
<p class="text-lg text-muted-foreground">Error code: {$page.status}</p> | ||
<p class="text-base text-muted-foreground">Error message: {$page.error?.message}</p> | ||
</div> |
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,22 @@ | ||
import type { PageServerLoad } from './$types'; | ||
import type { UserResponse } from '$lib/types'; | ||
import { error } from '@sveltejs/kit'; | ||
|
||
export const load: PageServerLoad = async ({ fetch }) => { | ||
async function getUserData() { | ||
try { | ||
const res = await fetch('http://localhost:8080/user'); | ||
if (res.ok) { | ||
return (await res.json()) as UserResponse; | ||
} | ||
throw error(res.status, `Unable to fetch user data: ${res.status} ${res.statusText}`); | ||
} catch (e) { | ||
console.error(e); | ||
throw error(500, 'Unable to fetch user data. API is down.'); | ||
} | ||
} | ||
|
||
return { | ||
user: await getUserData() | ||
}; | ||
}; |
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 |
---|---|---|
@@ -1,21 +1,22 @@ | ||
<script lang="ts"> | ||
import { formatDate } from '$lib/helpers'; | ||
import type { UserResponse } from '$lib/types'; | ||
export let data; | ||
interface ExportedData { | ||
user: UserResponse; | ||
} | ||
export let data: ExportedData; | ||
</script> | ||
|
||
<svelte:head> | ||
<title>Iceberg | Home</title> | ||
</svelte:head> | ||
|
||
<div class="flex flex-col w-full p-8 md:px-24 lg:px-32"> | ||
{#if data.user} | ||
<h1 class="text-xl md:text-2xl font-semibold">Welcome {data.user?.username}</h1> | ||
<p class="md:text-lg text-muted-foreground">{data.user?.email}</p> | ||
<p class="md:text-lg text-muted-foreground break-words"> | ||
Premium expires on {formatDate(data.user?.expiration, 'short')} | ||
</p> | ||
{:else} | ||
<p class="md:text-lg text-muted-foreground">You are not logged in.</p> | ||
{/if} | ||
</div> |
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,10 @@ | ||
<script lang="ts"> | ||
import { Construction } from "lucide-svelte"; | ||
</script> | ||
|
||
<div class="flex flex-col p-8 md:px-24 lg:px-32"> | ||
<div class="flex flex-wrap gap-2 items-center"> | ||
<Construction class="w-12 h-12 text-white" /> | ||
<h1 class="text-xl md:text-2xl font-semibold">This page is under construction</h1> | ||
</div> | ||
</div> |
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 type { PageServerLoad } from './$types'; | ||
import { error } from '@sveltejs/kit'; | ||
|
||
export const load: PageServerLoad = async ({ fetch }) => { | ||
async function getStates() { | ||
try { | ||
const res = await fetch('http://localhost:8080/items/states'); | ||
if (res.ok) { | ||
return await res.json(); | ||
} | ||
throw error(res.status, `Unable to fetch states data: ${res.status} ${res.statusText}`); | ||
} catch (e) { | ||
console.error(e); | ||
throw error(500, 'Unable to fetch states data. API is down.'); | ||
} | ||
} | ||
|
||
async function getItems() { | ||
try { | ||
const res = await fetch('http://localhost:8080/items/'); | ||
if (res.ok) { | ||
return await res.json(); | ||
} | ||
throw error(res.status, `Unable to fetch items data: ${res.status} ${res.statusText}`); | ||
} catch (e) { | ||
console.error(e); | ||
throw error(500, 'Unable to fetch items data. API is down.'); | ||
} | ||
} | ||
|
||
return { | ||
streamed: { | ||
items: getItems() | ||
}, | ||
states: await getStates() | ||
}; | ||
}; |
Oops, something went wrong.