diff --git a/apps/web/components/AdditionalCalendarSelector.tsx b/apps/web/components/AdditionalCalendarSelector.tsx index 192aff0df21d8..dbeab7cb8e544 100644 --- a/apps/web/components/AdditionalCalendarSelector.tsx +++ b/apps/web/components/AdditionalCalendarSelector.tsx @@ -4,11 +4,11 @@ import { OptionProps } from "react-select"; import { InstallAppButton } from "@calcom/app-store/components"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { trpc } from "@calcom/trpc/react"; import type { App } from "@calcom/types/App"; import { Button } from "@calcom/ui"; import { QueryCell } from "@lib/QueryCell"; -import { trpc } from "@lib/trpc"; interface AdditionalCalendarSelectorProps { isLoading?: boolean; diff --git a/apps/web/components/App.tsx b/apps/web/components/App.tsx index 5704f2df579e0..98f1b7f25fbcc 100644 --- a/apps/web/components/App.tsx +++ b/apps/web/components/App.tsx @@ -16,12 +16,11 @@ import useAddAppMutation from "@calcom/app-store/_utils/useAddAppMutation"; import { InstallAppButton } from "@calcom/app-store/components"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { trpc } from "@calcom/trpc/react"; import { App as AppType } from "@calcom/types/App"; import { Button, SkeletonButton } from "@calcom/ui"; import LicenseRequired from "@ee/components/LicenseRequired"; -import { trpc } from "@lib/trpc"; - import Shell from "@components/Shell"; import Badge from "@components/ui/Badge"; diff --git a/apps/web/components/DestinationCalendarSelector.tsx b/apps/web/components/DestinationCalendarSelector.tsx index 25f4a7f5ac982..d459a03c9318b 100644 --- a/apps/web/components/DestinationCalendarSelector.tsx +++ b/apps/web/components/DestinationCalendarSelector.tsx @@ -3,8 +3,7 @@ import React, { useEffect, useState } from "react"; import Select from "react-select"; import { useLocale } from "@calcom/lib/hooks/useLocale"; - -import { trpc } from "@lib/trpc"; +import { trpc } from "@calcom/trpc/react"; interface Props { onChange: (value: { externalId: string; integration: string }) => void; diff --git a/apps/web/components/Embed.tsx b/apps/web/components/Embed.tsx index 736931db187bf..cc4c8fdc3d2aa 100644 --- a/apps/web/components/Embed.tsx +++ b/apps/web/components/Embed.tsx @@ -8,12 +8,12 @@ import { components, ControlProps } from "react-select"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; import { EventType } from "@calcom/prisma/client"; +import { trpc } from "@calcom/trpc/react"; import { Button, Switch } from "@calcom/ui"; import { Dialog, DialogClose, DialogContent } from "@calcom/ui/Dialog"; import { InputLeading, Label, TextArea, TextField } from "@calcom/ui/form/fields"; import { EMBED_LIB_URL, WEBAPP_URL } from "@lib/config/constants"; -import { trpc } from "@lib/trpc"; import NavTabs from "@components/NavTabs"; import ColorPicker from "@components/ui/colorpicker"; diff --git a/apps/web/components/I18nLanguageHandler.tsx b/apps/web/components/I18nLanguageHandler.tsx index 1a78b6557ee60..c4c7d2070ebd0 100644 --- a/apps/web/components/I18nLanguageHandler.tsx +++ b/apps/web/components/I18nLanguageHandler.tsx @@ -1,7 +1,7 @@ import { useTranslation } from "next-i18next"; import { useEffect } from "react"; -import { trpc } from "@lib/trpc"; +import { trpc } from "@calcom/trpc/react"; export function useViewerI18n() { return trpc.useQuery(["viewer.public.i18n"], { diff --git a/apps/web/components/Shell.tsx b/apps/web/components/Shell.tsx index be6f88816bfd0..6eee53d45c0ee 100644 --- a/apps/web/components/Shell.tsx +++ b/apps/web/components/Shell.tsx @@ -24,6 +24,7 @@ import { Toaster } from "react-hot-toast"; import { useIsEmbed } from "@calcom/embed-core/embed-iframe"; import { WEBAPP_URL, JOIN_SLACK, ROADMAP } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { trpc } from "@calcom/trpc/react"; import Button from "@calcom/ui/Button"; import Dropdown, { DropdownMenuContent, @@ -39,7 +40,6 @@ import ErrorBoundary from "@lib/ErrorBoundary"; import classNames from "@lib/classNames"; import { shouldShowOnboarding } from "@lib/getting-started"; import useMeQuery from "@lib/hooks/useMeQuery"; -import { trpc } from "@lib/trpc"; import CustomBranding from "@components/CustomBranding"; import { KBarRoot, KBarContent, KBarTrigger } from "@components/Kbar"; @@ -494,7 +494,17 @@ function UserDropdown({ small }: { small?: boolean }) { const { t } = useLocale(); const query = useMeQuery(); const user = query.data; - + useEffect(() => { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + //@ts-ignore + const Beacon = window.Beacon; + // window.Beacon is defined when user actually opens up HelpScout and username is available here. On every re-render update session info, so that it is always latest. + Beacon && + Beacon("session-data", { + username: user?.username || "Unknown", + screenResolution: `${screen.width}x${screen.height}`, + }); + }); const mutation = trpc.useMutation("viewer.away", { onSettled() { utils.invalidateQueries("viewer.me"); diff --git a/apps/web/components/apps/AppCard.tsx b/apps/web/components/apps/AppCard.tsx index c6a6ee17f4f87..6397b9e46b414 100644 --- a/apps/web/components/apps/AppCard.tsx +++ b/apps/web/components/apps/AppCard.tsx @@ -1,9 +1,8 @@ import Link from "next/link"; +import { trpc } from "@calcom/trpc/react"; import Button from "@calcom/ui/Button"; -import { trpc } from "@lib/trpc"; - import Badge from "@components/ui/Badge"; interface AppCardProps { diff --git a/apps/web/components/auth/SAMLLogin.tsx b/apps/web/components/auth/SAMLLogin.tsx index 76f7c75c8c3ae..62ec48ef0fe73 100644 --- a/apps/web/components/auth/SAMLLogin.tsx +++ b/apps/web/components/auth/SAMLLogin.tsx @@ -2,11 +2,11 @@ import { signIn } from "next-auth/react"; import { Dispatch, SetStateAction } from "react"; import { useFormContext } from "react-hook-form"; +import { trpc } from "@calcom/trpc/react"; import Button from "@calcom/ui/Button"; import { useLocale } from "@lib/hooks/useLocale"; import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@lib/telemetry"; -import { trpc } from "@lib/trpc"; interface Props { email: string; diff --git a/apps/web/components/availability/NewScheduleButton.tsx b/apps/web/components/availability/NewScheduleButton.tsx index 1d1fc7ae30df9..b0f591b466566 100644 --- a/apps/web/components/availability/NewScheduleButton.tsx +++ b/apps/web/components/availability/NewScheduleButton.tsx @@ -4,12 +4,12 @@ import { useForm } from "react-hook-form"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { trpc } from "@calcom/trpc/react"; import { Button } from "@calcom/ui"; import { Dialog, DialogClose, DialogContent, DialogTrigger } from "@calcom/ui/Dialog"; import { Form } from "@calcom/ui/form/fields"; import { HttpError } from "@lib/core/http/error"; -import { trpc } from "@lib/trpc"; export function NewScheduleButton({ name = "new-schedule" }: { name?: string }) { const router = useRouter(); diff --git a/apps/web/components/availability/ScheduleListItem.tsx b/apps/web/components/availability/ScheduleListItem.tsx index 74f759563b2ae..e498b1f8f489f 100644 --- a/apps/web/components/availability/ScheduleListItem.tsx +++ b/apps/web/components/availability/ScheduleListItem.tsx @@ -5,11 +5,10 @@ import { Fragment } from "react"; import { availabilityAsString } from "@calcom/lib/availability"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { Availability } from "@calcom/prisma/client"; +import { inferQueryOutput } from "@calcom/trpc/react"; import { Button } from "@calcom/ui"; import Dropdown, { DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@calcom/ui/Dropdown"; -import { inferQueryOutput } from "@lib/trpc"; - export function ScheduleListItem({ schedule, deleteFunction, diff --git a/apps/web/components/booking/AvailableTimes.tsx b/apps/web/components/booking/AvailableTimes.tsx index e80afaae5c495..1d0273b92cd24 100644 --- a/apps/web/components/booking/AvailableTimes.tsx +++ b/apps/web/components/booking/AvailableTimes.tsx @@ -6,13 +6,12 @@ import { FC, useEffect, useState } from "react"; import dayjs, { Dayjs } from "@calcom/dayjs"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { nameOfDay } from "@calcom/lib/weekday"; +import type { Slot } from "@calcom/trpc/server/routers/viewer/slots"; import { SkeletonContainer, SkeletonText } from "@calcom/ui"; import classNames from "@lib/classNames"; import { timeZone } from "@lib/clock"; -import type { Slot } from "@server/routers/viewer/slots"; - type AvailableTimesProps = { timeFormat: string; eventTypeId: number; diff --git a/apps/web/components/booking/BookingListItem.tsx b/apps/web/components/booking/BookingListItem.tsx index e562feb378be7..65861d1cc3e7c 100644 --- a/apps/web/components/booking/BookingListItem.tsx +++ b/apps/web/components/booking/BookingListItem.tsx @@ -18,6 +18,7 @@ import classNames from "@calcom/lib/classNames"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; import { getEveryFreqFor } from "@calcom/lib/recurringStrings"; +import { inferQueryInput, inferQueryOutput, trpc } from "@calcom/trpc/react"; import Button from "@calcom/ui/Button"; import { Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader } from "@calcom/ui/Dialog"; import { Tooltip } from "@calcom/ui/Tooltip"; @@ -28,7 +29,6 @@ import useMeQuery from "@lib/hooks/useMeQuery"; import { linkValueToString } from "@lib/linkValueToString"; import { LocationType } from "@lib/location"; import { extractRecurringDates } from "@lib/parseDate"; -import { inferQueryInput, inferQueryOutput, trpc } from "@lib/trpc"; import { EditLocationDialog } from "@components/dialog/EditLocationDialog"; import { RescheduleDialog } from "@components/dialog/RescheduleDialog"; diff --git a/apps/web/components/booking/pages/AvailabilityPage.tsx b/apps/web/components/booking/pages/AvailabilityPage.tsx index 8010f2565f5e2..dc26259084b3e 100644 --- a/apps/web/components/booking/pages/AvailabilityPage.tsx +++ b/apps/web/components/booking/pages/AvailabilityPage.tsx @@ -35,6 +35,7 @@ import { CAL_URL, WEBSITE_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { getRecurringFreq } from "@calcom/lib/recurringStrings"; import { localStorage } from "@calcom/lib/webstorage"; +import { trpc } from "@calcom/trpc/react"; import DatePicker from "@calcom/ui/booker/DatePicker"; import { timeZone as localStorageTimeZone } from "@lib/clock"; @@ -44,7 +45,6 @@ import useTheme from "@lib/hooks/useTheme"; import { isBrandingHidden } from "@lib/isBrandingHidden"; import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@lib/telemetry"; import { detectBrowserTimeFormat } from "@lib/timeFormat"; -import { trpc } from "@lib/trpc"; import CustomBranding from "@components/CustomBranding"; import AvailableTimes from "@components/booking/AvailableTimes"; diff --git a/apps/web/components/dialog/EditLocationDialog.tsx b/apps/web/components/dialog/EditLocationDialog.tsx index f96668703c035..94233f49f81a8 100644 --- a/apps/web/components/dialog/EditLocationDialog.tsx +++ b/apps/web/components/dialog/EditLocationDialog.tsx @@ -8,6 +8,7 @@ import { z } from "zod"; import classNames from "@calcom/lib/classNames"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { inferQueryOutput, trpc } from "@calcom/trpc/react"; import { Button } from "@calcom/ui"; import { Dialog, DialogContent } from "@calcom/ui/Dialog"; import { Form } from "@calcom/ui/form/fields"; @@ -16,7 +17,6 @@ import { QueryCell } from "@lib/QueryCell"; import { linkValueToString } from "@lib/linkValueToString"; import { LocationType } from "@lib/location"; import { LocationOptionsToString } from "@lib/locationOptions"; -import { inferQueryOutput, trpc } from "@lib/trpc"; import CheckboxField from "@components/ui/form/CheckboxField"; import type PhoneInputType from "@components/ui/form/PhoneInput"; diff --git a/apps/web/components/dialog/RescheduleDialog.tsx b/apps/web/components/dialog/RescheduleDialog.tsx index 7e11fbf453e68..60aa8afc6019e 100644 --- a/apps/web/components/dialog/RescheduleDialog.tsx +++ b/apps/web/components/dialog/RescheduleDialog.tsx @@ -5,12 +5,12 @@ import { useMutation } from "react-query"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { trpc } from "@calcom/trpc/react"; import Button from "@calcom/ui/Button"; import { Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader } from "@calcom/ui/Dialog"; import { TextArea } from "@calcom/ui/form/fields"; import * as fetchWrapper from "@lib/core/http/fetch-wrapper"; -import { trpc } from "@lib/trpc"; interface IRescheduleDialog { isOpenDialog: boolean; diff --git a/apps/web/components/eventtype/CreateEventType.tsx b/apps/web/components/eventtype/CreateEventType.tsx index 10e18bb5879b2..a8c9317a4cf35 100644 --- a/apps/web/components/eventtype/CreateEventType.tsx +++ b/apps/web/components/eventtype/CreateEventType.tsx @@ -6,9 +6,11 @@ import { useEffect } from "react"; import { useForm } from "react-hook-form"; import type { z } from "zod"; +import { WEBAPP_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; import { createEventTypeInput } from "@calcom/prisma/zod/custom/eventtype"; +import { trpc } from "@calcom/trpc/react"; import { Alert } from "@calcom/ui/Alert"; import { Button } from "@calcom/ui/Button"; import { Dialog, DialogClose, DialogContent } from "@calcom/ui/Dialog"; @@ -23,7 +25,6 @@ import { Form, InputLeading, TextAreaField, TextField } from "@calcom/ui/form/fi import { HttpError } from "@lib/core/http/error"; import { slugify } from "@lib/slugify"; -import { trpc } from "@lib/trpc"; import Avatar from "@components/ui/Avatar"; import * as RadioArea from "@components/ui/form/radio-area"; @@ -164,7 +165,7 @@ export default function CreateEventTypeButton(props: Props) { onSelect={() => openModal(option)}> diff --git a/apps/web/components/integrations/CalendarListContainer.tsx b/apps/web/components/integrations/CalendarListContainer.tsx index ffb1819f0c942..55fc7d00e46b5 100644 --- a/apps/web/components/integrations/CalendarListContainer.tsx +++ b/apps/web/components/integrations/CalendarListContainer.tsx @@ -4,12 +4,12 @@ import { useMutation } from "react-query"; import { InstallAppButton } from "@calcom/app-store/components"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { inferQueryOutput, trpc } from "@calcom/trpc/react"; import { Alert } from "@calcom/ui/Alert"; import Button from "@calcom/ui/Button"; import Switch from "@calcom/ui/Switch"; import { QueryCell } from "@lib/QueryCell"; -import { inferQueryOutput, trpc } from "@lib/trpc"; import AdditionalCalendarSelector from "@components/AdditionalCalendarSelector"; import DestinationCalendarSelector from "@components/DestinationCalendarSelector"; diff --git a/apps/web/components/integrations/DisconnectIntegration.tsx b/apps/web/components/integrations/DisconnectIntegration.tsx index 9568aac2779c0..ec74fea0b2c76 100644 --- a/apps/web/components/integrations/DisconnectIntegration.tsx +++ b/apps/web/components/integrations/DisconnectIntegration.tsx @@ -3,11 +3,10 @@ import { useMutation } from "react-query"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { trpc } from "@calcom/trpc/react"; import { ButtonBaseProps } from "@calcom/ui/Button"; import { Dialog } from "@calcom/ui/Dialog"; -import { trpc } from "@lib/trpc"; - import ConfirmationDialogContent from "@components/dialog/ConfirmationDialogContent"; export default function DisconnectIntegration(props: { diff --git a/apps/web/components/security/DisableUserImpersonation.tsx b/apps/web/components/security/DisableUserImpersonation.tsx index c17d114ce770b..79b1f297c4b1c 100644 --- a/apps/web/components/security/DisableUserImpersonation.tsx +++ b/apps/web/components/security/DisableUserImpersonation.tsx @@ -1,9 +1,8 @@ import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { trpc } from "@calcom/trpc/react"; import Button from "@calcom/ui/Button"; -import { trpc } from "@lib/trpc"; - import Badge from "@components/ui/Badge"; const DisableUserImpersonation = ({ disableImpersonation }: { disableImpersonation: boolean }) => { diff --git a/apps/web/components/team/DisableTeamImpersonation.tsx b/apps/web/components/team/DisableTeamImpersonation.tsx index 1e1065f8b0526..d1b75b5f7c9ec 100644 --- a/apps/web/components/team/DisableTeamImpersonation.tsx +++ b/apps/web/components/team/DisableTeamImpersonation.tsx @@ -1,9 +1,8 @@ import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { trpc } from "@calcom/trpc/react"; import Button from "@calcom/ui/Button"; -import { trpc } from "@lib/trpc"; - import Badge from "@components/ui/Badge"; const DisableTeamImpersonation = ({ teamId, memberId }: { teamId: number; memberId: number }) => { diff --git a/apps/web/components/team/MemberChangeRoleModal.tsx b/apps/web/components/team/MemberChangeRoleModal.tsx index 263cd3d9687ee..642675bc7ce97 100644 --- a/apps/web/components/team/MemberChangeRoleModal.tsx +++ b/apps/web/components/team/MemberChangeRoleModal.tsx @@ -2,10 +2,9 @@ import { MembershipRole } from "@prisma/client"; import { SyntheticEvent, useMemo, useState } from "react"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { trpc } from "@calcom/trpc/react"; import Button from "@calcom/ui/Button"; -import { trpc } from "@lib/trpc"; - import ModalContainer from "@components/ui/ModalContainer"; import Select from "@components/ui/form/Select"; diff --git a/apps/web/components/team/MemberInvitationModal.tsx b/apps/web/components/team/MemberInvitationModal.tsx index 7d7495d398c03..2ead04d2d979f 100644 --- a/apps/web/components/team/MemberInvitationModal.tsx +++ b/apps/web/components/team/MemberInvitationModal.tsx @@ -3,13 +3,13 @@ import { InformationCircleIcon } from "@heroicons/react/solid"; import { MembershipRole } from "@prisma/client"; import React, { useState, SyntheticEvent, useMemo } from "react"; +import { TeamWithMembers } from "@calcom/lib/server/queries/teams"; +import { trpc } from "@calcom/trpc/react"; import Button from "@calcom/ui/Button"; import { Dialog, DialogContent, DialogFooter } from "@calcom/ui/Dialog"; import { TextField } from "@calcom/ui/form/fields"; import { useLocale } from "@lib/hooks/useLocale"; -import { TeamWithMembers } from "@lib/queries/teams"; -import { trpc } from "@lib/trpc"; import Select from "@components/ui/form/Select"; diff --git a/apps/web/components/team/MemberList.tsx b/apps/web/components/team/MemberList.tsx index 0d41d4d69368f..24cf37ebe7770 100644 --- a/apps/web/components/team/MemberList.tsx +++ b/apps/web/components/team/MemberList.tsx @@ -1,4 +1,4 @@ -import { inferQueryOutput } from "@lib/trpc"; +import { inferQueryOutput } from "@calcom/trpc/react"; import MemberListItem from "./MemberListItem"; diff --git a/apps/web/components/team/MemberListItem.tsx b/apps/web/components/team/MemberListItem.tsx index 952308e3bd0c9..18ee2496e8dad 100644 --- a/apps/web/components/team/MemberListItem.tsx +++ b/apps/web/components/team/MemberListItem.tsx @@ -8,6 +8,7 @@ import { useState } from "react"; import { WEBAPP_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { inferQueryOutput, trpc } from "@calcom/trpc/react"; import Button from "@calcom/ui/Button"; import { Dialog, DialogTrigger } from "@calcom/ui/Dialog"; import Dropdown, { @@ -20,7 +21,6 @@ import { Tooltip } from "@calcom/ui/Tooltip"; import TeamAvailabilityModal from "@ee/components/team/availability/TeamAvailabilityModal"; import useCurrentUserId from "@lib/hooks/useCurrentUserId"; -import { inferQueryOutput, trpc } from "@lib/trpc"; import ConfirmationDialogContent from "@components/dialog/ConfirmationDialogContent"; import Avatar from "@components/ui/Avatar"; diff --git a/apps/web/components/team/TeamCreateModal.tsx b/apps/web/components/team/TeamCreateModal.tsx index b96ae5a804323..1c0189cac32f4 100644 --- a/apps/web/components/team/TeamCreateModal.tsx +++ b/apps/web/components/team/TeamCreateModal.tsx @@ -2,12 +2,11 @@ import { UsersIcon } from "@heroicons/react/outline"; import { useRef, useState } from "react"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { trpc } from "@calcom/trpc/react"; import { Button } from "@calcom/ui"; import { Alert } from "@calcom/ui/Alert"; import { Dialog, DialogContent, DialogFooter } from "@calcom/ui/Dialog"; -import { trpc } from "@lib/trpc"; - interface Props { isOpen: boolean; onClose: () => void; diff --git a/apps/web/components/team/TeamList.tsx b/apps/web/components/team/TeamList.tsx index f8177700429a4..fdb9466f72569 100644 --- a/apps/web/components/team/TeamList.tsx +++ b/apps/web/components/team/TeamList.tsx @@ -1,6 +1,5 @@ import showToast from "@calcom/lib/notification"; - -import { inferQueryOutput, trpc } from "@lib/trpc"; +import { inferQueryOutput, trpc } from "@calcom/trpc/react"; import TeamListItem from "./TeamListItem"; diff --git a/apps/web/components/team/TeamListItem.tsx b/apps/web/components/team/TeamListItem.tsx index 57482bffe03ae..a6901fa40b6ff 100644 --- a/apps/web/components/team/TeamListItem.tsx +++ b/apps/web/components/team/TeamListItem.tsx @@ -13,6 +13,7 @@ import Link from "next/link"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { inferQueryOutput, trpc } from "@calcom/trpc/react"; import Button from "@calcom/ui/Button"; import { Dialog, DialogTrigger } from "@calcom/ui/Dialog"; import Dropdown, { @@ -25,7 +26,6 @@ import { Tooltip } from "@calcom/ui/Tooltip"; import classNames from "@lib/classNames"; import { getPlaceholderAvatar } from "@lib/getPlaceholderAvatar"; -import { inferQueryOutput, trpc } from "@lib/trpc"; import ConfirmationDialogContent from "@components/dialog/ConfirmationDialogContent"; import Avatar from "@components/ui/Avatar"; diff --git a/apps/web/components/team/TeamSettings.tsx b/apps/web/components/team/TeamSettings.tsx index 16f81c94ee723..d1134e7f622e5 100644 --- a/apps/web/components/team/TeamSettings.tsx +++ b/apps/web/components/team/TeamSettings.tsx @@ -4,13 +4,12 @@ import React, { useRef, useState } from "react"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; import { objectKeys } from "@calcom/lib/objectKeys"; +import { TeamWithMembers } from "@calcom/lib/server/queries/teams"; +import { trpc } from "@calcom/trpc/react"; import { Alert } from "@calcom/ui/Alert"; import Button from "@calcom/ui/Button"; import { TextField } from "@calcom/ui/form/fields"; -import { TeamWithMembers } from "@lib/queries/teams"; -import { trpc } from "@lib/trpc"; - import ImageUploader from "@components/ImageUploader"; import SettingInputContainer from "@components/ui/SettingInputContainer"; diff --git a/apps/web/components/team/TeamSettingsRightSidebar.tsx b/apps/web/components/team/TeamSettingsRightSidebar.tsx index e4c857f59508e..420c153594441 100644 --- a/apps/web/components/team/TeamSettingsRightSidebar.tsx +++ b/apps/web/components/team/TeamSettingsRightSidebar.tsx @@ -5,11 +5,11 @@ import { useRouter } from "next/router"; import React from "react"; import showToast from "@calcom/lib/notification"; +import { TeamWithMembers } from "@calcom/lib/server/queries/teams"; +import { trpc } from "@calcom/trpc/react"; import { Dialog, DialogTrigger } from "@calcom/ui/Dialog"; import { useLocale } from "@lib/hooks/useLocale"; -import { TeamWithMembers } from "@lib/queries/teams"; -import { trpc } from "@lib/trpc"; import ConfirmationDialogContent from "@components/dialog/ConfirmationDialogContent"; import CreateEventTypeButton from "@components/eventtype/CreateEventType"; diff --git a/apps/web/components/team/UpgradeToFlexibleProModal.tsx b/apps/web/components/team/UpgradeToFlexibleProModal.tsx index 19ec8d3925992..34e19e5714f7f 100644 --- a/apps/web/components/team/UpgradeToFlexibleProModal.tsx +++ b/apps/web/components/team/UpgradeToFlexibleProModal.tsx @@ -1,6 +1,7 @@ import { useState } from "react"; import showToast from "@calcom/lib/notification"; +import { trpc } from "@calcom/trpc/react"; import { Alert } from "@calcom/ui/Alert"; import Button from "@calcom/ui/Button"; import { @@ -13,7 +14,6 @@ import { } from "@calcom/ui/Dialog"; import { useLocale } from "@lib/hooks/useLocale"; -import { trpc } from "@lib/trpc"; interface Props { teamId: number; diff --git a/apps/web/components/ui/Avatar.tsx b/apps/web/components/ui/Avatar.tsx index d20056d09590f..44373297f787b 100644 --- a/apps/web/components/ui/Avatar.tsx +++ b/apps/web/components/ui/Avatar.tsx @@ -1,11 +1,11 @@ import * as AvatarPrimitive from "@radix-ui/react-avatar"; import * as Tooltip from "@radix-ui/react-tooltip"; +import { Maybe } from "@calcom/trpc/server"; + import classNames from "@lib/classNames"; import { defaultAvatarSrc } from "@lib/profile"; -import { Maybe } from "@trpc/server"; - export type AvatarProps = { className?: string; size?: number; diff --git a/apps/web/components/ui/UsernameAvailability/PremiumTextfield.tsx b/apps/web/components/ui/UsernameAvailability/PremiumTextfield.tsx index 6044eac72c51a..685c662c6fc88 100644 --- a/apps/web/components/ui/UsernameAvailability/PremiumTextfield.tsx +++ b/apps/web/components/ui/UsernameAvailability/PremiumTextfield.tsx @@ -7,15 +7,13 @@ import { fetchUsername } from "@calcom/lib/fetchUsername"; import hasKeyInMetadata from "@calcom/lib/hasKeyInMetadata"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { User } from "@calcom/prisma/client"; +import { TRPCClientErrorLike } from "@calcom/trpc/client"; +import { trpc } from "@calcom/trpc/react"; +import type { AppRouter } from "@calcom/trpc/server/routers/_app"; import Button from "@calcom/ui/Button"; import { Dialog, DialogClose, DialogContent, DialogHeader } from "@calcom/ui/Dialog"; import { Input, Label } from "@calcom/ui/form/fields"; -import { trpc } from "@lib/trpc"; - -import { AppRouter } from "@server/routers/_app"; -import { TRPCClientErrorLike } from "@trpc/client"; - export enum UsernameChangeStatusEnum { NORMAL = "NORMAL", UPGRADE = "UPGRADE", diff --git a/apps/web/components/ui/UsernameAvailability/UsernameTextfield.tsx b/apps/web/components/ui/UsernameAvailability/UsernameTextfield.tsx index 325647f3be861..3971f92f5688e 100644 --- a/apps/web/components/ui/UsernameAvailability/UsernameTextfield.tsx +++ b/apps/web/components/ui/UsernameAvailability/UsernameTextfield.tsx @@ -5,15 +5,13 @@ import { MutableRefObject, useCallback, useEffect, useState } from "react"; import { fetchUsername } from "@calcom/lib/fetchUsername"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { TRPCClientErrorLike } from "@calcom/trpc/client"; +import { trpc } from "@calcom/trpc/react"; +import { AppRouter } from "@calcom/trpc/server/routers/_app"; import Button from "@calcom/ui/Button"; import { Dialog, DialogClose, DialogContent, DialogHeader } from "@calcom/ui/Dialog"; import { Input, Label } from "@calcom/ui/form/fields"; -import { trpc } from "@lib/trpc"; - -import { AppRouter } from "@server/routers/_app"; -import { TRPCClientErrorLike } from "@trpc/client"; - interface ICustomUsernameProps { currentUsername: string | undefined; setCurrentUsername: (value: string | undefined) => void; diff --git a/apps/web/components/webhook/WebhookDialogForm.tsx b/apps/web/components/webhook/WebhookDialogForm.tsx index 4ca59e5c6b1e0..6773e9b649fda 100644 --- a/apps/web/components/webhook/WebhookDialogForm.tsx +++ b/apps/web/components/webhook/WebhookDialogForm.tsx @@ -3,12 +3,12 @@ import { Controller, useForm } from "react-hook-form"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { trpc } from "@calcom/trpc/react"; import Button from "@calcom/ui/Button"; import { DialogFooter } from "@calcom/ui/Dialog"; import Switch from "@calcom/ui/Switch"; import { FieldsetLegend, Form, InputGroupBox, TextArea, TextField } from "@calcom/ui/form/fields"; -import { trpc } from "@lib/trpc"; import { WEBHOOK_TRIGGER_EVENTS_GROUPED_BY_APP } from "@lib/webhooks/constants"; import customTemplate, { hasTemplateIntegration } from "@lib/webhooks/integrationTemplate"; diff --git a/apps/web/components/webhook/WebhookListContainer.tsx b/apps/web/components/webhook/WebhookListContainer.tsx index 85fb600a1c8cb..ba5c95ae03583 100644 --- a/apps/web/components/webhook/WebhookListContainer.tsx +++ b/apps/web/components/webhook/WebhookListContainer.tsx @@ -1,11 +1,11 @@ import { PlusIcon } from "@heroicons/react/solid"; import { useState } from "react"; +import { trpc } from "@calcom/trpc/react"; import Button from "@calcom/ui/Button"; import { Dialog, DialogContent } from "@calcom/ui/Dialog"; import { QueryCell } from "@lib/QueryCell"; -import { trpc } from "@lib/trpc"; import { List } from "@components/List"; import { ShellSubHeading } from "@components/Shell"; diff --git a/apps/web/components/webhook/WebhookListItem.tsx b/apps/web/components/webhook/WebhookListItem.tsx index 4f163866560ad..fdf77a926587b 100644 --- a/apps/web/components/webhook/WebhookListItem.tsx +++ b/apps/web/components/webhook/WebhookListItem.tsx @@ -1,12 +1,12 @@ import { PencilAltIcon, TrashIcon } from "@heroicons/react/outline"; import classNames from "@calcom/lib/classNames"; +import { inferQueryOutput, trpc } from "@calcom/trpc/react"; import Button from "@calcom/ui/Button"; import { Dialog, DialogTrigger } from "@calcom/ui/Dialog"; import { Tooltip } from "@calcom/ui/Tooltip"; import { useLocale } from "@lib/hooks/useLocale"; -import { inferQueryOutput, trpc } from "@lib/trpc"; import { ListItem } from "@components/List"; import ConfirmationDialogContent from "@components/dialog/ConfirmationDialogContent"; diff --git a/apps/web/components/webhook/WebhookTestDisclosure.tsx b/apps/web/components/webhook/WebhookTestDisclosure.tsx index ffd94db8e9865..7fd419916ba5b 100644 --- a/apps/web/components/webhook/WebhookTestDisclosure.tsx +++ b/apps/web/components/webhook/WebhookTestDisclosure.tsx @@ -5,11 +5,11 @@ import { useWatch } from "react-hook-form"; import classNames from "@calcom/lib/classNames"; import showToast from "@calcom/lib/notification"; +import { trpc } from "@calcom/trpc/react"; import Button from "@calcom/ui/Button"; import { InputGroupBox } from "@calcom/ui/form/fields"; import { useLocale } from "@lib/hooks/useLocale"; -import { trpc } from "@lib/trpc"; export default function WebhookTestDisclosure() { const subscriberUrl: string = useWatch({ name: "subscriberUrl" }); diff --git a/apps/web/ee/components/apiKeys/ApiKeyDialogForm.tsx b/apps/web/ee/components/apiKeys/ApiKeyDialogForm.tsx index 370d8e7c7ad83..9a6b0b6ab01bd 100644 --- a/apps/web/ee/components/apiKeys/ApiKeyDialogForm.tsx +++ b/apps/web/ee/components/apiKeys/ApiKeyDialogForm.tsx @@ -5,14 +5,13 @@ import { Controller, useForm } from "react-hook-form"; import dayjs from "@calcom/dayjs"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { trpc } from "@calcom/trpc/react"; import Button from "@calcom/ui/Button"; import { DialogFooter } from "@calcom/ui/Dialog"; import Switch from "@calcom/ui/Switch"; import { Tooltip } from "@calcom/ui/Tooltip"; import { Form, TextField } from "@calcom/ui/form/fields"; -import { trpc } from "@lib/trpc"; - import { DatePicker } from "@components/ui/form/DatePicker"; import LicenseRequired from "../LicenseRequired"; diff --git a/apps/web/ee/components/apiKeys/ApiKeyListContainer.tsx b/apps/web/ee/components/apiKeys/ApiKeyListContainer.tsx index 47fedac8da661..219eaca43376f 100644 --- a/apps/web/ee/components/apiKeys/ApiKeyListContainer.tsx +++ b/apps/web/ee/components/apiKeys/ApiKeyListContainer.tsx @@ -2,13 +2,13 @@ import { PlusIcon } from "@heroicons/react/outline"; import { useState } from "react"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { trpc } from "@calcom/trpc/react"; import Button from "@calcom/ui/Button"; import { Dialog, DialogContent } from "@calcom/ui/Dialog"; import ApiKeyDialogForm from "@ee/components/apiKeys/ApiKeyDialogForm"; import ApiKeyListItem, { TApiKeys } from "@ee/components/apiKeys/ApiKeyListItem"; import { QueryCell } from "@lib/QueryCell"; -import { trpc } from "@lib/trpc"; import { List } from "@components/List"; import { ShellSubHeading } from "@components/Shell"; diff --git a/apps/web/ee/components/apiKeys/ApiKeyListItem.tsx b/apps/web/ee/components/apiKeys/ApiKeyListItem.tsx index 81ac3ec46e4c6..c1c6a1c6b230d 100644 --- a/apps/web/ee/components/apiKeys/ApiKeyListItem.tsx +++ b/apps/web/ee/components/apiKeys/ApiKeyListItem.tsx @@ -4,12 +4,11 @@ import { ExclamationIcon } from "@heroicons/react/solid"; import dayjs from "@calcom/dayjs"; import classNames from "@calcom/lib/classNames"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { inferQueryOutput, trpc } from "@calcom/trpc/react"; import Button from "@calcom/ui/Button"; import { Dialog, DialogTrigger } from "@calcom/ui/Dialog"; import { Tooltip } from "@calcom/ui/Tooltip"; -import { inferQueryOutput, trpc } from "@lib/trpc"; - import { ListItem } from "@components/List"; import ConfirmationDialogContent from "@components/dialog/ConfirmationDialogContent"; import Badge from "@components/ui/Badge"; diff --git a/apps/web/ee/components/saml/Configuration.tsx b/apps/web/ee/components/saml/Configuration.tsx index 7778b647dab81..d2e4fe34d3f87 100644 --- a/apps/web/ee/components/saml/Configuration.tsx +++ b/apps/web/ee/components/saml/Configuration.tsx @@ -2,13 +2,13 @@ import React, { useEffect, useRef, useState } from "react"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { trpc } from "@calcom/trpc/react"; import { Alert } from "@calcom/ui/Alert"; import Button from "@calcom/ui/Button"; import { Dialog, DialogTrigger } from "@calcom/ui/Dialog"; import { TextArea } from "@calcom/ui/form/fields"; import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@lib/telemetry"; -import { trpc } from "@lib/trpc"; import ConfirmationDialogContent from "@components/dialog/ConfirmationDialogContent"; import Badge from "@components/ui/Badge"; diff --git a/apps/web/ee/components/support/HelpMenuItem.tsx b/apps/web/ee/components/support/HelpMenuItem.tsx index 757b71db2e1ad..25f0231034296 100644 --- a/apps/web/ee/components/support/HelpMenuItem.tsx +++ b/apps/web/ee/components/support/HelpMenuItem.tsx @@ -4,10 +4,10 @@ import { HelpScout, useChat } from "react-live-chat-loader"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { trpc } from "@calcom/trpc/react"; import Button from "@calcom/ui/Button"; import classNames from "@lib/classNames"; -import { trpc } from "@lib/trpc"; import ContactMenuItem from "./ContactMenuItem"; diff --git a/apps/web/ee/components/team/availability/TeamAvailabilityModal.tsx b/apps/web/ee/components/team/availability/TeamAvailabilityModal.tsx index 35308514a5125..70cdc4bb7f008 100644 --- a/apps/web/ee/components/team/availability/TeamAvailabilityModal.tsx +++ b/apps/web/ee/components/team/availability/TeamAvailabilityModal.tsx @@ -2,10 +2,9 @@ import React, { useState, useEffect } from "react"; import dayjs from "@calcom/dayjs"; import { WEBAPP_URL } from "@calcom/lib/constants"; +import { inferQueryOutput, trpc } from "@calcom/trpc/react"; import LicenseRequired from "@ee/components/LicenseRequired"; -import { inferQueryOutput, trpc } from "@lib/trpc"; - import Avatar from "@components/ui/Avatar"; import { DatePicker } from "@components/ui/form/DatePicker"; import Select from "@components/ui/form/Select"; diff --git a/apps/web/ee/components/team/availability/TeamAvailabilityScreen.tsx b/apps/web/ee/components/team/availability/TeamAvailabilityScreen.tsx index 55ae53e831b58..763a9da3395cf 100644 --- a/apps/web/ee/components/team/availability/TeamAvailabilityScreen.tsx +++ b/apps/web/ee/components/team/availability/TeamAvailabilityScreen.tsx @@ -4,8 +4,7 @@ import { FixedSizeList as List } from "react-window"; import dayjs from "@calcom/dayjs"; import { CAL_URL } from "@calcom/lib/constants"; - -import { inferQueryOutput, trpc } from "@lib/trpc"; +import { inferQueryOutput, trpc } from "@calcom/trpc/react"; import Avatar from "@components/ui/Avatar"; import { DatePicker } from "@components/ui/form/DatePicker"; diff --git a/apps/web/ee/components/team/availability/TeamAvailabilityTimes.tsx b/apps/web/ee/components/team/availability/TeamAvailabilityTimes.tsx index f89aff6718eda..601ed1e0c63ae 100644 --- a/apps/web/ee/components/team/availability/TeamAvailabilityTimes.tsx +++ b/apps/web/ee/components/team/availability/TeamAvailabilityTimes.tsx @@ -3,9 +3,8 @@ import React from "react"; import { ITimezone } from "react-timezone-select"; import { Dayjs } from "@calcom/dayjs"; - -import getSlots from "@lib/slots"; -import { trpc } from "@lib/trpc"; +import getSlots from "@calcom/lib/slots"; +import { trpc } from "@calcom/trpc/react"; import Loader from "@components/Loader"; diff --git a/apps/web/ee/components/workflows/NewWorkflowButton.tsx b/apps/web/ee/components/workflows/NewWorkflowButton.tsx index b62d7355bbfb7..5840e96c05e56 100644 --- a/apps/web/ee/components/workflows/NewWorkflowButton.tsx +++ b/apps/web/ee/components/workflows/NewWorkflowButton.tsx @@ -9,6 +9,7 @@ import { z } from "zod"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { trpc } from "@calcom/trpc/react"; import { Button } from "@calcom/ui"; import { Dialog, DialogClose, DialogContent, DialogTrigger } from "@calcom/ui/Dialog"; import { Form, TextField } from "@calcom/ui/form/fields"; @@ -20,7 +21,6 @@ import { } from "@ee/lib/workflows/getOptions"; import { HttpError } from "@lib/core/http/error"; -import { trpc } from "@lib/trpc"; import PhoneInput from "@components/ui/form/PhoneInput"; import Select from "@components/ui/form/Select"; diff --git a/apps/web/ee/components/workflows/WorkflowDetailsPage.tsx b/apps/web/ee/components/workflows/WorkflowDetailsPage.tsx index 51659d6762354..b936a201efd4c 100644 --- a/apps/web/ee/components/workflows/WorkflowDetailsPage.tsx +++ b/apps/web/ee/components/workflows/WorkflowDetailsPage.tsx @@ -6,14 +6,13 @@ import { Controller, UseFormReturn } from "react-hook-form"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { HttpError } from "@calcom/lib/http-error"; import showToast from "@calcom/lib/notification"; +import { trpc } from "@calcom/trpc/react"; import { Button } from "@calcom/ui"; import { Form } from "@calcom/ui/form/fields"; import { AddActionDialog } from "@ee/components/workflows/AddActionDialog"; import WorkflowStepContainer from "@ee/components/workflows/WorkflowStepContainer"; import { FormValues } from "@ee/pages/workflows/[workflow]"; -import { trpc } from "@lib/trpc"; - import MultiSelectCheckboxes, { Option } from "@components/ui/form/MultiSelectCheckboxes"; interface Props { diff --git a/apps/web/ee/components/workflows/WorkflowListPage.tsx b/apps/web/ee/components/workflows/WorkflowListPage.tsx index c04cd19b8f73c..db865c4cb5167 100644 --- a/apps/web/ee/components/workflows/WorkflowListPage.tsx +++ b/apps/web/ee/components/workflows/WorkflowListPage.tsx @@ -6,13 +6,13 @@ import { useState } from "react"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; import { EventType, Workflow, WorkflowsOnEventTypes } from "@calcom/prisma/client"; +import { trpc } from "@calcom/trpc/react"; import { Button, Tooltip } from "@calcom/ui"; import { Dialog } from "@calcom/ui/Dialog"; import Dropdown, { DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@calcom/ui/Dropdown"; import EmptyScreen from "@calcom/ui/EmptyScreen"; import { HttpError } from "@lib/core/http/error"; -import { trpc } from "@lib/trpc"; import ConfirmationDialogContent from "@components/dialog/ConfirmationDialogContent"; diff --git a/apps/web/ee/lib/stripe/server.ts b/apps/web/ee/lib/stripe/server.ts deleted file mode 100644 index 6796946bb028e..0000000000000 --- a/apps/web/ee/lib/stripe/server.ts +++ /dev/null @@ -1,181 +0,0 @@ -import { PaymentType, Prisma } from "@prisma/client"; -import Stripe from "stripe"; -import { v4 as uuidv4 } from "uuid"; -import { z } from "zod"; - -import getAppKeysFromSlug from "@calcom/app-store/_utils/getAppKeysFromSlug"; -import { sendAwaitingPaymentEmail, sendOrganizerPaymentRefundFailedEmail } from "@calcom/emails"; -import { getErrorFromUnknown } from "@calcom/lib/errors"; -import prisma from "@calcom/prisma"; -import { createPaymentLink } from "@calcom/stripe/client"; -import stripe, { PaymentData } from "@calcom/stripe/server"; -import { CalendarEvent } from "@calcom/types/Calendar"; - -const stripeKeysSchema = z.object({ - payment_fee_fixed: z.number(), - payment_fee_percentage: z.number(), -}); - -const stripeCredentialSchema = z.object({ - stripe_user_id: z.string(), - stripe_publishable_key: z.string(), -}); - -export async function handlePayment( - evt: CalendarEvent, - selectedEventType: { - price: number; - currency: string; - }, - stripeCredential: { key: Prisma.JsonValue }, - booking: { - user: { email: string | null; name: string | null; timeZone: string } | null; - id: number; - startTime: { toISOString: () => string }; - uid: string; - } -) { - const appKeys = await getAppKeysFromSlug("stripe"); - const { payment_fee_fixed, payment_fee_percentage } = stripeKeysSchema.parse(appKeys); - - const paymentFee = Math.round(selectedEventType.price * payment_fee_percentage + payment_fee_fixed); - const { stripe_user_id, stripe_publishable_key } = stripeCredentialSchema.parse(stripeCredential.key); - - const params: Stripe.PaymentIntentCreateParams = { - amount: selectedEventType.price, - currency: selectedEventType.currency, - payment_method_types: ["card"], - application_fee_amount: paymentFee, - }; - - const paymentIntent = await stripe.paymentIntents.create(params, { stripeAccount: stripe_user_id }); - - const payment = await prisma.payment.create({ - data: { - type: PaymentType.STRIPE, - uid: uuidv4(), - booking: { - connect: { - id: booking.id, - }, - }, - amount: selectedEventType.price, - fee: paymentFee, - currency: selectedEventType.currency, - success: false, - refunded: false, - data: Object.assign({}, paymentIntent, { - stripe_publishable_key, - stripeAccount: stripe_user_id, - }) /* We should treat this */ as PaymentData /* but Prisma doesn't know how to handle it, so it we treat it */ as unknown /* and then */ as Prisma.InputJsonValue, - externalId: paymentIntent.id, - }, - }); - - await sendAwaitingPaymentEmail({ - ...evt, - paymentInfo: { - link: createPaymentLink({ - paymentUid: payment.uid, - name: booking.user?.name, - email: booking.user?.email, - date: booking.startTime.toISOString(), - }), - }, - }); - - return payment; -} - -export async function refund( - booking: { - id: number; - uid: string; - startTime: Date; - payment: { - id: number; - success: boolean; - refunded: boolean; - externalId: string; - data: Prisma.JsonValue; - type: PaymentType; - }[]; - }, - calEvent: CalendarEvent -) { - try { - const payment = booking.payment.find((e) => e.success && !e.refunded); - if (!payment) return; - - if (payment.type !== PaymentType.STRIPE) { - await handleRefundError({ - event: calEvent, - reason: "cannot refund non Stripe payment", - paymentId: "unknown", - }); - return; - } - - const refund = await stripe.refunds.create( - { - payment_intent: payment.externalId, - }, - { stripeAccount: (payment.data as unknown as PaymentData)["stripeAccount"] } - ); - - if (!refund || refund.status === "failed") { - await handleRefundError({ - event: calEvent, - reason: refund?.failure_reason || "unknown", - paymentId: payment.externalId, - }); - return; - } - - await prisma.payment.update({ - where: { - id: payment.id, - }, - data: { - refunded: true, - }, - }); - } catch (e) { - const err = getErrorFromUnknown(e); - console.error(err, "Refund failed"); - await handleRefundError({ - event: calEvent, - reason: err.message || "unknown", - paymentId: "unknown", - }); - } -} - -export const closePayments = async (paymentIntentId: string, stripeAccount: string) => { - try { - // Expire all current sessions - const sessions = await stripe.checkout.sessions.list( - { - payment_intent: paymentIntentId, - }, - { stripeAccount } - ); - for (const session of sessions.data) { - await stripe.checkout.sessions.expire(session.id, { stripeAccount }); - } - // Then cancel the payment intent - await stripe.paymentIntents.cancel(paymentIntentId, { stripeAccount }); - return; - } catch (e) { - console.error(e); - return; - } -}; - -async function handleRefundError(opts: { event: CalendarEvent; reason: string; paymentId: string }) { - console.error(`refund failed: ${opts.reason} for booking '${opts.event.uid}'`); - await sendOrganizerPaymentRefundFailedEmail({ - ...opts.event, - paymentInfo: { reason: opts.reason, id: opts.paymentId }, - }); -} diff --git a/apps/web/ee/pages/settings/teams/[id]/availability.tsx b/apps/web/ee/pages/settings/teams/[id]/availability.tsx index 6b280f73371b6..13de941875a81 100644 --- a/apps/web/ee/pages/settings/teams/[id]/availability.tsx +++ b/apps/web/ee/pages/settings/teams/[id]/availability.tsx @@ -2,13 +2,13 @@ import { useRouter } from "next/router"; import { useMemo, useState } from "react"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { trpc } from "@calcom/trpc/react"; import { Alert } from "@calcom/ui/Alert"; import LicenseRequired from "@ee/components/LicenseRequired"; import TeamAvailabilityScreen from "@ee/components/team/availability/TeamAvailabilityScreen"; import { getPlaceholderAvatar } from "@lib/getPlaceholderAvatar"; import useMeQuery from "@lib/hooks/useMeQuery"; -import { trpc } from "@lib/trpc"; import Loader from "@components/Loader"; import Shell from "@components/Shell"; diff --git a/apps/web/ee/pages/workflows/[workflow].tsx b/apps/web/ee/pages/workflows/[workflow].tsx index 8da46fe82abf8..84adc3c8191d9 100644 --- a/apps/web/ee/pages/workflows/[workflow].tsx +++ b/apps/web/ee/pages/workflows/[workflow].tsx @@ -9,6 +9,7 @@ import { useForm } from "react-hook-form"; import { z } from "zod"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { trpc } from "@calcom/trpc/react"; import { Alert } from "@calcom/ui/Alert"; import Loader from "@calcom/ui/Loader"; import LicenseRequired from "@ee/components/LicenseRequired"; @@ -21,7 +22,6 @@ import { } from "@ee/lib/workflows/constants"; import useMeQuery from "@lib/hooks/useMeQuery"; -import { trpc } from "@lib/trpc"; import Shell from "@components/Shell"; import { Option } from "@components/ui/form/MultiSelectCheckboxes"; diff --git a/apps/web/ee/pages/workflows/index.tsx b/apps/web/ee/pages/workflows/index.tsx index a324eb6b3d056..c3e075923b07f 100644 --- a/apps/web/ee/pages/workflows/index.tsx +++ b/apps/web/ee/pages/workflows/index.tsx @@ -1,13 +1,13 @@ import { useSession } from "next-auth/react"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { trpc } from "@calcom/trpc/react"; import { Alert } from "@calcom/ui/Alert"; import LicenseRequired from "@ee/components/LicenseRequired"; import { NewWorkflowButton } from "@ee/components/workflows/NewWorkflowButton"; import WorkflowList from "@ee/components/workflows/WorkflowListPage"; import useMeQuery from "@lib/hooks/useMeQuery"; -import { trpc } from "@lib/trpc"; import Loader from "@components/Loader"; import Shell from "@components/Shell"; diff --git a/apps/web/lib/QueryCell.tsx b/apps/web/lib/QueryCell.tsx index 9918d2b3c3bd5..b1ee6fa588f23 100644 --- a/apps/web/lib/QueryCell.tsx +++ b/apps/web/lib/QueryCell.tsx @@ -8,22 +8,19 @@ import { UseQueryResult, } from "react-query"; -import { Alert } from "@calcom/ui/Alert"; - -import { trpc } from "@lib/trpc"; - -import Loader from "@components/Loader"; - -import type { AppRouter } from "@server/routers/_app"; -import type { TRPCClientErrorLike } from "@trpc/client"; -import type { UseTRPCQueryOptions } from "@trpc/react"; -// import type { inferProcedures } from "@trpc/react/src/createReactQueryHooks"; +import type { TRPCClientErrorLike } from "@calcom/trpc/client"; +import { trpc } from "@calcom/trpc/react"; +import type { UseTRPCQueryOptions } from "@calcom/trpc/react"; import type { inferHandlerInput, inferProcedureInput, inferProcedureOutput, ProcedureRecord, -} from "@trpc/server"; +} from "@calcom/trpc/server"; +import type { AppRouter } from "@calcom/trpc/server/routers/_app"; +import { Alert } from "@calcom/ui/Alert"; + +import Loader from "@components/Loader"; type ErrorLike = { message: string; diff --git a/apps/web/lib/app-providers.tsx b/apps/web/lib/app-providers.tsx index 54b899002f05d..d5cf8226d81fb 100644 --- a/apps/web/lib/app-providers.tsx +++ b/apps/web/lib/app-providers.tsx @@ -1,15 +1,14 @@ import { SessionProvider } from "next-auth/react"; import { appWithTranslation } from "next-i18next"; import type { AppProps as NextAppProps, AppProps as NextJsAppProps } from "next/app"; -import { ComponentProps, ReactNode, useMemo } from "react"; +import { ComponentProps, ReactNode } from "react"; +import { trpc } from "@calcom/trpc/react"; import DynamicHelpscoutProvider from "@ee/lib/helpscout/providerDynamic"; import DynamicIntercomProvider from "@ee/lib/intercom/providerDynamic"; import usePublicPage from "@lib/hooks/usePublicPage"; -import { trpc } from "./trpc"; - const I18nextAdapter = appWithTranslation(({ children }) => ( <>{children} )); diff --git a/apps/web/lib/core/i18n/i18n.utils.ts b/apps/web/lib/core/i18n/i18n.utils.ts index 1ba93e3d916cd..9899a5654e61f 100644 --- a/apps/web/lib/core/i18n/i18n.utils.ts +++ b/apps/web/lib/core/i18n/i18n.utils.ts @@ -1,11 +1,11 @@ import parser from "accept-language-parser"; import { IncomingMessage } from "http"; +import { Maybe } from "@calcom/trpc/server"; + import { getSession } from "@lib/auth"; import prisma from "@lib/prisma"; -import { Maybe } from "@trpc/server"; - import { i18n } from "../../../next-i18next.config"; export function getLocaleFromHeaders(req: IncomingMessage): string { diff --git a/apps/web/lib/hooks/useMeQuery.ts b/apps/web/lib/hooks/useMeQuery.ts index a8d0a051ce39c..0eb0bb77fd20a 100644 --- a/apps/web/lib/hooks/useMeQuery.ts +++ b/apps/web/lib/hooks/useMeQuery.ts @@ -1,4 +1,4 @@ -import { trpc } from "../trpc"; +import { trpc } from "@calcom/trpc/react"; export function useMeQuery() { const meQuery = trpc.useQuery(["viewer.me"], { diff --git a/apps/web/lib/hooks/useTheme.tsx b/apps/web/lib/hooks/useTheme.tsx index 38dc9f504beb7..d7891ba41d565 100644 --- a/apps/web/lib/hooks/useTheme.tsx +++ b/apps/web/lib/hooks/useTheme.tsx @@ -2,8 +2,7 @@ import Head from "next/head"; import { useEffect, useState } from "react"; import { useEmbedTheme } from "@calcom/embed-core/embed-iframe"; - -import { Maybe } from "@trpc/server"; +import { Maybe } from "@calcom/trpc/server"; // This method is stringified and executed only on client. So, // - Pass all the params explicitly to this method. Don't use closure diff --git a/apps/web/lib/isOutOfBounds.tsx b/apps/web/lib/isOutOfBounds.tsx index 1a115f737de37..d4d3bacbbc793 100644 --- a/apps/web/lib/isOutOfBounds.tsx +++ b/apps/web/lib/isOutOfBounds.tsx @@ -1,41 +1,3 @@ -import { EventType, PeriodType } from "@prisma/client"; - -import dayjs from "@calcom/dayjs"; - -function isOutOfBounds( - time: dayjs.ConfigType, - { - periodType, - periodDays, - periodCountCalendarDays, - periodStartDate, - periodEndDate, - }: Pick< - EventType, - "periodType" | "periodDays" | "periodCountCalendarDays" | "periodStartDate" | "periodEndDate" - > -) { - const date = dayjs(time); - periodDays = periodDays || 0; - - switch (periodType) { - case PeriodType.ROLLING: { - const periodRollingEndDay = periodCountCalendarDays - ? dayjs().utcOffset(date.utcOffset()).add(periodDays, "days").endOf("day") - : dayjs().utcOffset(date.utcOffset()).businessDaysAdd(periodDays).endOf("day"); - return date.endOf("day").isAfter(periodRollingEndDay); - } - - case PeriodType.RANGE: { - const periodRangeStartDay = dayjs(periodStartDate).utcOffset(date.utcOffset()).endOf("day"); - const periodRangeEndDay = dayjs(periodEndDate).utcOffset(date.utcOffset()).endOf("day"); - return date.endOf("day").isBefore(periodRangeStartDay) || date.endOf("day").isAfter(periodRangeEndDay); - } - - case PeriodType.UNLIMITED: - default: - return false; - } -} - -export default isOutOfBounds; +/* Prefer import from `@calcom/lib/isOutOfBounds` */ +export * from "@calcom/lib/isOutOfBounds"; +export { default } from "@calcom/lib/isOutOfBounds"; diff --git a/apps/web/lib/parseDate.ts b/apps/web/lib/parseDate.ts index 1b07301e9c394..4d068fe427cff 100644 --- a/apps/web/lib/parseDate.ts +++ b/apps/web/lib/parseDate.ts @@ -2,10 +2,10 @@ import { I18n } from "next-i18next"; import { RRule } from "rrule"; import dayjs, { Dayjs } from "@calcom/dayjs"; +import { inferQueryOutput } from "@calcom/trpc/react"; import { RecurringEvent } from "@calcom/types/Calendar"; import { detectBrowserTimeFormat } from "@lib/timeFormat"; -import { inferQueryOutput } from "@lib/trpc"; import { parseZone } from "./parseZone"; diff --git a/apps/web/lib/saml.ts b/apps/web/lib/saml.ts index 8dda87d125b9d..6af24b61c9506 100644 --- a/apps/web/lib/saml.ts +++ b/apps/web/lib/saml.ts @@ -1,8 +1,8 @@ import { PrismaClient } from "@prisma/client"; -import { BASE_URL } from "@lib/config/constants"; +import { TRPCError } from "@calcom/trpc/server"; -import { TRPCError } from "@trpc/server"; +import { BASE_URL } from "@lib/config/constants"; export const samlDatabaseUrl = process.env.SAML_DATABASE_URL || ""; export const samlLoginUrl = BASE_URL; diff --git a/apps/web/lib/slots.ts b/apps/web/lib/slots.ts index 1e4870024910a..82c1fff3e759a 100644 --- a/apps/web/lib/slots.ts +++ b/apps/web/lib/slots.ts @@ -1,114 +1,3 @@ -import dayjs, { Dayjs } from "@calcom/dayjs"; - -import { getWorkingHours } from "./availability"; -import { WorkingHours } from "./types/schedule"; - -export type GetSlots = { - inviteeDate: Dayjs; - frequency: number; - workingHours: WorkingHours[]; - minimumBookingNotice: number; - eventLength: number; -}; -export type WorkingHoursTimeFrame = { startTime: number; endTime: number }; - -const splitAvailableTime = ( - startTimeMinutes: number, - endTimeMinutes: number, - frequency: number, - eventLength: number -): Array => { - let initialTime = startTimeMinutes; - const finalizationTime = endTimeMinutes; - const result = [] as Array; - while (initialTime < finalizationTime) { - const periodTime = initialTime + frequency; - const slotEndTime = initialTime + eventLength; - /* - check if the slot end time surpasses availability end time of the user - 1 minute is added to round up the hour mark so that end of the slot is considered in the check instead of x9 - eg: if finalization time is 11:59, slotEndTime is 12:00, we ideally want the slot to be available - */ - if (slotEndTime <= finalizationTime + 1) result.push({ startTime: initialTime, endTime: periodTime }); - initialTime += frequency; - } - return result; -}; - -const getSlots = ({ inviteeDate, frequency, minimumBookingNotice, workingHours, eventLength }: GetSlots) => { - // current date in invitee tz - const startDate = dayjs().add(minimumBookingNotice, "minute"); - const startOfDay = dayjs.utc().startOf("day"); - const startOfInviteeDay = inviteeDate.startOf("day"); - // checks if the start date is in the past - - /** - * TODO: change "day" for "hour" to stop displaying 1 day before today - * This is displaying a day as available as sometimes difference between two dates is < 24 hrs. - * But when doing timezones an available day for an owner can be 2 days available in other users tz. - * - * */ - if (inviteeDate.isBefore(startDate, "day")) { - return []; - } - - const localWorkingHours = getWorkingHours( - { utcOffset: -inviteeDate.utcOffset() }, - workingHours.map((schedule) => ({ - days: schedule.days, - startTime: startOfDay.add(schedule.startTime, "minute"), - endTime: startOfDay.add(schedule.endTime, "minute"), - })) - ).filter((hours) => hours.days.includes(inviteeDate.day())); - - const slots: Dayjs[] = []; - - const slotsTimeFrameAvailable = [] as Array; - // Here we split working hour in chunks for every frequency available that can fit in whole working hours - const computedLocalWorkingHours: WorkingHoursTimeFrame[] = []; - let tempComputeTimeFrame: WorkingHoursTimeFrame | undefined; - const computeLength = localWorkingHours.length - 1; - const makeTimeFrame = (item: typeof localWorkingHours[0]): WorkingHoursTimeFrame => ({ - startTime: item.startTime, - endTime: item.endTime, - }); - localWorkingHours.forEach((item, index) => { - if (!tempComputeTimeFrame) { - tempComputeTimeFrame = makeTimeFrame(item); - } else { - // please check the comment in splitAvailableTime func for the added 1 minute - if (tempComputeTimeFrame.endTime + 1 === item.startTime) { - // to deal with time that across the day, e.g. from 11:59 to to 12:01 - tempComputeTimeFrame.endTime = item.endTime; - } else { - computedLocalWorkingHours.push(tempComputeTimeFrame); - tempComputeTimeFrame = makeTimeFrame(item); - } - } - if (index == computeLength) { - computedLocalWorkingHours.push(tempComputeTimeFrame); - } - }); - computedLocalWorkingHours.forEach((item) => { - slotsTimeFrameAvailable.push(...splitAvailableTime(item.startTime, item.endTime, frequency, eventLength)); - }); - - slotsTimeFrameAvailable.forEach((item) => { - const slot = startOfInviteeDay.add(item.startTime, "minute"); - // Validating slot its not on the past - if (!slot.isBefore(startDate)) { - slots.push(slot); - } - }); - - const uniq = (a: Dayjs[]) => { - const seen: Record = {}; - return a.filter((item) => { - return seen.hasOwnProperty(item.format()) ? false : (seen[item.format()] = true); - }); - }; - - return uniq(slots); -}; - -export default getSlots; +/** Prefer import from `@calcom/lib/slots` */ +export * from "@calcom/lib/slots"; +export { default } from "@calcom/lib/slots"; diff --git a/apps/web/next-i18next.config.js b/apps/web/next-i18next.config.js index 923695bde3f3c..0d55e2dabbf3b 100644 --- a/apps/web/next-i18next.config.js +++ b/apps/web/next-i18next.config.js @@ -1,36 +1,10 @@ const path = require("path"); +const i18nConfig = require("@calcom/config/next-i18next.config"); /** @type {import("next-i18next").UserConfig} */ const config = { - i18n: { - defaultLocale: "en", - locales: [ - "en", - "fr", - "it", - "ru", - "es", - "de", - "pt", - "ro", - "nl", - "pt-BR", - "es-419", - "ko", - "ja", - "pl", - "ar", - "iw", - "zh-CN", - "zh-TW", - "cs", - "sr", - "sv", - "vi", - ], - }, + ...i18nConfig, localePath: path.resolve("./public/static/locales"), - reloadOnPrerender: process.env.NODE_ENV !== "production", }; module.exports = config; diff --git a/apps/web/next.config.js b/apps/web/next.config.js index 9d16c1fc8bc7c..62aa8d0781846 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -5,14 +5,15 @@ const withTM = require("next-transpile-modules")([ "@calcom/core", "@calcom/dayjs", "@calcom/ee", - "@calcom/lib", - "@calcom/prisma", - "@calcom/stripe", - "@calcom/ui", "@calcom/emails", "@calcom/embed-core", "@calcom/embed-react", "@calcom/embed-snippet", + "@calcom/lib", + "@calcom/prisma", + "@calcom/stripe", + "@calcom/trpc", + "@calcom/ui", ]); const { i18n } = require("./next-i18next.config"); diff --git a/apps/web/package.json b/apps/web/package.json index 5721dc1988527..b84bb6d488380 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -28,8 +28,8 @@ }, "dependencies": { "@boxyhq/saml-jackson": "0.3.6", - "@calcom/app-store": "*", "@calcom/app-store-cli": "*", + "@calcom/app-store": "*", "@calcom/core": "*", "@calcom/dayjs": "*", "@calcom/ee": "*", @@ -39,6 +39,7 @@ "@calcom/lib": "*", "@calcom/prisma": "*", "@calcom/stripe": "*", + "@calcom/trpc": "*", "@calcom/tsconfig": "*", "@calcom/ui": "*", "@daily-co/daily-js": "^0.26.0", @@ -61,10 +62,6 @@ "@radix-ui/react-tooltip": "^0.1.0", "@stripe/react-stripe-js": "^1.8.0", "@stripe/stripe-js": "^1.29.0", - "@trpc/client": "^9.25.2", - "@trpc/next": "^9.25.2", - "@trpc/react": "^9.25.2", - "@trpc/server": "^9.25.2", "@vercel/edge-functions-ui": "^0.2.1", "@wojtekmaj/react-daterange-picker": "^3.3.1", "accept-language-parser": "^1.5.0", diff --git a/apps/web/pages/_app.tsx b/apps/web/pages/_app.tsx index 57db0b2baabe2..55126806d4ace 100644 --- a/apps/web/pages/_app.tsx +++ b/apps/web/pages/_app.tsx @@ -4,6 +4,14 @@ import Head from "next/head"; import superjson from "superjson"; import "@calcom/embed-core/src/embed-iframe"; +import { httpBatchLink } from "@calcom/trpc/client/links/httpBatchLink"; +import { httpLink } from "@calcom/trpc/client/links/httpLink"; +import { loggerLink } from "@calcom/trpc/client/links/loggerLink"; +import { splitLink } from "@calcom/trpc/client/links/splitLink"; +import { withTRPC } from "@calcom/trpc/next"; +import type { TRPCClientErrorLike } from "@calcom/trpc/react"; +import { Maybe } from "@calcom/trpc/server"; +import type { AppRouter } from "@calcom/trpc/server/routers/_app"; import LicenseRequired from "@ee/components/LicenseRequired"; import AppProviders, { AppProps } from "@lib/app-providers"; @@ -12,15 +20,6 @@ import useTheme from "@lib/hooks/useTheme"; import I18nLanguageHandler from "@components/I18nLanguageHandler"; -import type { AppRouter } from "@server/routers/_app"; -import { httpBatchLink } from "@trpc/client/links/httpBatchLink"; -import { httpLink } from "@trpc/client/links/httpLink"; -import { loggerLink } from "@trpc/client/links/loggerLink"; -import { splitLink } from "@trpc/client/links/splitLink"; -import { withTRPC } from "@trpc/next"; -import type { TRPCClientErrorLike } from "@trpc/react"; -import { Maybe } from "@trpc/server"; - import { ContractsProvider } from "../contexts/contractsContext"; import "../styles/fonts.css"; import "../styles/globals.css"; diff --git a/apps/web/pages/api/availability/eventtype.ts b/apps/web/pages/api/availability/eventtype.ts index be214855d5058..e5721a5258dc7 100644 --- a/apps/web/pages/api/availability/eventtype.ts +++ b/apps/web/pages/api/availability/eventtype.ts @@ -1,9 +1,9 @@ import type { NextApiRequest, NextApiResponse } from "next"; -import { getSession } from "@lib/auth"; +import { createContext } from "@calcom/trpc/server/createContext"; +import { viewerRouter } from "@calcom/trpc/server/routers/viewer"; -import { createContext } from "@server/createContext"; -import { viewerRouter } from "@server/routers/viewer"; +import { getSession } from "@lib/auth"; export default async function handler(req: NextApiRequest, res: NextApiResponse) { const session = await getSession({ req }); diff --git a/apps/web/pages/api/book/confirm.ts b/apps/web/pages/api/book/confirm.ts index 76b0dd0529a87..77fd3ff925287 100644 --- a/apps/web/pages/api/book/confirm.ts +++ b/apps/web/pages/api/book/confirm.ts @@ -8,8 +8,8 @@ import { isPrismaObjOrUndefined, parseRecurringEvent } from "@calcom/lib"; import logger from "@calcom/lib/logger"; import { defaultHandler, defaultResponder } from "@calcom/lib/server"; import prisma from "@calcom/prisma"; +import { refund } from "@calcom/stripe/server"; import type { AdditionalInformation, CalendarEvent } from "@calcom/types/Calendar"; -import { refund } from "@ee/lib/stripe/server"; import { scheduleWorkflowReminders } from "@ee/lib/workflows/reminders/reminderScheduler"; import { getSession } from "@lib/auth"; diff --git a/apps/web/pages/api/book/event.ts b/apps/web/pages/api/book/event.ts index 76ba1a5bdefab..2ea3373d59611 100644 --- a/apps/web/pages/api/book/event.ts +++ b/apps/web/pages/api/book/event.ts @@ -18,20 +18,20 @@ import { import { getLuckyUsers, isPrismaObjOrUndefined, parseRecurringEvent } from "@calcom/lib"; import { getDefaultEvent, getGroupName, getUsernameList } from "@calcom/lib/defaultEvents"; import { getErrorFromUnknown } from "@calcom/lib/errors"; +import isOutOfBounds from "@calcom/lib/isOutOfBounds"; import logger from "@calcom/lib/logger"; import { defaultResponder } from "@calcom/lib/server"; import prisma, { userSelect } from "@calcom/prisma"; import { extendedBookingCreateBody } from "@calcom/prisma/zod-utils"; +import { handlePayment } from "@calcom/stripe/server"; import type { BufferedBusyTime } from "@calcom/types/BufferedBusyTime"; import type { AdditionalInformation, CalendarEvent } from "@calcom/types/Calendar"; import type { EventResult, PartialReference } from "@calcom/types/EventManager"; -import { handlePayment } from "@ee/lib/stripe/server"; import { scheduleWorkflowReminders } from "@ee/lib/workflows/reminders/reminderScheduler"; import { HttpError } from "@lib/core/http/error"; import { ensureArray } from "@lib/ensureArray"; import { getEventName } from "@lib/event"; -import isOutOfBounds from "@lib/isOutOfBounds"; import sendPayload from "@lib/webhooks/sendPayload"; import getSubscribers from "@lib/webhooks/subscriptions"; diff --git a/apps/web/pages/api/cancel.ts b/apps/web/pages/api/cancel.ts index 582d2d5f8ed8c..1ab17eff5962d 100644 --- a/apps/web/pages/api/cancel.ts +++ b/apps/web/pages/api/cancel.ts @@ -19,8 +19,8 @@ import { isPrismaObjOrUndefined, parseRecurringEvent } from "@calcom/lib"; import { HttpError } from "@calcom/lib/http-error"; import { defaultHandler, defaultResponder } from "@calcom/lib/server"; import prisma, { bookingMinimalSelect } from "@calcom/prisma"; +import { refund } from "@calcom/stripe/server"; import type { CalendarEvent } from "@calcom/types/Calendar"; -import { refund } from "@ee/lib/stripe/server"; import { deleteScheduledEmailReminder } from "@ee/lib/workflows/reminders/emailReminderManager"; import { sendCancelledReminders } from "@ee/lib/workflows/reminders/reminderScheduler"; import { deleteScheduledSMSReminder } from "@ee/lib/workflows/reminders/smsReminderManager"; diff --git a/apps/web/pages/api/intent-username/index.ts b/apps/web/pages/api/intent-username/index.ts index d43cbf874f9ab..c74002830b04b 100644 --- a/apps/web/pages/api/intent-username/index.ts +++ b/apps/web/pages/api/intent-username/index.ts @@ -2,11 +2,10 @@ import type { NextApiRequest, NextApiResponse } from "next"; import { getSession } from "next-auth/react"; import { defaultHandler } from "@calcom/lib/server"; +import { checkUsername } from "@calcom/lib/server/checkUsername"; import prisma from "@calcom/prisma"; import { userMetadata as zodUserMetadata } from "@calcom/prisma/zod-utils"; -import { checkUsername } from "@lib/core/server/checkUsername"; - export async function getHandler(req: NextApiRequest, res: NextApiResponse) { const { intentUsername } = req.body; // Check that user is authenticated diff --git a/apps/web/pages/api/teams/[team]/index.ts b/apps/web/pages/api/teams/[team]/index.ts index 881540b28abe4..e576069c134df 100644 --- a/apps/web/pages/api/teams/[team]/index.ts +++ b/apps/web/pages/api/teams/[team]/index.ts @@ -1,8 +1,9 @@ import type { NextApiRequest, NextApiResponse } from "next"; +import { getTeamWithMembers } from "@calcom/lib/server/queries/teams"; + import { getSession } from "@lib/auth"; import prisma from "@lib/prisma"; -import { getTeamWithMembers } from "@lib/queries/teams"; export default async function handler(req: NextApiRequest, res: NextApiResponse) { const session = await getSession({ req: req }); diff --git a/apps/web/pages/api/trpc/[trpc].ts b/apps/web/pages/api/trpc/[trpc].ts index da0ab1fedaf16..7204fc2a301f5 100644 --- a/apps/web/pages/api/trpc/[trpc].ts +++ b/apps/web/pages/api/trpc/[trpc].ts @@ -1,9 +1,9 @@ /** * This file contains tRPC's HTTP response handler */ -import { createContext } from "@server/createContext"; -import { appRouter } from "@server/routers/_app"; -import * as trpcNext from "@trpc/server/adapters/next"; +import * as trpcNext from "@calcom/trpc/server/adapters/next"; +import { createContext } from "@calcom/trpc/server/createContext"; +import { appRouter } from "@calcom/trpc/server/routers/_app"; export default trpcNext.createNextApiHandler({ router: appRouter, diff --git a/apps/web/pages/api/username.ts b/apps/web/pages/api/username.ts index 57fddb64d082c..9251aada56e36 100644 --- a/apps/web/pages/api/username.ts +++ b/apps/web/pages/api/username.ts @@ -1,6 +1,6 @@ import type { NextApiRequest, NextApiResponse } from "next"; -import { checkUsername } from "@lib/core/server/checkUsername"; +import { checkUsername } from "@calcom/lib/server/checkUsername"; type Response = { available: boolean; diff --git a/apps/web/pages/apps/installed.tsx b/apps/web/pages/apps/installed.tsx index f0b46d02cc005..fc39738c714a9 100644 --- a/apps/web/pages/apps/installed.tsx +++ b/apps/web/pages/apps/installed.tsx @@ -6,6 +6,7 @@ import { InstallAppButton } from "@calcom/app-store/components"; import { WEBSITE_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { trpc } from "@calcom/trpc/react"; import type { App } from "@calcom/types/App"; import { Alert } from "@calcom/ui/Alert"; import Button from "@calcom/ui/Button"; @@ -14,7 +15,6 @@ import EmptyScreen from "@calcom/ui/EmptyScreen"; import { QueryCell } from "@lib/QueryCell"; import classNames from "@lib/classNames"; import { HttpError } from "@lib/core/http/error"; -import { trpc } from "@lib/trpc"; import AppsShell from "@components/AppsShell"; import { List, ListItem, ListItemText, ListItemTitle } from "@components/List"; diff --git a/apps/web/pages/auth/sso/[provider].tsx b/apps/web/pages/auth/sso/[provider].tsx index 9b0fc6fd120db..707e640ec00cf 100644 --- a/apps/web/pages/auth/sso/[provider].tsx +++ b/apps/web/pages/auth/sso/[provider].tsx @@ -3,12 +3,12 @@ import { signIn } from "next-auth/react"; import { useRouter } from "next/router"; import { useEffect } from "react"; +import { checkUsername } from "@calcom/lib/server/checkUsername"; import stripe from "@calcom/stripe/server"; import { getPremiumPlanPrice } from "@calcom/stripe/utils"; import { asStringOrNull } from "@lib/asStringOrNull"; import { getSession } from "@lib/auth"; -import { checkUsername } from "@lib/core/server/checkUsername"; import prisma from "@lib/prisma"; import { hostedCal, isSAMLLoginEnabled, samlProductID, samlTenantID, samlTenantProduct } from "@lib/saml"; import { inferSSRProps } from "@lib/types/inferSSRProps"; diff --git a/apps/web/pages/availability/[schedule].tsx b/apps/web/pages/availability/[schedule].tsx index 224798a858882..94774d83214e0 100644 --- a/apps/web/pages/availability/[schedule].tsx +++ b/apps/web/pages/availability/[schedule].tsx @@ -6,13 +6,13 @@ import { Controller, useForm } from "react-hook-form"; import { DEFAULT_SCHEDULE, availabilityAsString } from "@calcom/lib/availability"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { inferQueryOutput, trpc } from "@calcom/trpc/react"; import Button from "@calcom/ui/Button"; import Switch from "@calcom/ui/Switch"; import { Form } from "@calcom/ui/form/fields"; import { QueryCell } from "@lib/QueryCell"; import { HttpError } from "@lib/core/http/error"; -import { inferQueryOutput, trpc } from "@lib/trpc"; import Shell from "@components/Shell"; import Schedule from "@components/availability/Schedule"; diff --git a/apps/web/pages/availability/index.tsx b/apps/web/pages/availability/index.tsx index 3653344840ec7..8181ed674e15d 100644 --- a/apps/web/pages/availability/index.tsx +++ b/apps/web/pages/availability/index.tsx @@ -2,11 +2,11 @@ import { ClockIcon } from "@heroicons/react/outline"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { inferQueryOutput, trpc } from "@calcom/trpc/react"; import EmptyScreen from "@calcom/ui/EmptyScreen"; import { withQuery } from "@lib/QueryCell"; import { HttpError } from "@lib/core/http/error"; -import { inferQueryOutput, trpc } from "@lib/trpc"; import Shell from "@components/Shell"; import { NewScheduleButton } from "@components/availability/NewScheduleButton"; diff --git a/apps/web/pages/availability/troubleshoot.tsx b/apps/web/pages/availability/troubleshoot.tsx index eafa6195cb3fa..0d0de59433571 100644 --- a/apps/web/pages/availability/troubleshoot.tsx +++ b/apps/web/pages/availability/troubleshoot.tsx @@ -2,9 +2,9 @@ import { useEffect, useState } from "react"; import dayjs, { Dayjs } from "@calcom/dayjs"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { inferQueryOutput, trpc } from "@calcom/trpc/react"; import { QueryCell } from "@lib/QueryCell"; -import { inferQueryOutput, trpc } from "@lib/trpc"; import Loader from "@components/Loader"; import Shell from "@components/Shell"; diff --git a/apps/web/pages/bookings/[status].tsx b/apps/web/pages/bookings/[status].tsx index 944fa9be14d96..418f1fc107385 100644 --- a/apps/web/pages/bookings/[status].tsx +++ b/apps/web/pages/bookings/[status].tsx @@ -4,12 +4,12 @@ import { Fragment } from "react"; import { WipeMyCalActionButton } from "@calcom/app-store/wipemycalother/components"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { inferQueryInput, inferQueryOutput, trpc } from "@calcom/trpc/react"; import { Alert } from "@calcom/ui/Alert"; import Button from "@calcom/ui/Button"; import EmptyScreen from "@calcom/ui/EmptyScreen"; import { useInViewObserver } from "@lib/hooks/useInViewObserver"; -import { inferQueryInput, inferQueryOutput, trpc } from "@lib/trpc"; import BookingsShell from "@components/BookingsShell"; import Shell from "@components/Shell"; @@ -76,7 +76,7 @@ export default function Bookings() { }; return ( }> - +
diff --git a/apps/web/pages/event-types/[type].tsx b/apps/web/pages/event-types/[type].tsx index c960e094b3580..2bac1df15ee2a 100644 --- a/apps/web/pages/event-types/[type].tsx +++ b/apps/web/pages/event-types/[type].tsx @@ -37,6 +37,7 @@ import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; import prisma from "@calcom/prisma"; import { StripeData } from "@calcom/stripe/server"; +import { trpc } from "@calcom/trpc/react"; import { RecurringEvent } from "@calcom/types/Calendar"; import { Alert } from "@calcom/ui/Alert"; import Button from "@calcom/ui/Button"; @@ -52,7 +53,6 @@ import { HttpError } from "@lib/core/http/error"; import { isSuccessRedirectAvailable } from "@lib/isSuccessRedirectAvailable"; import { LocationObject, LocationType } from "@lib/location"; import { slugify } from "@lib/slugify"; -import { trpc } from "@lib/trpc"; import { inferSSRProps } from "@lib/types/inferSSRProps"; import { ClientSuspense } from "@components/ClientSuspense"; diff --git a/apps/web/pages/event-types/index.tsx b/apps/web/pages/event-types/index.tsx index 2e28209fab619..b7042c7de8c33 100644 --- a/apps/web/pages/event-types/index.tsx +++ b/apps/web/pages/event-types/index.tsx @@ -22,6 +22,7 @@ import React, { Fragment, useEffect, useState } from "react"; import { CAL_URL, WEBAPP_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { inferQueryOutput, trpc } from "@calcom/trpc/react"; import { Button } from "@calcom/ui"; import { Alert } from "@calcom/ui/Alert"; import { Dialog } from "@calcom/ui/Dialog"; @@ -37,7 +38,6 @@ import { Tooltip } from "@calcom/ui/Tooltip"; import { withQuery } from "@lib/QueryCell"; import classNames from "@lib/classNames"; import { HttpError } from "@lib/core/http/error"; -import { inferQueryOutput, trpc } from "@lib/trpc"; import { EmbedButton, EmbedDialog } from "@components/Embed"; import Shell from "@components/Shell"; diff --git a/apps/web/pages/getting-started.tsx b/apps/web/pages/getting-started.tsx index e8a9682347fe8..06947fb8e9a57 100644 --- a/apps/web/pages/getting-started.tsx +++ b/apps/web/pages/getting-started.tsx @@ -17,6 +17,7 @@ import { getCalendarCredentials, getConnectedCalendars } from "@calcom/core/Cale import dayjs from "@calcom/dayjs"; import { DOCS_URL } from "@calcom/lib/constants"; import { fetchUsername } from "@calcom/lib/fetchUsername"; +import { trpc } from "@calcom/trpc/react"; import { Alert } from "@calcom/ui/Alert"; import Button from "@calcom/ui/Button"; import { Form } from "@calcom/ui/form/fields"; @@ -26,7 +27,6 @@ import { DEFAULT_SCHEDULE } from "@lib/availability"; import { useLocale } from "@lib/hooks/useLocale"; import prisma from "@lib/prisma"; import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@lib/telemetry"; -import { trpc } from "@lib/trpc"; import { inferSSRProps } from "@lib/types/inferSSRProps"; import { Schedule as ScheduleType } from "@lib/types/schedule"; diff --git a/apps/web/pages/settings/developer.tsx b/apps/web/pages/settings/developer.tsx index 2c052e6beedc2..2b639a49342af 100644 --- a/apps/web/pages/settings/developer.tsx +++ b/apps/web/pages/settings/developer.tsx @@ -1,8 +1,7 @@ import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { trpc } from "@calcom/trpc/react"; import ApiKeyListContainer from "@ee/components/apiKeys/ApiKeyListContainer"; -import { trpc } from "@lib/trpc"; - import SettingsShell from "@components/SettingsShell"; import WebhookListContainer from "@components/webhook/WebhookListContainer"; diff --git a/apps/web/pages/settings/profile.tsx b/apps/web/pages/settings/profile.tsx index a571b0652d25d..995f91486462d 100644 --- a/apps/web/pages/settings/profile.tsx +++ b/apps/web/pages/settings/profile.tsx @@ -8,6 +8,9 @@ import TimezoneSelect, { ITimezone } from "react-timezone-select"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { TRPCClientErrorLike } from "@calcom/trpc/client"; +import { trpc } from "@calcom/trpc/react"; +import { AppRouter } from "@calcom/trpc/server/routers/_app"; import { Alert } from "@calcom/ui/Alert"; import Button from "@calcom/ui/Button"; import { Dialog, DialogTrigger } from "@calcom/ui/Dialog"; @@ -18,7 +21,6 @@ import { getSession } from "@lib/auth"; import { nameOfDay } from "@lib/core/i18n/weekday"; import { isBrandingHidden } from "@lib/isBrandingHidden"; import prisma from "@lib/prisma"; -import { trpc } from "@lib/trpc"; import { inferSSRProps } from "@lib/types/inferSSRProps"; import ImageUploader from "@components/ImageUploader"; @@ -31,9 +33,6 @@ import { UsernameAvailability } from "@components/ui/UsernameAvailability"; import ColorPicker from "@components/ui/colorpicker"; import Select from "@components/ui/form/Select"; -import { AppRouter } from "@server/routers/_app"; -import { TRPCClientErrorLike } from "@trpc/client"; - import { UpgradeToProDialog } from "../../components/UpgradeToProDialog"; type Props = inferSSRProps; diff --git a/apps/web/pages/settings/security.tsx b/apps/web/pages/settings/security.tsx index b7493a8f4d335..bb2f0eab04d82 100644 --- a/apps/web/pages/settings/security.tsx +++ b/apps/web/pages/settings/security.tsx @@ -2,10 +2,10 @@ import { IdentityProvider } from "@prisma/client"; import React from "react"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { trpc } from "@calcom/trpc/react"; import SAMLConfiguration from "@ee/components/saml/Configuration"; import { identityProviderNameMap } from "@lib/auth"; -import { trpc } from "@lib/trpc"; import SettingsShell from "@components/SettingsShell"; import ChangePasswordSection from "@components/security/ChangePasswordSection"; diff --git a/apps/web/pages/settings/teams/[id]/index.tsx b/apps/web/pages/settings/teams/[id]/index.tsx index 7032bd7568912..2d12a1a7c7d97 100644 --- a/apps/web/pages/settings/teams/[id]/index.tsx +++ b/apps/web/pages/settings/teams/[id]/index.tsx @@ -4,6 +4,7 @@ import { useRouter } from "next/router"; import { useEffect, useState } from "react"; import showToast from "@calcom/lib/notification"; +import { trpc } from "@calcom/trpc/react"; import { SkeletonAvatar, SkeletonText } from "@calcom/ui"; import { Alert } from "@calcom/ui/Alert"; import { Button } from "@calcom/ui/Button"; @@ -13,7 +14,6 @@ import { QueryCell } from "@lib/QueryCell"; import { getPlaceholderAvatar } from "@lib/getPlaceholderAvatar"; import useCurrentUserId from "@lib/hooks/useCurrentUserId"; import { useLocale } from "@lib/hooks/useLocale"; -import { trpc } from "@lib/trpc"; import Shell from "@components/Shell"; import DisableTeamImpersonation from "@components/team/DisableTeamImpersonation"; diff --git a/apps/web/pages/settings/teams/index.tsx b/apps/web/pages/settings/teams/index.tsx index 04f4e526be494..e110def713165 100644 --- a/apps/web/pages/settings/teams/index.tsx +++ b/apps/web/pages/settings/teams/index.tsx @@ -5,12 +5,12 @@ import { Trans } from "next-i18next"; import { useState } from "react"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { trpc } from "@calcom/trpc/react"; import { Alert } from "@calcom/ui/Alert"; import Button from "@calcom/ui/Button"; import EmptyScreen from "@calcom/ui/EmptyScreen"; import useMeQuery from "@lib/hooks/useMeQuery"; -import { trpc } from "@lib/trpc"; import SettingsShell from "@components/SettingsShell"; import SkeletonLoaderTeamList from "@components/team/SkeletonloaderTeamList"; diff --git a/apps/web/pages/team/[slug].tsx b/apps/web/pages/team/[slug].tsx index d90d07f595fa0..3510dbcce89f9 100644 --- a/apps/web/pages/team/[slug].tsx +++ b/apps/web/pages/team/[slug].tsx @@ -8,6 +8,7 @@ import React, { useEffect } from "react"; import { useIsEmbed } from "@calcom/embed-core/embed-iframe"; import { CAL_URL } from "@calcom/lib/constants"; +import { getTeamWithMembers } from "@calcom/lib/server/queries/teams"; import Button from "@calcom/ui/Button"; import { getPlaceholderAvatar } from "@lib/getPlaceholderAvatar"; @@ -15,7 +16,6 @@ import { useExposePlanGlobally } from "@lib/hooks/useExposePlanGlobally"; import { useLocale } from "@lib/hooks/useLocale"; import useTheme from "@lib/hooks/useTheme"; import { useToggleQuery } from "@lib/hooks/useToggleQuery"; -import { getTeamWithMembers } from "@lib/queries/teams"; import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@lib/telemetry"; import { inferSSRProps } from "@lib/types/inferSSRProps"; diff --git a/apps/web/public/static/locales/fr/common.json b/apps/web/public/static/locales/fr/common.json index 579c41423efe7..6e55d6984da57 100644 --- a/apps/web/public/static/locales/fr/common.json +++ b/apps/web/public/static/locales/fr/common.json @@ -130,7 +130,6 @@ "dismiss": "Ignorer", "no_data_yet": "Aucune donnée pour l'instant", "ping_test": "Test ping", - "add_time_availability": "Ajouter une disponibilité horaire", "add_to_homescreen": "Ajoutez cette application à l'écran d'accueil de votre mobile pour un accès plus rapide et une meilleure expérience.", "upcoming": "À venir", "recurring": "Récurrent", @@ -376,6 +375,7 @@ "enable": "Activer", "code": "Code", "code_is_incorrect": "Code incorrect.", + "add_time_availability": "Ajouter une disponibilité horaire", "add_an_extra_layer_of_security": "Ajoutez une sécurité supplémentaire à votre compte en cas de vol de votre mot de passe.", "2fa": "Double authentification", "enable_2fa": "Activer la double authentification", diff --git a/apps/web/server/lib/i18n.ts b/apps/web/server/lib/i18n.ts index 19528ab7d0a90..0a3f56aead03e 100644 --- a/apps/web/server/lib/i18n.ts +++ b/apps/web/server/lib/i18n.ts @@ -1,18 +1 @@ -import i18next from "i18next"; -import { i18n as nexti18next } from "next-i18next"; -import { serverSideTranslations } from "next-i18next/serverSideTranslations"; - -export const getTranslation = async (locale: string, ns: string) => { - const create = async () => { - const { _nextI18Next } = await serverSideTranslations(locale, [ns]); - const _i18n = i18next.createInstance(); - _i18n.init({ - lng: locale, - resources: _nextI18Next.initialI18nStore, - fallbackLng: _nextI18Next.userConfig?.i18n.defaultLocale, - }); - return _i18n; - }; - const _i18n = nexti18next != null ? nexti18next : await create(); - return _i18n.getFixedT(locale, ns); -}; +export * from "@calcom/lib/server/i18n"; diff --git a/apps/web/server/lib/ssg.ts b/apps/web/server/lib/ssg.ts index a7abd8668d38e..090adbc3c14a9 100644 --- a/apps/web/server/lib/ssg.ts +++ b/apps/web/server/lib/ssg.ts @@ -3,10 +3,9 @@ import { i18n } from "next-i18next.config"; import { serverSideTranslations } from "next-i18next/serverSideTranslations"; import superjson from "superjson"; -import prisma from "@lib/prisma"; - -import { appRouter } from "@server/routers/_app"; -import { createSSGHelpers } from "@trpc/react/ssg"; +import prisma from "@calcom/prisma"; +import { createSSGHelpers } from "@calcom/trpc/react/ssg"; +import { appRouter } from "@calcom/trpc/server/routers/_app"; /** * Initialize static site rendering tRPC helpers. diff --git a/apps/web/server/lib/ssr.ts b/apps/web/server/lib/ssr.ts index c57a0a5111b14..80b8108da8690 100644 --- a/apps/web/server/lib/ssr.ts +++ b/apps/web/server/lib/ssr.ts @@ -1,10 +1,9 @@ import { GetServerSidePropsContext } from "next"; import superjson from "superjson"; -import { createContext } from "@server/createContext"; -import { createSSGHelpers } from "@trpc/react/ssg"; - -import { appRouter } from "../routers/_app"; +import { createSSGHelpers } from "@calcom/trpc/react/ssg"; +import { createContext } from "@calcom/trpc/server/createContext"; +import { appRouter } from "@calcom/trpc/server/routers/_app"; /** * Initialize server-side rendering tRPC helpers. diff --git a/apps/web/test/lib/getSchedule.test.ts b/apps/web/test/lib/getSchedule.test.ts index bf1d590f69f52..15b92e70072a9 100644 --- a/apps/web/test/lib/getSchedule.test.ts +++ b/apps/web/test/lib/getSchedule.test.ts @@ -5,8 +5,7 @@ import { v4 as uuidv4 } from "uuid"; import logger from "@calcom/lib/logger"; import prisma from "@calcom/prisma"; import { BookingStatus, PeriodType } from "@calcom/prisma/client"; - -import { getSchedule } from "../../server/routers/viewer/slots"; +import { getSchedule } from "@calcom/trpc/server/routers/viewer/slots"; declare global { // eslint-disable-next-line @typescript-eslint/no-namespace diff --git a/apps/web/test/lib/slots.test.ts b/apps/web/test/lib/slots.test.ts index 38285b7ba942d..c08324953f525 100644 --- a/apps/web/test/lib/slots.test.ts +++ b/apps/web/test/lib/slots.test.ts @@ -2,10 +2,10 @@ import { expect, it } from "@jest/globals"; import MockDate from "mockdate"; import dayjs from "@calcom/dayjs"; +import getSlots from "@calcom/lib/slots"; import { MINUTES_DAY_END, MINUTES_DAY_START } from "@lib/availability"; import { getFilteredTimes } from "@lib/hooks/useSlots"; -import getSlots from "@lib/slots"; MockDate.set("2021-06-20T11:59:59Z"); diff --git a/package.json b/package.json index 3b2dc17ce1bd9..8534db7b12439 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ ], "scripts": { "build": "turbo run build --scope=\"@calcom/web\" --include-dependencies", - "clean": "turbo run clean && rm -rf node_modules", + "clean": "find . -name node_modules -o -name .next -o -name .turbo -o -name dist -type d -prune | xargs rm -rf", "db-deploy": "turbo run db-deploy", "db-seed": "turbo run db-seed", "db-studio": "yarn workspace @calcom/prisma db-studio", diff --git a/packages/app-store/components.tsx b/packages/app-store/components.tsx index f9b7099a5e246..18556f9af9277 100644 --- a/packages/app-store/components.tsx +++ b/packages/app-store/components.tsx @@ -4,10 +4,9 @@ import { useState, useEffect, useRef } from "react"; import { WEBAPP_URL } from "@calcom/lib/constants"; import { deriveAppDictKeyFromType } from "@calcom/lib/deriveAppDictKeyFromType"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { trpc } from "@calcom/trpc/react"; import type { App } from "@calcom/types/App"; -import { trpc } from "@lib/trpc"; - import { UpgradeToProDialog } from "@components/UpgradeToProDialog"; import { InstallAppButtonMap } from "./apps.browser.generated"; diff --git a/packages/app-store/ee/routing_forms/components/SideBar.tsx b/packages/app-store/ee/routing_forms/components/SideBar.tsx index c5520157c10ce..f0a7f0cd4c5fd 100644 --- a/packages/app-store/ee/routing_forms/components/SideBar.tsx +++ b/packages/app-store/ee/routing_forms/components/SideBar.tsx @@ -4,9 +4,9 @@ import { useRouter } from "next/router"; import { CAL_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { trpc } from "@calcom/trpc/react"; import { Switch } from "@calcom/ui"; import { DialogTrigger, Dialog } from "@calcom/ui/Dialog"; -import { trpc } from "@calcom/web/lib/trpc"; import ConfirmationDialogContent from "@components/dialog/ConfirmationDialogContent"; diff --git a/packages/app-store/ee/routing_forms/pages/form-edit/[...appPages].tsx b/packages/app-store/ee/routing_forms/pages/form-edit/[...appPages].tsx index 57de7476854b2..0235fecd8e265 100644 --- a/packages/app-store/ee/routing_forms/pages/form-edit/[...appPages].tsx +++ b/packages/app-store/ee/routing_forms/pages/form-edit/[...appPages].tsx @@ -1,16 +1,16 @@ -import { TrashIcon, PlusIcon, ArrowUpIcon, CollectionIcon, ArrowDownIcon } from "@heroicons/react/solid"; +import { ArrowDownIcon, ArrowUpIcon, CollectionIcon, PlusIcon, TrashIcon } from "@heroicons/react/solid"; import { useRouter } from "next/router"; -import { useState, useEffect } from "react"; -import { useForm, UseFormReturn, useFieldArray, Controller } from "react-hook-form"; +import { useEffect, useState } from "react"; +import { Controller, useFieldArray, useForm, UseFormReturn } from "react-hook-form"; import { v4 as uuidv4 } from "uuid"; import classNames from "@calcom/lib/classNames"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { trpc } from "@calcom/trpc/react"; import { AppGetServerSidePropsContext, AppPrisma, AppUser } from "@calcom/types/AppGetServerSideProps"; -import { Button, Select, BooleanToggleGroup, EmptyScreen } from "@calcom/ui"; +import { BooleanToggleGroup, Button, EmptyScreen, Select } from "@calcom/ui"; import { Form, TextArea } from "@calcom/ui/form/fields"; -import { trpc } from "@calcom/web/lib/trpc"; import { inferSSRProps } from "@lib/types/inferSSRProps"; diff --git a/packages/app-store/ee/routing_forms/pages/forms/[...appPages].tsx b/packages/app-store/ee/routing_forms/pages/forms/[...appPages].tsx index bd421353884ec..0ebda3d0d1f6a 100644 --- a/packages/app-store/ee/routing_forms/pages/forms/[...appPages].tsx +++ b/packages/app-store/ee/routing_forms/pages/forms/[...appPages].tsx @@ -17,6 +17,7 @@ import classNames from "@calcom/lib/classNames"; import { CAL_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { trpc } from "@calcom/trpc/react"; import { AppGetServerSidePropsContext, AppPrisma, AppUser } from "@calcom/types/AppGetServerSideProps"; import { Button, EmptyScreen, Tooltip } from "@calcom/ui"; import Dropdown, { @@ -25,7 +26,6 @@ import Dropdown, { DropdownMenuSeparator, DropdownMenuTrigger, } from "@calcom/ui/Dropdown"; -import { trpc } from "@calcom/web/lib/trpc"; import { inferSSRProps } from "@lib/types/inferSSRProps"; diff --git a/packages/app-store/ee/routing_forms/pages/route-builder/[...appPages].tsx b/packages/app-store/ee/routing_forms/pages/route-builder/[...appPages].tsx index 08e1a28967cd6..98786bec50932 100644 --- a/packages/app-store/ee/routing_forms/pages/route-builder/[...appPages].tsx +++ b/packages/app-store/ee/routing_forms/pages/route-builder/[...appPages].tsx @@ -7,11 +7,11 @@ import { JsonTree, ImmutableTree, BuilderProps } from "react-awesome-query-build import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { trpc } from "@calcom/trpc/react"; import { AppGetServerSidePropsContext, AppPrisma, AppUser } from "@calcom/types/AppGetServerSideProps"; import { inferSSRProps } from "@calcom/types/inferSSRProps"; import { Button } from "@calcom/ui"; import { Label } from "@calcom/ui/form/fields"; -import { trpc } from "@calcom/web/lib/trpc"; import PencilEdit from "@components/PencilEdit"; import { SelectWithValidation as Select } from "@components/ui/form/Select"; diff --git a/packages/app-store/ee/routing_forms/pages/routing-link/[...appPages].tsx b/packages/app-store/ee/routing_forms/pages/routing-link/[...appPages].tsx index f207dfed6f3fd..0d4e5883a7320 100644 --- a/packages/app-store/ee/routing_forms/pages/routing-link/[...appPages].tsx +++ b/packages/app-store/ee/routing_forms/pages/routing-link/[...appPages].tsx @@ -7,10 +7,10 @@ import { Toaster } from "react-hot-toast"; import { v4 as uuidv4 } from "uuid"; import showToast from "@calcom/lib/notification"; +import { trpc } from "@calcom/trpc/react"; import { AppGetServerSidePropsContext, AppPrisma } from "@calcom/types/AppGetServerSideProps"; import { inferSSRProps } from "@calcom/types/inferSSRProps"; import { Button } from "@calcom/ui"; -import { trpc } from "@calcom/web/lib/trpc"; import { getSerializableForm } from "../../utils"; import { getQueryBuilderConfig } from "../route-builder/[...appPages]"; diff --git a/packages/app-store/ee/routing_forms/trpc-router.ts b/packages/app-store/ee/routing_forms/trpc-router.ts index f079b284b5f51..c736eec0d7aa7 100644 --- a/packages/app-store/ee/routing_forms/trpc-router.ts +++ b/packages/app-store/ee/routing_forms/trpc-router.ts @@ -2,12 +2,12 @@ import { Prisma, WebhookTriggerEvents } from "@prisma/client"; import { v4 as uuidv4 } from "uuid"; import { z } from "zod"; +import { TRPCError } from "@calcom/trpc/server"; +import { createProtectedRouter, createRouter } from "@calcom/trpc/server/createRouter"; + import { sendGenericWebhookPayload } from "@lib/webhooks/sendPayload"; import getWebhooks from "@lib/webhooks/subscriptions"; -import { createProtectedRouter, createRouter } from "@server/createRouter"; -import { TRPCError } from "@trpc/server"; - import { zodFields, zodRoutes } from "./zod"; const app_RoutingForms = createRouter() diff --git a/packages/app-store/wipemycalother/components/confirmDialog.tsx b/packages/app-store/wipemycalother/components/confirmDialog.tsx index a79f38a328e2f..22e77cf939282 100644 --- a/packages/app-store/wipemycalother/components/confirmDialog.tsx +++ b/packages/app-store/wipemycalother/components/confirmDialog.tsx @@ -1,19 +1,18 @@ -import { ClockIcon, XIcon } from "@heroicons/react/outline"; -import { Dispatch, SetStateAction } from "react"; -import { useState } from "react"; +import { ClockIcon } from "@heroicons/react/outline"; +import { Dispatch, SetStateAction, useState } from "react"; import { useMutation } from "react-query"; import dayjs from "@calcom/dayjs"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import logger from "@calcom/lib/logger"; import showToast from "@calcom/lib/notification"; +import { trpc } from "@calcom/trpc/react"; import Button from "@calcom/ui/Button"; -import { Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader } from "@calcom/ui/Dialog"; +import { Dialog, DialogContent, DialogFooter, DialogHeader } from "@calcom/ui/Dialog"; interface IConfirmDialogWipe { isOpenDialog: boolean; setIsOpenDialog: Dispatch>; - trpc: any; } interface IWipeMyCalAction { @@ -45,7 +44,7 @@ const wipeMyCalAction = async (props: IWipeMyCalAction) => { export const ConfirmDialog = (props: IConfirmDialogWipe) => { const { t } = useLocale(); - const { isOpenDialog, setIsOpenDialog, trpc } = props; + const { isOpenDialog, setIsOpenDialog } = props; const [isLoading, setIsLoading] = useState(false); const today = dayjs(); const initialDate = today.startOf("day"); diff --git a/packages/app-store/wipemycalother/components/wipeMyCalActionButton.tsx b/packages/app-store/wipemycalother/components/wipeMyCalActionButton.tsx index 476c868553aaf..ad243f4051db7 100644 --- a/packages/app-store/wipemycalother/components/wipeMyCalActionButton.tsx +++ b/packages/app-store/wipemycalother/components/wipeMyCalActionButton.tsx @@ -1,17 +1,17 @@ import { useState } from "react"; +import { trpc } from "@calcom/trpc/react"; import Button from "@calcom/ui/Button"; import { ConfirmDialog } from "./confirmDialog"; interface IWipeMyCalActionButtonProps { - trpc: any; bookingsEmpty: boolean; bookingStatus: "upcoming" | "recurring" | "past" | "cancelled"; } const WipeMyCalActionButton = (props: IWipeMyCalActionButtonProps) => { - const { trpc, bookingsEmpty, bookingStatus } = props; + const { bookingsEmpty, bookingStatus } = props; const [openDialog, setOpenDialog] = useState(false); const { isSuccess, isLoading, data } = trpc.useQuery([ "viewer.integrations", @@ -21,9 +21,7 @@ const WipeMyCalActionButton = (props: IWipeMyCalActionButtonProps) => { if (bookingStatus !== "upcoming" || bookingsEmpty) { return <>; } - const wipeMyCalCredentials: { credentialIds: number[] } = data?.items.find( - (item: { type: string }) => item.type === "wipemycal_other" - ); + const wipeMyCalCredentials = data?.items.find((item: { type: string }) => item.type === "wipemycal_other"); const [credentialId] = wipeMyCalCredentials?.credentialIds || [false]; @@ -31,7 +29,7 @@ const WipeMyCalActionButton = (props: IWipeMyCalActionButtonProps) => {
{data && isSuccess && !isLoading && credentialId && ( <> - + diff --git a/packages/app-store/zapier/pages/setup/index.tsx b/packages/app-store/zapier/pages/setup/index.tsx index ac2e13a071cad..27c8fc11fe79f 100644 --- a/packages/app-store/zapier/pages/setup/index.tsx +++ b/packages/app-store/zapier/pages/setup/index.tsx @@ -6,11 +6,9 @@ import { Toaster } from "react-hot-toast"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; +import { trpc } from "@calcom/trpc/react"; import { Button, Loader, Tooltip } from "@calcom/ui"; -/** TODO: Maybe extract this into a package to prevent circular dependencies */ -import { trpc } from "@calcom/web/lib/trpc"; - export interface IZapierSetupProps { inviteLink: string; } @@ -21,11 +19,7 @@ export default function ZapierSetup(props: IZapierSetupProps) { const [newApiKey, setNewApiKey] = useState(""); const { t } = useLocale(); const utils = trpc.useContext(); - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore const integrations = trpc.useQuery(["viewer.integrations", { variant: "other" }]); - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore const oldApiKey = trpc.useQuery(["viewer.apiKeys.findKeyOfType", { appId: ZAPIER }]); const deleteApiKey = trpc.useMutation("viewer.apiKeys.delete"); @@ -38,8 +32,6 @@ export default function ZapierSetup(props: IZapierSetupProps) { async function createApiKey() { const event = { note: "Zapier", expiresAt: null, appId: ZAPIER }; - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore const apiKey = await utils.client.mutation("viewer.apiKeys.create", event); if (oldApiKey.data) { deleteApiKey.mutate({ diff --git a/packages/config/next-i18next.config.js b/packages/config/next-i18next.config.js new file mode 100644 index 0000000000000..c0c2c65203f4a --- /dev/null +++ b/packages/config/next-i18next.config.js @@ -0,0 +1,35 @@ +const path = require("path"); + +/** @type {import("next-i18next").UserConfig} */ +const config = { + i18n: { + defaultLocale: "en", + locales: [ + "en", + "fr", + "it", + "ru", + "es", + "de", + "pt", + "ro", + "nl", + "pt-BR", + "es-419", + "ko", + "ja", + "pl", + "ar", + "iw", + "zh-CN", + "zh-TW", + "cs", + "sr", + "sv", + "vi", + ], + }, + reloadOnPrerender: process.env.NODE_ENV !== "production", +}; + +module.exports = config; diff --git a/packages/core/videoClient.ts b/packages/core/videoClient.ts index d2102c6f206b8..af5e5ebc9fd80 100644 --- a/packages/core/videoClient.ts +++ b/packages/core/videoClient.ts @@ -6,7 +6,7 @@ import appStore from "@calcom/app-store"; import { sendBrokenIntegrationEmail } from "@calcom/emails"; import { getUid } from "@calcom/lib/CalEventParser"; import logger from "@calcom/lib/logger"; -import type { CalendarEvent } from "@calcom/types/Calendar"; +import type { CalendarEvent, EventBusyDate } from "@calcom/types/Calendar"; import type { EventResult, PartialReference } from "@calcom/types/EventManager"; import type { VideoApiAdapter, VideoApiAdapterFactory, VideoCallData } from "@calcom/types/VideoApiAdapter"; @@ -29,8 +29,8 @@ const getVideoAdapters = (withCredentials: Credential[]): VideoApiAdapter[] => }, []); const getBusyVideoTimes = (withCredentials: Credential[]) => - Promise.all(getVideoAdapters(withCredentials).map((c) => c.getAvailability())).then((results) => - results.reduce((acc, availability) => acc.concat(availability), []) + Promise.all(getVideoAdapters(withCredentials).map((c) => c?.getAvailability())).then((results) => + results.reduce((acc, availability) => acc.concat(availability), [] as (EventBusyDate | undefined)[]) ); const createMeeting = async (credential: Credential, calEvent: CalendarEvent) => { @@ -44,7 +44,7 @@ const createMeeting = async (credential: Credential, calEvent: CalendarEvent) => const videoAdapters = getVideoAdapters([credential]); const [firstVideoAdapter] = videoAdapters; - const createdMeeting = await firstVideoAdapter.createMeeting(calEvent).catch(async (e) => { + const createdMeeting = await firstVideoAdapter?.createMeeting(calEvent).catch(async (e) => { await sendBrokenIntegrationEmail(calEvent, "video"); console.error("createMeeting failed", e, calEvent); }); @@ -79,7 +79,7 @@ const updateMeeting = async ( const [firstVideoAdapter] = getVideoAdapters([credential]); const updatedMeeting = credential && bookingRef - ? await firstVideoAdapter.updateMeeting(bookingRef, calEvent).catch(async (e) => { + ? await firstVideoAdapter?.updateMeeting(bookingRef, calEvent).catch(async (e) => { await sendBrokenIntegrationEmail(calEvent, "video"); log.error("updateMeeting failed", e, calEvent); success = false; @@ -107,7 +107,11 @@ const updateMeeting = async ( const deleteMeeting = (credential: Credential, uid: string): Promise => { if (credential) { - return getVideoAdapters([credential])[0].deleteMeeting(uid); + const videoAdapter = getVideoAdapters([credential])[0]; + // There are certain video apps with no video adapter defined. e.g. riverby,whereby + if (videoAdapter) { + return videoAdapter.deleteMeeting(uid); + } } return Promise.resolve({}); diff --git a/packages/emails/templates/attendee-request-reschedule-email.ts b/packages/emails/templates/attendee-request-reschedule-email.ts index fbc842e434940..2a325a79cc7e9 100644 --- a/packages/emails/templates/attendee-request-reschedule-email.ts +++ b/packages/emails/templates/attendee-request-reschedule-email.ts @@ -2,7 +2,7 @@ import { createEvent, DateArray, Person } from "ics"; import dayjs from "@calcom/dayjs"; import { getCancelLink } from "@calcom/lib/CalEventParser"; -import { CalendarEvent } from "@calcom/types/Calendar"; +import type { CalendarEvent } from "@calcom/types/Calendar"; import { renderEmail } from "../"; import OrganizerScheduledEmail from "./organizer-scheduled-email"; diff --git a/packages/emails/templates/organizer-request-reschedule-email.ts b/packages/emails/templates/organizer-request-reschedule-email.ts index 06d6b77d4ffb5..452c3489a33fb 100644 --- a/packages/emails/templates/organizer-request-reschedule-email.ts +++ b/packages/emails/templates/organizer-request-reschedule-email.ts @@ -2,7 +2,7 @@ import { createEvent, DateArray, Person } from "ics"; import dayjs from "@calcom/dayjs"; import { getRichDescription } from "@calcom/lib/CalEventParser"; -import { CalendarEvent } from "@calcom/types/Calendar"; +import type { CalendarEvent } from "@calcom/types/Calendar"; import { renderEmail } from "../"; import OrganizerScheduledEmail from "./organizer-scheduled-email"; diff --git a/packages/embeds/embed-core/src/ModalBox/ModalBoxHtml.ts b/packages/embeds/embed-core/src/ModalBox/ModalBoxHtml.ts index bd8f76110fa3a..c0985c9731ca5 100644 --- a/packages/embeds/embed-core/src/ModalBox/ModalBoxHtml.ts +++ b/packages/embeds/embed-core/src/ModalBox/ModalBoxHtml.ts @@ -10,30 +10,16 @@ const html = `