-
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
Showing
3 changed files
with
40 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,40 @@ | ||
<script> | ||
<script lang="ts"> | ||
let command = '' | ||
let loading = false | ||
let error: string | null = null | ||
async function submit() { | ||
const res = await fetch('https://api.fastspend.poom.dev/command', { | ||
method: 'POST', | ||
body: JSON.stringify({command}), | ||
}) | ||
loading = true | ||
console.log(res.status) | ||
try { | ||
await fetch('https://api.fastspend.poom.dev/command', { | ||
method: 'POST', | ||
body: JSON.stringify({command}), | ||
}) | ||
error = null | ||
} catch (err) { | ||
error = err.message | ||
} finally { | ||
command = '' | ||
loading = false | ||
} | ||
} | ||
</script> | ||
|
||
<div class="flex flex-col items-center justify-between v-fill bg-stone-100"> | ||
<div>A</div> | ||
<div class="w-full"> | ||
<input | ||
type="text" | ||
class="w-full bg-neutral-900 text-white px-4 py-4 text-3xl font-extralight rounded-none" | ||
bind:value={command} | ||
on:keypress={(e) => e.key === 'Enter' && submit()} | ||
/> | ||
</div> | ||
<div | ||
class="flex flex-col items-center justify-center min-h-screen bg-stone-100 space-y-4" | ||
> | ||
<input | ||
type="text" | ||
class="bg-neutral-900 text-white px-4 py-4 text-3xl font-extralight rounded-md shadow-2xl text-center" | ||
class:error-input={error} | ||
class:loading-input={loading} | ||
bind:value={command} | ||
on:keypress={(e) => e.key === 'Enter' && submit()} | ||
/> | ||
|
||
{#if error} | ||
<div class="text-red-500">Error: {error}</div> | ||
{/if} | ||
</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