- app/hooks/useStoreOwnership.ts: the old redirect logic sent owners to /
the moment useMyStores briefly resolved to []. That empty array came from
useMyStores's dead `if (!token) return []` inside the queryFn, so any
transient auth blip left the store page thinking the user has no stores.
Now compares usernames case-insensitively, only redirects while the query
is settled (!isLoading && !isFetching && !isError), and never bounces to
home on empty — worst case the seller sees an empty dashboard rather than
a silent kick-out.
- app/requestHandler/use-seller-hooks.ts: removed the unreachable
`if (!token) return []` in useMyStores and added the token to the
queryKey so a login switch stops serving the previous user's cached list.
- app/routes/store.$storeId._index.tsx: mount StorePushPromptCard at the
top of the store dashboard.
- app/routes/store.$storeId.tsx: sidebar "پیامها" badge reads
badges.sellerChat[storeId] (per-store) instead of the buyer-side
badges.chat, matching the badge-serializer split.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Review fixes:
- useMyStores throws on a failed response instead of resolving to [] — a
transient 401/blip no longer looks like "no stores" and bounces an owner off
their own dashboard (query stays in error/retry, keeps prior data).
- Add useRequireOwner() guard and apply it to the owner-only routes
(financial-dashboard + its cash-funds/reports/transactions sub-routes and
shipping-method) so staff who hit those URLs directly are redirected to the
dashboard. (Financial data was already backend-protected; this is the matching
client-side gate.)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- useMyStores + team hooks (invite by phone / list / remove) in use-seller-hooks.
- useStoreOwnership rewritten to allow staff (not just the owner) via my-stores;
exposes `role` so callers can gate owner-only UI, and no longer redirects
members away from a store they help manage.
- Store settings: owner-only items (financial, shipping, edit store, instagram
sync, team) hidden from staff; new "مدیریت اعضای تیم" entry (owner-only).
- New /store/:storeId/team page: invite by phone + members list with pending/
active status + remove (owner-only, redirects staff). MyLayout keeps store mode
on the team route.
- StoreForm edit is owner-only (redirects staff). Profile "enter my store" now
routes owners to their store and staff to the store they manage.
- Chat already split earlier: seller inbox vs personal buyer inbox.
Depends on the seller-team backend; ships on this branch, not main.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>