Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:relievers/relive
- Loading branch information
Showing
6 changed files
with
127 additions
and
5 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
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,21 @@ | ||
const DATABASE_URL = 'http://localhost:8080/'; | ||
|
||
function get(path: string) { | ||
return fetch(DATABASE_URL + path, { method: 'GET' }).then((res) => { | ||
if (!res.ok) { | ||
throw res; | ||
} | ||
return res; | ||
}); | ||
} | ||
|
||
function post(path: string, body) { | ||
return fetch(DATABASE_URL + path, { method: 'POST', body: body }).then((res) => { | ||
if (!res.ok) { | ||
throw res; | ||
} | ||
return res; | ||
}); | ||
} | ||
|
||
export default { get, post }; |
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,6 +1,73 @@ | ||
<script> | ||
import { goto } from '$app/navigation'; | ||
import { page } from '$app/stores'; | ||
import api from '$lib/api'; | ||
import { getUser } from '$lib/user-service'; | ||
import { onMount } from 'svelte'; | ||
let user; | ||
let name = ''; | ||
onMount(() => { | ||
user = getUser(); | ||
if (!user) return; | ||
joinEvent(); | ||
}); | ||
async function joinEvent() { | ||
const eventId = $page.params.eventId; | ||
try { | ||
const response = await api.post(`events/${eventId}/participations`, {}); | ||
console.log(response); | ||
goto('/'); | ||
} catch (e) { | ||
alert(e); | ||
} | ||
} | ||
async function createUser() { | ||
try { | ||
const response = await api.post('users', { name: name }); | ||
console.log(response); | ||
} catch (e) { | ||
alert(e); | ||
} | ||
} | ||
</script> | ||
<main> | ||
<p class="text-white">{$page.params.eventId}</p> | ||
</main> | ||
|
||
<main | ||
class="flex-grow bg-background text-center flex flex-col justify-between items-center text-white px-16 py-8 relative" | ||
> | ||
<button | ||
on:click={createUser} | ||
class="bg-accent h-14 w-14 rounded-full absolute bottom-10 mb-4 right-8 flex justify-center items-center" | ||
> | ||
<i class="fa fa-arrow-right" /> | ||
</button> | ||
<!-- <h1 class="text-4xl">Name</h1> --> | ||
<div /> | ||
|
||
<div class="flex flex-col gap-10"> | ||
<h2 class="text-accent text-3xl">What should we call you?</h2> | ||
<input | ||
class="bg-background w-full border-b-2 border-accent text-2xl placeholder:text-accent" | ||
placeholder="Your Name..." | ||
minlength="2" | ||
bind:value={name} | ||
/> | ||
</div> | ||
|
||
<div /> | ||
|
||
<!-- {#if step === 1} | ||
<Step1 /> | ||
{:else if step === 2} | ||
<Step2 /> | ||
{/if} --> | ||
|
||
<!-- <div class="w-full h-1 flex justify-between gap-3"> | ||
<div class="w-full bg-accent" class:bg-purple-500={step == 1} /> | ||
<div class="w-full bg-accent" class:bg-purple-500={step == 1} /> | ||
</div> --> | ||
</main> |
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 @@ | ||
<!-- <h1 class="text-4xl">Name</h1> --> | ||
<div></div> | ||
|
||
<div class="flex flex-col gap-10"> | ||
<h2 class="text-accent text-3xl">What should we call you?</h2> | ||
<input class="bg-background w-full border-b-2 border-accent text-2xl placeholder:text-accent" placeholder="Your Name..." /> | ||
</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,8 @@ | ||
<h1 class="text-4xl">Step 2</h1> | ||
|
||
<div class="flex flex-col gap-10"> | ||
<h2 class="text-accent text-3xl">What should we call you?</h2> | ||
<input class="bg-background w-full border-b-2 border-accent text-2xl placeholder:text-accent" placeholder="Your Name..." /> | ||
</div> | ||
|
||
<div /> |