+
{entry.bookerEmail}
+ {isSystem && entry.organization && (
+
+
+
{entry.organization.name}
+
+ )}
+
+ {isSystem && !entry.organization && (
+
+
+
{t("individual")}
+
+ )}
+
{reasonMap[entry.reason] || entry.reason}
@@ -146,6 +139,7 @@ export function BookingReportEntryDetailsModal({
{t("what_would_you_like_to_block")}
+ {isSystem &&
{t("system_wide_blocklist_warning")}
}
+ disabled={isSubmitting || isAddingToBlocklist || isDismissing}>
{t("go_back")}
@@ -188,15 +182,15 @@ export function BookingReportEntryDetailsModal({
type="button"
color="secondary"
onClick={handleDismiss}
- loading={dismissBookingReport.isPending}
- disabled={isSubmitting || addToWatchlist.isPending || dismissBookingReport.isPending}>
+ loading={isDismissing}
+ disabled={isSubmitting || isAddingToBlocklist || isDismissing}>
{t("dont_block")}
diff --git a/apps/web/modules/ee/organizations/privacy/components/create-blocklist-entry-modal.tsx b/packages/features/blocklist/components/CreateBlocklistEntryModal.tsx
similarity index 73%
rename from apps/web/modules/ee/organizations/privacy/components/create-blocklist-entry-modal.tsx
rename to packages/features/blocklist/components/CreateBlocklistEntryModal.tsx
index 3fe4ab7257..49f444bec8 100644
--- a/apps/web/modules/ee/organizations/privacy/components/create-blocklist-entry-modal.tsx
+++ b/packages/features/blocklist/components/CreateBlocklistEntryModal.tsx
@@ -1,31 +1,36 @@
"use client";
+import { useEffect } from "react";
import { Controller, useForm } from "react-hook-form";
import { domainRegex, emailRegex } from "@calcom/lib/emailSchema";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { WatchlistType } from "@calcom/prisma/enums";
-import { trpc } from "@calcom/trpc/react";
+import { Alert } from "@calcom/ui/components/alert";
import { Button } from "@calcom/ui/components/button";
import { Dialog, DialogContent, DialogFooter, DialogHeader } from "@calcom/ui/components/dialog";
import { Input, Label, TextArea, ToggleGroup } from "@calcom/ui/components/form";
import { Icon } from "@calcom/ui/components/icon";
-import { showToast } from "@calcom/ui/components/toast";
-interface CreateBlocklistEntryModalProps {
+import type { BlocklistScope, CreateBlocklistEntryFormData } from "../types";
+
+export interface CreateBlocklistEntryModalProps {
isOpen: boolean;
onClose: () => void;
+ scope: BlocklistScope;
+ onCreateEntry: (data: CreateBlocklistEntryFormData) => void;
+ isPending: boolean;
}
-interface FormData {
- type: WatchlistType;
- value: string;
- description?: string;
-}
-
-export function CreateBlocklistEntryModal({ isOpen, onClose }: CreateBlocklistEntryModalProps) {
+export function CreateBlocklistEntryModal({
+ isOpen,
+ onClose,
+ scope,
+ onCreateEntry,
+ isPending,
+}: CreateBlocklistEntryModalProps) {
const { t } = useLocale();
- const utils = trpc.useUtils();
+ const isSystem = scope === "system";
const {
control,
@@ -34,7 +39,7 @@ export function CreateBlocklistEntryModal({ isOpen, onClose }: CreateBlocklistEn
setValue,
reset,
formState: { errors, isSubmitting },
- } = useForm
({
+ } = useForm({
defaultValues: {
type: WatchlistType.EMAIL,
value: "",
@@ -44,24 +49,19 @@ export function CreateBlocklistEntryModal({ isOpen, onClose }: CreateBlocklistEn
const watchType = watch("type");
- const createWatchlistEntry = trpc.viewer.organizations.createWatchlistEntry.useMutation({
- onSuccess: async () => {
- await utils.viewer.organizations.listWatchlistEntries.invalidate();
- showToast(t("blocklist_entry_created"), "success");
- onClose();
+ useEffect(() => {
+ if (isOpen) {
reset();
- },
- onError: (error) => {
- showToast(error.message, "error");
- },
- });
+ }
+ }, [isOpen, reset]);
- const onSubmit = (data: FormData) => {
- createWatchlistEntry.mutate({
- type: data.type,
- value: data.value,
- description: data.description,
- });
+ const onSubmit = (data: CreateBlocklistEntryFormData) => {
+ onCreateEntry(data);
+ };
+
+ const handleClose = () => {
+ onClose();
+ reset();
};
const validateValue = (value: string) => {
@@ -86,11 +86,19 @@ export function CreateBlocklistEntryModal({ isOpen, onClose }: CreateBlocklistEn
];
return (
-