-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: Remove trpc/react dependency from @calcom/atoms
#23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: coderabbit_combined_20260121_augment_sentry_coderabbit_1_base_refactor_remove_trpc_react_dependency_from_calcom_atoms_pr722
Are you sure you want to change the base?
Changes from all commits
68a54f9
4560ebf
8ffcb18
19ebf02
d58c13c
3211cba
cad4cbb
70d3c6e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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, | ||
| }; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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"; | ||
|
|
@@ -99,7 +99,7 @@ export type AvailabilitySettingsScheduleType = { | |
| type AvailabilitySettingsProps = { | ||
| skeletonLabel?: string; | ||
| schedule: AvailabilitySettingsScheduleType; | ||
| travelSchedules?: RouterOutputs["viewer"]["travelSchedules"]["get"]; | ||
| travelSchedules?: Awaited<ReturnType<typeof TravelScheduleRepository.findTravelSchedulesByUserId>>; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Find all usages of AvailabilitySettings component
rg -n '<AvailabilitySettings' --type=tsx -g '!**/AvailabilitySettings.tsx'Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 113 🏁 Script executed: #!/bin/bash
# Find the AvailabilitySettings file and examine lines 102 and 198
fd -e tsx -p '*AvailabilitySettings.tsx' | head -5Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 390 🏁 Script executed: #!/bin/bash
# Count lines to understand file size before reading
wc -l packages/platform/atoms/availability/AvailabilitySettings.tsxRepository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 151 🏁 Script executed: #!/bin/bash
# Read the AvailabilitySettings file to see lines 102 and 198
sed -n '95,110p; 190,205p' packages/platform/atoms/availability/AvailabilitySettings.tsxRepository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 994 🏁 Script executed: #!/bin/bash
# Find all usages of AvailabilitySettings component - search for the component name being used
rg -n '<AvailabilitySettings' --type=ts | head -20Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 888 🏁 Script executed: #!/bin/bash
# Find where travelSchedules prop is passed to AvailabilitySettings
rg -n 'travelSchedules' packages/platform/atoms/availability/ -A2 -B2Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 3178 🏁 Script executed: #!/bin/bash
# Find TravelScheduleRepository to understand the return type
fd -name '*TravelScheduleRepository*'Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 316 🏁 Script executed: #!/bin/bash
# Find TravelScheduleRepository file with corrected syntax
fd 'TravelScheduleRepository'Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 159 🏁 Script executed: #!/bin/bash
# Check the consumer files to see what types they pass for travelSchedules
cat -n packages/platform/atoms/availability/wrappers/AvailabilitySettingsPlatformWrapper.tsx | sed -n '145,160p'Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 552 🏁 Script executed: #!/bin/bash
# Check another consumer file
cat -n apps/web/modules/availability/[schedule]/schedule-view.tsx | sed -n '100,120p'Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 909 🏁 Script executed: #!/bin/bash
# Search for the old type RouterOutputs to see if it's still used
rg 'RouterOutputs.*travelSchedules.*get'Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 473 🏁 Script executed: #!/bin/bash
# Find where TravelScheduleRepository.findTravelSchedulesByUserId is used/called
rg 'findTravelSchedulesByUserId'Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 933 🏁 Script executed: #!/bin/bash
# Check the handler to see what it returns
cat -n packages/trpc/server/routers/viewer/travelSchedules/getTravelSchedules.handler.tsRepository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 617 🏁 Script executed: #!/bin/bash
# Check schedule-view.tsx more broadly to understand types
cat -n apps/web/modules/availability/[schedule]/schedule-view.tsx | sed -n '1,50p'Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 2619 🏁 Script executed: #!/bin/bash
# Check what RouterOutputs["viewer"]["travelSchedules"]["get"] is
rg -A5 '"viewer".*travelSchedules' --type=ts | head -30Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 1763 🏁 Script executed: #!/bin/bash
# Check TravelScheduleRepository.findTravelSchedulesByUserId implementation
cat -n packages/features/travelSchedule/repositories/TravelScheduleRepository.tsRepository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 632 🏁 Script executed: #!/bin/bash
# Check how the TRPC route is structured
fd '*travelSchedules*' -t f | grep -E '(router|procedures)'Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 382 🏁 Script executed: #!/bin/bash
# Look for the TRPC route definition for travelSchedules
rg 'travelSchedules.*procedure' -A5Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 68 🏁 Script executed: #!/bin/bash
# Look for the TRPC router structure
fd -name '*.ts' --type f -path '*/routers/viewer/*' | grep -i travelRepository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 316 🏁 Script executed: #!/bin/bash
# Check the TRPC router definition for travelSchedules
rg -A10 'travelSchedules.*:' packages/trpc/server/routers/viewer/ | head -30Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 2267 🏁 Script executed: #!/bin/bash
# Check if there are any TS compilation errors or type mismatches by looking at type definitions
cat -n packages/trpc/react/index.ts | sed -n '1,50p'Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 263 🏁 Script executed: #!/bin/bash
# Find the travelSchedules router
fd 'travelSchedules' --type f -path '*/routers/viewer/*'Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 254 🏁 Script executed: #!/bin/bash
# Check the structure of the travelSchedules router
find packages/trpc/server/routers/viewer -name '*travelSchedule*' -type fRepository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 68 🏁 Script executed: #!/bin/bash
# Look at the structure of the handler being exported
rg -B5 -A15 'getTravelSchedulesHandler' packages/trpc/server/routers/viewer/travelSchedules/Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 1889 🏁 Script executed: #!/bin/bash
# Check the procedure definition in the router
cat packages/trpc/server/routers/viewer/travelSchedules/getTravelSchedules.handler.ts
cat packages/trpc/server/routers/viewer/travelSchedules/getTravelSchedules.ts 2>/dev/null || echo "File not found, checking for other files:"
find packages/trpc/server/routers/viewer/travelSchedules -type fRepository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 802 🏁 Script executed: #!/bin/bash
# Check for any TypeScript compilation errors or type issues
# Look at the actual types that should be inferred
rg 'Awaited<ReturnType' packages/platform/atoms/availability/AvailabilitySettings.tsxRepository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 289 🏁 Script executed: #!/bin/bash
# Check if schedule-view.tsx actually compiles/uses the type correctly
cat -n apps/web/modules/availability/[schedule]/schedule-view.tsx | sed -n '108,115p'Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 414 🏁 Script executed: #!/bin/bash
# Check what DateOverrideList expects (it receives travelSchedules)
cat -n packages/features/schedules/components/DateOverrideList.tsx | sed -n '1,40p'Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 1799 🏁 Script executed: #!/bin/bash
# Confirm that the schema or any other constraints don't differ
cat packages/trpc/server/routers/viewer/travelSchedules/getTravelSchedules.schema.tsRepository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 96 🏁 Script executed: #!/bin/bash
# Check what AvailabilitySettings passes to DateOverrideList
cat -n packages/platform/atoms/availability/AvailabilitySettings.tsx | sed -n '240,250p'Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 558 🏁 Script executed: #!/bin/bash
# Search for where DateOverrideList receives the travelSchedules prop from AvailabilitySettings
rg -B3 -A3 'DateOverrideList' packages/platform/atoms/availability/AvailabilitySettings.tsx | head -40Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 805 🏁 Script executed: #!/bin/bash
# Check what type the function accepts
cat -n packages/platform/atoms/availability/AvailabilitySettings.tsx | sed -n '230,260p'Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 1412 🏁 Script executed: #!/bin/bash
# Check if there's a type mismatch between what AvailabilitySettings provides and what DateOverrideList expects
# Look at the exact parameter type definition in DateOverrideList
cat -n packages/features/schedules/components/DateOverrideList.tsx | sed -n '36,42p'Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 391 🏁 Script executed: #!/bin/bash
# Verify the actual usage - does AvailabilitySettings pass the prop directly?
# Check the exact line where travelSchedules is passed from AvailabilitySettings to DateOverrideList
rg -n 'travelSchedules=' packages/platform/atoms/availability/AvailabilitySettings.tsxRepository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 193 🏁 Script executed: #!/bin/bash
# Check if there are any type assertions or workarounds in AvailabilitySettings
cat -n packages/platform/atoms/availability/AvailabilitySettings.tsx | sed -n '100,115p'Repository: qodo-benchmark/cal.com-combined-coderabbit Length of output: 765 Type mismatch requires fixing: DateOverrideList incompatibility. The prop type change at line 102 creates a type compatibility issue. Although both types resolve to the same runtime shape, TypeScript treats them as different types. Either align 🤖 Prompt for AI Agents |
||
| handleDelete: () => void; | ||
| allowDelete?: boolean; | ||
| allowSetToDefault?: boolean; | ||
|
|
@@ -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?: { | ||
|
|
@@ -642,7 +642,7 @@ export const AvailabilitySettings = forwardRef<AvailabilitySettingsFormRef, Avai | |
| form="availability-form" | ||
| loading={isSaving} | ||
| disabled={isLoading || !formHasChanges} | ||
| > | ||
| > | ||
| {t("save")} | ||
| </Button> | ||
| <Button | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical regression: Rendering bypasses search filter and weight merging.
The list now renders
teamMembersdirectly instead offilteredMembers, which breaks:searchQueryfiltering is no longer appliedlocalWeightsvalues are not merged into the rendered membersassignAllTeamMemberscondition (lines 242-248) is bypassedThe
filteredMembersmemo (lines 231-249) is still computed but unused.🐛 Proposed fix to restore filteredMembers usage
📝 Committable suggestion
🤖 Prompt for AI Agents