Commit Graph
5 Commits
Author SHA1 Message Date
hamedandClaude Opus 5 601d211d6f fix(subscription): report the acting environment's plan for gating
Feature gates and the resource cap are enforced against the environment
the user is standing in, but /subscription/my only ever returned the
plan of the environment they own. A doctor working as a guest in another
clinic consumed the host clinic's resource quota while the panel showed
their own plan's cap, so the quota number and the menu locks disagreed
with what the server would allow.

/subscription/my now also returns context_plan — limits and features of
the acting environment, without the other environment's plan identity.
effective_plan, subscription and used_trial stay on the owned
environment so the purchase flow is unchanged, and useSubscription
reads its caps and hasFeature from context_plan.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 14:48:13 +03:30
hamedandClaude Opus 5 1ce9957538 fix(admin): drop cached environment data when switching context
A doctor who also owns a clinic runs two environments, and a subscription
belongs to an environment, not to the user. The panel treated it as the
user's: the subscription query was keyed ['subscription-my'] with no
context, and switching environments never touched the react-query cache. So
upgrading the clinic left the personal practice showing the clinic's plan
with its feature-gated menu items unlocked, and vice versa.

The query key now carries the active dbUuid, and the context switch clears
the whole cache — every cached response belongs to the environment it was
fetched in, not just this one.

The API was already correct: DualEnvironmentSubscriptionTest pins that
granting one environment leaves the other on free.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-19 22:15:56 +03:30
hamed 3e7028d77a feat(subscription): implement resource quota management based on subscription plans 2026-08-04 19:38:49 +03:30
hamed 828e3552c0 feat(subscription): implement effective plan logic and update free plan features 2026-07-05 10:46:31 +03:30
hamed fa6656df48 feat(subscription): implement feature gating for subscription-based access in admin panel 2026-06-15 12:00:36 +03:30