diff --git a/handler/user/user.go b/handler/user/user.go index 755ae78..39e4ea8 100644 --- a/handler/user/user.go +++ b/handler/user/user.go @@ -17,7 +17,7 @@ func init() { func GET(w http.ResponseWriter, r *http.Request) { userSession := r.Context().Value("user").(types.User) - component := userView.Main("User Page", userSession.Email, userSession.Username, session.GetSessions(userSession.Email)) + component := userView.Main("User Page", userSession, session.GetSessions(userSession.Email)) err := component.Render(r.Context(), w) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) diff --git a/view/index/index.templ b/view/index/index.templ index 64c81c3..c5b3e47 100644 --- a/view/index/index.templ +++ b/view/index/index.templ @@ -8,64 +8,7 @@ import ( templ content(title string, user types.User) { @layout.Base(title){
-
- -
- if user.Authenticated { -
-
- - - - - - - - - - - - -
- -
- } else { - - Sign up - - - Sign in - - } -
-
+ @layout.Navbar(user)

Your files, always within reach.

@@ -168,32 +111,7 @@ templ content(title string, user types.User) {

- + @layout.Footer() } } diff --git a/view/layout/base.templ b/view/layout/base.templ index a47a52c..fac4fc3 100644 --- a/view/layout/base.templ +++ b/view/layout/base.templ @@ -1,5 +1,7 @@ package layout +import "github.com/fossyy/filekeeper/types" + templ Base(title string){ @@ -13,4 +15,94 @@ templ Base(title string){ { children... } +} + +templ Navbar(user types.User) { +
+
+ + + Filekeeper + +
+
+ if user.Authenticated { +
+
+ + + + + + + + + + + + +
+ +
+ } else { + + Sign up + + + Sign in + + } +
+
+} + +templ Footer() { + } \ No newline at end of file diff --git a/view/user/user.templ b/view/user/user.templ index 91bf505..c84b957 100644 --- a/view/user/user.templ +++ b/view/user/user.templ @@ -1,12 +1,14 @@ package userView import ( + "github.com/fossyy/filekeeper/types" "github.com/fossyy/filekeeper/view/layout" "github.com/fossyy/filekeeper/session" ) -templ content(email string, username string, title string, ListSession []*session.SessionInfo) { +templ content(title string, user types.User, ListSession []*session.SessionInfo) { @layout.Base(title){ + @layout.Navbar(user)
@@ -21,7 +23,7 @@ templ content(email string, username string, title string, ListSession []*sessio + id="name" placeholder="Enter your name" value={user.Username} disabled />
+ @layout.Footer() } } -templ Main(title string, email string, username string, ListSession []*session.SessionInfo) { - @content(email, username, title, ListSession) +templ Main(title string, user types.User, ListSession []*session.SessionInfo) { + @content(title, user, ListSession) } \ No newline at end of file