From 68f9e86cdd84ab0549ef8676c9ea085b347c7ad6 Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Sun, 19 Oct 2025 10:14:45 -0300 Subject: [PATCH] fix: remove circular dependency by moving useLastUsed hook to auth features (#24552) - Move useLastUsed hook from packages/lib/hooks to packages/features/auth/lib/hooks - Update imports in SAMLLogin.tsx and login-view.tsx - Remove cross-package tsconfig include of ../trpc/types/router.d.ts from packages/lib/tsconfig.json This fixes the issue where the IDE was unnecessarily initializing packages/ui/tsconfig.json when navigating to definitions in packages/lib. The hook was importing from @calcom/ui/classNames, creating a circular dependency since packages/ui depends on packages/lib. By moving the hook to packages/features/auth where it's actually used, we eliminate the circular dependency without adding tailwind dependencies to packages/lib. Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- apps/web/modules/auth/login-view.tsx | 4 ++-- packages/features/auth/SAMLLogin.tsx | 2 +- packages/{ => features/auth}/lib/hooks/useLastUsed.tsx | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename packages/{ => features/auth}/lib/hooks/useLastUsed.tsx (100%) diff --git a/apps/web/modules/auth/login-view.tsx b/apps/web/modules/auth/login-view.tsx index c6a60ff0f5..30da969333 100644 --- a/apps/web/modules/auth/login-view.tsx +++ b/apps/web/modules/auth/login-view.tsx @@ -11,11 +11,11 @@ import { z } from "zod"; import { SAMLLogin } from "@calcom/features/auth/SAMLLogin"; import { ErrorCode } from "@calcom/features/auth/lib/ErrorCode"; +import { LastUsed, useLastUsed } from "@calcom/features/auth/lib/hooks/useLastUsed"; import { HOSTED_CAL_FEATURES, WEBAPP_URL, WEBSITE_URL } from "@calcom/lib/constants"; import { emailRegex } from "@calcom/lib/emailSchema"; import { getSafeRedirectUrl } from "@calcom/lib/getSafeRedirectUrl"; import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams"; -import { LastUsed, useLastUsed } from "@calcom/lib/hooks/useLastUsed"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { useTelemetry } from "@calcom/lib/hooks/useTelemetry"; import { collectPageParameters, telemetryEventTypes } from "@calcom/lib/telemetry"; @@ -62,7 +62,7 @@ export default function Login({ .string() .min(1, `${t("error_required_field")}`) .regex(emailRegex, `${t("enter_valid_email")}`), - ...(!!totpEmail ? {} : { password: z.string().min(1, `${t("error_required_field")}`) }), + ...(totpEmail ? {} : { password: z.string().min(1, `${t("error_required_field")}`) }), }) // Passthrough other fields like totpCode .passthrough(); diff --git a/packages/features/auth/SAMLLogin.tsx b/packages/features/auth/SAMLLogin.tsx index 0ea0a26591..98fbbe3724 100644 --- a/packages/features/auth/SAMLLogin.tsx +++ b/packages/features/auth/SAMLLogin.tsx @@ -3,9 +3,9 @@ import type { Dispatch, SetStateAction } from "react"; import { useFormContext } from "react-hook-form"; import z from "zod"; +import { LastUsed, useLastUsed } from "@calcom/features/auth/lib/hooks/useLastUsed"; import { HOSTED_CAL_FEATURES } from "@calcom/lib/constants"; import { emailRegex } from "@calcom/lib/emailSchema"; -import { LastUsed, useLastUsed } from "@calcom/lib/hooks/useLastUsed"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc/react"; import type { ButtonProps } from "@calcom/ui/components/button"; diff --git a/packages/lib/hooks/useLastUsed.tsx b/packages/features/auth/lib/hooks/useLastUsed.tsx similarity index 100% rename from packages/lib/hooks/useLastUsed.tsx rename to packages/features/auth/lib/hooks/useLastUsed.tsx