Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import {
import { showToast } from "@calcom/ui/components/toast";

import {
useTeamMembersWithSegment,
useTeamMembersWithSegmentPlatform,
} from "../../../../../packages/platform/atoms/event-types/hooks/useTeamMembersWithSegment";
} from "@calcom/atoms/event-types/hooks/useTeamMembersWithSegmentPlatform";
import { useTeamMembersWithSegment } from "@calcom/web/modules/event-types/hooks/useTeamMembersWithSegment";

type TeamMemberItemProps = {
member: Omit<TeamMember, "defaultScheduleId"> & { weight?: number };
Expand Down Expand Up @@ -125,7 +125,7 @@ export const EditWeightsForAllTeamMembers = ({

const useTeamMembersHook = isPlatform ? useTeamMembersWithSegmentPlatform : useTeamMembersWithSegment;

const { teamMembers, localWeightsInitialValues } = useTeamMembersHook({
const { teamMembers, localWeightsInitialValues, isPending } = useTeamMembersHook({
initialTeamMembers,
assignRRMembersUsingSegment,
teamId,
Expand Down Expand Up @@ -301,10 +301,10 @@ export const EditWeightsForAllTeamMembers = ({
/>

<div className="flex max-h-[80dvh] flex-col overflow-y-auto rounded-md border">
{filteredMembers.map((member) => (
{teamMembers.map((member) => (
<TeamMemberItem key={member.value} member={member} onWeightChange={handleWeightChange} />
))}
{filteredMembers.length === 0 && (
{teamMembers.length === 0 && (
<div className="text-subtle py-4 text-center text-sm">{t("no_members_found")}</div>
)}
Comment on lines 303 to 309
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Search/filter no longer applied to the rendered list.

The UI now renders teamMembers directly, so search and assignAllTeamMembers filtering (computed in filteredMembers) is ignored, and the empty-state check is wrong. This regresses filtering behavior for users.

✅ Proposed fix
-              <div className="flex max-h-[80dvh] flex-col overflow-y-auto rounded-md border">
-                {teamMembers.map((member) => (
+              <div className="flex max-h-[80dvh] flex-col overflow-y-auto rounded-md border">
+                {filteredMembers.map((member) => (
                   <TeamMemberItem key={member.value} member={member} onWeightChange={handleWeightChange} />
                 ))}
-                {teamMembers.length === 0 && (
+                {filteredMembers.length === 0 && (
                   <div className="text-subtle py-4 text-center text-sm">{t("no_members_found")}</div>
                 )}
               </div>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div className="flex max-h-[80dvh] flex-col overflow-y-auto rounded-md border">
{filteredMembers.map((member) => (
{teamMembers.map((member) => (
<TeamMemberItem key={member.value} member={member} onWeightChange={handleWeightChange} />
))}
{filteredMembers.length === 0 && (
{teamMembers.length === 0 && (
<div className="text-subtle py-4 text-center text-sm">{t("no_members_found")}</div>
)}
<div className="flex max-h-[80dvh] flex-col overflow-y-auto rounded-md border">
{filteredMembers.map((member) => (
<TeamMemberItem key={member.value} member={member} onWeightChange={handleWeightChange} />
))}
{filteredMembers.length === 0 && (
<div className="text-subtle py-4 text-center text-sm">{t("no_members_found")}</div>
)}
</div>
🤖 Prompt for AI Agents
In `@apps/web/modules/event-types/components/EditWeightsForAllTeamMembers.tsx`
around lines 303 - 309, The rendered list is using teamMembers directly which
ignores the search/filter and assignAllTeamMembers logic computed into
filteredMembers; update the JSX to map over filteredMembers (rendering
<TeamMemberItem key={member.value} member={member}
onWeightChange={handleWeightChange} />) and change the empty-state check to use
filteredMembers.length === 0 so the search/filter and assign-all behavior are
respected.

</div>
Expand Down
37 changes: 37 additions & 0 deletions apps/web/modules/event-types/hooks/useTeamMembersWithSegment.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { useQuery } from "@tanstack/react-query";
import type { AttributesQueryValue } from "@calcom/lib/raqb/types";
import { trpc } from "@calcom/trpc/react";
import { type UseTeamMembersWithSegmentProps, useProcessTeamMembersData } from "@calcom/atoms/event-types/hooks/useTeamMembersWithSegmentPlatform";

export const useTeamMembersWithSegment = ({
initialTeamMembers,
assignRRMembersUsingSegment,
teamId,
queryValue,
value,
}: UseTeamMembersWithSegmentProps) => {
const { data: matchingTeamMembersWithResult, isPending } =
trpc.viewer.attributes.findTeamMembersMatchingAttributeLogic.useQuery(
{
teamId: teamId || 0,
attributesQueryValue: queryValue as AttributesQueryValue,
_enablePerf: true,
},
{
enabled: assignRRMembersUsingSegment && !!queryValue && !!teamId,
}
);

const { teamMembers, localWeightsInitialValues } = useProcessTeamMembersData({
initialTeamMembers,
assignRRMembersUsingSegment,
matchingTeamMembersWithResult: matchingTeamMembersWithResult?.result ? { result: matchingTeamMembersWithResult.result } : matchingTeamMembersWithResult,
value,
});

return {
teamMembers,
localWeightsInitialValues,
isPending,
};
};
32 changes: 32 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,38 @@
}
}
}
},
{
"includes": [
"packages/platform/atoms/**/*.{ts,tsx,js,jsx,mts,mjs,cjs,cts}"
],
"linter": {
"rules": {
"style": {
"noRestrictedImports": {
"level": "error",
"options": {
"patterns": [
{
"group": [
"@calcom/trpc/react",
"@calcom/trpc/react/**"
],
"message": "atoms package should not import from @calcom/trpc/react."
},
{
"group": [
"../../trpc/react",
"../../trpc/react/**"
],
"message": "atoms package should not import from trpc/react."
}
]
}
}
}
}
}
}
]
}
8 changes: 4 additions & 4 deletions packages/platform/atoms/availability/AvailabilitySettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import WebSchedule, {
import { availabilityAsString } from "@calcom/lib/availability";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { sortAvailabilityStrings } from "@calcom/lib/weekstart";
import type { RouterOutputs } from "@calcom/trpc/react";
import type { TravelScheduleRepository } from "@calcom/features/travelSchedule/repositories/TravelScheduleRepository";
import type { TimeRange, WorkingHours } from "@calcom/types/schedule";
import classNames from "@calcom/ui/classNames";
import { Button } from "@calcom/ui/components/button";
Expand Down Expand Up @@ -99,7 +99,7 @@ export type AvailabilitySettingsScheduleType = {
type AvailabilitySettingsProps = {
skeletonLabel?: string;
schedule: AvailabilitySettingsScheduleType;
travelSchedules?: RouterOutputs["viewer"]["travelSchedules"]["get"];
travelSchedules?: Awaited<ReturnType<typeof TravelScheduleRepository.findTravelSchedulesByUserId>>;
handleDelete: () => void;
allowDelete?: boolean;
allowSetToDefault?: boolean;
Expand Down Expand Up @@ -195,7 +195,7 @@ const DateOverride = ({
}: {
workingHours: WorkingHours[];
userTimeFormat: number | null;
travelSchedules?: RouterOutputs["viewer"]["travelSchedules"]["get"];
travelSchedules?: Awaited<ReturnType<typeof TravelScheduleRepository.findTravelSchedulesByUserId>>;
weekStart: 0 | 1 | 2 | 3 | 4 | 5 | 6;
overridesModalClassNames?: string;
classNames?: {
Expand Down Expand Up @@ -642,7 +642,7 @@ export const AvailabilitySettings = forwardRef<AvailabilitySettingsFormRef, Avai
form="availability-form"
loading={isSaving}
disabled={isLoading || !formHasChanges}
>
>
{t("save")}
</Button>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { trpc } from "@calcom/trpc/react";
import { useAtomsContext } from "../../hooks/useAtomsContext";
import http from "../../lib/http";

interface UseTeamMembersWithSegmentProps {
export interface UseTeamMembersWithSegmentProps {
initialTeamMembers: TeamMember[];
assignRRMembersUsingSegment: boolean;
teamId?: number;
Expand All @@ -24,7 +24,7 @@ interface UseTeamMembersWithSegmentProps {
value: Host[];
}

const useProcessTeamMembersData = ({
export const useProcessTeamMembersData = ({
initialTeamMembers,
assignRRMembersUsingSegment,
matchingTeamMembersWithResult,
Expand Down Expand Up @@ -105,37 +105,4 @@ export const useTeamMembersWithSegmentPlatform = ({
localWeightsInitialValues,
isPending,
};
};

export const useTeamMembersWithSegment = ({
initialTeamMembers,
assignRRMembersUsingSegment,
teamId,
queryValue,
value,
}: UseTeamMembersWithSegmentProps) => {
const { data: matchingTeamMembersWithResult, isPending } =
trpc.viewer.attributes.findTeamMembersMatchingAttributeLogic.useQuery(
{
teamId: teamId || 0,
attributesQueryValue: queryValue as AttributesQueryValue,
_enablePerf: true,
},
{
enabled: assignRRMembersUsingSegment && !!queryValue && !!teamId,
}
);

const { teamMembers, localWeightsInitialValues } = useProcessTeamMembersData({
initialTeamMembers,
assignRRMembersUsingSegment,
matchingTeamMembersWithResult,
value,
});

return {
teamMembers,
localWeightsInitialValues,
isPending,
};
};
};
1 change: 1 addition & 0 deletions packages/platform/atoms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"./event-types/hooks/useEventTypeForm": "./event-types/hooks/useEventTypeForm.ts",
"./event-types/hooks/useHandleRouteChange": "./event-types/hooks/useHandleRouteChange.ts",
"./event-types/hooks/useTabsNavigations": "./event-types/hooks/useTabsNavigations.tsx",
"./event-types/hooks/useTeamMembersWithSegmentPlatform": "./event-types/hooks/useTeamMembersWithSegmentPlatform.tsx",
"./timezone": "./timezone/index.tsx"
},
"types": "./dist/index.d.ts",
Expand Down
1 change: 0 additions & 1 deletion packages/platform/atoms/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"../../dayjs",
"../../prisma/zod-utils.ts",
"../../prisma/zod",
"../../trpc/react",
"../../trpc/server/routers/viewer/slots",
"../../trpc/server/types",
"../../features/eventtypes",
Expand Down
Loading