Skip to content

Commit 68f9e86

Browse files
fix: remove circular dependency by moving useLastUsed hook to auth features (calcom#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>
1 parent 5da754d commit 68f9e86

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

apps/web/modules/auth/login-view.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import { z } from "zod";
1111

1212
import { SAMLLogin } from "@calcom/features/auth/SAMLLogin";
1313
import { ErrorCode } from "@calcom/features/auth/lib/ErrorCode";
14+
import { LastUsed, useLastUsed } from "@calcom/features/auth/lib/hooks/useLastUsed";
1415
import { HOSTED_CAL_FEATURES, WEBAPP_URL, WEBSITE_URL } from "@calcom/lib/constants";
1516
import { emailRegex } from "@calcom/lib/emailSchema";
1617
import { getSafeRedirectUrl } from "@calcom/lib/getSafeRedirectUrl";
1718
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
18-
import { LastUsed, useLastUsed } from "@calcom/lib/hooks/useLastUsed";
1919
import { useLocale } from "@calcom/lib/hooks/useLocale";
2020
import { useTelemetry } from "@calcom/lib/hooks/useTelemetry";
2121
import { collectPageParameters, telemetryEventTypes } from "@calcom/lib/telemetry";
@@ -62,7 +62,7 @@ export default function Login({
6262
.string()
6363
.min(1, `${t("error_required_field")}`)
6464
.regex(emailRegex, `${t("enter_valid_email")}`),
65-
...(!!totpEmail ? {} : { password: z.string().min(1, `${t("error_required_field")}`) }),
65+
...(totpEmail ? {} : { password: z.string().min(1, `${t("error_required_field")}`) }),
6666
})
6767
// Passthrough other fields like totpCode
6868
.passthrough();

packages/features/auth/SAMLLogin.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import type { Dispatch, SetStateAction } from "react";
33
import { useFormContext } from "react-hook-form";
44
import z from "zod";
55

6+
import { LastUsed, useLastUsed } from "@calcom/features/auth/lib/hooks/useLastUsed";
67
import { HOSTED_CAL_FEATURES } from "@calcom/lib/constants";
78
import { emailRegex } from "@calcom/lib/emailSchema";
8-
import { LastUsed, useLastUsed } from "@calcom/lib/hooks/useLastUsed";
99
import { useLocale } from "@calcom/lib/hooks/useLocale";
1010
import { trpc } from "@calcom/trpc/react";
1111
import type { ButtonProps } from "@calcom/ui/components/button";
File renamed without changes.

0 commit comments

Comments
 (0)