Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Refresh the staff list after a profile save

Damian Legawiecada20eed7b46
diff --git a/packages/admin-sdk/src/admin-client.ts b/packages/admin-sdk/src/admin-client.ts
index 9095354142..afb183d5fa 100644
--- a/packages/admin-sdk/src/admin-client.ts
+++ b/packages/admin-sdk/src/admin-client.ts
@@ -78,14 +78,12 @@ export interface PermissionRule {
}
export interface MeResponse {
- user: {
- id: string
- email: string
- first_name: string | null
- last_name: string | null
- selected_locale: string | null
- avatar_url: string | null
- }
+ /**
+ * The signed-in admin, serialized exactly like every other admin user — so a
+ * profile save can be merged straight into the auth context without dropping
+ * the fields the top bar reads (`full_name`, `avatar_url`).
+ */
+ user: AdminUser
permissions: PermissionRule[]
/**
* The flat expanded catalog permission keys the user holds on the current
diff --git a/packages/dashboard/src/hooks/use-profile.ts b/packages/dashboard/src/hooks/use-profile.ts
index 368d66a7ae..fcbd926588 100644
--- a/packages/dashboard/src/hooks/use-profile.ts
+++ b/packages/dashboard/src/hooks/use-profile.ts
@@ -20,7 +20,9 @@ export function useUpdateProfile() {
return useResourceMutation<MeResponse, Error, MeUpdateParams>({
mutationFn: (params) => adminClient.me.update(params),
- invalidate: [['profile']],
+ // The signed-in admin is also a row on the staff page, so their own name
+ // and avatar there go stale on a self-edit unless that list is refetched.
+ invalidate: [['profile'], ['staff']],
successMessage: false, // the dialog toasts success itself
errorMessage: false, // the dialog maps 422s inline via mapSpreeErrorsToForm
// Write the response into the cache instead of leaning on the invalidation