package templates
// ShareRow is a single share grant shown in the UI, for either a calendar
// or an address book (Kind distinguishes them for form targets).
type ShareRow struct {
ResourceName string
SharedWith string
Permission string // "read" or "write"
}
// ResourceCard describes one of the user's own calendars/address books
// plus who it's currently shared with.
type ResourceCard struct {
Kind string // "calendar", "addressbook", or "ics" (read-only ICS subscription)
Name string
Color string // hex color like "#3b82f6"; only used for calendars/ics
URL string // remote ICS/webcal URL; only used for kind "ics"
Shares []ShareRow
Virtual bool // true for computed calendars (e.g. birthdays): no delete/sharing, just a color picker
}
// SharedWithMeItem describes a resource another user has shared with the
// current user.
type SharedWithMeItem struct {
Kind string
Owner string
Name string
Permission string
}
templ Dashboard(username string, resources []ResourceCard, sharedWithMe []SharedWithMeItem) {
@Layout("Dashboard", username) {
Your calendars & address books
@ResourceList(resources)
if len(sharedWithMe) > 0 {
}
}
}
// ResourceList renders the #resources container. It's re-rendered as a
// whole after a create/delete (which changes the set of cards), whereas a
// share update only swaps a single ResourceCardView.
templ ResourceList(resources []ResourceCard) {
for _, r := range resources {
@ResourceCardView(r)
}
if len(resources) == 0 {
You don't have any calendars or address books yet — add one above.
}
}
templ ResourceCardView(r ResourceCard) {
if r.Kind == "calendar" || r.Kind == "ics" {
}
{ r.Name }
{ r.Kind }
if r.Virtual {
(computed from contacts)
}
if r.Kind == "ics" {
(read-only subscription)
}
if !r.Virtual {
}