Revert b3430c8efc: fix Atoms build failures on CI (#27575)
This commit is contained in:
1 parent
40e5b739d6
commit
51b3f5c74d
108 files changed
+139
-188
No files matched your search
@@ -2,7 +2,7 @@
|
||||
|
||||
import { useReducer } from "react";
|
||||
|
||||
import SettingsHeader from "@calcom/web/modules/settings/components/SettingsHeader";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
@@ -14,14 +14,14 @@ import { showToast } from "@calcom/ui/components/toast";
|
||||
import { AppList } from "./AppList";
|
||||
import DisconnectIntegrationModal from "@calcom/features/apps/components/DisconnectIntegrationModal";
|
||||
|
||||
type UpdateUsersDefaultConferencingAppParams = {
|
||||
export type UpdateUsersDefaultConferencingAppParams = {
|
||||
appSlug: string;
|
||||
appLink?: string;
|
||||
onSuccessCallback: () => void;
|
||||
onErrorCallback: () => void;
|
||||
};
|
||||
|
||||
type BulkUpdatParams = { eventTypeIds: number[]; callback: () => void };
|
||||
export type BulkUpdatParams = { eventTypeIds: number[]; callback: () => void };
|
||||
type RemoveAppParams = { credentialId: number; teamId?: number; callback: () => void };
|
||||
|
||||
export const SkeletonLoader = () => {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useMemo } from "react";
|
||||
import { z } from "zod";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { useBookingLocation } from "@calcom/web/modules/bookings/hooks/useBookingLocation";
|
||||
import { useBookingLocation } from "@calcom/features/bookings/hooks";
|
||||
import { shouldShowFieldInCustomResponses } from "@calcom/lib/bookings/SystemField";
|
||||
import { formatPrice } from "@calcom/lib/currencyConversions";
|
||||
import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { TFunction } from "i18next";
|
||||
import { useMemo } from "react";
|
||||
|
||||
import { useBookingLocation } from "@calcom/web/modules/bookings/hooks/useBookingLocation";
|
||||
import { useBookingLocation } from "@calcom/features/bookings/hooks";
|
||||
import type { BookingStatus } from "@calcom/prisma/enums";
|
||||
import { bookingMetadataSchema } from "@calcom/prisma/zod-utils";
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider";
|
||||
import { WEBAPP_URL, WEBSITE_URL } from "@calcom/lib/constants";
|
||||
|
||||
export const useBookerUrl = () => {
|
||||
const orgBranding = useOrgBranding();
|
||||
return orgBranding?.fullDomain ?? WEBSITE_URL ?? WEBAPP_URL;
|
||||
};
|
||||
|
||||
export const useEmbedBookerUrl = () => {
|
||||
const orgBranding = useOrgBranding();
|
||||
return orgBranding?.fullDomain ?? WEBAPP_URL;
|
||||
};
|
||||
@@ -1,77 +0,0 @@
|
||||
import type { TFunction } from "i18next";
|
||||
import { useMemo } from "react";
|
||||
|
||||
import { getSuccessPageLocationMessage, guessEventLocationType } from "@calcom/app-store/locations";
|
||||
import type { BookingStatus } from "@calcom/prisma/enums";
|
||||
|
||||
interface UseBookingLocationParams {
|
||||
/**
|
||||
* The booking location value from the booking object
|
||||
*/
|
||||
location: string | null | undefined;
|
||||
/**
|
||||
* The video call URL from booking metadata (if available)
|
||||
*/
|
||||
videoCallUrl?: string | null;
|
||||
/**
|
||||
* Translation function
|
||||
*/
|
||||
t: TFunction;
|
||||
/**
|
||||
* Booking status (optional)
|
||||
*/
|
||||
bookingStatus?: BookingStatus;
|
||||
}
|
||||
|
||||
interface UseBookingLocationReturn {
|
||||
/**
|
||||
* The location message to display (URL or text)
|
||||
*/
|
||||
locationToDisplay: string | null;
|
||||
/**
|
||||
* The provider information (label, iconUrl, etc.)
|
||||
*/
|
||||
provider: ReturnType<typeof guessEventLocationType>;
|
||||
/**
|
||||
* Whether the location is a URL that can be clicked
|
||||
*/
|
||||
isLocationURL: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom hook to process booking location information
|
||||
*
|
||||
* This hook handles the common pattern of:
|
||||
* 1. Determining the actual location (video call URL vs. raw location)
|
||||
* 2. Getting the display message for the location
|
||||
* 3. Determining the provider type
|
||||
* 4. Checking if the location is a clickable URL
|
||||
*/
|
||||
export function useBookingLocation({
|
||||
location,
|
||||
videoCallUrl,
|
||||
t,
|
||||
bookingStatus,
|
||||
}: UseBookingLocationParams): UseBookingLocationReturn {
|
||||
const locationToDisplay = useMemo(() => {
|
||||
if (!location) return null;
|
||||
|
||||
const effectiveLocation = videoCallUrl ?? location;
|
||||
return getSuccessPageLocationMessage(effectiveLocation, t, bookingStatus);
|
||||
}, [location, videoCallUrl, t, bookingStatus]);
|
||||
|
||||
const provider = useMemo(() => {
|
||||
if (!location) return null;
|
||||
return guessEventLocationType(location);
|
||||
}, [location]);
|
||||
|
||||
const isLocationURL = useMemo(() => {
|
||||
return typeof locationToDisplay === "string" && locationToDisplay.startsWith("http");
|
||||
}, [locationToDisplay]);
|
||||
|
||||
return {
|
||||
locationToDisplay,
|
||||
provider,
|
||||
isLocationURL,
|
||||
};
|
||||
}
|
||||
@@ -1,248 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { keepPreviousData } from "@tanstack/react-query";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
import {
|
||||
BlockedEntriesTable,
|
||||
CreateBlocklistEntryModal,
|
||||
PendingReportsBadge,
|
||||
PendingReportsTable,
|
||||
type SortByOption,
|
||||
} from "@calcom/features/blocklist";
|
||||
import { DataTableProvider, useDataTable } from "@calcom/features/data-table";
|
||||
import { DataTableToolbar } from "~/data-table/components";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import {
|
||||
Dropdown,
|
||||
DropdownItem,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@calcom/ui/components/dropdown";
|
||||
import { ToggleGroup } from "@calcom/ui/components/form";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
import { BulkDeleteBlocklistEntries } from "./blocklist/BulkDeleteBlocklistEntries";
|
||||
import { BulkDismissReports } from "./blocklist/BulkDismissReports";
|
||||
|
||||
type ViewType = "blocked" | "pending";
|
||||
|
||||
function SystemBlocklistContent() {
|
||||
const { t } = useLocale();
|
||||
const { limit, offset, searchTerm } = useDataTable();
|
||||
const [activeView, setActiveView] = useState<ViewType>("blocked");
|
||||
const [showCreateModal, setShowCreateModal] = useState(false);
|
||||
const [selectedEntryId, setSelectedEntryId] = useState<string | null>(null);
|
||||
const [sortBy, setSortBy] = useState<SortByOption>("createdAt");
|
||||
|
||||
const utils = trpc.useUtils();
|
||||
|
||||
const { data: blockedData, isPending: isBlockedPending } =
|
||||
trpc.viewer.admin.watchlist.list.useQuery(
|
||||
{ limit, offset, searchTerm },
|
||||
{ placeholderData: keepPreviousData, enabled: activeView === "blocked" }
|
||||
);
|
||||
|
||||
const { data: reportsData, isPending: isReportsPending } =
|
||||
trpc.viewer.admin.watchlist.listReports.useQuery(
|
||||
{
|
||||
limit,
|
||||
offset,
|
||||
searchTerm,
|
||||
sortBy,
|
||||
systemFilters: { systemStatus: ["PENDING"] },
|
||||
},
|
||||
{ placeholderData: keepPreviousData, enabled: activeView === "pending" }
|
||||
);
|
||||
|
||||
const { data: pendingReportsCount } =
|
||||
trpc.viewer.admin.watchlist.pendingReportsCount.useQuery();
|
||||
|
||||
const { data: entryDetails, isLoading: isDetailsLoading } =
|
||||
trpc.viewer.admin.watchlist.getDetails.useQuery(
|
||||
{ id: selectedEntryId ?? "" },
|
||||
{ enabled: !!selectedEntryId }
|
||||
);
|
||||
|
||||
const createEntry = trpc.viewer.admin.watchlist.create.useMutation({
|
||||
onSuccess: async () => {
|
||||
await utils.viewer.admin.watchlist.list.invalidate();
|
||||
showToast(t("system_blocklist_entry_created"), "success");
|
||||
setShowCreateModal(false);
|
||||
},
|
||||
onError: (error) => {
|
||||
showToast(error.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
const deleteEntry = trpc.viewer.admin.watchlist.delete.useMutation({
|
||||
onSuccess: async () => {
|
||||
await utils.viewer.admin.watchlist.list.invalidate();
|
||||
setSelectedEntryId(null);
|
||||
showToast(t("system_blocklist_entry_deleted"), "success");
|
||||
},
|
||||
onError: (error) => {
|
||||
showToast(error.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
const addToWatchlist = trpc.viewer.admin.watchlist.addToWatchlist.useMutation(
|
||||
{
|
||||
onSuccess: async () => {
|
||||
await utils.viewer.admin.watchlist.listReports.invalidate();
|
||||
await utils.viewer.admin.watchlist.list.invalidate();
|
||||
await utils.viewer.admin.watchlist.pendingReportsCount.invalidate();
|
||||
showToast(t("system_blocklist_entry_created"), "success");
|
||||
},
|
||||
onError: (error) => {
|
||||
showToast(error.message, "error");
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const dismissReport = trpc.viewer.admin.watchlist.dismissReport.useMutation({
|
||||
onSuccess: async () => {
|
||||
await utils.viewer.admin.watchlist.listReports.invalidate();
|
||||
await utils.viewer.admin.watchlist.pendingReportsCount.invalidate();
|
||||
showToast(t("booking_report_dismissed"), "success");
|
||||
},
|
||||
onError: (error) => {
|
||||
showToast(error.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-4 flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<ToggleGroup
|
||||
value={activeView}
|
||||
onValueChange={(value) => {
|
||||
if (value) setActiveView(value as ViewType);
|
||||
}}
|
||||
options={[
|
||||
{ value: "blocked", label: t("blocked") },
|
||||
{
|
||||
value: "pending",
|
||||
label: (
|
||||
<span className="flex items-center">
|
||||
{t("pending")}
|
||||
<PendingReportsBadge count={pendingReportsCount} />
|
||||
</span>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<DataTableToolbar.SearchBar />
|
||||
{activeView === "pending" && (
|
||||
<Dropdown modal={false}>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button type="button" color="secondary" EndIcon="chevron-down">
|
||||
{sortBy === "reportCount" ? t("most_reports") : t("most_recent")}
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem>
|
||||
<DropdownItem
|
||||
type="button"
|
||||
onClick={() => setSortBy("createdAt")}
|
||||
className={sortBy === "createdAt" ? "font-medium" : ""}>
|
||||
{t("most_recent")}
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem>
|
||||
<DropdownItem
|
||||
type="button"
|
||||
onClick={() => setSortBy("reportCount")}
|
||||
className={sortBy === "reportCount" ? "font-medium" : ""}>
|
||||
{t("most_reports")}
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</Dropdown>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
{activeView === "blocked" && (
|
||||
<Button
|
||||
color="primary"
|
||||
StartIcon="plus"
|
||||
onClick={() => setShowCreateModal(true)}
|
||||
>
|
||||
{t("add")}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{activeView === "blocked" ? (
|
||||
<BlockedEntriesTable
|
||||
scope="system"
|
||||
data={blockedData?.rows ?? []}
|
||||
totalRowCount={blockedData?.meta?.totalRowCount ?? 0}
|
||||
isPending={isBlockedPending}
|
||||
limit={limit}
|
||||
searchTerm={searchTerm}
|
||||
onAddClick={() => setShowCreateModal(true)}
|
||||
onDelete={(entry) => deleteEntry.mutate({ id: entry.id })}
|
||||
isDeleting={deleteEntry.isPending}
|
||||
detailsQuery={{ data: entryDetails, isLoading: isDetailsLoading }}
|
||||
selectedEntryId={selectedEntryId ?? undefined}
|
||||
onSelectEntry={setSelectedEntryId}
|
||||
enableRowSelection
|
||||
renderBulkActions={(selectedEntries, clearSelection) => (
|
||||
<BulkDeleteBlocklistEntries
|
||||
entries={selectedEntries}
|
||||
onRemove={clearSelection}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
) : (
|
||||
<PendingReportsTable
|
||||
scope="system"
|
||||
data={reportsData?.rows ?? []}
|
||||
totalRowCount={reportsData?.meta?.totalRowCount ?? 0}
|
||||
isPending={isReportsPending}
|
||||
limit={limit}
|
||||
onAddToBlocklist={(email, type, onSuccess) =>
|
||||
addToWatchlist.mutate({ email, type }, { onSuccess })
|
||||
}
|
||||
onDismiss={(email, onSuccess) =>
|
||||
dismissReport.mutate({ email }, { onSuccess })
|
||||
}
|
||||
isAddingToBlocklist={addToWatchlist.isPending}
|
||||
isDismissing={dismissReport.isPending}
|
||||
enableRowSelection
|
||||
renderBulkActions={(selectedReports, clearSelection) => (
|
||||
<BulkDismissReports
|
||||
reports={selectedReports}
|
||||
onRemove={clearSelection}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
|
||||
<CreateBlocklistEntryModal
|
||||
isOpen={showCreateModal}
|
||||
onClose={() => setShowCreateModal(false)}
|
||||
scope="system"
|
||||
onCreateEntry={(data) => createEntry.mutate(data)}
|
||||
isPending={createEntry.isPending}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default function SystemBlocklistView() {
|
||||
const pathname = usePathname();
|
||||
|
||||
return (
|
||||
<DataTableProvider tableIdentifier={pathname ?? "system-blocklist"}>
|
||||
<SystemBlocklistContent />
|
||||
</DataTableProvider>
|
||||
);
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
import { Dialog } from "@calcom/features/components/controlled-dialog";
|
||||
import { DataTableSelectionBar } from "~/data-table/components";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import {
|
||||
DialogTrigger,
|
||||
ConfirmationDialogContent,
|
||||
} from "@calcom/ui/components/dialog";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
type BlocklistEntry =
|
||||
RouterOutputs["viewer"]["admin"]["watchlist"]["list"]["rows"][number];
|
||||
|
||||
interface Props {
|
||||
entries: BlocklistEntry[];
|
||||
onRemove: () => void;
|
||||
}
|
||||
|
||||
export function BulkDeleteBlocklistEntries({ entries, onRemove }: Props) {
|
||||
const { t } = useLocale();
|
||||
const utils = trpc.useUtils();
|
||||
|
||||
const bulkDeleteMutation = trpc.viewer.admin.watchlist.bulkDelete.useMutation(
|
||||
{
|
||||
onSuccess: async (data) => {
|
||||
await utils.viewer.admin.watchlist.list.invalidate();
|
||||
showToast(
|
||||
data.failed === 0
|
||||
? t("entries_deleted_successfully", { count: data.success })
|
||||
: t("entries_deleted_with_errors", {
|
||||
success: data.success,
|
||||
failed: data.failed,
|
||||
}),
|
||||
data.failed === 0 ? "success" : "warning"
|
||||
);
|
||||
onRemove();
|
||||
},
|
||||
onError: (error) => {
|
||||
showToast(error.message, "error");
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
return (
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
<DataTableSelectionBar.Button icon="trash" color="destructive">
|
||||
{t("remove_from_blocklist")}
|
||||
</DataTableSelectionBar.Button>
|
||||
</DialogTrigger>
|
||||
<ConfirmationDialogContent
|
||||
variety="danger"
|
||||
title={t("remove_entries_from_system_blocklist")}
|
||||
confirmBtnText={t("remove")}
|
||||
isPending={bulkDeleteMutation.isPending}
|
||||
onConfirm={() => {
|
||||
bulkDeleteMutation.mutate({
|
||||
ids: entries.map((entry) => entry.id),
|
||||
});
|
||||
}}
|
||||
>
|
||||
<p className="mt-5">
|
||||
{t("remove_entries_confirm", { count: entries.length })}
|
||||
</p>
|
||||
</ConfirmationDialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
import { Dialog } from "@calcom/features/components/controlled-dialog";
|
||||
import { DataTableSelectionBar } from "~/data-table/components";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import {
|
||||
DialogTrigger,
|
||||
ConfirmationDialogContent,
|
||||
} from "@calcom/ui/components/dialog";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
type BookingReport =
|
||||
RouterOutputs["viewer"]["admin"]["watchlist"]["listReports"]["rows"][number];
|
||||
|
||||
interface Props {
|
||||
reports: BookingReport[];
|
||||
onRemove: () => void;
|
||||
}
|
||||
|
||||
export function BulkDismissReports({ reports, onRemove }: Props) {
|
||||
const { t } = useLocale();
|
||||
const utils = trpc.useUtils();
|
||||
|
||||
const bulkDismissMutation =
|
||||
trpc.viewer.admin.watchlist.bulkDismiss.useMutation({
|
||||
onSuccess: async (data) => {
|
||||
await utils.viewer.admin.watchlist.listReports.invalidate();
|
||||
await utils.viewer.admin.watchlist.pendingReportsCount.invalidate();
|
||||
showToast(
|
||||
data.failed === 0
|
||||
? t("reports_dismissed_successfully", { count: data.success })
|
||||
: t("reports_dismissed_with_errors", {
|
||||
success: data.success,
|
||||
failed: data.failed,
|
||||
}),
|
||||
data.failed === 0 ? "success" : "warning"
|
||||
);
|
||||
onRemove();
|
||||
},
|
||||
onError: (error) => {
|
||||
showToast(error.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
<DataTableSelectionBar.Button icon="x" color="secondary">
|
||||
{t("dismiss")}
|
||||
</DataTableSelectionBar.Button>
|
||||
</DialogTrigger>
|
||||
<ConfirmationDialogContent
|
||||
variety="warning"
|
||||
title={t("dismiss_reports_title")}
|
||||
confirmBtnText={t("dismiss")}
|
||||
isPending={bulkDismissMutation.isPending}
|
||||
onConfirm={() => {
|
||||
bulkDismissMutation.mutate({
|
||||
emails: reports.map((group) => group.bookerEmail),
|
||||
});
|
||||
}}
|
||||
>
|
||||
<p className="mt-5">
|
||||
{t("dismiss_reports_confirm", { count: reports.length })}
|
||||
</p>
|
||||
</ConfirmationDialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState } from "react";
|
||||
import { Controller, useFormContext } from "react-hook-form";
|
||||
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/SectionBottomActions";
|
||||
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
|
||||
import { DEFAULT_LIGHT_BRAND_COLOR, DEFAULT_DARK_BRAND_COLOR } from "@calcom/lib/constants";
|
||||
import { checkWCAGContrastColor } from "@calcom/lib/getBrandColours";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/SectionBottomActions";
|
||||
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
|
||||
import { SkeletonButton, SkeletonContainer, SkeletonText } from "@calcom/ui/components/skeleton";
|
||||
|
||||
export const AppearanceSkeletonLoader = () => {
|
||||
|
||||
@@ -1,274 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import type { SessionContextValue } from "next-auth/react";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import type { Ensure } from "@calcom/types/utils";
|
||||
import { Alert } from "@calcom/ui/components/alert";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { Label, TextField, ToggleGroup, Form } from "@calcom/ui/components/form";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
import { UserPermissionRole } from "@calcom/prisma/enums";
|
||||
|
||||
export const CreateANewLicenseKeyForm = () => {
|
||||
const session = useSession();
|
||||
if (session.data?.user.role !== "ADMIN") {
|
||||
return null;
|
||||
}
|
||||
// @ts-expect-error session can't be null due to the early return
|
||||
return <CreateANewLicenseKeyFormChild session={session} />;
|
||||
};
|
||||
|
||||
enum BillingType {
|
||||
PER_BOOKING = "PER_BOOKING",
|
||||
PER_USER = "PER_USER",
|
||||
}
|
||||
|
||||
enum BillingPeriod {
|
||||
MONTHLY = "MONTHLY",
|
||||
ANNUALLY = "ANNUALLY",
|
||||
}
|
||||
|
||||
interface FormValues {
|
||||
billingType: BillingType;
|
||||
entityCount: number;
|
||||
entityPrice: number;
|
||||
billingPeriod: BillingPeriod;
|
||||
overages: number;
|
||||
billingEmail: string;
|
||||
}
|
||||
|
||||
const CreateANewLicenseKeyFormChild = ({ session }: { session: Ensure<SessionContextValue, "data"> }) => {
|
||||
const { t } = useLocale();
|
||||
const [serverErrorMessage, setServerErrorMessage] = useState<string | null>(null);
|
||||
const [stripeCheckoutUrl, setStripeCheckoutUrl] = useState<string | null>(null);
|
||||
const isAdmin = session.data.user.role === UserPermissionRole.ADMIN;
|
||||
const newLicenseKeyFormMethods = useForm<FormValues>({
|
||||
defaultValues: {
|
||||
billingType: BillingType.PER_BOOKING,
|
||||
billingPeriod: BillingPeriod.MONTHLY,
|
||||
entityCount: 500,
|
||||
overages: 99, // $0.99
|
||||
entityPrice: 50, // $0.5
|
||||
billingEmail: undefined,
|
||||
},
|
||||
});
|
||||
|
||||
const mutation = trpc.viewer.admin.createSelfHostedLicense.useMutation({
|
||||
onSuccess: async (values) => {
|
||||
showToast(`Success: We have created a stripe payment URL for this billing email`, "success");
|
||||
setStripeCheckoutUrl(values.stripeCheckoutUrl);
|
||||
},
|
||||
onError: async (err) => {
|
||||
setServerErrorMessage(err.message);
|
||||
},
|
||||
});
|
||||
|
||||
const watchedBillingPeriod = newLicenseKeyFormMethods.watch("billingPeriod");
|
||||
const watchedEntityCount = newLicenseKeyFormMethods.watch("entityCount");
|
||||
const watchedEntityPrice = newLicenseKeyFormMethods.watch("entityPrice");
|
||||
|
||||
function calculateMonthlyPrice() {
|
||||
const occurrence = watchedBillingPeriod === "MONTHLY" ? 1 : 12;
|
||||
|
||||
const sum = watchedEntityCount * watchedEntityPrice;
|
||||
return `$ ${sum / 100} / ${occurrence} months`;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{!stripeCheckoutUrl ? (
|
||||
<Form
|
||||
form={newLicenseKeyFormMethods}
|
||||
className="stack-y-5"
|
||||
id="createOrg"
|
||||
handleSubmit={(values) => {
|
||||
mutation.mutate(values);
|
||||
}}>
|
||||
<div>
|
||||
{serverErrorMessage && (
|
||||
<div className="mb-5">
|
||||
<Alert severity="error" message={serverErrorMessage} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="mb-5">
|
||||
<Controller
|
||||
name="billingPeriod"
|
||||
control={newLicenseKeyFormMethods.control}
|
||||
render={({ field: { value, onChange } }) => (
|
||||
<>
|
||||
<Label htmlFor="billingPeriod">Billing Period</Label>
|
||||
<ToggleGroup
|
||||
isFullWidth
|
||||
id="billingPeriod"
|
||||
defaultValue={value}
|
||||
onValueChange={(e) => onChange(e)}
|
||||
options={[
|
||||
{
|
||||
value: "MONTHLY",
|
||||
label: "Monthly",
|
||||
},
|
||||
{
|
||||
value: "ANNUALLY",
|
||||
label: "Annually",
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Controller
|
||||
name="billingEmail"
|
||||
control={newLicenseKeyFormMethods.control}
|
||||
rules={{
|
||||
required: t("must_enter_billing_email"),
|
||||
}}
|
||||
render={({ field: { value, onChange } }) => (
|
||||
<div className="flex">
|
||||
<TextField
|
||||
containerClassName="w-full"
|
||||
placeholder="[email protected]"
|
||||
name="billingEmail"
|
||||
disabled={!isAdmin}
|
||||
label="Billing Email for Customer"
|
||||
defaultValue={value}
|
||||
onChange={onChange}
|
||||
autoComplete="off"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Controller
|
||||
name="billingType"
|
||||
control={newLicenseKeyFormMethods.control}
|
||||
render={({ field: { value, onChange } }) => (
|
||||
<>
|
||||
<Label htmlFor="bookingType">Booking Type</Label>
|
||||
<ToggleGroup
|
||||
isFullWidth
|
||||
id="bookingType"
|
||||
defaultValue={value}
|
||||
onValueChange={(e) => onChange(e)}
|
||||
options={[
|
||||
{
|
||||
value: "PER_BOOKING",
|
||||
label: "Per Booking",
|
||||
tooltip: "Configure pricing on a per booking basis",
|
||||
},
|
||||
{
|
||||
value: "PER_USER",
|
||||
label: "Per User",
|
||||
tooltip: "Configure pricing on a per user basis",
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap gap-2 *:flex-1">
|
||||
<Controller
|
||||
name="entityCount"
|
||||
control={newLicenseKeyFormMethods.control}
|
||||
rules={{
|
||||
required: "Must enter a total of billable users",
|
||||
}}
|
||||
render={({ field: { value, onChange } }) => (
|
||||
<TextField
|
||||
className="mt-2"
|
||||
name="entityCount"
|
||||
label="Total entities included"
|
||||
placeholder="100"
|
||||
defaultValue={value}
|
||||
onChange={(event) => onChange(+event.target.value)}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
name="entityPrice"
|
||||
control={newLicenseKeyFormMethods.control}
|
||||
rules={{
|
||||
required: "Must enter fixed price per user",
|
||||
}}
|
||||
render={({ field: { value, onChange } }) => (
|
||||
<TextField
|
||||
className="mt-2"
|
||||
name="entityPrice"
|
||||
label="Fixed price per entity"
|
||||
addOnSuffix="$"
|
||||
defaultValue={value / 100}
|
||||
onChange={(event) => onChange(+event.target.value * 100)}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Controller
|
||||
name="overages"
|
||||
control={newLicenseKeyFormMethods.control}
|
||||
rules={{
|
||||
required: "Must enter overages",
|
||||
}}
|
||||
render={({ field: { value, onChange } }) => (
|
||||
<>
|
||||
<TextField
|
||||
className="mt-2"
|
||||
placeholder="Acme"
|
||||
name="overages"
|
||||
addOnSuffix="$"
|
||||
label="Overages"
|
||||
disabled={!isAdmin}
|
||||
defaultValue={value / 100}
|
||||
onChange={(event) => onChange(+event.target.value * 100)}
|
||||
autoComplete="off"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex space-x-2 rtl:space-x-reverse">
|
||||
<Button
|
||||
disabled={newLicenseKeyFormMethods.formState.isSubmitting}
|
||||
color="primary"
|
||||
type="submit"
|
||||
form="createOrg"
|
||||
loading={mutation.isPending}
|
||||
className="w-full justify-center">
|
||||
{t("continue")} - {calculateMonthlyPrice()}
|
||||
</Button>
|
||||
</div>
|
||||
</Form>
|
||||
) : (
|
||||
<div className="w-full">
|
||||
<div className="">
|
||||
<TextField className="flex-1" disabled value={stripeCheckoutUrl} />
|
||||
</div>
|
||||
|
||||
<div className="mt-4 flex gap-2 *:flex-1 *:justify-center">
|
||||
<Button
|
||||
color="secondary"
|
||||
onClick={() => {
|
||||
newLicenseKeyFormMethods.reset();
|
||||
setStripeCheckoutUrl(null);
|
||||
}}>
|
||||
Back
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -8,8 +8,8 @@ import { useForm } from "react-hook-form";
|
||||
import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner";
|
||||
import BrandColorsForm from "~/ee/common/components/BrandColorsForm";
|
||||
import { AppearanceSkeletonLoader } from "~/ee/common/components/CommonSkeletonLoaders";
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/SectionBottomActions";
|
||||
import ThemeLabel from "@calcom/web/modules/settings/components/ThemeLabel";
|
||||
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
|
||||
import ThemeLabel from "@calcom/features/settings/ThemeLabel";
|
||||
import { DEFAULT_LIGHT_BRAND_COLOR, DEFAULT_DARK_BRAND_COLOR } from "@calcom/lib/constants";
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { FeaturesSettings } from "@calcom/features/feature-opt-in/components/FeaturesSettings";
|
||||
import SettingsHeader from "@calcom/web/modules/settings/components/SettingsHeader";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { ReactElement } from "react";
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import { DisableAutofillOnBookingPageSwitch } from "~/ee/organizations/component
|
||||
import { DisablePhoneOnlySMSNotificationsSwitch } from "~/ee/organizations/components/DisablePhoneOnlySMSNotificationsSwitch";
|
||||
import { LockEventTypeSwitch } from "~/ee/organizations/components/LockEventTypeSwitch";
|
||||
import { NoSlotsNotificationSwitch } from "~/ee/organizations/components/NoSlotsNotificationSwitch";
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/SectionBottomActions";
|
||||
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { nameOfDay } from "@calcom/lib/weekday";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
|
||||
@@ -9,7 +9,7 @@ import { z } from "zod";
|
||||
import LicenseRequired from "~/ee/common/components/LicenseRequired";
|
||||
import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider";
|
||||
import { subdomainSuffix } from "@calcom/features/ee/organizations/lib/orgDomains";
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/SectionBottomActions";
|
||||
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
|
||||
import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { md } from "@calcom/lib/markdownIt";
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useMemo } from "react";
|
||||
import { useForm, useFieldArray, Controller } from "react-hook-form";
|
||||
|
||||
import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner";
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/SectionBottomActions";
|
||||
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { useForm } from "react-hook-form";
|
||||
|
||||
import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner";
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/SectionBottomActions";
|
||||
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { RRResetInterval, RRTimestampBasis } from "@calcom/prisma/enums";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
|
||||
@@ -7,8 +7,8 @@ import { useForm } from "react-hook-form";
|
||||
import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner";
|
||||
import BrandColorsForm from "~/ee/common/components/BrandColorsForm";
|
||||
import { AppearanceSkeletonLoader } from "~/ee/common/components/CommonSkeletonLoaders";
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/SectionBottomActions";
|
||||
import ThemeLabel from "@calcom/web/modules/settings/components/ThemeLabel";
|
||||
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
|
||||
import ThemeLabel from "@calcom/features/settings/ThemeLabel";
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
import { DEFAULT_LIGHT_BRAND_COLOR, DEFAULT_DARK_BRAND_COLOR } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
|
||||
@@ -12,7 +12,7 @@ import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner";
|
||||
import { Dialog } from "@calcom/features/components/controlled-dialog";
|
||||
import { getTeamUrlSync } from "@calcom/features/ee/organizations/lib/getTeamUrlSync";
|
||||
import { trackFormbricksAction } from "@calcom/web/modules/formbricks/lib/trackFormbricksAction";
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/SectionBottomActions";
|
||||
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
|
||||
import { IS_TEAM_BILLING_ENABLED, WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
|
||||
@@ -7,7 +7,7 @@ import { useForm, Controller } from "react-hook-form";
|
||||
|
||||
import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner";
|
||||
import { AppearanceSkeletonLoader } from "~/ee/common/components/CommonSkeletonLoaders";
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/SectionBottomActions";
|
||||
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { useParamsWithFallback } from "@calcom/lib/hooks/useParamsWithFallback";
|
||||
import type { IntervalLimit } from "@calcom/lib/intervalLimits/intervalLimitSchema";
|
||||
|
||||
@@ -54,21 +54,19 @@ import { HorizontalTabs } from "@calcom/ui/components/navigation";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
import { useBookerTime } from "@calcom/features/bookings/Booker/hooks/useBookerTime";
|
||||
import { EmbedTabName, type tabs } from "./EmbedTabs";
|
||||
import { EmbedTabName } from "@calcom/features/embed/lib/EmbedTabs";
|
||||
import { buildCssVarsPerTheme } from "@calcom/features/embed/lib/buildCssVarsPerTheme";
|
||||
import { EmbedTheme } from "@calcom/features/embed/lib/constants";
|
||||
import { getDimension } from "@calcom/features/embed/lib/getDimension";
|
||||
import { useEmbedDialogCtx } from "@calcom/features/embed/lib/hooks/useEmbedDialogCtx";
|
||||
import { useEmbedParams } from "@calcom/features/embed/lib/hooks/useEmbedParams";
|
||||
import type {
|
||||
EmbedTabs,
|
||||
EmbedType,
|
||||
EmbedTypes,
|
||||
PreviewState,
|
||||
EmbedConfig,
|
||||
} from "@calcom/features/embed/types";
|
||||
import { useEmbedTypes } from "../hooks/useEmbedTypes";
|
||||
|
||||
type EmbedTypes = ReturnType<typeof useEmbedTypes>;
|
||||
type EmbedTabs = typeof tabs;
|
||||
|
||||
type EventType =
|
||||
| RouterOutputs["viewer"]["eventTypes"]["get"]["eventType"]
|
||||
|
||||
@@ -1,341 +0,0 @@
|
||||
import type { MutableRefObject } from "react";
|
||||
import { forwardRef } from "react";
|
||||
|
||||
import type { BookerLayout } from "@calcom/features/bookings/Booker/types";
|
||||
import { useEmbedBookerUrl } from "../../bookings/hooks/useBookerUrl";
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { TextArea } from "@calcom/ui/components/form";
|
||||
|
||||
import type { EmbedFramework, EmbedType, PreviewState } from "@calcom/features/embed/types";
|
||||
import { Codes } from "@calcom/features/embed/lib/EmbedCodes";
|
||||
import { buildCssVarsPerTheme } from "@calcom/features/embed/lib/buildCssVarsPerTheme";
|
||||
import { embedLibUrl, EMBED_PREVIEW_HTML_URL } from "@calcom/features/embed/lib/constants";
|
||||
import { getApiNameForReactSnippet, getApiNameForVanillaJsSnippet } from "@calcom/features/embed/lib/getApiName";
|
||||
import { getDimension } from "@calcom/features/embed/lib/getDimension";
|
||||
import { useEmbedCalOrigin } from "../hooks/useEmbedCalOrigin";
|
||||
|
||||
export const enum EmbedTabName {
|
||||
HTML = "embed-code",
|
||||
IFRAME_REACT = "embed-react",
|
||||
ATOM_REACT = "embed-atom-react",
|
||||
}
|
||||
|
||||
export const tabs = [
|
||||
{
|
||||
name: "HTML (iframe)",
|
||||
href: "embedTabName=embed-code",
|
||||
icon: "code" as const,
|
||||
type: "code",
|
||||
"data-testid": "HTML",
|
||||
Component: forwardRef<
|
||||
HTMLTextAreaElement | HTMLIFrameElement | null,
|
||||
{ embedType: EmbedType; calLink: string; previewState: PreviewState; namespace: string }
|
||||
>(function EmbedHtml({ embedType, calLink, previewState, namespace }, ref) {
|
||||
const { t } = useLocale();
|
||||
const embedSnippetString = useGetEmbedSnippetString(namespace);
|
||||
const embedCalOrigin = useEmbedCalOrigin();
|
||||
if (ref instanceof Function || !ref) {
|
||||
return null;
|
||||
}
|
||||
if (ref.current && !(ref.current instanceof HTMLTextAreaElement)) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<small className="text-subtle flex py-2">
|
||||
{t("place_where_cal_widget_appear", { appName: APP_NAME })}
|
||||
</small>
|
||||
</div>
|
||||
<TextArea
|
||||
data-testid="embed-code"
|
||||
ref={ref as typeof ref & MutableRefObject<HTMLTextAreaElement>}
|
||||
name="embed-code"
|
||||
className="text-default bg-default h-[calc(100%-50px)] font-mono"
|
||||
style={{ resize: "none", overflow: "auto" }}
|
||||
readOnly
|
||||
value={`<!-- Cal ${embedType} embed code begins -->\n${
|
||||
embedType === "inline"
|
||||
? `<div style="width:${getDimension(previewState.inline.width)};height:${getDimension(
|
||||
previewState.inline.height
|
||||
)};overflow:scroll" id="my-cal-inline-${namespace}"></div>\n`
|
||||
: ""
|
||||
}<script type="text/javascript">
|
||||
${embedSnippetString}
|
||||
${getEmbedTypeSpecificString({
|
||||
embedFramework: "HTML",
|
||||
embedType,
|
||||
calLink,
|
||||
previewState,
|
||||
embedCalOrigin,
|
||||
namespace,
|
||||
})}
|
||||
</script>
|
||||
<!-- Cal ${embedType} embed code ends -->`}
|
||||
/>
|
||||
<p className="text-subtle hidden text-sm">{t("need_help_embedding")}</p>
|
||||
</>
|
||||
);
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "React (iframe)",
|
||||
href: "embedTabName=embed-react",
|
||||
"data-testid": "react",
|
||||
icon: "code" as const,
|
||||
type: "code",
|
||||
Component: forwardRef<
|
||||
HTMLTextAreaElement | HTMLIFrameElement | null,
|
||||
{ embedType: EmbedType; calLink: string; previewState: PreviewState; namespace: string }
|
||||
>(function EmbedReact({ embedType, calLink, previewState, namespace }, ref) {
|
||||
const { t } = useLocale();
|
||||
const embedCalOrigin = useEmbedCalOrigin();
|
||||
|
||||
if (ref instanceof Function || !ref) {
|
||||
return null;
|
||||
}
|
||||
if (ref.current && !(ref.current instanceof HTMLTextAreaElement)) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<small className="text-subtle flex py-2">{t("create_update_react_component")}</small>
|
||||
<TextArea
|
||||
data-testid="embed-react"
|
||||
ref={ref as typeof ref & MutableRefObject<HTMLTextAreaElement>}
|
||||
name="embed-react"
|
||||
className="text-default bg-default h-[calc(100%-50px)] font-mono"
|
||||
readOnly
|
||||
style={{ resize: "none", overflow: "auto" }}
|
||||
value={`/* First make sure that you have installed the package */
|
||||
|
||||
/* If you are using yarn */
|
||||
// yarn add @calcom/embed-react
|
||||
|
||||
/* If you are using npm */
|
||||
// npm install @calcom/embed-react
|
||||
${getEmbedTypeSpecificString({
|
||||
embedFramework: "react",
|
||||
embedType,
|
||||
calLink,
|
||||
previewState,
|
||||
embedCalOrigin,
|
||||
namespace,
|
||||
})}
|
||||
`}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "React (Atom)",
|
||||
href: `embedTabName=${EmbedTabName.ATOM_REACT}`,
|
||||
"data-testid": "react-atom",
|
||||
icon: "code" as const,
|
||||
type: "code",
|
||||
Component: forwardRef<
|
||||
HTMLTextAreaElement | HTMLIFrameElement | null,
|
||||
{ embedType: EmbedType; calLink: string; previewState: PreviewState; namespace: string }
|
||||
>(function EmbedReactAtom({ embedType, calLink, previewState, namespace }, ref) {
|
||||
const { t } = useLocale();
|
||||
const embedCalOrigin = useEmbedCalOrigin();
|
||||
|
||||
if (ref instanceof Function || !ref) {
|
||||
return null;
|
||||
}
|
||||
if (ref.current && !(ref.current instanceof HTMLTextAreaElement)) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<small className="text-subtle flex py-2">{t("create_update_react_component")}</small>
|
||||
<TextArea
|
||||
data-testid={`${EmbedTabName.ATOM_REACT}`}
|
||||
ref={ref as typeof ref & MutableRefObject<HTMLTextAreaElement>}
|
||||
name={`${EmbedTabName.ATOM_REACT}`}
|
||||
className="text-default bg-default h-[calc(100%-50px)] font-mono"
|
||||
readOnly
|
||||
style={{ resize: "none", overflow: "auto" }}
|
||||
value={`/* First make sure that you have installed the package */
|
||||
|
||||
/* If you are using yarn */
|
||||
// yarn add @calcom/atoms
|
||||
|
||||
/* If you are using npm */
|
||||
// npm install @calcom/atoms
|
||||
${getEmbedTypeSpecificString({
|
||||
embedFramework: "react-atom" as EmbedFramework,
|
||||
embedType,
|
||||
calLink,
|
||||
previewState,
|
||||
embedCalOrigin,
|
||||
namespace,
|
||||
})}`}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "Preview",
|
||||
href: "embedTabName=embed-preview",
|
||||
icon: "trello" as const,
|
||||
type: "iframe",
|
||||
"data-testid": "Preview",
|
||||
Component: forwardRef<
|
||||
HTMLIFrameElement | HTMLTextAreaElement | null,
|
||||
{ calLink: string; embedType: EmbedType; previewState: PreviewState; namespace: string }
|
||||
>(function Preview({ calLink, embedType }, ref) {
|
||||
const bookerUrl = useEmbedBookerUrl();
|
||||
const iframeSrc = `${EMBED_PREVIEW_HTML_URL}?embedType=${embedType}&calLink=${calLink}&embedLibUrl=${embedLibUrl}&bookerUrl=${bookerUrl}`;
|
||||
if (ref instanceof Function || !ref) {
|
||||
return null;
|
||||
}
|
||||
if (ref.current && !(ref.current instanceof HTMLIFrameElement)) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<iframe
|
||||
ref={ref as typeof ref & MutableRefObject<HTMLIFrameElement>}
|
||||
data-testid="embed-preview"
|
||||
className="rounded-md border"
|
||||
width="100%"
|
||||
height="100%"
|
||||
src={iframeSrc}
|
||||
key={iframeSrc}
|
||||
/>
|
||||
);
|
||||
}),
|
||||
},
|
||||
];
|
||||
|
||||
const getEmbedTypeSpecificString = ({
|
||||
embedFramework,
|
||||
embedType,
|
||||
calLink,
|
||||
embedCalOrigin,
|
||||
previewState,
|
||||
namespace,
|
||||
}: {
|
||||
embedFramework: EmbedFramework;
|
||||
embedType: EmbedType;
|
||||
calLink: string;
|
||||
previewState: PreviewState;
|
||||
embedCalOrigin: string;
|
||||
namespace: string;
|
||||
}) => {
|
||||
const frameworkCodes = Codes[embedFramework];
|
||||
if (!frameworkCodes) {
|
||||
throw new Error(`No code available for the framework:${embedFramework}`);
|
||||
}
|
||||
if (embedType === "email") return "";
|
||||
let uiInstructionStringArg: {
|
||||
apiName: string;
|
||||
theme: PreviewState["theme"];
|
||||
brandColor: string | null;
|
||||
darkBrandColor: string | null;
|
||||
hideEventTypeDetails: boolean;
|
||||
layout?: BookerLayout;
|
||||
};
|
||||
const baseUiInstructionStringArg = {
|
||||
theme: previewState.theme,
|
||||
brandColor: previewState.palette.brandColor,
|
||||
darkBrandColor: previewState.palette.darkBrandColor,
|
||||
hideEventTypeDetails: previewState.hideEventTypeDetails,
|
||||
layout: previewState.layout,
|
||||
};
|
||||
if (embedFramework === "react") {
|
||||
uiInstructionStringArg = {
|
||||
...baseUiInstructionStringArg,
|
||||
apiName: getApiNameForReactSnippet({ mainApiName: "cal" }),
|
||||
};
|
||||
} else {
|
||||
uiInstructionStringArg = {
|
||||
...baseUiInstructionStringArg,
|
||||
apiName: getApiNameForVanillaJsSnippet({ namespace, mainApiName: "Cal" }),
|
||||
};
|
||||
}
|
||||
if (!frameworkCodes[embedType]) {
|
||||
throw new Error(`Code not available for framework:${embedFramework} and embedType:${embedType}`);
|
||||
}
|
||||
|
||||
const codeGeneratorInput = {
|
||||
calLink,
|
||||
uiInstructionCode: getEmbedUIInstructionString(uiInstructionStringArg),
|
||||
embedCalOrigin,
|
||||
namespace,
|
||||
};
|
||||
|
||||
if (embedType === "inline") {
|
||||
return frameworkCodes[embedType]({
|
||||
...codeGeneratorInput,
|
||||
previewState: previewState.inline,
|
||||
});
|
||||
} else if (embedType === "floating-popup") {
|
||||
return frameworkCodes[embedType]({
|
||||
...codeGeneratorInput,
|
||||
previewState: previewState.floatingPopup,
|
||||
});
|
||||
} else if (embedType === "element-click") {
|
||||
return frameworkCodes[embedType]({
|
||||
...codeGeneratorInput,
|
||||
previewState: previewState.elementClick,
|
||||
});
|
||||
} else if (embedType === "headless") {
|
||||
return frameworkCodes[embedType]();
|
||||
}
|
||||
return "";
|
||||
};
|
||||
|
||||
const getEmbedUIInstructionString = ({
|
||||
apiName,
|
||||
theme,
|
||||
brandColor,
|
||||
darkBrandColor,
|
||||
hideEventTypeDetails,
|
||||
layout,
|
||||
}: {
|
||||
apiName: string;
|
||||
theme?: string;
|
||||
brandColor: string | null;
|
||||
darkBrandColor: string | null;
|
||||
hideEventTypeDetails: boolean;
|
||||
layout?: string;
|
||||
}) => {
|
||||
theme = theme !== "auto" ? theme : undefined;
|
||||
|
||||
return getInstructionString({
|
||||
apiName,
|
||||
instructionName: "ui",
|
||||
instructionArg: {
|
||||
theme,
|
||||
cssVarsPerTheme: buildCssVarsPerTheme({ brandColor, darkBrandColor }),
|
||||
hideEventTypeDetails,
|
||||
layout,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const getInstructionString = ({
|
||||
apiName,
|
||||
instructionName,
|
||||
instructionArg,
|
||||
}: {
|
||||
apiName: string;
|
||||
instructionName: string;
|
||||
instructionArg: Record<string, unknown>;
|
||||
}) => {
|
||||
return `${apiName}("${instructionName}", ${JSON.stringify(instructionArg)});`;
|
||||
};
|
||||
|
||||
function useGetEmbedSnippetString(namespace: string | null) {
|
||||
const bookerUrl = useEmbedBookerUrl();
|
||||
// TODO: Import this string from @calcom/embed-snippet
|
||||
// Right now the problem is that embed-snippet export is not minified and has comments which makes it unsuitable for giving it to users.
|
||||
// If we can minify that during build time and then import the built code here, that could work
|
||||
return `(function (C, A, L) { let p = function (a, ar) { a.q.push(ar); }; let d = C.document; C.Cal = C.Cal || function () { let cal = C.Cal; let ar = arguments; if (!cal.loaded) { cal.ns = {}; cal.q = cal.q || []; d.head.appendChild(d.createElement("script")).src = A; cal.loaded = true; } if (ar[0] === L) { const api = function () { p(api, arguments); }; const namespace = ar[1]; api.q = api.q || []; if(typeof namespace === "string"){cal.ns[namespace] = cal.ns[namespace] || api;p(cal.ns[namespace], ar);p(cal, ["initNamespace", namespace]);} else p(cal, ar); return;} p(cal, ar); }; })(window, "${embedLibUrl}", "init");
|
||||
Cal("init", ${namespace ? `"${namespace}",` : ""} {origin:"${bookerUrl}"});
|
||||
`;
|
||||
}
|
||||
@@ -3,8 +3,8 @@ import type { ComponentProps } from "react";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
|
||||
import { EmbedButton, EmbedDialog } from "./Embed";
|
||||
import { tabs } from "./EmbedTabs";
|
||||
import { useEmbedTypes } from "../hooks/useEmbedTypes";
|
||||
import { tabs } from "@calcom/features/embed/lib/EmbedTabs";
|
||||
import { useEmbedTypes } from "@calcom/features/embed/lib/hooks";
|
||||
|
||||
export const EventTypeEmbedDialog = () => {
|
||||
const types = useEmbedTypes();
|
||||
|
||||
@@ -5,8 +5,8 @@ import { IS_CALCOM } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
|
||||
import { tabs } from "./EmbedTabs";
|
||||
import { useEmbedTypes } from "../hooks/useEmbedTypes";
|
||||
import { tabs } from "@calcom/features/embed/lib/EmbedTabs";
|
||||
import { useEmbedTypes } from "@calcom/features/embed/lib/hooks";
|
||||
|
||||
export const RoutingFormEmbedDialog = () => {
|
||||
const types = useEmbedTypes();
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import { useEmbedBookerUrl } from "~/bookings/hooks/useBookerUrl";
|
||||
|
||||
export const useEmbedCalOrigin = () => {
|
||||
const bookerUrl = useEmbedBookerUrl();
|
||||
return bookerUrl;
|
||||
};
|
||||
|
||||
@@ -1,318 +0,0 @@
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
|
||||
export const useEmbedTypes = () => {
|
||||
const { t } = useLocale();
|
||||
return [
|
||||
{
|
||||
title: t("inline_embed"),
|
||||
subtitle: t("load_inline_content"),
|
||||
type: "inline",
|
||||
illustration: (
|
||||
<svg
|
||||
width="100%"
|
||||
height="100%"
|
||||
className="rounded-md"
|
||||
viewBox="0 0 308 265"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M0 1.99999C0 0.895423 0.895431 0 2 0H306C307.105 0 308 0.895431 308 2V263C308 264.105 307.105 265 306 265H2C0.895431 265 0 264.105 0 263V1.99999Z"
|
||||
fill="white"
|
||||
/>
|
||||
<rect x="24" width="260" height="38.5" rx="6" fill="#F3F4F6" />
|
||||
<rect x="24.5" y="51" width="139" height="163" rx="1.5" fill="#F8F8F8" />
|
||||
<rect opacity="0.8" x="48" y="74.5" width="80" height="8" rx="6" fill="#F3F4F6" />
|
||||
<rect x="48" y="86.5" width="48" height="4" rx="6" fill="#F3F4F6" />
|
||||
<rect x="49" y="99.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="61" y="99.5" width="6" height="6" rx="1" fill="#3E3E3E" />
|
||||
<rect x="73" y="99.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="85" y="99.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="97" y="99.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="109" y="99.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="121" y="99.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="133" y="99.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="85" y="113.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="97" y="113.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="109" y="113.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="121" y="113.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="133" y="113.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="49" y="125.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="61" y="125.5" width="6" height="6" rx="1" fill="#3E3E3E" />
|
||||
<path
|
||||
d="M61 124.5H67V122.5H61V124.5ZM68 125.5V131.5H70V125.5H68ZM67 132.5H61V134.5H67V132.5ZM60 131.5V125.5H58V131.5H60ZM61 132.5C60.4477 132.5 60 132.052 60 131.5H58C58 133.157 59.3431 134.5 61 134.5V132.5ZM68 131.5C68 132.052 67.5523 132.5 67 132.5V134.5C68.6569 134.5 70 133.157 70 131.5H68ZM67 124.5C67.5523 124.5 68 124.948 68 125.5H70C70 123.843 68.6569 122.5 67 122.5V124.5ZM61 122.5C59.3431 122.5 58 123.843 58 125.5H60C60 124.948 60.4477 124.5 61 124.5V122.5Z"
|
||||
fill="#3E3E3E"
|
||||
/>
|
||||
<rect x="73" y="125.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="85" y="125.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="97" y="125.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="109" y="125.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="121" y="125.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="133" y="125.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="49" y="137.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="61" y="137.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="73" y="137.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="85" y="137.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="97" y="137.5" width="6" height="6" rx="1" fill="#3E3E3E" />
|
||||
<rect x="109" y="137.5" width="6" height="6" rx="1" fill="#3E3E3E" />
|
||||
<rect x="121" y="137.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="133" y="137.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="49" y="149.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="61" y="149.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="73" y="149.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="85" y="149.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="97" y="149.5" width="6" height="6" rx="1" fill="#3E3E3E" />
|
||||
<rect x="109" y="149.5" width="6" height="6" rx="1" fill="#3E3E3E" />
|
||||
<rect x="121" y="149.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="133" y="149.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="49" y="161.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="61" y="161.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="73" y="161.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="85" y="161.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="97" y="161.5" width="6" height="6" rx="1" fill="#3E3E3E" />
|
||||
<rect x="109" y="161.5" width="6" height="6" rx="1" fill="#C6C6C6" />
|
||||
<rect x="24.5" y="51" width="139" height="163" rx="6" stroke="#292929" />
|
||||
<rect x="176" y="50.5" width="108" height="164" rx="6" fill="#F3F4F6" />
|
||||
<rect x="24" y="226.5" width="260" height="38.5" rx="6" fill="#F3F4F6" />
|
||||
</svg>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t("floating_pop_up_button"),
|
||||
subtitle: t("floating_button_trigger_modal"),
|
||||
type: "floating-popup",
|
||||
illustration: (
|
||||
<svg
|
||||
width="100%"
|
||||
height="100%"
|
||||
className="rounded-md"
|
||||
viewBox="0 0 308 265"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M0 1.99999C0 0.895423 0.895431 0 2 0H306C307.105 0 308 0.895431 308 2V263C308 264.105 307.105 265 306 265H2C0.895431 265 0 264.105 0 263V1.99999Z"
|
||||
fill="white"
|
||||
/>
|
||||
<rect x="24" width="260" height="38.5" rx="6" fill="#F3F4F6" />
|
||||
<rect x="24" y="50.5" width="120" height="76" rx="6" fill="#F3F4F6" />
|
||||
<rect x="24" y="138.5" width="120" height="76" rx="6" fill="#F3F4F6" />
|
||||
<rect x="156" y="50.5" width="128" height="164" rx="6" fill="#F3F4F6" />
|
||||
<rect x="24" y="226.5" width="260" height="38.5" rx="6" fill="#F3F4F6" />
|
||||
<rect x="226" y="223.5" width="66" height="26" rx="6" fill="#292929" />
|
||||
<rect x="242" y="235.5" width="34" height="2" rx="1" fill="white" />
|
||||
</svg>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t("pop_up_element_click"),
|
||||
subtitle: t("open_dialog_with_element_click"),
|
||||
type: "element-click",
|
||||
illustration: (
|
||||
<svg
|
||||
width="100%"
|
||||
height="100%"
|
||||
className="rounded-md"
|
||||
viewBox="0 0 308 265"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M0 1.99999C0 0.895423 0.895431 0 2 0H306C307.105 0 308 0.895431 308 2V263C308 264.105 307.105 265 306 265H2C0.895431 265 0 264.105 0 263V1.99999Z"
|
||||
fill="white"
|
||||
/>
|
||||
<rect x="24" y="0.50293" width="260" height="24" rx="6" fill="#F3F4F6" />
|
||||
<rect x="24" y="35" width="259" height="192" rx="5.5" fill="#F9FAFB" />
|
||||
<g filter="url(#filter0_i_3223_14162)">
|
||||
<rect opacity="0.8" x="40" y="99" width="24" height="24" rx="2" fill="#E5E7EB" />
|
||||
<rect x="40" y="127" width="48" height="8" rx="1" fill="#E5E7EB" />
|
||||
<rect x="40" y="139" width="82" height="8" rx="1" fill="#E5E7EB" />
|
||||
<rect x="40" y="151" width="34" height="4" rx="1" fill="#E5E7EB" />
|
||||
<rect x="40" y="159" width="34" height="4" rx="1" fill="#E5E7EB" />
|
||||
</g>
|
||||
<rect x="152" y="48" width="2" height="169" rx="2" fill="#E5E7EB" />
|
||||
|
||||
<rect opacity="0.8" x="176" y="84" width="80" height="8" rx="2" fill="#E5E7EB" />
|
||||
<rect x="176" y="96" width="48" height="4" rx="1" fill="#E5E7EB" />
|
||||
<rect x="177" y="109" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="189" y="109" width="6" height="6" rx="1" fill="#0D121D" />
|
||||
<rect x="201" y="109" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="213" y="109" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="225" y="109" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="237" y="109" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="249" y="109" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="261" y="109" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="213" y="123" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="225" y="123" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="237" y="123" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="249" y="123" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="261" y="123" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="177" y="135" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="189" y="135" width="6" height="6" rx="1" fill="#0D121D" />
|
||||
<rect x="187.3" y="133.4" width="9" height="9" rx="1.5" stroke="#0D121D" />
|
||||
<rect x="201" y="135" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="213" y="135" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="225" y="135" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="237" y="135" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="249" y="135" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="261" y="135" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="177" y="147" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="189" y="147" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="201" y="147" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="213" y="147" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="225" y="147" width="6" height="6" rx="1" fill="#0D121D" />
|
||||
<rect x="237" y="147" width="6" height="6" rx="1" fill="#0D121D" />
|
||||
<rect x="249" y="147" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="261" y="147" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="177" y="159" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="189" y="159" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="201" y="159" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="213" y="159" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="225" y="159" width="6" height="6" rx="1" fill="#0D121D" />
|
||||
<rect x="237" y="159" width="6" height="6" rx="1" fill="#0D121D" />
|
||||
<rect x="249" y="159" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="261" y="159" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="177" y="171" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="189" y="171" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="201" y="171" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="213" y="171" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="225" y="171" width="6" height="6" rx="1" fill="#0D121D" />
|
||||
<rect x="237" y="171" width="6" height="6" rx="1" fill="#E5E7EB" />
|
||||
<rect x="24" y="35" width="259" height="192" rx="5.5" stroke="#101010" />
|
||||
<rect x="24" y="241.503" width="260" height="24" rx="6" fill="#F3F4F6" />
|
||||
</svg>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t("email_embed"),
|
||||
subtitle: t("add_times_to_your_email"),
|
||||
type: "email",
|
||||
illustration: (
|
||||
<svg
|
||||
width="100%"
|
||||
height="100%"
|
||||
className="rounded-md"
|
||||
viewBox="0 0 308 265"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_457_1339)">
|
||||
<rect width="308" height="265" rx="8" fill="white" />
|
||||
<rect width="308" height="18" rx="4" fill="#F3F4F6" />
|
||||
<rect y="19" width="308" height="18" rx="4" fill="#F3F4F6" />
|
||||
<rect y="38" width="308" height="18" rx="4" fill="#F3F4F6" />
|
||||
<rect y="57" width="308" height="18" rx="4" fill="#F3F4F6" />
|
||||
<rect y="76" width="308" height="18" rx="4" fill="#F3F4F6" />
|
||||
<rect y="95" width="308" height="18" rx="4" fill="#F3F4F6" />
|
||||
<rect y="114" width="308" height="18" rx="4" fill="#F3F4F6" />
|
||||
<rect y="133" width="308" height="18" rx="4" fill="#F3F4F6" />
|
||||
<rect y="152" width="308" height="18" rx="4" fill="#F3F4F6" />
|
||||
<rect y="171" width="308" height="18" rx="4" fill="#F3F4F6" />
|
||||
<rect y="190" width="308" height="18" rx="4" fill="#F3F4F6" />
|
||||
<rect y="209" width="308" height="18" rx="4" fill="#F3F4F6" />
|
||||
<rect y="228" width="308" height="18" rx="4" fill="#F3F4F6" />
|
||||
<rect y="247" width="308" height="18" rx="4" fill="#F3F4F6" />
|
||||
<g clip-path="url(#clip1_457_1339)">
|
||||
<rect x="107" y="64" width="189" height="189" rx="6" fill="white" />
|
||||
<g clip-path="url(#clip2_457_1339)">
|
||||
<path
|
||||
d="M124.671 75.5243C124.671 75.1018 124.325 74.756 123.902 74.756H117.756C117.334 74.756 116.988 75.1018 116.988 75.5243M124.671 75.5243V80.1341C124.671 80.5567 124.325 80.9024 123.902 80.9024H117.756C117.334 80.9024 116.988 80.5567 116.988 80.1341V75.5243M124.671 75.5243L120.829 78.2134L116.988 75.5243"
|
||||
stroke="#9CA3AF"
|
||||
stroke-width="1.15244"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</g>
|
||||
<rect x="130.049" y="75.5244" width="92.1951" height="4.60976" rx="2.30488" fill="#D1D5DB" />
|
||||
<rect x="130.049" y="84.7439" width="55.3171" height="4.60976" rx="2.30488" fill="#E5E7EB" />
|
||||
<rect
|
||||
opacity="0.8"
|
||||
x="107"
|
||||
y="98.5732"
|
||||
width="189"
|
||||
height="1.15244"
|
||||
rx="0.576219"
|
||||
fill="#E5E7EB"
|
||||
/>
|
||||
<rect x="116.219" y="113.555" width="92.1951" height="4.60976" rx="2.30488" fill="#D1D5DB" />
|
||||
<rect x="116.219" y="122.774" width="42.6402" height="4.60976" rx="2.30488" fill="#E5E7EB" />
|
||||
<rect x="116.219" y="136.604" width="55.3171" height="4.60976" rx="2.30488" fill="#D1D5DB" />
|
||||
<rect x="116.719" y="145.171" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />
|
||||
<rect x="142.073" y="145.171" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />
|
||||
<rect x="167.427" y="145.171" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />
|
||||
<rect x="192.781" y="145.171" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />
|
||||
<rect x="218.134" y="145.171" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />
|
||||
<rect x="116.219" y="160.805" width="55.3171" height="4.60976" rx="2.30488" fill="#D1D5DB" />
|
||||
<rect x="116.719" y="169.372" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />
|
||||
<rect x="142.073" y="169.372" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />
|
||||
<rect x="167.427" y="169.372" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />
|
||||
<rect x="192.781" y="169.372" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />
|
||||
<rect x="218.134" y="169.372" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />
|
||||
<rect x="116.219" y="185.006" width="55.3171" height="4.60976" rx="2.30488" fill="#D1D5DB" />
|
||||
<rect x="116.719" y="193.573" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />
|
||||
<rect x="142.073" y="193.573" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />
|
||||
<rect x="167.427" y="193.573" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />
|
||||
<rect x="192.781" y="193.573" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />
|
||||
<rect x="218.134" y="193.573" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />
|
||||
<rect
|
||||
opacity="0.8"
|
||||
x="107"
|
||||
y="223.037"
|
||||
width="189"
|
||||
height="1.15244"
|
||||
rx="0.576219"
|
||||
fill="#E5E7EB"
|
||||
/>
|
||||
<rect width="189" height="28.811" transform="translate(107 224.189)" fill="#F9FAFB" />
|
||||
<rect x="116.219" y="233.985" width="23.0488" height="9.21951" rx="2.30488" fill="#9CA3AF" />
|
||||
<rect
|
||||
opacity="0.8"
|
||||
x="141.573"
|
||||
y="233.985"
|
||||
width="9.21951"
|
||||
height="9.21951"
|
||||
rx="2.30488"
|
||||
fill="#E5E7EB"
|
||||
/>
|
||||
<rect
|
||||
opacity="0.8"
|
||||
x="153.098"
|
||||
y="233.985"
|
||||
width="9.21951"
|
||||
height="9.21951"
|
||||
rx="2.30488"
|
||||
fill="#E5E7EB"
|
||||
/>
|
||||
<rect
|
||||
opacity="0.8"
|
||||
x="164.622"
|
||||
y="233.985"
|
||||
width="9.21951"
|
||||
height="9.21951"
|
||||
rx="2.30488"
|
||||
fill="#E5E7EB"
|
||||
/>
|
||||
</g>
|
||||
<rect
|
||||
x="106.424"
|
||||
y="63.4238"
|
||||
width="190.152"
|
||||
height="190.152"
|
||||
rx="6.57622"
|
||||
stroke="#101010"
|
||||
stroke-width="1.15244"
|
||||
/>
|
||||
</g>
|
||||
<rect x="0.5" y="0.5" width="307" height="264" rx="7.5" stroke="#E5E7EB" />
|
||||
<defs>
|
||||
<clipPath id="clip0_457_1339">
|
||||
<rect width="308" height="265" rx="8" fill="white" />
|
||||
</clipPath>
|
||||
<clipPath id="clip1_457_1339">
|
||||
<rect x="107" y="64" width="189" height="189" rx="6" fill="white" />
|
||||
</clipPath>
|
||||
<clipPath id="clip2_457_1339">
|
||||
<rect width="9.21951" height="9.21951" fill="white" transform="translate(116.219 73.2195)" />
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
),
|
||||
},
|
||||
];
|
||||
};
|
||||
@@ -6,7 +6,7 @@ import type {
|
||||
SettingsToggleClassNames,
|
||||
TeamMember,
|
||||
} from "@calcom/features/eventtypes/lib/types";
|
||||
import { Segment } from "@calcom/web/modules/event-types/components/Segment";
|
||||
import { Segment } from "@calcom/features/Segment";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { AttributesQueryValue } from "@calcom/lib/raqb/types";
|
||||
import { Label, SettingsToggle } from "@calcom/ui/components/form";
|
||||
|
||||
@@ -1,209 +0,0 @@
|
||||
import { render, screen, waitFor } from "@testing-library/react";
|
||||
import React from "react";
|
||||
import { describe, expect, it, vi, beforeEach } from "vitest";
|
||||
import type { Mock } from "vitest";
|
||||
|
||||
import { Segment } from "@calcom/web/modules/event-types/components/Segment";
|
||||
import type { AttributesQueryValue } from "@calcom/lib/raqb/types";
|
||||
import { AttributeType } from "@calcom/prisma/enums";
|
||||
import { trpc, type RouterOutputs } from "@calcom/trpc/react";
|
||||
|
||||
type Attributes = RouterOutputs["viewer"]["appRoutingForms"]["getAttributesForTeam"];
|
||||
type MatchingTeamMembersData = RouterOutputs["viewer"]["attributes"]["findTeamMembersMatchingAttributeLogic"];
|
||||
const mockGetAttributesForTeam = (
|
||||
arg: { data: Attributes; isPending: false } | { data: undefined; isPending: true }
|
||||
) => {
|
||||
(
|
||||
trpc.viewer.appRoutingForms.getAttributesForTeam.useQuery as Mock<
|
||||
typeof trpc.viewer.appRoutingForms.getAttributesForTeam.useQuery
|
||||
>
|
||||
)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
.mockReturnValue(arg as any);
|
||||
};
|
||||
|
||||
const mockGetMatchingTeamMembers = (
|
||||
arg:
|
||||
| {
|
||||
data: MatchingTeamMembersData;
|
||||
isPending: false;
|
||||
}
|
||||
| {
|
||||
data: undefined;
|
||||
isPending: true;
|
||||
}
|
||||
) => {
|
||||
(
|
||||
trpc.viewer.attributes.findTeamMembersMatchingAttributeLogic.useQuery as Mock<
|
||||
typeof trpc.viewer.attributes.findTeamMembersMatchingAttributeLogic.useQuery
|
||||
>
|
||||
)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
.mockReturnValue(arg as any);
|
||||
};
|
||||
|
||||
const mockAttributesWithSingleSelect = () => {
|
||||
return mockGetAttributesForTeam({
|
||||
data: [
|
||||
{
|
||||
id: "a",
|
||||
slug: "department",
|
||||
name: "Department",
|
||||
type: AttributeType.SINGLE_SELECT,
|
||||
isWeightsEnabled: false,
|
||||
options: [
|
||||
{ id: "1", value: "Sales", slug: "sales", contains: [], isGroup: false },
|
||||
{ id: "2", value: "Engineering", slug: "engineering", contains: [], isGroup: false },
|
||||
],
|
||||
},
|
||||
],
|
||||
isPending: false,
|
||||
});
|
||||
};
|
||||
|
||||
// Mock the TRPC hooks
|
||||
vi.mock("@calcom/trpc/react", () => ({
|
||||
trpc: {
|
||||
viewer: {
|
||||
appRoutingForms: {
|
||||
getAttributesForTeam: {
|
||||
useQuery: vi.fn(),
|
||||
},
|
||||
},
|
||||
attributes: {
|
||||
findTeamMembersMatchingAttributeLogic: {
|
||||
useQuery: vi.fn(),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
// Mock useLocale hook
|
||||
vi.mock("@calcom/lib/hooks/useLocale", () => ({
|
||||
useLocale: () => ({
|
||||
t: (key: string) => key,
|
||||
}),
|
||||
}));
|
||||
|
||||
describe("Segment", () => {
|
||||
const defaultQueryValue = {
|
||||
id: "root",
|
||||
type: "group",
|
||||
children1: {
|
||||
"rule-1": {
|
||||
type: "rule",
|
||||
properties: {
|
||||
field: "department",
|
||||
operator: "select_equals",
|
||||
value: ["Sales"],
|
||||
},
|
||||
},
|
||||
},
|
||||
} as AttributesQueryValue;
|
||||
|
||||
const defaultProps = {
|
||||
teamId: 1,
|
||||
queryValue: defaultQueryValue,
|
||||
onQueryValueChange: vi.fn(),
|
||||
className: "test-class",
|
||||
};
|
||||
beforeEach(() => {
|
||||
mockAttributesWithSingleSelect();
|
||||
});
|
||||
|
||||
it("renders query builder when attributes are loaded", async () => {
|
||||
mockGetMatchingTeamMembers({
|
||||
data: {
|
||||
mainWarnings: null,
|
||||
fallbackWarnings: null,
|
||||
troubleshooter: undefined,
|
||||
result: [
|
||||
{
|
||||
id: 1,
|
||||
name: "John Doe",
|
||||
email: "[email protected]",
|
||||
},
|
||||
],
|
||||
},
|
||||
isPending: false,
|
||||
});
|
||||
render(<Segment {...defaultProps} />);
|
||||
|
||||
await waitFor(() => {
|
||||
// Query builder container should be present
|
||||
expect(screen.getByTestId("query-builder-container")).toBeInTheDocument();
|
||||
expect(screen.queryByTestId("segment_loading_state")).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("renders in loading state when matching team members are not loaded", async () => {
|
||||
mockGetMatchingTeamMembers({
|
||||
data: undefined,
|
||||
isPending: true,
|
||||
});
|
||||
render(<Segment {...defaultProps} />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTestId("segment_loading_state")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("shows no filter selected message when empty query value is provided", async () => {
|
||||
mockGetMatchingTeamMembers({
|
||||
isPending: true,
|
||||
data: undefined,
|
||||
});
|
||||
|
||||
const emptyQueryValue = {
|
||||
id: "root",
|
||||
type: "group",
|
||||
children1: {},
|
||||
} as AttributesQueryValue;
|
||||
|
||||
render(<Segment {...defaultProps} queryValue={emptyQueryValue} />);
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("no_filter_set")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("shows matching team members when valid query value is provided", async () => {
|
||||
mockGetMatchingTeamMembers({
|
||||
isPending: false,
|
||||
data: {
|
||||
mainWarnings: null,
|
||||
fallbackWarnings: null,
|
||||
troubleshooter: undefined,
|
||||
result: [
|
||||
{
|
||||
id: 1,
|
||||
name: "John Doe",
|
||||
email: "[email protected]",
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
render(<Segment {...defaultProps} queryValue={defaultQueryValue} />);
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("John Doe")).toBeInTheDocument();
|
||||
expect(screen.getByText("([email protected])")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("shows no filter message when no query is set", async () => {
|
||||
mockGetMatchingTeamMembers({
|
||||
data: {
|
||||
mainWarnings: null,
|
||||
fallbackWarnings: null,
|
||||
troubleshooter: undefined,
|
||||
result: [] as MatchingTeamMembersData["result"],
|
||||
},
|
||||
isPending: false,
|
||||
});
|
||||
render(<Segment {...defaultProps} queryValue={null} />);
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("no_filter_set")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,219 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { buildStateFromQueryValue } from "@calcom/app-store/_utils/raqb/raqbUtils.client";
|
||||
import {
|
||||
ConfigFor,
|
||||
withRaqbSettingsAndWidgets,
|
||||
} from "@calcom/app-store/routing-forms/components/react-awesome-query-builder/config/uiConfig";
|
||||
import { getQueryBuilderConfigForAttributes } from "@calcom/app-store/routing-forms/lib/getQueryBuilderConfig";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { isEqual } from "@calcom/lib/isEqual";
|
||||
import type { AttributesQueryValue } from "@calcom/lib/raqb/types";
|
||||
import { type RouterOutputs, trpc } from "@calcom/trpc/react";
|
||||
import cn from "@calcom/ui/classNames";
|
||||
import { useCallback, useState } from "react";
|
||||
import type { BuilderProps, ImmutableTree, JsonTree } from "react-awesome-query-builder";
|
||||
import { Builder, Utils as QbUtils, Query } from "react-awesome-query-builder";
|
||||
|
||||
export type Attributes = RouterOutputs["viewer"]["appRoutingForms"]["getAttributesForTeam"];
|
||||
export function useAttributes(teamId: number) {
|
||||
const { data: attributes, isPending } = trpc.viewer.appRoutingForms.getAttributesForTeam.useQuery({
|
||||
teamId,
|
||||
});
|
||||
return {
|
||||
attributes,
|
||||
isPending,
|
||||
};
|
||||
}
|
||||
|
||||
function SegmentWithAttributes({
|
||||
attributes,
|
||||
teamId,
|
||||
queryValue: initialQueryValue,
|
||||
onQueryValueChange,
|
||||
className,
|
||||
filterMemberIds,
|
||||
}: {
|
||||
attributes: Attributes;
|
||||
teamId: number;
|
||||
queryValue: AttributesQueryValue | null;
|
||||
onQueryValueChange: ({ queryValue }: { queryValue: AttributesQueryValue }) => void;
|
||||
className?: string;
|
||||
filterMemberIds?: number[];
|
||||
}) {
|
||||
const attributesQueryBuilderConfig = getQueryBuilderConfigForAttributes({
|
||||
attributes,
|
||||
});
|
||||
|
||||
const [queryValue, setQueryValue] = useState(initialQueryValue);
|
||||
const attributesQueryBuilderConfigWithRaqbSettingsAndWidgets = withRaqbSettingsAndWidgets({
|
||||
config: attributesQueryBuilderConfig,
|
||||
configFor: ConfigFor.Attributes,
|
||||
});
|
||||
|
||||
const queryBuilderData = buildStateFromQueryValue({
|
||||
queryValue: queryValue as JsonTree,
|
||||
config: attributesQueryBuilderConfigWithRaqbSettingsAndWidgets,
|
||||
});
|
||||
|
||||
const renderBuilder = useCallback(
|
||||
(props: BuilderProps) => (
|
||||
<div className="query-builder-container" data-testid="query-builder-container">
|
||||
<div className="query-builder qb-lite">
|
||||
<Builder {...props} />
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
[]
|
||||
);
|
||||
|
||||
function onChange(immutableTree: ImmutableTree) {
|
||||
const jsonTree = QbUtils.getTree(immutableTree) as AttributesQueryValue;
|
||||
|
||||
// IMPORTANT: RAQB calls onChange even without explicit user action. It just identifies if the props have changed or not. isEqual ensures that we don't end up having infinite re-renders.
|
||||
if (!isEqual(jsonTree, queryValue)) {
|
||||
setQueryValue(jsonTree);
|
||||
onQueryValueChange({
|
||||
queryValue: jsonTree,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
// cal-query-builder class has special styling through global CSS, allowing us to customize RAQB
|
||||
<div>
|
||||
<div className={cn("cal-query-builder", className)}>
|
||||
<Query
|
||||
{...attributesQueryBuilderConfigWithRaqbSettingsAndWidgets}
|
||||
value={queryBuilderData.state.tree}
|
||||
onChange={onChange}
|
||||
renderBuilder={renderBuilder}
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-4 text-sm">
|
||||
<MatchingTeamMembers teamId={teamId} queryValue={queryValue} filterMemberIds={filterMemberIds} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function MatchingTeamMembers({
|
||||
teamId,
|
||||
queryValue,
|
||||
filterMemberIds,
|
||||
}: {
|
||||
teamId: number;
|
||||
queryValue: AttributesQueryValue | null;
|
||||
filterMemberIds?: number[];
|
||||
}) {
|
||||
const { t } = useLocale();
|
||||
|
||||
// Check if queryValue has valid children properties value
|
||||
const hasValidValue = queryValue?.children1
|
||||
? Object.values(queryValue.children1).some(
|
||||
(child) => child.properties?.value?.[0] !== undefined && child.properties?.value?.[0] !== null
|
||||
)
|
||||
: false;
|
||||
|
||||
const { data: matchingTeamMembersWithResult, isPending } =
|
||||
trpc.viewer.attributes.findTeamMembersMatchingAttributeLogic.useQuery(
|
||||
{
|
||||
teamId,
|
||||
attributesQueryValue: queryValue,
|
||||
_enablePerf: true,
|
||||
},
|
||||
{
|
||||
enabled: hasValidValue,
|
||||
}
|
||||
);
|
||||
|
||||
if (!hasValidValue) {
|
||||
return (
|
||||
<div className="border-subtle bg-cal-muted mt-4 stack-y-3 rounded-md border p-4">
|
||||
<div className="text-subtle flex items-center text-sm font-medium">
|
||||
<span>{t("no_filter_set")}</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (isPending) {
|
||||
return (
|
||||
<div
|
||||
className="border-subtle bg-cal-muted mt-4 stack-y-3 rounded-md border p-4"
|
||||
data-testid="segment_loading_state">
|
||||
<div className="text-emphasis flex items-center text-sm font-medium">
|
||||
<div className="bg-subtle h-4 w-32 animate-pulse rounded" />
|
||||
</div>
|
||||
<ul className="divide-subtle divide-y">
|
||||
{[...Array(3)].map((_, index) => (
|
||||
<li key={index} className="flex items-center py-2">
|
||||
<div className="flex flex-1 items-center space-x-2 text-sm">
|
||||
<div className="bg-subtle h-4 w-24 animate-pulse rounded" />
|
||||
<div className="bg-subtle h-4 w-32 animate-pulse rounded" />
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!matchingTeamMembersWithResult) return <span>{t("something_went_wrong")}</span>;
|
||||
const { result: allMatchingTeamMembers } = matchingTeamMembersWithResult;
|
||||
|
||||
const matchingTeamMembers = filterMemberIds
|
||||
? allMatchingTeamMembers?.filter((member) => filterMemberIds.includes(member.id))
|
||||
: allMatchingTeamMembers;
|
||||
|
||||
return (
|
||||
<div className="border-subtle bg-cal-muted mt-4 stack-y-3 rounded-md border p-4">
|
||||
<div className="text-emphasis flex items-center text-sm font-medium">
|
||||
<span>{t("x_matching_members", { x: matchingTeamMembers?.length ?? 0 })}</span>
|
||||
</div>
|
||||
<ul className="divide-subtle divide-y">
|
||||
{matchingTeamMembers?.map((member) => (
|
||||
<li key={member.id} className="flex items-center py-2">
|
||||
<div className="flex flex-1 items-center space-x-2 text-sm">
|
||||
<span className="font-medium">{member.name}</span>
|
||||
<span className="text-subtle">({member.email})</span>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function Segment({
|
||||
teamId,
|
||||
queryValue,
|
||||
onQueryValueChange,
|
||||
className,
|
||||
filterMemberIds,
|
||||
}: {
|
||||
teamId: number;
|
||||
queryValue: AttributesQueryValue | null;
|
||||
onQueryValueChange: ({ queryValue }: { queryValue: AttributesQueryValue }) => void;
|
||||
className?: string;
|
||||
filterMemberIds?: number[];
|
||||
}) {
|
||||
const { attributes, isPending } = useAttributes(teamId);
|
||||
const { t } = useLocale();
|
||||
if (isPending) return <span>Loading...</span>;
|
||||
if (!attributes) {
|
||||
console.error("Error fetching attributes");
|
||||
return <span>{t("something_went_wrong")}</span>;
|
||||
}
|
||||
|
||||
return (
|
||||
<SegmentWithAttributes
|
||||
teamId={teamId}
|
||||
attributes={attributes}
|
||||
queryValue={queryValue}
|
||||
onQueryValueChange={onQueryValueChange}
|
||||
className={className}
|
||||
filterMemberIds={filterMemberIds}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -14,7 +14,7 @@ vi.mock("@formkit/auto-animate/react", () => ({
|
||||
}));
|
||||
|
||||
// Mock Segment component
|
||||
vi.mock("@calcom/web/modules/event-types/components/Segment", () => ({
|
||||
vi.mock("@calcom/features/Segment", () => ({
|
||||
Segment: vi.fn().mockImplementation(({ onQueryValueChange }) => (
|
||||
<div data-testid="mock-segment">
|
||||
<button onClick={() => onQueryValueChange({ queryValue: { id: "test" } })}>Update Query</button>
|
||||
|
||||
@@ -34,7 +34,7 @@ import type {
|
||||
SettingsToggleClassNames,
|
||||
} from "@calcom/features/eventtypes/lib/types";
|
||||
import { FormBuilder } from "./FormBuilder";
|
||||
import { BookerLayoutSelector } from "@calcom/web/modules/settings/components/BookerLayoutSelector";
|
||||
import { BookerLayoutSelector } from "@calcom/features/settings/BookerLayoutSelector";
|
||||
import {
|
||||
DEFAULT_LIGHT_BRAND_COLOR,
|
||||
DEFAULT_DARK_BRAND_COLOR,
|
||||
|
||||
@@ -7,7 +7,7 @@ import { trpc } from "@calcom/trpc/react";
|
||||
|
||||
import { OAuthClientsAdminSkeleton } from "./oauth-clients-admin-skeleton";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
import SettingsHeader from "@calcom/web/modules/settings/components/SettingsHeader";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
|
||||
import type { OAuthClientCreateFormValues } from "../oauth/create/OAuthClientCreateModal";
|
||||
import { OAuthClientCreateDialog } from "../oauth/create/OAuthClientCreateModal";
|
||||
|
||||
@@ -1,256 +0,0 @@
|
||||
import * as RadioGroup from "@radix-ui/react-radio-group";
|
||||
import Link from "next/link";
|
||||
import { useCallback, useState } from "react";
|
||||
import { Controller, useFormContext } from "react-hook-form";
|
||||
|
||||
import ServerTrans from "@calcom/lib/components/ServerTrans";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { BookerLayouts, defaultBookerLayoutSettings } from "@calcom/prisma/zod-utils";
|
||||
import { bookerLayoutOptions, type BookerLayoutSettings } from "@calcom/prisma/zod-utils";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { Label } from "@calcom/ui/components/form";
|
||||
import { CheckboxField } from "@calcom/ui/components/form";
|
||||
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/SectionBottomActions";
|
||||
|
||||
type BookerLayoutSelectorProps = {
|
||||
title?: string;
|
||||
description?: string;
|
||||
name?: string;
|
||||
/**
|
||||
* If this boolean is set, it will show the user settings if the event does not have any settings (is null).
|
||||
* In that case it also will NOT register itself in the form, so that way when submitting the form, the
|
||||
* values won't be overridden. Because as long as the event's value is null, it will fallback to the user's
|
||||
* settings.
|
||||
*/
|
||||
fallbackToUserSettings?: boolean;
|
||||
/**
|
||||
* isDark boolean should be passed in when the user selected 'dark mode' in the theme settings in profile/appearance.
|
||||
* So it's not based on the user's system settings, but on the user's preference for the booker.
|
||||
* This boolean is then used to show a dark version of the layout image. It's only easthetic, no functionality is attached
|
||||
* to this boolean.
|
||||
*/
|
||||
isDark?: boolean;
|
||||
isLoading?: boolean;
|
||||
isDisabled?: boolean;
|
||||
isOuterBorder?: boolean;
|
||||
user?: Partial<Pick<RouterOutputs["viewer"]["me"]["get"], "defaultBookerLayouts">>;
|
||||
isUserLoading?: boolean;
|
||||
};
|
||||
|
||||
const defaultFieldName = "metadata.bookerLayouts";
|
||||
|
||||
export const BookerLayoutSelector = ({
|
||||
title,
|
||||
description,
|
||||
name,
|
||||
fallbackToUserSettings,
|
||||
isDark,
|
||||
isDisabled = false,
|
||||
isOuterBorder = false,
|
||||
isLoading = false,
|
||||
user,
|
||||
isUserLoading,
|
||||
}: BookerLayoutSelectorProps) => {
|
||||
const { control, getValues } = useFormContext();
|
||||
const { t } = useLocale();
|
||||
// Only fallback if event current does not have any settings, and the fallbackToUserSettings boolean is set.
|
||||
const shouldShowUserSettings = (fallbackToUserSettings && !getValues(name || defaultFieldName)) || false;
|
||||
|
||||
return (
|
||||
<div className={classNames(isOuterBorder && "border-subtle rounded-lg border p-6")}>
|
||||
<div className={classNames(isOuterBorder ? "pb-5" : "border-subtle rounded-t-xl border p-6")}>
|
||||
<Label className={classNames("mb-1 font-semibold", isOuterBorder ? "text-sm" : "text-base")}>
|
||||
{title ? title : t("layout")}
|
||||
</Label>
|
||||
<p className="text-subtle max-w-full wrap-break-word text-sm leading-tight">
|
||||
{description ? description : t("bookerlayout_description")}
|
||||
</p>
|
||||
</div>
|
||||
<Controller
|
||||
// If the event does not have any settings, we don't want to register this field in the form.
|
||||
// That way the settings won't get saved into the event on save, but remain null. Thus keep using
|
||||
// the global user's settings.
|
||||
control={shouldShowUserSettings ? undefined : control}
|
||||
name={name || defaultFieldName}
|
||||
render={({ field: { value, onChange } }) => (
|
||||
<>
|
||||
<BookerLayoutFields
|
||||
showUserSettings={shouldShowUserSettings}
|
||||
settings={value}
|
||||
onChange={onChange}
|
||||
isDark={isDark}
|
||||
isOuterBorder={isOuterBorder}
|
||||
user={user}
|
||||
isUserLoading={isUserLoading}
|
||||
/>
|
||||
{!isOuterBorder && (
|
||||
<SectionBottomActions align="end">
|
||||
<Button loading={isLoading} type="submit" disabled={isDisabled} color="primary">
|
||||
{t("update")}
|
||||
</Button>
|
||||
</SectionBottomActions>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
type BookerLayoutFieldsProps = {
|
||||
settings: BookerLayoutSettings;
|
||||
onChange: (settings: BookerLayoutSettings) => void;
|
||||
showUserSettings: boolean;
|
||||
isDark?: boolean;
|
||||
isOuterBorder?: boolean;
|
||||
user?: Partial<Pick<RouterOutputs["viewer"]["me"]["get"], "defaultBookerLayouts">>;
|
||||
isUserLoading?: boolean;
|
||||
};
|
||||
|
||||
type BookerLayoutState = { [key in BookerLayouts]: boolean };
|
||||
|
||||
const BookerLayoutFields = ({
|
||||
settings,
|
||||
onChange,
|
||||
showUserSettings,
|
||||
isDark,
|
||||
isOuterBorder,
|
||||
user,
|
||||
isUserLoading,
|
||||
}: BookerLayoutFieldsProps) => {
|
||||
const { t } = useLocale();
|
||||
const [isOverridingSettings, setIsOverridingSettings] = useState(false);
|
||||
|
||||
const disableFields = showUserSettings && !isOverridingSettings;
|
||||
const shownSettings = disableFields ? user?.defaultBookerLayouts : settings;
|
||||
const defaultLayout = shownSettings?.defaultLayout || BookerLayouts.MONTH_VIEW;
|
||||
|
||||
// Converts the settings array into a boolean object, which can be used as form values.
|
||||
const toggleValues: BookerLayoutState = bookerLayoutOptions.reduce((layouts, layout) => {
|
||||
layouts[layout] = !shownSettings?.enabledLayouts
|
||||
? defaultBookerLayoutSettings.enabledLayouts.indexOf(layout) > -1
|
||||
: shownSettings.enabledLayouts.indexOf(layout) > -1;
|
||||
return layouts;
|
||||
}, {} as BookerLayoutState);
|
||||
|
||||
const onLayoutToggleChange = useCallback(
|
||||
(changedLayout: BookerLayouts, checked: boolean) => {
|
||||
const newEnabledLayouts = Object.keys(toggleValues).filter((layout) => {
|
||||
if (changedLayout === layout) return checked === true;
|
||||
return toggleValues[layout as BookerLayouts] === true;
|
||||
}) as BookerLayouts[];
|
||||
|
||||
const isDefaultLayoutToggledOff = newEnabledLayouts.indexOf(defaultLayout) === -1;
|
||||
const firstEnabledLayout = newEnabledLayouts[0];
|
||||
|
||||
onChange({
|
||||
enabledLayouts: newEnabledLayouts,
|
||||
// If default layout is toggled off, we set the default layout to the first enabled layout
|
||||
// if there's none enabled, we set it to month view.
|
||||
defaultLayout: isDefaultLayoutToggledOff
|
||||
? firstEnabledLayout || BookerLayouts.MONTH_VIEW
|
||||
: defaultLayout,
|
||||
});
|
||||
},
|
||||
[defaultLayout, onChange, toggleValues]
|
||||
);
|
||||
|
||||
const onDefaultLayoutChange = useCallback(
|
||||
(newDefaultLayout: BookerLayouts) => {
|
||||
onChange({
|
||||
enabledLayouts: Object.keys(toggleValues).filter(
|
||||
(layout) => toggleValues[layout as BookerLayouts] === true
|
||||
) as BookerLayouts[],
|
||||
defaultLayout: newDefaultLayout,
|
||||
});
|
||||
},
|
||||
[toggleValues, onChange]
|
||||
);
|
||||
|
||||
const onOverrideSettings = () => {
|
||||
setIsOverridingSettings(true);
|
||||
// Sent default layout settings to form, otherwise it would still have 'null' as it's value.
|
||||
if (user?.defaultBookerLayouts) onChange(user.defaultBookerLayouts);
|
||||
};
|
||||
return (
|
||||
<div className={classNames("stack-y-5", !isOuterBorder && "border-subtle border-x px-6 py-8")}>
|
||||
<div
|
||||
className={classNames(
|
||||
"flex flex-col gap-5 transition-opacity sm:flex-row sm:gap-3",
|
||||
disableFields && "pointer-events-none opacity-40",
|
||||
disableFields && isUserLoading && "animate-pulse"
|
||||
)}>
|
||||
{bookerLayoutOptions.map((layout) => (
|
||||
<div className="w-full" key={layout}>
|
||||
<label>
|
||||
<img
|
||||
className="mb-3 w-full max-w-none cursor-pointer"
|
||||
src={`/bookerlayout_${layout}${isDark ? "_dark" : ""}.svg`}
|
||||
alt="Layout preview"
|
||||
/>
|
||||
<CheckboxField
|
||||
value={layout}
|
||||
name={`bookerlayout_${layout}`}
|
||||
description={t(`bookerlayout_${layout}`)}
|
||||
checked={toggleValues[layout]}
|
||||
onChange={(ev) => onLayoutToggleChange(layout, ev.target.checked)}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<div
|
||||
hidden={Object.values(toggleValues).filter((value) => value === true).length <= 1}
|
||||
className={classNames(
|
||||
"transition-opacity",
|
||||
disableFields && "pointer-events-none opacity-40",
|
||||
disableFields && isUserLoading && "animate-pulse"
|
||||
)}>
|
||||
<Label>{t("bookerlayout_default_title")}</Label>
|
||||
<RadioGroup.Root
|
||||
key={defaultLayout}
|
||||
className="border-subtle flex w-full gap-2 rounded-md border p-1"
|
||||
defaultValue={defaultLayout}
|
||||
onValueChange={(layout: BookerLayouts) => onDefaultLayoutChange(layout)}>
|
||||
{bookerLayoutOptions.map((layout) => (
|
||||
<RadioGroup.Item
|
||||
className="aria-checked:bg-emphasis hover:[&:not(:disabled)]:bg-subtle focus:[&:not(:disabled)]:bg-subtle w-full rounded-[4px] p-1 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-40"
|
||||
disabled={toggleValues[layout] === false}
|
||||
key={layout}
|
||||
value={layout}>
|
||||
{t(`bookerlayout_${layout}`)}
|
||||
<RadioGroup.Indicator />
|
||||
</RadioGroup.Item>
|
||||
))}
|
||||
</RadioGroup.Root>
|
||||
</div>
|
||||
{disableFields && (
|
||||
<p className="text-sm">
|
||||
<ServerTrans
|
||||
t={t}
|
||||
i18nKey="bookerlayout_override_global_settings"
|
||||
components={[
|
||||
<Link
|
||||
key="appearance-link"
|
||||
target="_blank"
|
||||
href="/settings/my-account/appearance"
|
||||
className="underline">
|
||||
Appearance
|
||||
</Link>,
|
||||
<Button
|
||||
key="override-button"
|
||||
onClick={onOverrideSettings}
|
||||
color="minimal"
|
||||
className="h-fit p-0 font-normal underline hover:bg-transparent focus-visible:bg-transparent">
|
||||
Override
|
||||
</Button>,
|
||||
]}
|
||||
/>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,26 +0,0 @@
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
|
||||
const SectionBottomActions = ({
|
||||
align = "start",
|
||||
children,
|
||||
className,
|
||||
}: {
|
||||
align?: "start" | "end";
|
||||
children: ReactNode;
|
||||
className?: string;
|
||||
}) => {
|
||||
return (
|
||||
<div
|
||||
className={classNames(
|
||||
"border-subtle bg-cal-muted flex rounded-b-lg border px-6 py-4",
|
||||
align === "end" && "justify-end",
|
||||
className
|
||||
)}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SectionBottomActions;
|
||||
@@ -1,85 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import React, { Suspense } from "react";
|
||||
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
|
||||
type HeaderPropsBase = {
|
||||
children: React.ReactNode;
|
||||
title?: string;
|
||||
description?: string;
|
||||
CTA?: React.ReactNode;
|
||||
ctaClassName?: string;
|
||||
borderInShellHeader?: boolean;
|
||||
};
|
||||
|
||||
type HeaderPropsWithBackButton = HeaderPropsBase & {
|
||||
backButton: true;
|
||||
onBackButtonClick: () => void;
|
||||
};
|
||||
|
||||
type HeaderPropsWithoutBackButton = HeaderPropsBase & {
|
||||
backButton?: false;
|
||||
onBackButtonClick?: never;
|
||||
};
|
||||
|
||||
type HeaderProps = HeaderPropsWithBackButton | HeaderPropsWithoutBackButton;
|
||||
|
||||
export default function Header({
|
||||
children,
|
||||
title,
|
||||
description,
|
||||
CTA,
|
||||
ctaClassName,
|
||||
borderInShellHeader,
|
||||
backButton,
|
||||
onBackButtonClick,
|
||||
}: HeaderProps) {
|
||||
const { t } = useLocale();
|
||||
|
||||
return (
|
||||
<div>
|
||||
<header
|
||||
className={classNames(
|
||||
"border-subtle mx-auto flex justify-between",
|
||||
borderInShellHeader && "rounded-t-lg border px-4 py-6 sm:px-6",
|
||||
borderInShellHeader === undefined && "mb-8 border-b pb-8"
|
||||
)}>
|
||||
<div className="flex w-full items-center justify-between gap-2">
|
||||
<div className="flex items-center">
|
||||
{backButton && onBackButtonClick && (
|
||||
<Button
|
||||
variant="icon"
|
||||
size="sm"
|
||||
color="minimal"
|
||||
onClick={onBackButtonClick}
|
||||
className="rounded-md ltr:mr-2 rtl:ml-2"
|
||||
StartIcon="arrow-left"
|
||||
aria-label={t("go_back")}
|
||||
/>
|
||||
)}
|
||||
<div>
|
||||
{title ? (
|
||||
<h1 className="font-cal text-emphasis mb-1 text-xl font-semibold leading-5 tracking-wide">
|
||||
{title}
|
||||
</h1>
|
||||
) : (
|
||||
<div className="bg-emphasis mb-1 h-5 w-24 animate-pulse rounded-lg" />
|
||||
)}
|
||||
{description ? (
|
||||
<p className="text-default text-sm ltr:mr-4 rtl:ml-4">{description}</p>
|
||||
) : (
|
||||
<div className="bg-emphasis h-5 w-32 animate-pulse rounded-lg" />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className={classNames("shrink-0", ctaClassName)}>{CTA}</div>
|
||||
</div>
|
||||
</header>
|
||||
<Suspense fallback={<Icon name="loader" className="mx-auto my-5 animate-spin" />}>{children}</Suspense>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
import SettingsHeader from "./SettingsHeader";
|
||||
|
||||
type SettingsHeaderWithBackButtonProps = {
|
||||
children: ReactNode;
|
||||
title?: string;
|
||||
description?: string;
|
||||
CTA?: ReactNode;
|
||||
ctaClassName?: string;
|
||||
borderInShellHeader?: boolean;
|
||||
};
|
||||
|
||||
export default function SettingsHeaderWithBackButton(props: SettingsHeaderWithBackButtonProps) {
|
||||
const router = useRouter();
|
||||
|
||||
return (
|
||||
<SettingsHeader {...props} backButton={true} onBackButtonClick={() => router.back()} />
|
||||
);
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
interface ThemeLabelProps {
|
||||
variant: "light" | "dark" | "system";
|
||||
value: "light" | "dark" | "system";
|
||||
label: string;
|
||||
defaultChecked?: boolean;
|
||||
register: any;
|
||||
fieldName?: string;
|
||||
}
|
||||
|
||||
export default function ThemeLabel(props: ThemeLabelProps) {
|
||||
const { variant, label, value, defaultChecked, register, fieldName = "theme" } = props;
|
||||
|
||||
return (
|
||||
<label
|
||||
className="relative mb-4 flex-1 cursor-pointer text-center last:mb-0 last:mr-0 sm:mb-0 sm:mr-4"
|
||||
htmlFor={`${fieldName}-${variant}`}
|
||||
data-testid={`${fieldName}-${variant}`}>
|
||||
<input
|
||||
className="peer absolute left-8 top-8"
|
||||
type="radio"
|
||||
value={value}
|
||||
id={`${fieldName}-${variant}`}
|
||||
defaultChecked={defaultChecked}
|
||||
{...register(fieldName)}
|
||||
/>
|
||||
<div className="ring-inverted relative z-10 rounded-lg ring-offset-2 transition-all peer-checked:ring-2">
|
||||
<img
|
||||
aria-hidden="true"
|
||||
className="cover w-full rounded-lg"
|
||||
src={`/theme-${variant}.svg`}
|
||||
alt={`theme ${variant}`}
|
||||
/>
|
||||
</div>
|
||||
<p className="peer-checked:text-emphasis text-default mt-2 text-sm font-medium">{label}</p>
|
||||
</label>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import SettingsHeader from "@calcom/web/modules/settings/components/SettingsHeader";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { SkeletonText, SkeletonContainer } from "@calcom/ui/components/skeleton";
|
||||
|
||||
@@ -7,7 +7,7 @@ import LicenseRequired from "~/ee/common/components/LicenseRequired";
|
||||
import { Dialog } from "@calcom/features/components/controlled-dialog";
|
||||
import ApiKeyDialogForm from "~/ee/api-keys/components/ApiKeyDialogForm";
|
||||
import ApiKeyListItem from "~/ee/api-keys/components/ApiKeyListItem";
|
||||
import SettingsHeader from "@calcom/web/modules/settings/components/SettingsHeader";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { EmptyScreen } from "@calcom/ui/components/empty-screen";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
import SettingsHeader from "@calcom/web/modules/settings/components/SettingsHeader";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
|
||||
import type { OAuthClientCreateFormValues } from "../oauth/create/OAuthClientCreateModal";
|
||||
import { OAuthClientCreateDialog } from "../oauth/create/OAuthClientCreateModal";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { CreateANewLicenseKeyForm } from "@calcom/web/modules/ee/deployment/licensekey/CreateLicenseKeyForm";
|
||||
import { CreateANewLicenseKeyForm } from "@calcom/features/ee/deployment/licensekey/CreateLicenseKeyForm";
|
||||
import { WizardLayout } from "@calcom/ui/components/layout";
|
||||
|
||||
export const LayoutWrapper = ({ children }: { children: React.ReactNode }) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/SectionBottomActions";
|
||||
import SettingsHeader from "@calcom/web/modules/settings/components/SettingsHeader";
|
||||
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { SkeletonButton, SkeletonContainer, SkeletonText } from "@calcom/ui/components/skeleton";
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ import { useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import type { z } from "zod";
|
||||
|
||||
import { BookerLayoutSelector } from "@calcom/web/modules/settings/components/BookerLayoutSelector";
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/SectionBottomActions";
|
||||
import ThemeLabel from "@calcom/web/modules/settings/components/ThemeLabel";
|
||||
import SettingsHeader from "@calcom/web/modules/settings/components/SettingsHeader";
|
||||
import { BookerLayoutSelector } from "@calcom/features/settings/BookerLayoutSelector";
|
||||
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
|
||||
import ThemeLabel from "@calcom/features/settings/ThemeLabel";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
import { DEFAULT_LIGHT_BRAND_COLOR, DEFAULT_DARK_BRAND_COLOR } from "@calcom/lib/constants";
|
||||
import { checkWCAGContrastColor } from "@calcom/lib/getBrandColours";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { FeaturesSettings } from "@calcom/features/feature-opt-in/components/FeaturesSettings";
|
||||
import SettingsHeader from "@calcom/web/modules/settings/components/SettingsHeader";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { ReactElement } from "react";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import SettingsHeader from "@calcom/web/modules/settings/components/SettingsHeader";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Skeleton } from "@coss/ui/components/skeleton";
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ import { useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
|
||||
import { TimezoneSelect } from "@calcom/web/modules/timezone/components/TimezoneSelect";
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/SectionBottomActions";
|
||||
import SettingsHeader from "@calcom/web/modules/settings/components/SettingsHeader";
|
||||
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import { formatLocalizedDateTime } from "@calcom/lib/dayjs";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { localeOptions } from "@calcom/lib/i18n";
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { memo, useMemo, useCallback } from "react";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import SettingsHeader from "@calcom/web/modules/settings/components/SettingsHeader";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import { getHolidayEmoji } from "@calcom/lib/holidays/getHolidayEmoji";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import SettingsHeader from "@calcom/web/modules/settings/components/SettingsHeader";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import {
|
||||
|
||||
@@ -13,8 +13,8 @@ import { z } from "zod";
|
||||
import { ErrorCode } from "@calcom/features/auth/lib/ErrorCode";
|
||||
import { Dialog } from "@calcom/features/components/controlled-dialog";
|
||||
import { isCompanyEmail } from "@calcom/features/ee/organizations/lib/utils";
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/SectionBottomActions";
|
||||
import SettingsHeader from "@calcom/web/modules/settings/components/SettingsHeader";
|
||||
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import { APP_NAME, FULL_NAME_LENGTH_MAX_LIMIT } from "@calcom/lib/constants";
|
||||
import { emailSchema } from "@calcom/lib/emailSchema";
|
||||
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useWebPush } from "@calcom/web/modules/notifications/hooks/useWebPush";
|
||||
import SettingsHeader from "@calcom/web/modules/settings/components/SettingsHeader";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
} from "@calcom/features/data-table";
|
||||
import { DataTableWrapper, DataTableToolbar, DataTableFilters, DataTableSegment } from "~/data-table/components";
|
||||
import { useSegments } from "@calcom/features/data-table/hooks/useSegments";
|
||||
import SettingsHeader from "@calcom/web/modules/settings/components/SettingsHeader";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import ServerTrans from "@calcom/lib/components/ServerTrans";
|
||||
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
|
||||
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
|
||||
|
||||
@@ -4,7 +4,7 @@ import { signOut, useSession } from "next-auth/react";
|
||||
import { useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/SectionBottomActions";
|
||||
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { IdentityProvider } from "@calcom/prisma/enums";
|
||||
import { userMetadata as userMetadataSchema } from "@calcom/prisma/zod-utils";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { FeaturesSettings } from "@calcom/features/feature-opt-in/components/FeaturesSettings";
|
||||
import SettingsHeader from "@calcom/web/modules/settings/components/SettingsHeader";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { ReactElement } from "react";
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/SectionBottomActions";
|
||||
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
|
||||
import customTemplate, { hasTemplateIntegration } from "@calcom/features/webhooks/lib/integrationTemplate";
|
||||
import { WebhookVersion } from "@calcom/features/webhooks/lib/interface/IWebhookRepository";
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import SettingsHeaderWithBackButton from "@calcom/web/modules/settings/components/SettingsHeaderWithBackButton";
|
||||
import SettingsHeaderWithBackButton from "@calcom/features/settings/appDir/SettingsHeaderWithBackButton";
|
||||
import {
|
||||
WEBHOOK_VERSION_OPTIONS,
|
||||
getWebhookVersionLabel,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import SettingsHeaderWithBackButton from "@calcom/web/modules/settings/components/SettingsHeaderWithBackButton";
|
||||
import SettingsHeaderWithBackButton from "@calcom/features/settings/appDir/SettingsHeaderWithBackButton";
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { SkeletonText, SkeletonContainer } from "@calcom/ui/components/skeleton";
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useSession } from "next-auth/react";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import SettingsHeaderWithBackButton from "@calcom/web/modules/settings/components/SettingsHeaderWithBackButton";
|
||||
import SettingsHeaderWithBackButton from "@calcom/features/settings/appDir/SettingsHeaderWithBackButton";
|
||||
import {
|
||||
WEBHOOK_VERSION_OPTIONS,
|
||||
getWebhookVersionLabel,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import SettingsHeader from "@calcom/web/modules/settings/components/SettingsHeader";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { SkeletonText, SkeletonContainer } from "@calcom/ui/components/skeleton";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useBookerUrl } from "~/bookings/hooks/useBookerUrl";
|
||||
import { useBookerUrl } from "@calcom/features/bookings/hooks/useBookerUrl";
|
||||
import { APP_NAME, WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
|
||||
Reference in new issue
Block a user