added two fields to new transactions

This commit is contained in:
Nickiel12 2024-02-17 14:50:58 -08:00
parent aa88e9207d
commit 37d351e23d
6 changed files with 83 additions and 22 deletions

View file

@ -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",
};

View file

@ -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
}

View file

@ -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");
}

View file

@ -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);
}

View file

@ -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) {
<div id="new-transaction-pane" style="opacity: 0;" class="cr-all c-base d-flex-col">
<div class="my-3 d-flex">
<div class="my-2 d-flex">
<h2 class="ms-5">New Transaction</h2>
<button class="ms-auto me-4 my-auto exit-btn" id="close-transaction-pane">
<i class="my-auto" data-feather="x"></i>
</button>
</div>
<div class="d-flex" style="overflow-x: scroll;">
<div class="d-flex ms-5" style="overflow-x: scroll;">
for _, value := range *entry_types {
<button class="borderless-btn mx-3">
<button class="borderless-btn btn-sm mx-3">
{value.DisplayName}
</button>
}
</div>
<div class="c-mantle cr-all m-5 d-flex" style="height:85%">
<div class="p-5 mx-auto">
<label for="acnt-selection" id="acnt-selection-label">Account: </label>
<select class="ms-2 select light border" id="acnt-selection" value="">
for _, value := range *acnts {
<option value={strconv.Itoa(value.Id)}>{value.DisplayName.String}</option>
}
</select>
</div>
<div class="p-5 mx-auto">
<label for="acnt-date" id="data-selection-label">Date: </label>
<input id="acnt-date" type="date" />
</div>
</div>
</div>
}

View file

@ -16,16 +16,16 @@ templ TransactionsPage(userID int, accounts *[]string) {
</button>
<div class="popup-menu" id="filter-popup" role="tooltip" style="display:none;">
<div class="d-flex p-3">
<select class="select-swapout">
<select class="select-swapout select">
<option data-select-div="filter-accounts">Account</option>
<option data-select-div="filter-two-inputs">Amount</option>
<option data-select-div="filter-two-inputs">Date</option>
<option data-select-div="filter-contains">Desc. Contains</option>
<option data-select-div="filter-contains">Description</option>
<option data-select-div="filter-two-inputs">ID</option>
</select>
<div id="filter-two-inputs" class="d-flex" style="display: none;">
<input type="text"></input>
<select class="ms-2">
<select class="ms-2 select">
<option>></option>
<option>=</option>
<option>{"<"}</option>
@ -33,16 +33,17 @@ templ TransactionsPage(userID int, accounts *[]string) {
<input class="ms-2" type="text"></input>
</div>
<div id="filter-contains" class="d-flex" style="display: none;">
<select class="ms-2">
<select class="ms-2 select">
<option>Contains</option>
<option>Does Not Contain</option>
</select>
<input class="ms-2" type="text"></input>
</div>
<div id="filter-accounts" class="d-flex">
<select class="ms-2">
<select class="ms-2 select">
<option>=</option>
</select>
<select class="ms-2">
<select class="ms-2 select">
for _, value := range *accounts {
<option>{value}</option>
}