Add CSV client/pet bulk import#22
Merged
Merged
Conversation
…ar reconciliation) Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…aces Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
POST /:slug/admin/customers/import parses a CSV of client/pet rows, upserts customers and pets via existing repo helpers, dedups pets per client, and optionally sends invites to genuinely new customers. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Add the ImportResult type to represent the response from a bulk CSV import, and add the import method to adminApi.customers to call the backend import endpoint. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Uncontrolled <input type="file"> doesn't clear from a state reset alone; remount it via a key that bumps on success so the sitter can't accidentally resubmit the same file.
…hole request Wrap each row's DB-mutating work in try/catch and skip the row on failure instead of throwing uncaught -- previously processed rows in the same request had already been committed to D1, so a mid-loop throw silently left partial results with no response body at all.
A large import triggers ~5 sequential D1 calls per pet-bearing row and can exceed Workers' subrequest/CPU ceiling partway through the loop. That abort happens outside the per-row try/catch, so it returns a bare 500 with no partial-import report even though earlier rows already committed. Check the row count up front and fail fast with an actionable error instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…lines parseCsvRows() used to silently skip blank lines, but admin.ts computed each reported row number positionally against that filtered array. A blank line anywhere before a bad row shifted every subsequent skippedRows entry off from the sitter's actual spreadsheet line, undermining the whole point of the partial-import report. parseCsvRows() now emits every line (blank lines become a single [''] row), keeping array index aligned with source line number. The import loop gained an explicit blank-row check ahead of the malformed-row check so blank lines are still silently skipped, but line alignment for everything after them stays correct. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…p guard Rows are processed with sequential awaits, so by the time the same email recurs on a later row, getEndUserByEmail already sees the prior row's committed insert and existing is truthy — the .some() dedup branch could never actually fire. endUserId was also unused past this point, so freshCustomers collapses to string[]. Behavior-neutral; all existing import tests still pass. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Resolves conflicts from the concurrently-merged sitter booking dashboard feature: both branches added routes to the same admin.ts chain and types to the same api.ts file — merged to keep both sets of additions intact. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /:slug/admin/customers/importroute and a matching upload UI in the Clients section.insertInvitedCustomer/addEndUserPetidempotent repo functions.docs/examples/) and downloadable directly from the import UI (public/).Notable review findings (all resolved)
Test plan
npm run typechecknpm run lintnpm test(250/250 passing)npm run buildnpx wrangler deploy --dry-run🤖 Generated with Claude Code