package templates import "fmt" // AddressBookSummary is one of the user's own address books, listed on // the contacts home page. type AddressBookSummary struct { Name string Count int } // ContactSummary is a single contact row shown in a book's contact list. type ContactSummary struct { ID string FullName string Organization string Phone string Email string PhotoDataURL string // "data:image/...;base64,..." if the contact has a photo, else "" } // LabeledValue is one TEL/EMAIL entry with its TYPE parameter ("home", // "work", or "" for unspecified/other). type LabeledValue struct { Type string Value string } // AddressValue is one ADR entry with its TYPE parameter. type AddressValue struct { Type string Street string City string Region string PostalCode string Country string } // ContactFormData pre-fills the create/edit contact form. Phones, Emails, // and Addresses always contain at least one (possibly blank) entry so the // form always renders at least one input row per section. type ContactFormData struct { Book string ID string // empty when creating a new contact FullName string Organization string Birthday string // "YYYY-MM-DD", empty if not set Note string PhotoDataURL string // existing photo preview, "" if none Phones []LabeledValue Emails []LabeledValue Addresses []AddressValue } templ ContactsHome(username string, books []AddressBookSummary) { @Layout("Contacts", username) {
You don't have any address books yet — create one from the dashboard first.
} else {| Name | Organization | Phone | |||
|---|---|---|---|---|---|
| @avatar(c.PhotoDataURL, "w-8 h-8") | { c.FullName } | { c.Organization } | { c.Phone } | { c.Email } | Export |
| No contacts yet — add one above. | |||||
{ errMsg }
} } } func contactFormAction(data ContactFormData) templ.SafeURL { if data.ID == "" { return templ.URL("/web/contacts/" + data.Book + "/new") } return templ.URL("/web/contacts/" + data.Book + "/" + data.ID + "/edit") }