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
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,
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 @@ -10,12 +10,11 @@ import type {
TeamMemberDto,
FindTeamMembersMatchingAttributeOutputDto,
} from "@calcom/platform-types";
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 +23,7 @@ interface UseTeamMembersWithSegmentProps {
value: Host[];
}

const useProcessTeamMembersData = ({
export const useProcessTeamMembersData = ({
initialTeamMembers,
assignRRMembersUsingSegment,
matchingTeamMembersWithResult,
Expand Down Expand Up @@ -105,37 +104,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