#73 add sign out
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 48s

This commit is contained in:
Tim
2024-08-29 09:24:38 +02:00
parent fe1f47a55e
commit cda672caac
7 changed files with 149 additions and 51 deletions

View File

@@ -5,9 +5,9 @@ templ SignInOrUp(isSignIn bool) {
class="max-w-xl px-2 mx-auto flex flex-col gap-4 h-full justify-center"
method="POST"
if isSignIn {
hx-post="/api/auth/signin"
action="/api/auth/signin"
} else {
hx-post="/api/auth/signup"
action="/api/auth/signup"
}
>
<h2 class="text-6xl mb-10">

14
template/auth/user.templ Normal file
View File

@@ -0,0 +1,14 @@
package auth
templ UserComp(user string) {
<div id="user-info" class="flex gap-5">
if user != "" {
<a hx-get="/api/auth/signout" hx-target="#user-info" class="btn btn-sm">Sign Out</a>
<!-- <a href="/api/auth/signout" class="btn btn-sm">Sign Out</a> -->
{ user }
} else {
<a href="/auth/signup" class="btn btn-sm">Sign Up</a>
<a href="/auth/signin" class="btn btn-sm">Sign In</a>
}
</div>
}

View File

@@ -1,6 +1,6 @@
package template
templ Layout(comp templ.Component) {
templ Layout(slot templ.Component, user templ.Component) {
<!DOCTYPE html>
<html lang="en">
<head>
@@ -19,12 +19,11 @@ templ Layout(comp templ.Component) {
<img src="/static/favicon.svg" alt="ME-FIT logo"/>
<span>ME-FIT</span>
</a>
<a href="/auth/signup" class="btn btn-sm">Sign Up</a>
<a href="/auth/signin" class="btn btn-sm">Sign In</a>
@user
</div>
<div class="flex-1">
if comp != nil {
@comp
if slot != nil {
@slot
}
</div>
</div>