Added code to createurl component
This commit is contained in:
		@@ -1,6 +1,5 @@
 | 
			
		||||
<script>
 | 
			
		||||
    import Apiclient from "./Apiclient";
 | 
			
		||||
    
 | 
			
		||||
	import Apiclient from './Apiclient';
 | 
			
		||||
 | 
			
		||||
	$: targetUrl = '';
 | 
			
		||||
	$: customShortcode = '';
 | 
			
		||||
@@ -8,19 +7,18 @@
 | 
			
		||||
	$: error = '';
 | 
			
		||||
 | 
			
		||||
	function createUrl() {
 | 
			
		||||
            console.log("here")
 | 
			
		||||
		console.log('here');
 | 
			
		||||
		Apiclient.createUrl(targetUrl, shortcode).then((res) => {
 | 
			
		||||
                console.log(res)
 | 
			
		||||
			console.log(res);
 | 
			
		||||
			if (res.status != 200) {
 | 
			
		||||
				error = res.data;
 | 
			
		||||
                }
 | 
			
		||||
                else{
 | 
			
		||||
			} else {
 | 
			
		||||
				shortcode = res.data.shortcode;
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
        function reset() {
 | 
			
		||||
	function resetInput() {
 | 
			
		||||
		error = '';
 | 
			
		||||
		shortcode = '';
 | 
			
		||||
		customShortcode = '';
 | 
			
		||||
@@ -29,15 +27,21 @@
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<h2 class="text-center text-2xl font-bold text-gray-800 dark:text-gray-100 pb-3">Create new url</h2>
 | 
			
		||||
    {#if error != ""}
 | 
			
		||||
{#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"
 | 
			
		||||
                    fill="currentColor">
 | 
			
		||||
                    <path fill-rule="evenodd"
 | 
			
		||||
				<svg
 | 
			
		||||
					xmlns="http://www.w3.org/2000/svg"
 | 
			
		||||
					class="h-5 w-5 text-red-600"
 | 
			
		||||
					viewBox="0 0 20 20"
 | 
			
		||||
					fill="currentColor"
 | 
			
		||||
				>
 | 
			
		||||
					<path
 | 
			
		||||
						fill-rule="evenodd"
 | 
			
		||||
						d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z"
 | 
			
		||||
                        clip-rule="evenodd" />
 | 
			
		||||
						clip-rule="evenodd"
 | 
			
		||||
					/>
 | 
			
		||||
				</svg>
 | 
			
		||||
			</div>
 | 
			
		||||
			<div class="ml-3">
 | 
			
		||||
@@ -51,13 +55,22 @@
 | 
			
		||||
						on:click={() => {
 | 
			
		||||
							error = '';
 | 
			
		||||
						}}
 | 
			
		||||
                        class="inline-flex bg-red-100 rounded-md p-1.5 text-red-500 hover:bg-red-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-red-50 focus:ring-red-600">
 | 
			
		||||
						class="inline-flex bg-red-100 rounded-md p-1.5 text-red-500 hover:bg-red-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-red-50 focus:ring-red-600"
 | 
			
		||||
					>
 | 
			
		||||
						<span class="sr-only">Dismiss</span>
 | 
			
		||||
                        <svg class="h-5 w-5" x-description="Heroicon name: x" xmlns="http://www.w3.org/2000/svg"
 | 
			
		||||
                            viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
 | 
			
		||||
                            <path fill-rule="evenodd"
 | 
			
		||||
						<svg
 | 
			
		||||
							class="h-5 w-5"
 | 
			
		||||
							x-description="Heroicon name: x"
 | 
			
		||||
							xmlns="http://www.w3.org/2000/svg"
 | 
			
		||||
							viewBox="0 0 20 20"
 | 
			
		||||
							fill="currentColor"
 | 
			
		||||
							aria-hidden="true"
 | 
			
		||||
						>
 | 
			
		||||
							<path
 | 
			
		||||
								fill-rule="evenodd"
 | 
			
		||||
								d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
 | 
			
		||||
                                clip-rule="evenodd"></path>
 | 
			
		||||
								clip-rule="evenodd"
 | 
			
		||||
							/>
 | 
			
		||||
						</svg>
 | 
			
		||||
					</button>
 | 
			
		||||
				</div>
 | 
			
		||||
@@ -101,11 +114,10 @@
 | 
			
		||||
		</button>
 | 
			
		||||
	{:else}
 | 
			
		||||
		<button
 | 
			
		||||
            on:click={reset}
 | 
			
		||||
			on:click={resetInput}
 | 
			
		||||
			class="px-4 py-2 font-medium tracking-wide text-white capitalize transition-colors duration-200 transform bg-blue-600 rounded-md dark:bg-gray-900 hover:bg-blue-500 dark:hover:bg-gray-700 focus:outline-none focus:bg-blue-500 dark:focus:bg-gray-700"
 | 
			
		||||
		>
 | 
			
		||||
			Add another url
 | 
			
		||||
		</button>
 | 
			
		||||
	{/if}
 | 
			
		||||
</div>
 | 
			
		||||
    
 | 
			
		||||
		Reference in New Issue
	
	Block a user