package templates import ( "fmt" "strconv" "git.preston-baxter.com/Preston_PLB/capstone/frontend-service/db/models" ) func hasVendor(name string, vendors []models.VendorAccount) bool { for _, vendor := range vendors { if vendor.Name == name { return true } } return false } func hasPco(vendors []models.VendorAccount) bool { return hasVendor(models.PCO_VENDOR_NAME, vendors) } func hasYoutube(vendors []models.VendorAccount) bool { return hasVendor(models.YOUTUBE_VENDOR_NAME, vendors) } templ DashboardPage(user *models.User, vendorAccounts []models.VendorAccount, actionMappings []models.ActionMapping) { @Head("Dashboard")
@DashboardNav(user) @DashboardContent(user, vendorAccounts, actionMappings)
@DashboardFooter() @DashboardScript() @toggleDropdown() } templ DashboardNav(user *models.User) { } templ DashboardNavItem(icon, name, link string, enabled bool) {
  • { name }
  • } //Break this up templ DashboardContentNav(user *models.User) { } templ DashboardCardLoader(kind string) {
    ---
    ---

    --- ---

    @spinnerCentered()
    } templ DashboardCard(title, primaryVal, secondaryVal, subtitle string) {
    { title }
    { primaryVal }

    { secondaryVal } { subtitle }

    } templ DashboardVendorDropDown() {
    } templ DashboardVendorWidget(vendors []models.VendorAccount) {

    Vendors

    @DashboardVendorDropDown()
    if len(vendors) == 0 { } else { for _, vendor := range vendors { } }
    Name Status
    No accounts are available. Click + to add one
    { vendor.Name } if vendor.OauthCredentials != nil && vendor.OauthCredentials.AccessToken != "" { Active } else { }
    } templ DashboardActionModalForm(vendors []models.VendorAccount) {
    } templ DashboardActionModal(vendors []models.VendorAccount) {

    Modal Title

    @DashboardActionModalForm(vendors)
    } templ DashboardActionDropDown() { } templ DashboardActionEditButton(action *models.ActionMapping) { } templ DashboardActionsWidget(actions []models.ActionMapping) {

    Vendors

    @DashboardActionDropDown()
    if len(actions) == 0 { } else { for index, action := range actions { } }
    Id Event Source Event Action Action
    No actions are available. Click + to add one
    { strconv.Itoa(index) } { action.SourceEvent.Key } { action.Action.VendorName }: { action.Action.Type } @DashboardActionEditButton(&action)
    } templ DashboardContent(user *models.User, vendorAccounts []models.VendorAccount, actions []models.ActionMapping) {
    @DashboardContentNav(user)
    @DashboardCardLoader("events_received") @DashboardCardLoader("streams_scheduled")
    @DashboardVendorWidget(vendorAccounts)
    @DashboardActionsWidget(actions)
    } templ DashboardScript() { }