fix: use FeatureOptInService for bookings-v3 check (#27183)

* fix: use FeatureOptInService for bookings-v3 check

* refactor: simplify FeatureOptInService API and fix bookings page

- Add resolveFeatureStates method that takes only userId and featureIds
- Update listFeaturesForUser to take only userId parameter
- Remove getUserOrgAndTeamIds from _router.ts (now internal to service)
- Fix bookings page to use new resolveFeatureStates method
- Parallelize getUserFeaturesStatus and resolveFeatureStates calls

Co-Authored-By: [email protected] <[email protected]>

* check session?.user?.id first

* remove comment

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Eunjae LeeandDevin AI authored and GitHub committed 2026-01-28 14:28:36 +00:00
1 parent 987e727464
commit ddceabe5d4
4 files changed
+57 -70

No files matched your search

@@ -227,23 +227,32 @@ export class FeatureOptInService implements IFeatureOptInService {
};
}
async resolveFeatureStates(input: {
userId: number;
featureIds: FeatureId[];
}): Promise<Record<string, ResolvedFeatureState>> {
const { userId, featureIds } = input;
const { orgId, teamIds } = await this.getUserOrgAndTeamIds(userId);
return this.resolveFeatureStatesAcrossTeams({
userId,
orgId,
teamIds,
featureIds,
});
}
/**
* List all opt-in features with their states for a user across teams.
* Only returns features that are in the allowlist, globally enabled, and scoped to "user".
*/
async listFeaturesForUser(input: {
userId: number;
orgId: number | null;
teamIds: number[];
}): Promise<ListFeaturesForUserResult[]> {
const { userId, orgId, teamIds } = input;
async listFeaturesForUser(input: { userId: number }): Promise<ListFeaturesForUserResult[]> {
const { userId } = input;
const userScopedFeatures = getOptInFeaturesForScope("user");
const featureIds = userScopedFeatures.map((config) => config.slug);
const resolvedStates = await this.resolveFeatureStatesAcrossTeams({
const resolvedStates = await this.resolveFeatureStates({
userId,
orgId,
teamIds,
featureIds,
});
@@ -64,11 +64,11 @@ export interface IFeatureOptInService {
teamIds: number[];
featureIds: FeatureId[];
}): Promise<Record<string, ResolvedFeatureState>>;
listFeaturesForUser(input: {
resolveFeatureStates(input: {
userId: number;
orgId: number | null;
teamIds: number[];
}): Promise<ResolvedFeatureState[]>;
featureIds: FeatureId[];
}): Promise<Record<string, ResolvedFeatureState>>;
listFeaturesForUser(input: { userId: number }): Promise<ResolvedFeatureState[]>;
listFeaturesForTeam(input: {
teamId: number;
parentOrgId?: number | null;