Skip to content

Conversation

@tomrndom
Copy link

@tomrndom tomrndom commented Feb 6, 2026

ref: https://app.clickup.com/t/86b8e1vcf

Signed-off-by: Tomás Castillo tcastilloboireau@gmail.com

Summary by CodeRabbit

  • Refactor

    • Standardized sponsor assignment and form validation to use explicit "existing" vs "new" sponsor options for clearer selection and behavior.
  • New Features

    • Company input now supports creating new company entries inline and improves debounce/fetch behavior for smoother, more responsive autocomplete and option creation.

@tomrndom tomrndom requested a review from smarcet February 6, 2026 17:37
@coderabbitai
Copy link

coderabbitai bot commented Feb 6, 2026

📝 Walkthrough

Walkthrough

Introduces SPONSOR_USER_ASSIGNMENT_TYPE enum and replaces hard-coded "existing"/"new" strings across sponsor request processing and form logic; updates payload branching for existing vs new sponsor assignments; enhances CompanyInputMUI with allowCreate, debouncing, and create-option behavior.

Changes

Cohort / File(s) Summary
Constants
src/utils/constants.js
Adds SPONSOR_USER_ASSIGNMENT_TYPE export: { EXISTING: "existing", NEW: "new" }.
Sponsor actions
src/actions/sponsor-users-actions.js
Imports SPONSOR_USER_ASSIGNMENT_TYPE; changes processSponsorUserRequest to branch on assignment type and build payload for EXISTING vs NEW (sets sponsor_id for existing, sets company_id/company_name and includes sponsorship_types for new).
Sponsor form
src/pages/sponsors/sponsor-users-list-page/components/process-request-form.js
Replaces string literals with SPONSOR_USER_ASSIGNMENT_TYPE across initial values, Yup validation, radio options, disabled states, and conditional rendering.
Company autocomplete input
src/components/mui/formik-inputs/company-input-mui.js
Adds allowCreate prop and PropTypes entry; introduces isDebouncing state and debounced fetch handling; enables create-option filtering, custom getOptionLabel/renderOption, and value normalization for created items.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

  • smarcet

Poem

🐇 I hopped through enums, changing strings to light,
Tuned forms and payloads, made branches right.
I learned to wait (debounce), then craft what's new,
A create-option here, a tidy import too —
Tiny rabbit hops, code glowing bright. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title covers multiple distinct changes: adding constants, modifying payload structure, and enabling new company creation. While accurate, it's somewhat compressed and combines several different concerns.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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/sponsor-user-process-new

No actionable comments were generated in the recent review. 🎉


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

Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
@tomrndom tomrndom force-pushed the fix/sponsor-user-process-new branch from 7b09f66 to 443fd6f Compare February 6, 2026 18:23
Copy link

@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

Caution

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

⚠️ Outside diff range comments (1)
src/components/mui/formik-inputs/company-input-mui.js (1)

92-110: ⚠️ Potential issue | 🟡 Minor

Handle create-option values in multi-select when allowCreate is enabled.

The multi-select path doesn't normalize inputValue like the single-select path does. When users create a new entry:

  • With plainValue: stores 'Create "..."' instead of the user input text
  • Without plainValue: calls parseInt(v.value) where v.value is null (created at line 129), resulting in NaN ids

Apply the same inputValue handling from the single-select path (lines 106–109):

  • plainValue: v.inputValue || v.label
  • id: v.inputValue ? 0 : parseInt(v.value)
🔧 Proposed fix
   } else if (isMulti) {
     theValue = plainValue
-      ? newValue.map((v) => v.label)
-      : newValue.map((v) => ({
-          id: parseInt(v.value),
-          name: v.label
-        }));
+      ? newValue.map((v) => v.inputValue || v.label)
+      : newValue.map((v) => ({
+          id: v.inputValue ? 0 : parseInt(v.value),
+          name: v.inputValue || v.label
+        }));
   } else {

@tomrndom tomrndom changed the title fix: add constants, wip change payload structure fix: add constants, change payload structure, new company on input Feb 6, 2026
Copy link

@smarcet smarcet left a comment

Choose a reason for hiding this comment

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

@tomrndom please review comments

@@ -33,8 +34,9 @@ const buildInitialValues = (data) => {
normalized.send_email = true;

if (data.company_id !== 0 && data.sponsor)
Copy link

Choose a reason for hiding this comment

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

add a initial value for sponsor_type

normalized.sponsor_type = SPONSOR_USER_ASSIGNMENT_TYPE.NEW

Copy link

@smarcet smarcet left a comment

Choose a reason for hiding this comment

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

@tomrndom please review comments

Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
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