Skip to content

fix: user form#122

Merged
danielhe4rt merged 7 commits into
3.xfrom
fix/user-form
Nov 24, 2025
Merged

fix: user form#122
danielhe4rt merged 7 commits into
3.xfrom
fix/user-form

Conversation

@Clintonrocha98
Copy link
Copy Markdown
Collaborator

@Clintonrocha98 Clintonrocha98 commented Nov 24, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Monthly active user statistics now constrained to the current year and month
    • ZIP Code field in the user address form is now optional
  • Refactor

    • User edit form reorganized into modular, labeled sections for clearer layout and maintenance
    • User stats queries reformatted for readability without changing behavior
  • Tests

    • Added test coverage for concurrent Talk creation when an existing Talk is Pending
    • Updated user edit test inputs and assertions to reflect form changes

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Nov 24, 2025

Walkthrough

Refactors Filament user form into modular schemas, relaxes ZIP code required validation, adjusts user stats query year/month filtering, updates related user tests to use hardcoded inputs, and adds an events test ensuring a Talk can be created when an overlapping Pending talk exists.

Changes

Cohort / File(s) Summary
User Form Refactor
app-modules/user/src/Filament/Admin/Resources/Users/Pages/EditUser.php
Replaces inline field definitions with composed form schemas: UserForm, UserAddressForm, UserInformationForm; reorganizes sections (General Information, Gamefication, Providers) and adds imports.
Address Schema
app-modules/user/src/Filament/Shared/Schemas/UserAddressForm.php
Removes required validation from the ZIP Code (SmartCep) field while preserving masking and bindings.
User Stats Widget
app-modules/user/src/Filament/Shared/Widgets/UsersStatsOverview.php
Reformats query cloning and applies explicit whereYear() + whereMonth() filters for monthly counts (logic unchanged in outcome).
User Tests
app-modules/user/tests/Feature/Filament/Admin/Resources/User/EditUserTest.php
Replaces factory-generated update data with hardcoded values (fulano, fulano@email.com, 13000-000), updates assertions, and asserts no form errors after save.
Event Talk Tests
app-modules/events/tests/Feature/Filament/App/Talks/CreateTalkTest.php
Adds a test that verifies creating a Talk is allowed when an existing Talk for the same event/time has status Pending (no validation errors).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Pay attention to EditUser.php composition to ensure no missing fields/validation when migrating to schema components.
  • Verify removal of ZIP code required constraint doesn't break downstream validation, imports, or UI expectations.
  • Confirm UsersStatsOverview date filtering yields intended monthly counts.
  • Review tests for appropriate assertions and completeness.

Possibly related PRs

  • feat: talks time #105 — Related to talk scheduling validation and tests for overlapping talks with Pending status.

Suggested reviewers

  • danielhe4rt

Poem

🐇 I hopped through forms, rearranged each part,

ZIP code sighed and loosened its heart,
Counts now check months with clearer view,
Tests nod yes — overlapping talks pass through,
A small carrot cheer for code anew 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'fix: user form' is extremely vague and does not capture the main changes. The PR involves significant refactoring of user form components, removing ZIP code validation, reorganizing test scenarios, and reformatting code. A more specific title would better communicate the primary intent. Consider a more descriptive title such as 'refactor: consolidate user form schemas and remove ZIP code requirement' or 'refactor: modularize user form components' to better reflect the substantial changes made.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/user-form

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app-modules/events/tests/Feature/Filament/App/Talks/CreateTalkTest.php (1)

96-118: Fix typo in test description.

Line 96 contains a duplicate word: "should should be able to" should read "should be able to". Otherwise, the test logic correctly validates that pending talks don't block new talk creation, and the added blank lines improve readability.

Apply this diff to fix the typo:

-    it('should should be able to create a talk if there is already one but is not accepted yet', function (): void {
+    it('should be able to create a talk if there is already one but is not accepted yet', function (): void {
🧹 Nitpick comments (2)
app-modules/user/src/Filament/Admin/Resources/Users/Pages/EditUser.php (1)

50-88: Confirm that Gamefication and Providers are intended to be read‑only

In the “Gamefication” and “Providers” tabs you now use TextEntry components plus a Repeater that is addable(false) and deletable(false). That makes these areas effectively read‑only (no editing or managing providers from this form). If the intent is only to surface related data, this is fine; if users were previously able to edit character/progression or manage providers here, that capability has been removed.

Also, consider correcting the label from "Gamefication" to "Gamification" if you want a polished UI string.

app-modules/user/tests/Feature/Filament/Admin/Resources/User/EditUserTest.php (1)

29-41: Deterministic update test looks good; consider asserting ZIP behavior if relevant

Using fixed values for username/email plus assertHasNoFormErrors() makes the update test clearer and more robust. If zip_code is persisted on the same model (or a directly-related address model that this form saves), you may want to add an assertion for its stored value as well; if it’s only here to ensure validation no longer blocks the update, the current coverage is sufficient.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 91f3e3a and a3ceb79.

📒 Files selected for processing (5)
  • app-modules/events/tests/Feature/Filament/App/Talks/CreateTalkTest.php (1 hunks)
  • app-modules/user/src/Filament/Admin/Resources/Users/Pages/EditUser.php (2 hunks)
  • app-modules/user/src/Filament/Shared/Schemas/UserAddressForm.php (0 hunks)
  • app-modules/user/src/Filament/Shared/Widgets/UsersStatsOverview.php (1 hunks)
  • app-modules/user/tests/Feature/Filament/Admin/Resources/User/EditUserTest.php (1 hunks)
💤 Files with no reviewable changes (1)
  • app-modules/user/src/Filament/Shared/Schemas/UserAddressForm.php
🔇 Additional comments (1)
app-modules/user/src/Filament/Admin/Resources/Users/Pages/EditUser.php (1)

31-46: Modular form schemas for General/Address/Information look good

Delegating the tab content to UserForm::configure, UserAddressForm::form, and UserInformationForm::configure via Section + Schema closures is a nice cleanup and should improve reuse and consistency across pages.

Comment thread app-modules/user/src/Filament/Shared/Widgets/UsersStatsOverview.php Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
app-modules/user/src/Filament/Shared/Widgets/UsersStatsOverview.php (1)

28-39: Cloning fix looks good; consider range-based month filter for better index usage

Using (clone $query) for each aggregate correctly avoids the previous ->clone() undefined-method issue and keeps the tenant scoping intact for all three counts. The new year+month filter also makes the “this month” stat explicit.

If you want a small perf/clarity tweak, you could:

  • Capture now() once, and
  • Use a range on created_at instead of whereYear / whereMonth (which wrap the column in functions and can hinder index usage), e.g.:
$now = now();

$totalUsersMonth = (clone $query)
    ->whereBetween('created_at', [$now->copy()->startOfMonth(), $now->copy()->endOfMonth()])
    ->count();
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a3ceb79 and 547f582.

📒 Files selected for processing (1)
  • app-modules/user/src/Filament/Shared/Widgets/UsersStatsOverview.php (1 hunks)

@danielhe4rt danielhe4rt merged commit 8fe2418 into 3.x Nov 24, 2025
6 checks passed
@danielhe4rt danielhe4rt deleted the fix/user-form branch November 24, 2025 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants