Skip to content

fix(platform): fix import dialogs getting stuck and upload failing#699

Merged
Israeltheminer merged 3 commits into
mainfrom
fix/import-stuck-upload
Mar 6, 2026
Merged

fix(platform): fix import dialogs getting stuck and upload failing#699
Israeltheminer merged 3 commits into
mainfrom
fix/import-stuck-upload

Conversation

@Israeltheminer
Copy link
Copy Markdown
Collaborator

@Israeltheminer Israeltheminer commented Mar 6, 2026

Summary

  • Fix import button becoming permanently disabled by adding shouldDirty: true to all programmatic setValue calls in customer, product, and vendor import forms
  • Remove mode: 'onChange' and isValid gating from import dialogs that caused premature validation blocking
  • Add errorCode field to bulk create results (customers & vendors) so the UI can display specific error messages instead of generic failures
  • Simplify action menus by removing unused integration navigation shortcuts (Circuly, Shopify)
  • Add translated error messages for duplicate email, duplicate external ID, and unknown errors

Closes #688

Test plan

  • Upload a CSV file in Customer import — Import button should remain enabled
  • Upload a CSV file in Product import — Import button should remain enabled
  • Upload a CSV file in Vendor import — Import button should remain enabled
  • Trigger a duplicate email error during bulk import — should show specific error message
  • Verify file preview card removal re-enables upload

Summary by CodeRabbit

Release Notes

  • New Features

    • Import dialogs now display specific, localized error messages for failures like duplicate emails and invalid external IDs.
  • Bug Fixes

    • Fixed form dirty state tracking in file upload operations.
    • Removed unsupported external integrations from import workflows.
  • Refactor

    • Simplified import action menus for improved usability.

The import button became permanently disabled because setValue calls
did not propagate dirty state, and mode:'onChange' combined with isValid
gating blocked submission. Fix by adding shouldDirty:true to all
programmatic setValue calls in import forms, removing mode:'onChange',
and dropping the isValid gate from import dialogs.

Also add errorCode to bulk create results so the UI can show specific
error messages (duplicate email, duplicate external ID) instead of
generic failures. Simplify action menus by removing unused integration
navigation shortcuts.

Closes #688
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 6, 2026

📝 Walkthrough

Walkthrough

This PR addresses the customer import issue by improving form state tracking, error handling, and streamlining integrations. The changes add shouldDirty: true to form field updates across import forms for customers, products, and vendors to ensure proper form state tracking. Navigation integrations for Circuly and Shopify are removed from action menus. Form validation behavior is simplified by removing mode: 'onChange' configuration and discontinuing isValid propagation to dialogs. Backend error handling is enhanced with a new errorCode field in bulk operation results, and client-side code maps specific error codes to localized i18n keys for improved user feedback. Translation keys for error conditions (duplicate\_email, duplicate\_external\_id, unknown) are added.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

The changes span multiple files with consistent patterns (form dirtyness additions, error code integration, import simplifications), but require verification across several components and backend types. The error handling logic additions and form state changes are straightforward but need careful validation across each import flow.

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix: addressing import dialogs getting stuck and upload failures, which directly matches the core changes made to customer, product, and vendor import forms.
Linked Issues check ✅ Passed All code changes address the linked issue #688 objectives: shouldDirty fixes prevent form being marked pristine, removing mode:'onChange' and isValid gating prevents premature validation blocking submission, and errorCode additions enable specific error feedback.
Out of Scope Changes check ✅ Passed The removal of unused navigation shortcuts (Circuly, Shopify) from action menus is somewhat tangential but falls within reasonable scope as cleanup of dead code, though it goes slightly beyond the core issue #688 fix.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/import-stuck-upload

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: 5

Caution

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

⚠️ Outside diff range comments (1)
services/platform/app/features/documents/components/documents-action-menu.tsx (1)

1-1: ⚠️ Potential issue | 🟡 Minor

CI lint is currently failing due to formatting in this file.

GitHub Actions reports an oxfmt style error; please run bunx oxfmt -c ../../.oxfmtrc.json on this file before merge.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@services/platform/app/features/documents/components/documents-action-menu.tsx`
at line 1, CI lint fails due to formatting in documents-action-menu.tsx; run the
formatter with the repo config (bunx oxfmt -c ../../.oxfmtrc.json
services/platform/app/features/documents/components/documents-action-menu.tsx)
to reformat the file, then stage the changes so the oxFmt style error is
resolved before merging.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@services/platform/app/features/customers/components/customer-import-form.tsx`:
- Line 71: The onValueChange callback formatting is failing the oxfmt linter;
reformat the arrow function passed to onValueChange so it meets project style
(avoid inline statement that mixes expressions), e.g. use a properly spaced
concise arrow or a block body, and ensure the call to setValue('dataSource',
value, { shouldDirty: true }) is a single clear expression; locate the
onValueChange prop on the component and adjust the handler formatting for
setValue, keeping the same arguments and behavior.

In
`@services/platform/app/features/customers/components/customers-import-dialog.tsx`:
- Around line 181-194: The code unsafely casts firstError.errorCode and can
leave toast.description undefined; add a runtime type guard (e.g.,
isValidErrorCode) that checks if firstError?.errorCode is one of the keys of
errorCodeKeys before using it, compute errorKey =
isValidErrorCode(firstError.errorCode) ? errorCodeKeys[firstError.errorCode] :
errorCodeKeys.unknown, and always pass a description to toast by using
tCustomers(errorKey) (so description never becomes undefined); reference the
existing variables result, firstError, errorCodeKeys, errorKey, toast, and
tCustomers when applying this change.

In
`@services/platform/app/features/documents/components/documents-action-menu.tsx`:
- Around line 67-85: The DocumentUploadDialog is duplicated across branches;
keep a single render to avoid drift by moving the DocumentUploadDialog element
(using props open={isUploadDialogOpen} onOpenChange={setIsUploadDialogOpen}
organizationId={organizationId}) out of the hasMicrosoftAccount conditional and
only conditionally render the action control (DataTableActionMenu with label
tDocuments('upload.importDocuments'), icon Plus, and
onClick={handleDeviceUpload}) inside the branch that currently lacks Microsoft
account support; ensure state vars isUploadDialogOpen and setIsUploadDialogOpen
remain in scope and remove the duplicated dialog render in the other branch.

In `@services/platform/app/features/vendors/components/vendor-import-form.tsx`:
- Line 69: The onValueChange callback on the VendorImportForm is failing
formatting; reformat the arrow function call to comply with oxfmt by adjusting
spacing and line breaking for the expression using onValueChange and setValue
(specifically the onValueChange handler that calls setValue('dataSource', value,
{ shouldDirty: true })). Ensure the arrow function is formatted consistently
with surrounding JSX props (e.g., single-line or properly indented multi-line)
so onValueChange, setValue, and the options object conform to the project's
formatter.

In `@services/platform/app/features/vendors/components/vendors-import-dialog.tsx`:
- Around line 169-179: The frontend is using an unsafe type assertion on
firstError.errorCode; replace that with a type guard that checks whether
firstError?.errorCode is one of the keys of errorCodeKeys (e.g., use
Object.prototype.hasOwnProperty.call(errorCodeKeys, firstError.errorCode) or an
explicit set/array check) and only map to errorCodeKeys[...] when the guard
passes, otherwise fall back to errorCodeKeys.unknown; additionally, update the
backend bulkCreateVendors mutation
(services/platform/convex/vendors/mutations.ts) so each pushed error object
includes an explicit errorCode string like "duplicate_email" or
"duplicate_external_id" (set error.errorCode before pushing to result.errors) so
the frontend can rely on that field.

---

Outside diff comments:
In
`@services/platform/app/features/documents/components/documents-action-menu.tsx`:
- Line 1: CI lint fails due to formatting in documents-action-menu.tsx; run the
formatter with the repo config (bunx oxfmt -c ../../.oxfmtrc.json
services/platform/app/features/documents/components/documents-action-menu.tsx)
to reformat the file, then stage the changes so the oxFmt style error is
resolved before merging.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3adde6e1-5919-4ed4-8ef1-6781bb55e7ff

📥 Commits

Reviewing files that changed from the base of the PR and between 6152263 and 824566c.

📒 Files selected for processing (13)
  • services/platform/app/features/customers/components/customer-import-form.tsx
  • services/platform/app/features/customers/components/customers-action-menu.tsx
  • services/platform/app/features/customers/components/customers-import-dialog.tsx
  • services/platform/app/features/documents/components/documents-action-menu.tsx
  • services/platform/app/features/products/components/product-import-form.tsx
  • services/platform/app/features/products/components/products-action-menu.tsx
  • services/platform/app/features/products/components/products-import-dialog.tsx
  • services/platform/app/features/vendors/components/vendor-import-form.tsx
  • services/platform/app/features/vendors/components/vendors-import-dialog.tsx
  • services/platform/convex/customers/mutations.ts
  • services/platform/convex/customers/types.ts
  • services/platform/convex/vendors/validators.ts
  • services/platform/messages/en.json
💤 Files with no reviewable changes (1)
  • services/platform/app/features/customers/components/customers-action-menu.tsx

Comment thread services/platform/app/features/customers/components/customer-import-form.tsx Outdated
Comment thread services/platform/app/features/documents/components/documents-action-menu.tsx Outdated
Comment thread services/platform/app/features/vendors/components/vendor-import-form.tsx Outdated
@Israeltheminer Israeltheminer merged commit 0a6725a into main Mar 6, 2026
16 checks passed
@Israeltheminer Israeltheminer deleted the fix/import-stuck-upload branch March 6, 2026 15:54
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.

Bug: Customer import gets stuck and upload fails

1 participant