Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrum 43 Plaid Frontend #72

Merged
merged 14 commits into from
Dec 5, 2024
25 changes: 25 additions & 0 deletions backend/internal/controllers/investors.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,25 @@ func (c *InvestorsController) GetPortfolio(ctx *fiber.Ctx) error {
return ctx.JSON(investors)
}

func (c *InvestorsController) GetCashBalance(ctx *fiber.Ctx) error {
userId, ok := ctx.Locals("userId").(string)
if !ok {
return &api_errors.INVALID_UUID
}

id, err := uuid.Parse(userId)
if err != nil {
return &api_errors.INVALID_UUID
}

investors, err := transactions.GetCashBalance(c.ServiceParams.DB, id)
if err != nil {
return err
}

return ctx.JSON(investors)
}

func (c *InvestorsController) GetHistory(ctx *fiber.Ctx) error {
paginationParams := new(types.PaginationParams)

Expand Down Expand Up @@ -165,11 +184,17 @@ func (c *InvestorsController) GetInvestor(ctx *fiber.Ctx) error {
return err
}

cashBalance, err := transactions.GetCashBalance(c.ServiceParams.DB, id)
if err != nil {
return err
}

investor := models.Investor{
ID: id,
Profile: profile,
TotalInvestmentAmount: totalValue,
InvestmentBreakdown: investments,
CashBalance: cashBalance,
}

return ctx.Status(fiber.StatusOK).JSON(investor)
Expand Down
1 change: 1 addition & 0 deletions backend/internal/models/investor.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type Investor struct {
Profile InvestorProfile `json:"profile"`
TotalInvestmentAmount int `json:"total_investment_amount"`
InvestmentBreakdown map[uuid.UUID]int `json:"investment_breakdown"`
CashBalance int `json:"cash_balance"`
}

type InvestorProfile struct {
Expand Down
2 changes: 1 addition & 1 deletion backend/internal/transactions/investors.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func GetHistory(db *pgxpool.Pool, investorID uuid.UUID, limit int, offset int) (
return history, nil
}

func GetCashBalance(pool *pgxpool.Pool, investorID string) (int, error) {
func GetCashBalance(pool *pgxpool.Pool, investorID uuid.UUID) (int, error) {
query := "SELECT cash_balance_cents FROM investors WHERE supabase_id = $1"

var balance int
Expand Down
Binary file added frontend/assets/images/chase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/assets/images/confetti.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/assets/images/edit-icon-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/assets/images/edit-icon-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/assets/images/withdraw-error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading