1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-09 23:45:21 +02:00

Merge branch 'main' of github.com:maybe-finance/maybe into rule-name

This commit is contained in:
hatz 2025-05-01 18:42:08 -05:00
commit 7d367587e2
No known key found for this signature in database
8 changed files with 26 additions and 10 deletions

View file

@ -6,7 +6,7 @@
<% elsif variant == :avatar %>
<button data-menu-target="button">
<div class="w-9 h-9 cursor-pointer">
<%= render "settings/user_avatar", avatar_url: avatar_url %>
<%= render "settings/user_avatar", avatar_url: avatar_url, initials: initials %>
</div>
</button>
<% end %>

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
class MenuComponent < ViewComponent::Base
attr_reader :variant, :avatar_url, :placement, :offset, :icon_vertical, :no_padding, :testid
attr_reader :variant, :avatar_url, :initials, :placement, :offset, :icon_vertical, :no_padding, :testid
renders_one :button, ->(**button_options, &block) do
options_with_target = button_options.merge(data: { menu_target: "button" })
@ -23,9 +23,10 @@ class MenuComponent < ViewComponent::Base
VARIANTS = %i[icon button avatar].freeze
def initialize(variant: "icon", avatar_url: nil, placement: "bottom-end", offset: 12, icon_vertical: false, no_padding: false, testid: nil)
def initialize(variant: "icon", avatar_url: nil, initials: nil, placement: "bottom-end", offset: 12, icon_vertical: false, no_padding: false, testid: nil)
@variant = variant.to_sym
@avatar_url = avatar_url
@initials = initials
@placement = placement
@offset = offset
@icon_vertical = icon_vertical

View file

@ -4,6 +4,7 @@ class ApplicationController < ActionController::Base
before_action :detect_os
before_action :set_default_chat
before_action :set_active_storage_url_options
private
def detect_os
@ -23,4 +24,12 @@ class ApplicationController < ActionController::Base
@last_viewed_chat = Current.user&.last_viewed_chat
@chat = @last_viewed_chat
end
def set_active_storage_url_options
ActiveStorage::Current.url_options = {
protocol: request.protocol,
host: request.host,
port: request.optional_port
}
end
end

View file

@ -18,7 +18,11 @@ module Onboardable
return unless Current.user
return unless redirectable_path?(request.path)
if Current.user.onboarded_at.blank?
# Check if trial was started VERY recently (e.g., within the last few seconds)
# If so, assume onboarding was just completed in the previous request, even if onboarded_at appears blank momentarily.
trial_just_started = Current.family.trial_started_at.present? && Current.family.trial_started_at > 10.seconds.ago
if Current.user.onboarded_at.blank? && !trial_just_started
redirect_to onboarding_path
elsif !Current.family.subscribed? && !Current.family.trialing?
redirect_to upgrade_subscription_path

View file

@ -21,7 +21,7 @@ class User < ApplicationRecord
has_one_attached :profile_image do |attachable|
attachable.variant :thumbnail, resize_to_fill: [ 300, 300 ], convert: :webp, saver: { quality: 80 }
attachable.variant :small, resize_to_fill: [ 72, 72 ], convert: :webp, saver: { quality: 80 }
attachable.variant :small, resize_to_fill: [ 72, 72 ], convert: :webp, saver: { quality: 80 }, preprocessed: true
end
validate :profile_image_size

View file

@ -41,9 +41,9 @@
<p class="uppercase text-xs text-secondary font-medium"><%= Current.family.name %> &middot; <%= Current.family.users.size %></p>
</div>
<% @users.each do |user| %>
<div class="flex gap-2 items-center bg-container p-4 border border-alpha-black-25 rounded-lg">
<div class="flex gap-2 mt-2 items-center bg-container p-4 border border-alpha-black-25 rounded-lg">
<div class="w-9 h-9 shrink-0">
<%= render "settings/user_avatar", avatar_url: user.profile_image.url %>
<%= render "settings/user_avatar", avatar_url: user.profile_image&.variant(:small)&.url, initials: user.initials %>
</div>
<p class="text-primary font-medium text-sm"><%= user.display_name %></p>
<div class="rounded-md bg-surface px-1.5 py-0.5">

View file

@ -4,7 +4,9 @@
<div class="flex items-center gap-5">
<div class="flex items-center gap-2">
<%= render MenuComponent.new do |menu| %>
<% menu.with_item(variant: "button", text: "Dev only: Sync all", href: sync_all_accounts_path, method: :post, icon: "refresh-cw") %>
<% if Rails.env.development? %>
<% menu.with_item(variant: "button", text: "Dev only: Sync all", href: sync_all_accounts_path, method: :post, icon: "refresh-cw") %>
<% end %>
<% menu.with_item(variant: "link", text: "New rule", href: new_rule_path(resource_type: "transaction"), icon: "plus", data: { turbo_frame: :modal }) %>
<% menu.with_item(variant: "link", text: "Edit rules", href: rules_path, icon: "git-branch", data: { turbo_frame: :_top }) %>
<% menu.with_item(variant: "link", text: "Edit categories", href: categories_path, icon: "shapes", data: { turbo_frame: :_top }) %>

View file

@ -1,11 +1,11 @@
<%# locals: (user:, placement: "right-start", offset: 16) %>
<div data-testid="user-menu">
<%= render MenuComponent.new(variant: "avatar", avatar_url: user.profile_image&.variant(:small)&.url, placement: placement, offset: offset) do |menu| %>
<%= render MenuComponent.new(variant: "avatar", avatar_url: user.profile_image&.variant(:small)&.url, initials: user.initials, placement: placement, offset: offset) do |menu| %>
<%= menu.with_header do %>
<div class="px-4 py-3 flex items-center gap-3">
<div class="w-9 h-9 shrink-0">
<%= render "settings/user_avatar", avatar_url: user.profile_image&.variant(:small)&.url, lazy: true %>
<%= render "settings/user_avatar", avatar_url: user.profile_image&.variant(:small)&.url, initials: user.initials, lazy: true %>
</div>
<div class="overflow-hidden text-ellipsis text-sm">