Files
sure/app/views/goals/_status_callout.html.erb
Guillem Arias 612af6c14b fix(goals): apply CodeRabbit findings
- Switch the goal_accounts → accounts FK from on_delete: :cascade to
  :restrict. `Goal#must_have_at_least_one_linked_account` is enforced
  at write time; the cascade let a raw DELETE silently orphan a Goal
  whose only link pointed at the deleted account. Normal Rails
  Account#destroy still cleans up via `dependent: :destroy`, but the
  restrict guarantees the DB rejects any path that bypasses the
  association.
- projection_payload: required_monthly is now monthly_target_amount&.to_f
  so open-ended (no-target-date) goals serialize required_monthly: null
  instead of 0, matching the absence of a required pace.
- index page + sidebar nav-rail dot now read the Beta label via
  t("shared.beta") (and a new shared.beta locale key) instead of the
  hardcoded "Beta" literal.
- _status_callout uses the view-helper t(...) instead of I18n.t(...)
  for the status label so it follows the same convention as the rest
  of the goals views.
- goal_projection_chart: read the computed style before stamping
  position: relative so a stylesheet-defined position (fixed/sticky/
  absolute) isn't clobbered.
- preview-deploy: add `set -euo pipefail` around the wrangler
  container lookup so a curl/jq failure fails the job instead of
  producing an empty CONTAINER_ID and silently skipping cleanup.
2026-05-18 21:33:09 +02:00

29 lines
1.1 KiB
Plaintext

<%
context = goal.status_callout_context
return if context.blank?
variant_classes = case goal.status
when :behind
"bg-warning/10 border-warning/20 text-yellow-700 theme-dark:text-yellow-300"
when :on_track
"bg-success/10 border-success/20 text-green-700 theme-dark:text-green-300"
else
"bg-surface-inset border-secondary text-secondary"
end
icon_glyph = case goal.status
when :behind then "triangle-alert"
when :on_track then "circle-check"
when :no_target_date then "infinity"
else "info"
end
label = t("goals.status.#{goal.status}", default: goal.status.to_s.titleize)
%>
<div class="rounded-lg border px-3 py-2 text-sm flex items-center gap-2 <%= variant_classes %>">
<span class="shrink-0"><%= icon(icon_glyph, size: "sm") %></span>
<span class="font-medium"><%= label %></span>
<span class="opacity-60">·</span>
<span class="opacity-90"><%= context %></span>
</div>