1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-02 20:15:22 +02:00
This commit is contained in:
Josh Pigford 2024-02-11 12:51:04 -06:00
commit 74f245711a
6 changed files with 83 additions and 15 deletions

View file

@ -3,7 +3,7 @@ name: CI
on:
pull_request:
push:
branches: [ main ]
branches: [main]
jobs:
scan_ruby:
@ -92,6 +92,12 @@ jobs:
# REDIS_URL: redis://localhost:6379/0
run: bin/rails db:setup test test:system
- name: Smoke test database seeds
env:
RAILS_ENV: test
DATABASE_URL: postgres://postgres:postgres@localhost:5432
run: bin/rails db:reset
- name: Keep screenshots from failed system tests
uses: actions/upload-artifact@v4
if: failure()

View file

@ -18,6 +18,24 @@ module ApplicationHelper
render partial: "shared/modal", locals: { content: content }
end
def sidebar_link_to(name, path, options = {})
base_class_names = "block border border-transparent rounded-xl -ml-2 p-2 text-sm font-medium text-gray-500 flex items-center"
hover_class_names = "hover:bg-white hover:border-[#141414]/[0.07] hover:text-gray-900 hover:shadow-xs"
current_page_class_names = "bg-white border-[#141414]/[0.07] text-gray-900 shadow-xs"
link_class_names = class_names(
base_class_names,
hover_class_names,
current_page_class_names => current_page?(path)
)
merged_options = options.reverse_merge(class: link_class_names).except(:icon)
link_to path, merged_options do
lucide_icon(options[:icon], class: "w-5 h-5 mr-2") + name
end
end
def format_currency(number, options = {})
user_currency_preference = Current.family.try(:currency) || "USD"

View file

@ -0,0 +1,53 @@
import { Controller } from "@hotwired/stimulus"
// Connects to data-controller="account-collapse"
export default class extends Controller {
static values = { type: String }
boundOnToggle = null
initialToggle = false
STORAGE_NAME = "accountCollapseStates"
connect() {
this.boundOnToggle = this.onToggle.bind(this)
this.element.addEventListener("toggle", this.boundOnToggle)
this.updateFromLocalStorage()
}
disconnect() {
this.element.removeEventListener("toggle", this.boundOnToggle)
}
onToggle() {
if (this.initialToggle) {
this.initialToggle = false
return
}
const items = this.getItemsFromLocalStorage()
if (items.has(this.typeValue)) {
items.delete(this.typeValue)
} else {
items.add(this.typeValue)
}
localStorage.setItem(this.STORAGE_NAME, JSON.stringify([...items]))
}
updateFromLocalStorage() {
const items = this.getItemsFromLocalStorage()
if (items.has(this.typeValue)) {
this.initialToggle = true
this.element.setAttribute("open", "")
}
}
getItemsFromLocalStorage() {
try {
const items = localStorage.getItem(this.STORAGE_NAME)
return new Set(items ? JSON.parse(items) : [])
} catch (error) {
console.error("Error parsing items from localStorage:", error)
return new Set()
}
}
}

View file

@ -3,7 +3,7 @@
<% accounts = Current.family.accounts.where(accountable_type: type.name) %>
<% if accounts.sum(&:converted_balance) > 0 %>
<details class="mb-1 text-sm group">
<details class="mb-1 text-sm group" data-controller="account-collapse" data-account-collapse-type-value="<%= type %>">
<summary class="flex gap-4 px-2 py-3 items-center w-full rounded-[10px] font-medium hover:bg-[#f2f2f2]">
<%= lucide_icon("chevron-down", class: "hidden group-open:block text-[#737373] w-5 h-5") %>
<%= lucide_icon("chevron-right", class: "group-open:hidden text-[#737373] w-5 h-5") %>

View file

@ -47,22 +47,13 @@
<nav>
<ul class="mt-6 space-y">
<li>
<%= link_to root_path, class: 'block hover:bg-white border border-transparent hover:border-[#141414]/[0.07] rounded-xl hover:text-gray-900 hover:shadow-xs -ml-2 p-2 text-sm font-medium text-gray-500 flex items-center' do %>
<%= lucide_icon('layout-grid', class: 'w-5 h-5 mr-2') %>
<%= t('.dashboard') %>
<% end %>
<%= sidebar_link_to t('.dashboard'), root_path, icon: 'layout-grid' %>
</li>
<li>
<%= link_to accounts_path, class: 'block hover:bg-white border border-transparent hover:border-[#141414]/[0.07] rounded-xl hover:text-gray-900 hover:shadow-xs -ml-2 p-2 text-sm font-medium text-gray-500 flex items-center' do %>
<%= lucide_icon('layers', class: 'w-5 h-5 mr-2') %>
<%= t('.accounts') %>
<% end %>
<%= sidebar_link_to t('.accounts'), accounts_path, icon: 'layers' %>
</li>
<li>
<%= link_to "#", class: 'block hover:bg-white border border-transparent hover:border-[#141414]/[0.07] rounded-xl hover:text-gray-900 hover:shadow-xs -ml-2 p-2 text-sm font-medium text-gray-500 flex items-center' do %>
<%= lucide_icon('credit-card', class: 'w-5 h-5 mr-2') %>
<%= t('.transactions') %>
<% end %>
<%= sidebar_link_to t('.transactions'), "#", icon: 'credit-card' %>
</li>
</ul>
</nav>

View file

@ -1,6 +1,6 @@
class ReplaceMoneyField < ActiveRecord::Migration[7.2]
def change
add_monetize :accounts, :balance
add_column :accounts, :balance_cents
change_column :accounts, :balance_cents, :integer, limit: 8
Account.reset_column_information