Skip to content
Merged
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
3 changes: 2 additions & 1 deletion apps/web/__tests__/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { EmailAccountWithAI } from "@/utils/llms/types";
import type { EmailForLLM } from "@/utils/types";
import { ActionType, LogicalOperator } from "@/generated/prisma/enums";
import type { Action, Prisma } from "@/generated/prisma/client";
import { isGoogleProvider } from "@/utils/email/provider-types";

type EmailAccountSelect = {
id: string;
Expand Down Expand Up @@ -283,7 +284,7 @@ export function getCalendarConnection({
return {
id: `conn-${provider}`,
provider,
email: `test@${provider === "google" ? "gmail" : "outlook"}.com`,
email: `test@${isGoogleProvider(provider) ? "gmail" : "outlook"}.com`,
accessToken: "token",
refreshToken: "refresh",
expiresAt: new Date(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
} from "@/components/ui/dialog";
import { Textarea } from "@/components/ui/textarea";
import { Label } from "@/components/ui/label";
import { isGoogleProvider } from "@/utils/email/provider-types";

export function PersonalSignatureSetting() {
const { data, isLoading, error } = useEmailAccountFull();
Expand Down Expand Up @@ -71,7 +72,7 @@ function SignatureDialog({
const [selectedSignature, setSelectedSignature] = useState<string>("");
const [manualSignature, setManualSignature] = useState(currentSignature);

const isGmail = provider === "google";
const isGmail = isGoogleProvider(provider);

const { execute: executeSave, isExecuting: isSaving } = useAction(
saveSignatureAction.bind(null, emailAccountId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { useAccount } from "@/providers/EmailAccountProvider";
import { zodResolver } from "@hookform/resolvers/zod";
import { getActionErrorMessage } from "@/utils/error";
import { saveSignatureBody } from "@/utils/actions/user.validation";
import { isGoogleProvider } from "@/utils/email/provider-types";

export const SignatureSectionForm = ({
signature,
Expand All @@ -36,7 +37,7 @@ export const SignatureSectionForm = ({
const editorRef = useRef<TiptapHandle>(null);

const { emailAccountId, provider } = useAccount();
const isGmail = provider === "google";
const isGmail = isGoogleProvider(provider);

const { execute, isExecuting } = useAction(
saveSignatureAction.bind(null, emailAccountId),
Expand Down
8 changes: 5 additions & 3 deletions apps/web/app/(app)/accounts/AddAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ import { toastError } from "@/components/Toast";
import Image from "next/image";
import { TypographyP } from "@/components/Typography";
import { getAccountLinkingUrl } from "@/utils/account-linking";
import { isGoogleProvider } from "@/utils/email/provider-types";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Good refactor; remove console.error per repo guidelines (Line 9, Line 15-31).
You’re already toasting the failure; logging via console looks out-of-policy here.

Proposed diff
 } catch (error) {
-  console.error(`Error initiating ${provider} link:`, error);
   toastError({
     title: `Error initiating ${isGoogleProvider(provider) ? "Google" : "Microsoft"} link`,
     description: "Please try again or contact support",
   });
   setLoading(false);
 }

Also applies to: 15-31

🤖 Prompt for AI Agents
In @apps/web/app/(app)/accounts/AddAccount.tsx at line 9, Remove the
console.error calls in the AddAccount component error-handling block (the lines
referenced around 15-31) and rely on the existing toast failure UI; delete any
console.error(...) statements and do not replace them with console logging — if
persistent telemetry is required, use the project logger or error-tracking
utility instead (e.g., processLogger.error or Sentry) rather than console.error.


export function AddAccount() {
const [isLoadingGoogle, setIsLoadingGoogle] = useState(false);
const [isLoadingMicrosoft, setIsLoadingMicrosoft] = useState(false);

const handleAddAccount = async (provider: "google" | "microsoft") => {
const setLoading =
provider === "google" ? setIsLoadingGoogle : setIsLoadingMicrosoft;
const setLoading = isGoogleProvider(provider)
? setIsLoadingGoogle
: setIsLoadingMicrosoft;
setLoading(true);

try {
Expand All @@ -22,7 +24,7 @@ export function AddAccount() {
} catch (error) {
console.error(`Error initiating ${provider} link:`, error);
toastError({
title: `Error initiating ${provider === "google" ? "Google" : "Microsoft"} link`,
title: `Error initiating ${isGoogleProvider(provider) ? "Google" : "Microsoft"} link`,
description: "Please try again or contact support",
});
setLoading(false);
Expand Down
3 changes: 2 additions & 1 deletion apps/web/utils/account-linking.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { GetAuthLinkUrlResponse } from "@/app/api/google/linking/auth-url/route";
import type { GetOutlookAuthLinkUrlResponse } from "@/app/api/outlook/linking/auth-url/route";
import { isGoogleProvider } from "@/utils/email/provider-types";

/**
* Initiates the OAuth account linking flow for Google or Microsoft.
Expand All @@ -18,7 +19,7 @@ export async function getAccountLinkingUrl(

if (!response.ok) {
throw new Error(
`Failed to initiate ${provider === "google" ? "Google" : "Microsoft"} account linking`,
`Failed to initiate ${isGoogleProvider(provider) ? "Google" : "Microsoft"} account linking`,
);
}

Expand Down
3 changes: 2 additions & 1 deletion apps/web/utils/calendar/event-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Logger } from "@/utils/logger";
import type { CalendarEventProvider } from "@/utils/calendar/event-types";
import { GoogleCalendarEventProvider } from "@/utils/calendar/providers/google-events";
import { MicrosoftCalendarEventProvider } from "@/utils/calendar/providers/microsoft-events";
import { isGoogleProvider } from "@/utils/email/provider-types";

/**
* Create calendar event providers for all connected calendars.
Expand Down Expand Up @@ -37,7 +38,7 @@ export async function createCalendarEventProviders(
if (!connection.refreshToken) continue;

try {
if (connection.provider === "google") {
if (isGoogleProvider(connection.provider)) {
providers.push(
new GoogleCalendarEventProvider(
{
Expand Down
5 changes: 3 additions & 2 deletions apps/web/utils/calendar/unified-availability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import prisma from "@/utils/prisma";
import type { BusyPeriod } from "./availability-types";
import { createGoogleAvailabilityProvider } from "./providers/google-availability";
import { createMicrosoftAvailabilityProvider } from "./providers/microsoft-availability";
import { isGoogleProvider } from "@/utils/email/provider-types";

/**
* Fetch calendar availability across all connected calendars (Google and Microsoft)
Expand Down Expand Up @@ -61,8 +62,8 @@ export async function getUnifiedCalendarAvailability({
}

// Group calendars by provider
const googleConnections = calendarConnections.filter(
(conn) => conn.provider === "google",
const googleConnections = calendarConnections.filter((conn) =>
isGoogleProvider(conn.provider),
);
const microsoftConnections = calendarConnections.filter(
(conn) => conn.provider === "microsoft",
Expand Down
Loading