package views
import (
	"fmt"
	"git.32bit.cafe/32bitcafe/guestbook/internal/forms"
	"git.32bit.cafe/32bitcafe/guestbook/internal/models"
	"time"
)
func wUrl(w models.Website) string {
	return fmt.Sprintf("/websites/%s", shortIdToSlug(w.ShortId))
}
templ wSidebar(website models.Website) {
	{{ dashUrl := wUrl(website) + "/dashboard" }}
	{{ gbUrl := wUrl(website) + "/guestbook" }}
	
		
		
		
	 
}
templ websiteCreateForm(csrfToken string, form forms.WebsiteCreateForm) {
	 
	
		Website Settings 
		
			{{ err, exists := form.FieldErrors["ws_name"] }}
			Site Name *  
			if exists {
				{ err } 
			}
			 
			The display name for your website 
		
		
			{{ err, exists = form.FieldErrors["ws_url"] }}
			Site URL *  
			if exists {
				{ err } 
			}
			 
			The full URL where your website can be accessed 
		
		
			{{ err, exists = form.FieldErrors["ws_author"] }}
			Site Author *  
			if exists {
				{ err } 
			}
			 
			Your name or the website owner's name 
		
	 
	
		Add Website 
	
}
templ WebsiteList(title string, data CommonData, websites []models.Website) {
	@base(title, data) {
		
			
			
				if len(websites) == 0 {
					
No Websites yet. 
					Create your first website to get started with webweav.ing tools.
					Create Your First Website 
				} else {
					
						for _, w := range websites {
							
								
									
									
								 
							 
						}
					 
				}
			
 
		 
	}
}
templ WebsiteDashboard(title string, data CommonData, website models.Website) {
	@base(title, data) {
		
			@wSidebar(website)
			
				{{ gbUrl := fmt.Sprintf("https://%s/websites/%s/guestbook", data.RootUrl, shortIdToSlug(website.ShortId)) }}
				
					Embed your Guestbook 
					
						There are two ways to add your guestbook to your website: using our JavaScript component (recommended) or with an iframe.
					 
					
						Method 1: JavaScript Component (Recommended) 
						
						
							Step 2: Include in your HTML head 
							
								Add this script tag to your <head> section: 
								
									
										<head>
										<script type="module" src="js/guestbook.js"></script>
										</head>
									
								 
							 
						 
						
							Step 3: Add the custom elements 
							
								Place these elements where you want your guestbook to appear: 
								
									
										{ fmt.Sprintf(` 
 `, gbUrl, gbUrl) }
									
								 
							 
						 
					 
					
						Method 2: iframe (Alternative) 
						
							Use this method if your web host doesn't allow CORS requests 
							
								If your hosting provider blocks cross-origin requests, you can embed the guestbook using an iframe instead:
								
									iframe embedding code: 
									
										
											{ fmt.Sprintf(``, gbUrl, gbUrl) }
										
									 
								 
								
									Note:  The iframe method may have styling limitations and won't integrate as seamlessly with your site's design.
								 
							 
						 
					 
					
						Need Help? 
						If you're having trouble embedding your guestbook, check out our help documentation  or contact support.
					 
				 
			 
		 
	}
}
templ websiteSettingsForm(data CommonData, website models.Website, form forms.WebsiteSettingsForm) {
	Website Settings 
	
		{{ err, exists := form.FieldErrors["ws_name"] }}
		Site Name *  
		if exists {
			{ err } 
		}
		if form.SiteName != "" {
			 
		} else {
			 
		}
		The display name for your website 
	
	
		{{ err, exists = form.FieldErrors["ws_url"] }}
		Site URL *  
		if exists {
			{ err } 
		}
		if form.SiteUrl != "" {
			 
		} else {
			 
		}
		The full URL where your website can be accessed 
	
	
		{{ err, exists = form.FieldErrors["ws_author"] }}
		Site Author *  
		if exists {
			{ err } 
		}
		if form.AuthorName != "" {
			 
		} else {
			 
		}
		Your name or the website owner's name 
	
}
templ guestbookSettingsForm(data CommonData, website models.Website, gb models.Guestbook, form forms.WebsiteSettingsForm) {
	Guestbook Settings 
	
		
			Guestbook Visibility 
			
				 
				Public
			 
			
				 
				Private
			 
		 
	
	
		Guestbook Commenting 
		
		if !website.Guestbook.CanComment() {
			{{ localtime := gb.Settings.ReenableCommenting.In(data.CurrentUser.Settings.LocalTimezone) }}
			Commenting re-enabled on { localtime.Format("2 January 2006") } at { localtime.Format("3:04PM MST") }  
		}
		
	
	
		
			Enable Widgets 
			
				 
				Yes
			 
			
				 
				No
			 
		 
		Allow embedding guestbook on external websites 
	
}
templ SettingsForm(data CommonData, website models.Website, form forms.WebsiteSettingsForm, msg string) {
	{{ putUrl := fmt.Sprintf("/websites/%s/settings", shortIdToSlug(website.ShortId)) }}
	{{ gb := website.Guestbook }}
	
}
templ DeleteForm(data CommonData, website models.Website, form forms.WebsiteDeleteForm) {
	{{ putUrl := fmt.Sprintf("/websites/%s", shortIdToSlug(website.ShortId)) }}
	
}
templ WebsiteDashboardSettings(data CommonData, website models.Website, form forms.WebsiteSettingsForm) {
	{{ title := fmt.Sprintf("%s - Settings", website.Name) }}
	@base(title, data) {
		
			@wSidebar(website)
			
				
					@SettingsForm(data, website, form, "")
				 
				
					@DeleteForm(data, website, forms.WebsiteDeleteForm{})
				 
			
		 
	}
}
templ WebsiteDashboardComingSoon(title string, data CommonData, website models.Website) {
	@base(title, data) {
		
	}
}
templ WebsiteCreate(title string, data CommonData, form forms.WebsiteCreateForm) {
	@base(title, data) {
		
	}
}