Skip to content

Commit

Permalink
Merge commit '47b85744ce3b19533a8a0239acba9c17ef06aebc'
Browse files Browse the repository at this point in the history
  • Loading branch information
derGraph committed Aug 20, 2024
2 parents 41c4281 + 47b8574 commit f198781
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 57 deletions.
Empty file removed src/lib/Leaflet.css
Empty file.
1 change: 0 additions & 1 deletion src/lib/Leaflet.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script lang="ts">
import L from 'leaflet';
import 'leaflet/dist/leaflet.css';
import { onDestroy, onMount, setContext } from 'svelte';
import { modeCurrent } from '@skeletonlabs/skeleton';
Expand Down
3 changes: 3 additions & 0 deletions src/lib/errorStore.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { writable } from "svelte/store";

export default writable(new Response());
26 changes: 26 additions & 0 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import { Avatar } from '@skeletonlabs/skeleton';
import { setModeCurrent, setModeUserPrefers, modeCurrent } from '@skeletonlabs/skeleton';
import { onMount } from 'svelte';
import errorStore from '$lib/errorStore';
import { storePopup } from '@skeletonlabs/skeleton';
let navHeight = 2;
Expand All @@ -29,6 +30,10 @@
return 'htstps://upload.wikimedia.org/wikipedia/en/9/9a/Trollface_non-free.png';
}
function resetError() {
$errorStore = new Response();
}
$: user = data.user;
$: session = data.session;
</script>
Expand Down Expand Up @@ -90,6 +95,27 @@
</AppBar>
</div>
</svelte:fragment>
{#if $errorStore.status && $errorStore.status != 200}
<div class="md:container md:mx-auto flex flex-row flex flex-col pt-3 rounded-t-3xl">
<aside class="alert variant-ghost-warning text-warning-400-500-token">
<div class="material-symbols-outlined">warning</div>
<div class="alert-message">
{#await $errorStore.json()}
<h3 class="h3">"Loading..."</h3>
{:then parsed}
<h3 class="h3">{$errorStore.status} {$errorStore.statusText}: {parsed.message}</h3>
{:catch parsingError}
<h3 class="h3">Error in response: {parsingError}</h3>
{/await}
</div>
<div class="alert-actions">
<button class="btn variant-filled-warning" on:click={resetError}>
<span>Ok</span>
</button>
</div>
</aside>
</div>
{/if}
<slot />
<svelte:fragment slot="pageFooter">
<div
Expand Down
23 changes: 8 additions & 15 deletions src/routes/sign_in/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
<script lang="ts">
import errorStore from '$lib/errorStore.js';
export let form;
function resetForm() {
form!.error = '';
$: if(form?.error){
$errorStore = new Response(JSON.stringify({
message: form.error
}), {
statusText: "Bad request!",
status: 400
});
}
</script>

<div class="md:container md:mx-auto py-3 rounded-3xl my-3 bg-surface-100-800-token">
<form method="post" class="md:mx-auto max-w-max space-y-3.5">
<h3 class="h3 md:mx-auto">Sign in!</h3>
{#if form?.error}
<aside class="alert variant-ghost-warning text-warning-400-500-token">
<div class="material-symbols-outlined">warning</div>
<div class="alert-message">
<h3 class="h3">{form?.error}</h3>
</div>
<div class="alert-actions">
<button class="btn variant-filled-warning" on:click={resetForm}>
<span>Ok</span>
</button>
</div>
</aside>
{/if}
<label class="label">
<span>Username/Email</span>
<input name="identifier" class="input" type="text" placeholder="Username/Email" required />
Expand Down
24 changes: 9 additions & 15 deletions src/routes/sign_up/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
<script lang="ts">
import errorStore from '$lib/errorStore.js';
export let form;
function resetForm() {
form!.error = '';
$: if(form?.error){
$errorStore = new Response(JSON.stringify({
message: form.error
}), {
statusText: "Bad request!",
status: 400
});
}
</script>

<div class="md:container md:mx-auto py-3 rounded-3xl my-3 bg-surface-100-800-token">
<form method="post" class="md:mx-auto max-w-max space-y-3.5">
<h3 class="h3 md:mx-auto">Sign up!</h3>
{#if form?.error}
<aside class="alert variant-ghost-warning text-warning-400-500-token">
<div class="material-symbols-outlined">warning</div>
<div class="alert-message">
<h3 class="h3">{form?.error}</h3>
</div>
<div class="alert-actions">
<button class="btn variant-filled-warning" on:click={resetForm}>
<span>Ok</span>
</button>
</div>
</aside>
{/if}
<label class="label">
<span>Username</span>
<input name="username" class="input" type="text" placeholder="Username" required />
Expand Down
29 changes: 3 additions & 26 deletions src/routes/user/[requestedUser]/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import { Avatar, ListBox } from '@skeletonlabs/skeleton';
import { onMount } from 'svelte';
import errorStore from '$lib/errorStore.js';
import Tiptap from '$lib/Tiptap/+Tiptap.svelte';
export let data;
Expand All @@ -9,8 +10,6 @@
$: requestedUserName = data.requestedUser;
let error = new Response();
let requestedUser = {
firstName: '',
lastName: '',
Expand All @@ -28,7 +27,7 @@
requestedUser.username = Object.keys(response_data)[0];
});
} else {
error = response;
$errorStore = response;
}
});
});
Expand Down Expand Up @@ -75,7 +74,7 @@
if (response_data.ok) {
return true;
} else {
error = response_data;
$errorStore = response_data;
return false;
}
})
Expand All @@ -84,32 +83,10 @@
return false;
});
};
function resetError() {
error = new Response();
}
</script>

<div class="md:container md:mx-auto py-3 h-full w-full flex flex-row">
<div class="flex flex-col w-full bg-surface-100-800-token rounded-3xl items-center">
{#if error.status && error.status != 200}
<aside class="alert variant-ghost-warning text-warning-400-500-token">
<div class="material-symbols-outlined">warning</div>
<div class="alert-message">
{#await error.json()}
<h3 class="h3">"Loading..."</h3>
{:then parsed}
<h3 class="h3">{error.status} {error.statusText}: {parsed.message}</h3>
{:catch parsingError}
<h3 class="h3">Error in response: {parsingError}</h3>
{/await}
</div>
<div class="alert-actions">
<button class="btn variant-filled-warning" on:click={resetError}>
<span>Ok</span>
</button>
</div>
</aside>
{/if}
{#if requestedUser.firstName && requestedUser.lastName}
<Avatar
initials={getInitials(requestedUser)}
Expand Down

0 comments on commit f198781

Please sign in to comment.