landing page redirect + publish toggle

This commit is contained in:
nomadics9 2024-05-12 07:10:30 +03:00
parent 86f951a375
commit c77a9d26d1
2 changed files with 54 additions and 5 deletions

View file

@ -1,13 +1,46 @@
<script lang="ts">
import type { PageData } from "./$types";
let data: PageData
import { userData, user, auth} from "$lib/firebase";
import { goto } from '$app/navigation';
import { onMount } from "svelte";
function getLogged() {
if ($userData?.username != undefined) {
goto(`/${$userData?.username}`)
console.log(user)
}
else {
goto(`/login`)
}
}
onMount(() => {
setTimeout(getLogged, 2000)
})
</script>
<svelte:head>
<head>
<title>Linky</title>
<meta name="description" content="Your web tree!" />
<meta property="og:image" content="https://nmd.mov/favicon.png" />
<meta property="og:title" content="Linky" />
<meta property="og:description" content="Your web tree!" />
<meta property="og:url" content="https://nmd.mov" />
</svelte:head>
<a href="/login" class="btn btn-outline mx-auto my-auto">/Start</a>
</head>
{#if $userData == undefined}
<div class="mx-auto my-auto">
<a href="/login" class="btn btn-outline">/Start</a>
</div>
{/if}
{#if $userData != undefined}
<div class="m-auto">
<span class="loading loading-spinner text-success"></span>
</div>
{/if}

View file

@ -91,6 +91,16 @@
});
}
let publish = $userData?.published
function togglePublish() {
publish = !$userData?.published
const userRef = doc(db, "users", $user!.uid);
updateDoc(userRef, {
published: publish
});
}
publish == $userData?.published
function moveUp(index: any) {
const userRef = doc(db, "users", $user!.uid)
@ -222,6 +232,12 @@
>
Add a Link
</button>
<div class="form-control">
<label class="label cursor-pointer">
<span class="label-text">Published</span>
<input type="checkbox" class="toggle" bind:value={publish} on:change={togglePublish}/>
</label>
</div>
{/if}
{/if}