2024-03-06 09:56:59 -05:00
<div class="space-y-4">
2024-12-04 00:36:59 +05:30
<% if self_hosted? %>
<% if Current.family&.synth_overage? %>
<div class="bg-yellow-100 border border-yellow-400 text-yellow-700 px-4 py-3 rounded relative" role="alert">
Your Synth API credit limit has been exceeded. Please visit your <a href="https://dashboard.synthfinance.com/settings" class="font-medium underline hover:text-yellow-900">Synth billing settings</a> to upgrade your plan or wait for your credits to reset.
</div>
<% elsif !Current.family&.synth_valid? %>
<div class="bg-yellow-100 border border-yellow-400 text-yellow-700 px-4 py-3 rounded relative" role="alert">
Your Synth API Key is invalid. Please visit your <a href="https://dashboard.synthfinance.com/dashboard" class="font-medium underline hover:text-yellow-900">Synth dashboard</a> and verify that your API key is correct.
</div>
<% end %>
2024-11-26 07:45:00 -06:00
<% end %>
2024-04-18 10:32:36 -04:00
<header class="flex items-center justify-between">
<div>
2024-09-10 17:17:10 -04:00
<h1 class="sr-only"><%= t(".title") %></h1>
2024-10-10 15:03:47 -07:00
<p class="text-xl font-medium text-gray-900 mb-1">
<%= Current.user.first_name.present? ? t(".greeting", name: Current.user.first_name ) : t(".fallback_greeting") %>
</p>
2024-06-24 11:58:39 -04:00
<% unless @accounts.blank? %>
2024-05-03 12:11:31 +00:00
<p class="text-gray-500 text-sm"><%= t(".subtitle") %></p>
<% end %>
2024-04-18 10:32:36 -04:00
</div>
2024-09-10 17:17:10 -04:00
2024-10-01 10:47:59 -04:00
<div class="flex items-center gap-2">
<%= contextual_menu do %>
<div class="w-48 p-1 text-sm leading-6 text-gray-900 bg-white shadow-lg shrink rounded-xl ring-1 ring-gray-900/5">
<%= contextual_menu_modal_action_item t(".import"), new_import_path, icon: "hard-drive-upload" %>
</div>
<% end %>
2024-11-04 20:27:31 -05:00
<%= link_to new_account_path, class: "flex items-center gap-1 btn btn--primary", data: { turbo_frame: "modal" } do %>
2024-10-01 10:47:59 -04:00
<%= lucide_icon("plus", class: "w-5 h-5") %>
<span><%= t(".new") %></span>
<% end %>
</div>
2024-04-18 10:32:36 -04:00
</header>
2024-09-10 17:17:10 -04:00
2024-10-24 11:02:27 -04:00
<% if @accounts.empty? %>
2024-05-03 12:11:31 +00:00
<%= render "shared/no_account_empty_state" %>
<% else %>
2024-09-10 17:17:10 -04:00
<section class="flex gap-4">
<div class="bg-white border border-alpha-black-25 shadow-xs rounded-xl w-3/4 min-h-48 flex flex-col">
<div class="flex justify-between p-4">
<div>
<%= render partial: "shared/value_heading", locals: {
2024-04-18 10:32:36 -04:00
label: t(".net_worth"),
2024-03-06 09:56:59 -05:00
period: @period,
2024-04-18 10:32:36 -04:00
value: Current.family.net_worth,
2024-03-06 09:56:59 -05:00
trend: @net_worth_series.trend
2024-04-18 10:32:36 -04:00
} %>
2024-09-10 17:17:10 -04:00
</div>
<%= form_with url: root_path, method: :get, class: "flex items-center gap-4", data: { controller: "auto-submit-form" } do |form| %>
<%= period_select form: form, selected: @period.name %>
<% end %>
2024-04-18 10:32:36 -04:00
</div>
2024-09-10 17:17:10 -04:00
<%= render partial: "pages/dashboard/net_worth_chart", locals: { series: @net_worth_series } %>
2024-03-06 09:56:59 -05:00
</div>
2024-09-10 17:17:10 -04:00
<div class="bg-white p-4 border border-alpha-black-25 shadow-xs rounded-xl w-1/4">
<%= render partial: "pages/dashboard/allocation_chart", locals: { account_groups: @account_groups } %>
</div>
</section>
<section class="grid grid-cols-2 gap-4">
<div class="bg-white p-4 border border-alpha-black-25 shadow-xs rounded-xl">
<div class="flex flex-col gap-4 h-full">
<div class="flex gap-4">
<div class="grow">
<%= render partial: "shared/value_heading", locals: {
2024-04-24 13:34:50 +01:00
label: t(".income"),
period: Period.last_30_days,
value: @income_series.last&.value,
trend: @income_series.trend
} %>
2024-09-10 17:17:10 -04:00
</div>
<div
2024-04-24 13:34:50 +01:00
id="incomeChart"
class="h-full w-2/5"
data-controller="time-series-chart"
data-time-series-chart-data-value="<%= @income_series.to_json %>"
data-time-series-chart-use-labels-value="false"
data-time-series-chart-use-tooltip-value="false"></div>
2024-09-10 17:17:10 -04:00
</div>
2024-10-18 14:37:42 -04:00
<div class="flex gap-1.5 mt-auto">
2024-09-10 17:17:10 -04:00
<% @top_earners.first(3).each do |account| %>
2024-10-16 19:14:43 +02:00
<%= link_to account, class: "border border-alpha-black-25 rounded-full p-1 pr-2 flex items-center gap-1 text-xs text-gray-900 font-medium hover:bg-gray-25", data: { controller: "tooltip" } do %>
2024-10-18 14:37:42 -04:00
<%= render "accounts/logo", account: account, size: "sm" %>
2024-09-10 17:17:10 -04:00
<span>+<%= Money.new(account.income, account.currency) %></span>
2024-10-16 19:14:43 +02:00
<%= render partial: "shared/text_tooltip", locals: { tooltip_text: account.name } %>
2024-09-10 17:17:10 -04:00
<% end %>
2024-04-24 13:34:50 +01:00
<% end %>
2024-09-10 17:17:10 -04:00
<% if @top_earners.count > 3 %>
<div class="bg-gray-25 rounded-full flex h-full aspect-1 items-center justify-center text-xs font-medium text-gray-500">+<%= @top_earners.count - 3 %></div>
<% end %>
</div>
2024-03-06 09:56:59 -05:00
</div>
</div>
2024-09-10 17:17:10 -04:00
<div class="bg-white p-4 border border-alpha-black-25 shadow-xs rounded-xl">
<div class="flex flex-col gap-4 h-full">
<div class="flex gap-4">
<div class="grow">
<%= render partial: "shared/value_heading", locals: {
2024-04-24 13:34:50 +01:00
label: t(".spending"),
period: Period.last_30_days,
value: @spending_series.last&.value,
trend: @spending_series.trend
} %>
2024-09-10 17:17:10 -04:00
</div>
<div
2024-04-24 13:34:50 +01:00
id="spendingChart"
class="h-full w-2/5"
data-controller="time-series-chart"
data-time-series-chart-data-value="<%= @spending_series.to_json %>"
data-time-series-chart-use-labels-value="false"
data-time-series-chart-use-tooltip-value="false"></div>
2024-09-10 17:17:10 -04:00
</div>
2024-10-18 14:37:42 -04:00
<div class="mt-auto flex gap-1.5">
2024-09-10 17:17:10 -04:00
<% @top_spenders.first(3).each do |account| %>
2024-10-16 19:14:43 +02:00
<%= link_to account, class: "border border-alpha-black-25 rounded-full p-1 pr-2 flex items-center gap-1 text-xs text-gray-900 font-medium hover:bg-gray-25", data: { controller: "tooltip" } do %>
2024-10-18 14:37:42 -04:00
<%= render "accounts/logo", account: account, size: "sm" %>
2024-09-10 17:17:10 -04:00
-<%= Money.new(account.spending, account.currency) %>
2024-10-18 14:37:42 -04:00
<%= render partial: "shared/text_tooltip", locals: { tooltip_text: account.name } %>
2024-09-10 17:17:10 -04:00
<% end %>
2024-04-24 13:34:50 +01:00
<% end %>
2024-09-10 17:17:10 -04:00
<% if @top_spenders.count > 3 %>
<div class="bg-gray-25 rounded-full flex h-full aspect-1 items-center justify-center text-xs font-medium text-gray-500">+<%= @top_spenders.count - 3 %></div>
<% end %>
</div>
2024-03-06 09:56:59 -05:00
</div>
</div>
2024-09-10 17:17:10 -04:00
<div class="bg-white p-4 border border-alpha-black-25 shadow-xs rounded-xl">
<div class="flex flex-col gap-4 h-full">
<div class="flex gap-4">
<div class="grow">
<%= render partial: "shared/value_heading", locals: {
2024-04-24 15:02:22 +01:00
label: t(".savings_rate"),
period: Period.last_30_days,
value: @savings_rate_series.last&.value,
trend: @savings_rate_series.trend,
is_percentage: true
} %>
2024-09-10 17:17:10 -04:00
</div>
<div
2024-04-24 15:02:22 +01:00
id="savingsRateChart"
class="h-full w-2/5"
data-controller="time-series-chart"
data-time-series-chart-data-value="<%= @savings_rate_series.to_json %>"
data-time-series-chart-use-labels-value="false"
data-time-series-chart-use-tooltip-value="false"></div>
2024-09-10 17:17:10 -04:00
</div>
<div class="flex gap-1.5">
<% @top_savers.first(3).each do |account| %>
2024-10-09 11:38:34 -04:00
<% unless account.savings_rate.infinite? %>
2024-10-16 19:14:43 +02:00
<%= link_to account, class: "border border-alpha-black-25 rounded-full p-1 pr-2 flex items-center gap-1 text-xs text-gray-900 font-medium hover:bg-gray-25", data: { controller: "tooltip" } do %>
2024-10-18 14:37:42 -04:00
<%= render "accounts/logo", account: account, size: "sm" %>
2024-10-07 16:20:36 -04:00
<span><%= account.savings_rate > 0 ? "+" : "-" %><%= number_to_percentage(account.savings_rate.abs * 100, precision: 2) %></span>
2024-10-18 14:37:42 -04:00
<%= render partial: "shared/text_tooltip", locals: { tooltip_text: account.name } %>
2024-10-07 16:20:36 -04:00
<% end %>
2024-09-10 17:17:10 -04:00
<% end %>
2024-04-24 15:02:22 +01:00
<% end %>
2024-09-10 17:17:10 -04:00
<% if @top_savers.count > 3 %>
<div class="bg-gray-25 rounded-full flex h-full aspect-1 items-center justify-center text-xs font-medium text-gray-500">+<%= @top_savers.count - 3 %></div>
<% end %>
</div>
2024-03-06 09:56:59 -05:00
</div>
2024-04-18 10:32:36 -04:00
</div>
2024-09-10 17:17:10 -04:00
<div class="bg-white p-4 border border-alpha-black-25 shadow-xs rounded-xl">
<div class="flex gap-4 h-full">
<div class="grow">
<%= render partial: "shared/value_heading", locals: {
2024-04-18 10:32:36 -04:00
label: t(".investing"),
period: @period,
value: @investing_series.last.value,
trend: @investing_series.trend
} %>
2024-09-10 17:17:10 -04:00
</div>
<div
2024-04-22 11:44:26 -06:00
id="investingChart"
2024-04-18 10:32:36 -04:00
class="h-full w-2/5"
2024-04-22 11:44:26 -06:00
data-controller="time-series-chart"
data-time-series-chart-data-value="<%= @investing_series.to_json %>"
data-time-series-chart-use-labels-value="false"></div>
2024-03-06 09:56:59 -05:00
</div>
2024-04-18 10:32:36 -04:00
</div>
2024-09-10 17:17:10 -04:00
</section>
<section class="w-full">
2024-04-18 10:32:36 -04:00
<div class="bg-white p-4 border border-alpha-black-25 shadow-xs rounded-xl space-y-4">
2024-09-10 17:17:10 -04:00
<h2 class="text-lg font-medium text-gray-900"><%= t(".transactions") %></h2>
<% if @transaction_entries.empty? %>
<div class="text-gray-500 flex items-center justify-center py-12">
<p><%= t(".no_transactions") %></p>
</div>
<% else %>
<div class="text-gray-500 p-1 space-y-1 bg-gray-25 rounded-xl">
<%= entries_by_date(@transaction_entries, selectable: false) do |entries| %>
2024-11-04 20:27:31 -05:00
<%= render entries, selectable: false %>
2024-09-10 17:17:10 -04:00
<% end %>
<p class="py-2 text-sm text-center"><%= link_to t(".view_all"), transactions_path %></p>
</div>
<% end %>
2024-03-06 09:56:59 -05:00
</div>
2024-09-10 17:17:10 -04:00
</section>
2024-05-03 12:11:31 +00:00
<% end %>
2024-03-06 09:56:59 -05:00
</div>