package views
import "fmt"
import "git.32bit.cafe/32bitcafe/guestbook/internal/models"
import "git.32bit.cafe/32bitcafe/guestbook/internal/forms"
func gbUrl(gb models.Guestbook) string {
    return fmt.Sprintf("/guestbooks/%s", shortIdToSlug(gb.ShortId))
}
templ gbCreateForm(csrf_token string) {
    
    
    
    
}
templ GuestbookDashboardCommentsView(title string, data CommonData, website models.Website, guestbook models.Guestbook, comments []models.GuestbookComment) {
    @base(title, data) {
        
            @wSidebar(website)
            
                Comments on { website.SiteUrl }
                if len(comments) == 0 {
                    
No comments yet!
                }
                for  _, c := range comments {
                    @GuestbookDashboardCommentView(data, website, c)
                }
            
 
        
        
        {{ error, exists := form.FieldErrors["authorName"] }}
        if exists {
        
        }
        
    
    
        
        {{ error, exists = form.FieldErrors["authorEmail"] }}
        if exists {
        
        }
        
    
    
        
        {{ error, exists = form.FieldErrors["authorSite"] }}
        if exists {
        
        }
        
    
    
        
        {{ error, exists = form.FieldErrors["content"] }}
        if exists {
        
        }
        
    
    
        
    
}
templ GuestbookCommentList(comments []models.GuestbookComment) {
    if len(comments) == 0 {
        No comments yet!
    }
    for _, c := range comments {
        
            { c.AuthorName }
            { c.Created.Format("01-02-2006 03:04PM") }
            
                { c.CommentText }
            
         
    }
}
templ GuestbookView(title string, data CommonData, website models.Website, guestbook models.Guestbook, comments []models.GuestbookComment, form forms.CommentCreateForm) {
    {{ postUrl := fmt.Sprintf("/websites/%s/guestbook/comments/create", shortIdToSlug(website.ShortId)) }}
    if data.IsHtmx {
        @commentForm(form)
    } else {
        
            
            { title }
            
            
                
                    
                        
Guestbook for { website.SiteUrl }
                        
                    
                    
                
            
        
    }
}
templ CreateGuestbookComment(title string, data CommonData, website models.Website, guestbook models.Guestbook, form forms.CommentCreateForm) {
    {{ postUrl := fmt.Sprintf("/websites/%s/guestbook/comments/create", shortIdToSlug(website.ShortId)) }}
    if data.IsHtmx {
        
    } else {
        @base(title, data) {
            
        }
    }
}
templ GuestbookCommentView(c models.GuestbookComment) {
    
        { c.AuthorName }
        { c.Created.Format("01-02-2006 03:04PM") }
        
            { c.CommentText }
        
     
}
templ GuestbookDashboardCommentView(data CommonData, w models.Website, c models.GuestbookComment) {
    {{ commentUrl := fmt.Sprintf("%s/dashboard/guestbook/comments/%s", wUrl(w), shortIdToSlug(c.ShortId)) }}
    {{ hxHeaders := fmt.Sprintf("{\"X-CSRF-Token\": \"%s\"}", data.CSRFToken) }}
    
}
templ AllGuestbooksView(data CommonData, websites []models.Website) {
    @base("All Guestbooks", data) {
        
            All Guestbooks
            
                This page exists only for testing the service.
            
            
                for _, w := range websites {
                    - 
                        {{  gbUrl := fmt.Sprintf("/websites/%s/guestbook", shortIdToSlug(w.ShortId))}}
                        { w.Name }
                    }
 
    }
}