diff --git a/db/db.go b/db/db.go index df30327..f15ab05 100644 --- a/db/db.go +++ b/db/db.go @@ -2,6 +2,7 @@ package db import ( "fmt" + "database/sql" "github.com/jmoiron/sqlx" _ "github.com/lib/pq" @@ -67,10 +68,39 @@ func NewTransaction(transaction types.Transaction) error { return nil } -func GetTransPaneEntries(userID int) ([]types.QuickTransactionTypes, error) { - transaction_types := make([]types.QuickTransactionTypes, 1); +func GetUserAccounts(userID int) ([]types.Account, error) { + user_accounts := make([]types.Account, 4); - transaction_types[0] = types.QuickTransactionTypes { + user_accounts[0] = types.Account { + Id: 1, + DisplayName: sql.NullString { + String: "Savings", + Valid: true, + } , + Description: sql.NullString { + String: "BECU Saving Account", + Valid: true, + }, + }; + user_accounts[1] = types.Account { + Id: 2, + DisplayName: sql.NullString { + String: "Svngs", + Valid: true, + } , + Description: sql.NullString { + String: "BECU Saving Account", + Valid: true, + }, + }; + + return user_accounts, nil; +} + +func GetTransPaneEntries(userID int) ([]types.QuickTransactionType, error) { + transaction_types := make([]types.QuickTransactionType, 1); + + transaction_types[0] = types.QuickTransactionType { DisplayName: "Manual", }; diff --git a/types/types.go b/types/types.go index 641b85b..270f07a 100644 --- a/types/types.go +++ b/types/types.go @@ -15,6 +15,12 @@ type Transaction struct { Date time.Time `db:"trns_date" json:"TransactionDate"` } +type Account struct { + Id int `db:"acnt_id" json:"Id"` + DisplayName sql.NullString `db:"acnt_dsply_name" json:"DisplayName"` + Description sql.NullString `db:"acnt_description" json:"Description"` +} + type HumanLegibleTransaction struct { Id int `db:"trns_id" json:"Id"` Amount string `db:"trns_amount" json:"Amount"` @@ -26,7 +32,7 @@ type HumanLegibleTransaction struct { Date time.Time `db:"trns_date" json:"TransactionDate"` } -type QuickTransactionTypes struct { +type QuickTransactionType struct { DisplayName string } diff --git a/web/router.go b/web/router.go index 39a3b64..2c3dbdd 100644 --- a/web/router.go +++ b/web/router.go @@ -74,8 +74,9 @@ func renderFullPage(w http.ResponseWriter, c templ.Component, pageName string) { var new_tp bytes.Buffer; quick_trans_types, err := db.GetTransPaneEntries(0); + user_acnts, err := db.GetUserAccounts(0); - err = templates.NewTransactionPane(&quick_trans_types).Render(context.Background(), &new_tp); + err = templates.NewTransactionPane(&quick_trans_types, &user_acnts).Render(context.Background(), &new_tp); if err != nil { log.Fatal().Err(err).Msg("Could not render new transaction pane for index"); } diff --git a/web/sass/utility-classes.scss b/web/sass/utility-classes.scss index 54379fc..8c27164 100644 --- a/web/sass/utility-classes.scss +++ b/web/sass/utility-classes.scss @@ -214,13 +214,6 @@ table.table-striped { border-width: thin; transition: max-height 0.2s linear; - select { - font-size: 1em; - border: none; - border-radius: $border-radius; - background-color: var(--#{$prefix}-mantle); - color: var(--#{$prefix}-text); - } input { width: 5em; font-size: 1em; @@ -232,3 +225,18 @@ table.table-striped { } } +.select { + border: none; + font-size: 1em; + border-radius: $border-radius; + background-color: var(--#{$prefix}-mantle); + color: var(--#{$prefix}-text); +} + +.select.border { + border: 2pt solid var(--#{$prefix}-text); +} + +.select.light { + background-color: var(--#{$prefix}-base); +} diff --git a/web/templates/new_transaction_pane.templ b/web/templates/new_transaction_pane.templ index 7eeed9d..c203108 100644 --- a/web/templates/new_transaction_pane.templ +++ b/web/templates/new_transaction_pane.templ @@ -1,23 +1,38 @@ package templates import "nickiel.net/recount_server/types" +import "strconv" -templ NewTransactionPane(entry_types *[]types.QuickTransactionTypes) { +templ NewTransactionPane(entry_types *[]types.QuickTransactionType, acnts *[]types.Account) {