More basics for the shorturl creation module

This commit is contained in:
Nicolai Ort 2021-08-21 10:56:44 +02:00
parent 0c629e2416
commit 515370eac7
Signed by: niggl
GPG Key ID: 13AFA55AF62F269F
1 changed files with 107 additions and 94 deletions

View File

@ -1,11 +1,23 @@
<script>
import Apiclient from "./Apiclient";
$: targetUrl = '';
$: customShortcode = '';
$: shortcode = '';
$: error = '';
function createUrl() {
console.log("here")
Apiclient.createUrl(targetUrl, shortcode).then((res)=>{
console.log(res)
if(res.status != 200){
error = res.data;
}
else{
shortcode = res.data.shortcode;
}
});
}
function reset() {
@ -14,11 +26,11 @@
customShortcode = '';
targetUrl = '';
}
</script>
</script>
<h2 class="text-center text-2xl font-bold text-gray-800 dark:text-gray-100 pb-3">Create new url</h2>
{#if error != ""}
<div class="rounded-md bg-red-100 p-4 hidden" id="error_container">
<h2 class="text-center text-2xl font-bold text-gray-800 dark:text-gray-100 pb-3">Create new url</h2>
{#if error != ""}
<div class="rounded-md bg-red-100 p-4 hidden" id="error_container">
<div class="flex">
<div class="flex-shrink-0">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-red-600" viewBox="0 0 20 20"
@ -51,9 +63,9 @@
</div>
</div>
</div>
</div>
{/if}
{#if shortcode == ''}
</div>
{/if}
{#if shortcode == ''}
<div>
<div class="mx-auto lg:w-1/3 w-full mt-1 flex rounded-md shadow-sm">
<input
@ -76,10 +88,10 @@
/>
</div>
</div>
{:else}
TODO:
{/if}
<div class="mt-3 mx-auto text-center lg:w-1/3 w-full">
{:else}
<!-- TODO: -->
{/if}
<div class="mt-3 mx-auto text-center lg:w-1/3 w-full">
{#if shortcode == ''}
<button
on:click={createUrl}
@ -95,4 +107,5 @@
Add another url
</button>
{/if}
</div>
</div>