Skip to content

refactor(dashboard): move createResource call sites to frappe-ui composables - #502

Merged
harshtandiya merged 4 commits into
developfrom
refactor/composable-data-fetching
Sep 30, 2026
Merged

harshtandiya merged 4 commits into
developfrom
refactor/composable-data-fetching

Conversation

@harshtandiya

Copy link
Copy Markdown
Collaborator

What changed

Every createResource / createListResource / createDocumentResource call in the dashboard now uses useCall, useList, useDoc or useDoctype on the v2 API. 53 call sites, 40 files, net −180 lines. session.login / session.logout stay, per CLAUDE.md. Second commit strips the exception-type prefix frappe-ui adds to error text.

Things the diff does not say:

  • Writes are all method: "POST". Frappe rolls back a GET (frappe/app.py sync_database), so a write on the default verb returns 200 and saves nothing.
  • useCall.submit() in 1.0.0-beta.63 resolves null on a server error; the docs say it rejects. Call sites check .error and also .catch(() => null), so either behaviour works.
  • A composable's error cannot be cleared and data cannot be mutated. AddVenueDialog and AddMembersDialog keep a local message to reset on open; the optimistic logo write in SponsorshipDetails is gone, the reload covers it.
  • loading is false for one tick before the first fetch. Account.vue gates its redirect on isFinished instead.
  • frappe.client.get_value became useList with limit: 1: same get_list permission path, no full-document read.
  • validate_coupon and validate_ticket_for_checkin stay POST though they only read: keeps a guest's email out of the query string.
  • cacheKey on Account / SponsorshipsList was a no-op under createResource (the option is cache); dropped rather than start persisting un-keyed user data. userResource is uncached for the same reason.
  • serverErrorMessage (utils/serverError.ts) strips only the exact Type: message shape. frappe-ui main (rc.2) still builds the prefix, so this is not fixed by a bump.

Not changed / known:

Demo

No visual change. skip-demo.

Testing

Checks: yarn typecheck, oxlint, oxfmt clean. Browser on the local site: 15 pages as Administrator and 4 as guest load with no failed calls; writes exercised: sponsorship logo + withdraw, event details save, route check, venue add, proposal edit, forgot password. Not exercised: create event, invite members, team update, ticket transfer, cancellation, add-on preference, check-in, register interest, sign-up, email link, language and time zone save, and booking submit + OTP (BookingForm.submitBooking was restructured). serverErrorMessage checked with a one-off assert run, no test file. E2E left to CI.

…osables

Every createResource, createListResource and createDocumentResource call now
goes through useCall, useList, useDoc or useDoctype on the v2 API. Only
session.login and session.logout stay on createResource.

Reads are GET and writes are POST: Frappe rolls back a GET, so a write left on
the default verb would be lost. frappe.client.set_value and insert become
document API writes, get_list and get_value become useList.

useCall.submit resolves on a server error instead of rejecting, so call sites
check the recorded error rather than catching. Dialogs that cleared the
resource error on open keep their own message, since a composable error cannot
be reset.

Drops TransferTicketDialog, which nothing imported.
frappe-ui prefixes a composable error's message with the exception class
("ValidationError: Coupon expired"), and that reached attendees on booking,
OTP and login errors. serverErrorMessage strips it when the message has that
exact shape and returns anything else as it is.
@harshtandiya harshtandiya added the skip-demo Skip adding a video / screenshot in PR description. Passes the failing CI for demo addition label Sep 30, 2026

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

The dashboard now calls send_guest_booking_otp and get_ticket_details on
the v2 method path, which returns the payload under data instead of
message. The specs that read those responses off the network still
unwrapped message and got undefined.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@harshtandiya
harshtandiya merged commit c248246 into develop Sep 30, 2026
8 checks passed
@harshtandiya
harshtandiya deleted the refactor/composable-data-fetching branch September 30, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-demo Skip adding a video / screenshot in PR description. Passes the failing CI for demo addition

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant