refactor: remove 10 trpc imports from features package by moving 16 tRPC-driven components to apps/web/modules (#27336)
* refactor: move Segment, BookerLayoutSelector, CreateLicenseKeyForm from packages/features to apps/web/modules Co-Authored-By: [email protected] <[email protected]> * fix: update relative imports to absolute paths in moved files Co-Authored-By: [email protected] <[email protected]> * refactor: move useBookingLocation and blocklist components from packages/features to apps/web/modules Co-Authored-By: [email protected] <[email protected]> * refactor: move EmbedTabs and embed hooks from packages/features to apps/web/modules Co-Authored-By: [email protected] <[email protected]> * fix * migrate useBookerUrl * migrate embed tabs * fix * fix * fix * mv ThemeLabel * mv settings headers to webn * update imports * clean up --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
ea0d9cbbeb
commit
b3430c8efc
107 files changed
+186
-137
No files matched your search
@@ -0,0 +1,248 @@
|
||||
"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>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
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/features/settings/SectionBottomActions";
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/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/features/settings/SectionBottomActions";
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/SectionBottomActions";
|
||||
import { SkeletonButton, SkeletonContainer, SkeletonText } from "@calcom/ui/components/skeleton";
|
||||
|
||||
export const AppearanceSkeletonLoader = () => {
|
||||
|
||||
@@ -0,0 +1,274 @@
|
||||
"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/features/settings/SectionBottomActions";
|
||||
import ThemeLabel from "@calcom/features/settings/ThemeLabel";
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/SectionBottomActions";
|
||||
import ThemeLabel from "@calcom/web/modules/settings/components/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/features/settings/appDir/SettingsHeader";
|
||||
import SettingsHeader from "@calcom/web/modules/settings/components/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/features/settings/SectionBottomActions";
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/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/features/settings/SectionBottomActions";
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/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/features/settings/SectionBottomActions";
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/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/features/settings/SectionBottomActions";
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/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/features/settings/SectionBottomActions";
|
||||
import ThemeLabel from "@calcom/features/settings/ThemeLabel";
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/SectionBottomActions";
|
||||
import ThemeLabel from "@calcom/web/modules/settings/components/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/features/settings/SectionBottomActions";
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/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/features/settings/SectionBottomActions";
|
||||
import SectionBottomActions from "@calcom/web/modules/settings/components/SectionBottomActions";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { useParamsWithFallback } from "@calcom/lib/hooks/useParamsWithFallback";
|
||||
import type { IntervalLimit } from "@calcom/lib/intervalLimits/intervalLimitSchema";
|
||||
|
||||
Reference in new issue
Block a user