refactor: Move trpc-dependent components from features to web [1] (#25859)
* refactor: migrate UnconfirmedBookingBadge from features to apps/web Move UnconfirmedBookingBadge.tsx from packages/features/bookings/ to apps/web/modules/bookings/components/ as part of the architectural refactor to remove trpc client imports from the features layer. Also removes unused preserveBookingsQueryParams function from Navigation.tsx. Co-Authored-By: [email protected] <[email protected]> * refactor: move shell navigation and badges to apps/web Move shell navigation components and trpc-using badges from packages/features to apps/web/modules to fix circular dependency: - Move navigation folder to apps/web/modules/shell/navigation/ - Move TeamInviteBadge.tsx to apps/web/modules/shell/ - Create Shell wrapper in apps/web that provides MobileNavigationContainer - Update all Shell imports in apps/web to use the new wrapper - Remove MobileNavigationContainer default from features Shell.tsx - Fix pre-existing lint warnings in touched files This establishes the pattern for migrating React components that use trpc hooks from the features layer to the web app layer, ensuring proper dependency direction: apps/web imports from packages/features, never the reverse. Co-Authored-By: [email protected] <[email protected]> * fix: move SideBar.tsx to apps/web to fix build error SideBar.tsx was importing Navigation from the moved navigation folder, causing a build error. Moving SideBar.tsx to apps/web and updating the features Shell to not have a default SidebarContainer fixes this. The web Shell wrapper now provides both the default SidebarContainer and MobileNavigationContainer, maintaining the injection pattern. Co-Authored-By: [email protected] <[email protected]> * revert * revert * revert * wip * wip * wip * wip * wip * wip * not used anywhere * wip * wip * wip * wip * fix * fix * wip * wip * wip * wip * wip * fix * fix * fix * fix * migrate * migrate admin-adpi * wip * feat: migrate organization settings components from packages/features to apps/web/modules - Migrate profile.tsx, appearance.tsx, general.tsx, privacy.tsx, guest-notifications.tsx, delegationCredential.tsx, other-team-members-view.tsx, other-team-profile-view.tsx - Migrate attributes directory (AttributesForm.tsx, DeleteAttributeModal.tsx, ListSkeleton.tsx, attributes-create-view.tsx, attributes-edit-view.tsx, attributes-list-view.tsx) - Migrate admin directory (AdminOrgEditPage.tsx, AdminOrgPage.tsx, WorkspacePlatformPage.tsx) - Update all page imports to use new paths from ~/settings/organizations/ - Update relative imports in migrated files to use @calcom/features paths - Fix lint warnings in migrated files Co-Authored-By: [email protected] <[email protected]> * fix: update test import path after migration Co-Authored-By: [email protected] <[email protected]> * fix: remove unnecessary test-setup import (already in vitest config) Co-Authored-By: [email protected] <[email protected]> * wip * refactor: delete original files after migration to apps/web/modules Co-Authored-By: [email protected] <[email protected]> * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix * fix * fix * fix * wip * refactor more * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * mv * update import paths * wip * wip * fix * fix * fix * fix * fix * fix * fix * mv * mv * mv * fix * wip * wip * fix * fix * fix * fix: make test mocks resilient to vi.resetAllMocks() Co-Authored-By: [email protected] <[email protected]> * fix: fix AttributeForm test failures Co-Authored-By: [email protected] <[email protected]> * fix * fix * refactor: move ee files to apps/web/modules/ee/ folder - Move teams, workflows, and organizations folders to apps/web/modules/ee/ - Add LICENSE file to apps/web/modules/ee/ - Update all import paths from ~/teams/ to ~/ee/teams/ - Update all import paths from ~/settings/organizations/ to ~/ee/organizations/ - Remove duplicate MemberInvitationModal copy.tsx file Co-Authored-By: [email protected] <[email protected]> * fix: move useHasPaidPlan and dependent files to apps/web/modules - Move useHasPaidPlan.ts from packages/features/billing/hooks to apps/web/modules/billing/hooks - Move intercom files from packages/features/ee/support to apps/web/modules/ee/support - Move ContactMenuItem.tsx and dependencies (freshchat, helpscout, zendesk) to apps/web/modules/ee/support - Move ViewRecordingsDialog.tsx and RecordingListSkeleton to apps/web/modules/ee/video - Move CalVideoSettings.tsx to apps/web/modules/eventtypes/components/locations - Move CreateOrEditOutOfOfficeModal.tsx to apps/web/modules/settings/outOfOffice - Refactor UpgradeTeamsBadge to accept props and create wrapper in apps/web/modules/billing - Update all callers to use new file locations - Add eslint-disable comments for pre-existing lint warnings This fixes the tRPC server build failure caused by circular dependency where the server build was traversing into packages/features and pulling in React hooks that depend on @calcom/trpc/react types. Co-Authored-By: [email protected] <[email protected]> * fix: correct UpgradeTeamsBadge import path to use package export Co-Authored-By: [email protected] <[email protected]> * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix * fix * fix * fix * fix * fix * fix * fix: pass plan state through SelectProps to UpgradeTeamsBadge - Add upgradeTeamsBadgeProps field to ExtendedOption type in Select component - Update OptionComponent to spread upgradeTeamsBadgeProps to UpgradeTeamsBadge - Update getOptions.ts to accept PlanState object and include upgradeTeamsBadgeProps - Update WorkflowStepContainer.tsx to pass planState to getWorkflowTriggerOptions/getWorkflowTemplateOptions - Update WorkflowDetailsPage.tsx to pass upgradeTeamsBadgeProps in transformed action options - Update AddActionDialog.tsx interface and mapping to include upgradeTeamsBadgeProps - Add eslint-disable comments for pre-existing React Hook dependency warnings This fixes the UpgradeTeamsBadge refactoring issue where the badge was always showing 'upgrade' text instead of the correct text based on plan state (trial_mode, inactive_team_plan, etc.) Co-Authored-By: [email protected] <[email protected]> * fix: update import paths to use /ee/ folder for workflows and organizations Co-Authored-By: [email protected] <[email protected]> * fix: update workflow component imports to use /ee/ folder Co-Authored-By: [email protected] <[email protected]> * fix: add missing types.ts for LocationInput.tsx Co-Authored-By: [email protected] <[email protected]> * fix: extract BookingRedirectForm type to shared location Co-Authored-By: [email protected] <[email protected]> * fix * wip * wip * fix: update BookingRedirectForm import to use local types file Co-Authored-By: [email protected] <[email protected]> * wip * fix * fix --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
7847177e8b
commit
8afe87ff75
374 files changed
+1213
-1417
No files matched your search
@@ -8,7 +8,6 @@ import { useForm } from "react-hook-form";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider";
|
||||
import { MemberInvitationModalWithoutMembers } from "@calcom/features/ee/teams/components/MemberInvitationModal";
|
||||
import ServerTrans from "@calcom/lib/components/ServerTrans";
|
||||
import { IS_SMS_CREDITS_ENABLED } from "@calcom/lib/constants";
|
||||
import { downloadAsCsv } from "@calcom/lib/csvUtils";
|
||||
@@ -24,6 +23,8 @@ import { ProgressBar } from "@calcom/ui/components/progress-bar";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
import { Tooltip } from "@calcom/ui/components/tooltip";
|
||||
|
||||
import { MemberInvitationModalWithoutMembers } from "~/ee/teams/components/MemberInvitationModal";
|
||||
|
||||
import { BillingCreditsSkeleton } from "./BillingCreditsSkeleton";
|
||||
|
||||
type MonthOption = {
|
||||
|
||||
@@ -22,12 +22,13 @@ import type { userMetadata } from "@calcom/prisma/zod-utils";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import { Alert } from "@calcom/ui/components/alert";
|
||||
import { UpgradeTeamsBadge } from "@calcom/ui/components/badge";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { SettingsToggle, ColorPicker, Form } from "@calcom/ui/components/form";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
import { useCalcomTheme } from "@calcom/ui/styles";
|
||||
|
||||
import { UpgradeTeamsBadgeWebWrapper } from "~/billing/components/UpgradeTeamsBadgeWebWrapper";
|
||||
|
||||
const useBrandColors = (
|
||||
currentTheme: string | null,
|
||||
{
|
||||
@@ -393,7 +394,7 @@ const AppearanceView = ({
|
||||
disabled={!hasPaidPlan || mutation?.isPending}
|
||||
description={t("removes_cal_branding", { appName: APP_NAME })}
|
||||
checked={hasPaidPlan ? hideBrandingValue : false}
|
||||
Badge={<UpgradeTeamsBadge />}
|
||||
Badge={<UpgradeTeamsBadgeWebWrapper />}
|
||||
onCheckedChange={(checked) => {
|
||||
setHideBrandingValue(checked);
|
||||
mutation.mutate({ hideBranding: checked });
|
||||
|
||||
@@ -4,7 +4,6 @@ import { memo, useMemo, useCallback } from "react";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import { OutOfOfficeToggleGroup } from "@calcom/features/settings/outOfOffice/OutOfOfficeToggleGroup";
|
||||
import { getHolidayEmoji } from "@calcom/lib/holidays/getHolidayEmoji";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
@@ -17,6 +16,8 @@ import { Icon } from "@calcom/ui/components/icon";
|
||||
import { SkeletonContainer, SkeletonText } from "@calcom/ui/components/skeleton";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
import { OutOfOfficeToggleGroup } from "~/settings/outOfOffice/OutOfOfficeToggleGroup";
|
||||
|
||||
function HolidaysCTA() {
|
||||
const { t } = useLocale();
|
||||
return (
|
||||
|
||||
@@ -4,11 +4,13 @@ import { useEffect, useState } from "react";
|
||||
|
||||
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
|
||||
|
||||
import { CreateOrEditOutOfOfficeEntryModal } from "@calcom/features/settings/outOfOffice/CreateOrEditOutOfOfficeModal";
|
||||
import type { BookingRedirectForm } from "@calcom/features/settings/outOfOffice/CreateOrEditOutOfOfficeModal";
|
||||
import type { BookingRedirectForm } from "~/settings/outOfOffice/types";
|
||||
|
||||
import { CreateOrEditOutOfOfficeEntryModal } from "~/settings/outOfOffice/CreateOrEditOutOfOfficeModal";
|
||||
import OutOfOfficeEntriesList from "~/settings/outOfOffice/OutOfOfficeEntriesList";
|
||||
import { OutOfOfficeTab } from "~/settings/outOfOffice/OutOfOfficeToggleGroup";
|
||||
|
||||
import { HolidaysView } from "./holidays-view";
|
||||
import OutOfOfficeEntriesList from "@calcom/features/settings/outOfOffice/OutOfOfficeEntriesList";
|
||||
import { OutOfOfficeTab } from "@calcom/features/settings/outOfOffice/OutOfOfficeToggleGroup";
|
||||
|
||||
export default function OutOfOfficeView() {
|
||||
const [openModal, setOpenModal] = useState(false);
|
||||
|
||||
@@ -15,7 +15,6 @@ import { Dialog } from "@calcom/features/components/controlled-dialog";
|
||||
import { isCompanyEmail } from "@calcom/features/ee/organizations/lib/utils";
|
||||
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import { DisplayInfo } from "@calcom/features/users/components/UserTable/EditSheet/DisplayInfo";
|
||||
import { APP_NAME, FULL_NAME_LENGTH_MAX_LIMIT } from "@calcom/lib/constants";
|
||||
import { emailSchema } from "@calcom/lib/emailSchema";
|
||||
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
|
||||
@@ -38,6 +37,7 @@ import { TextField } from "@calcom/ui/components/form";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
import { ImageUploader } from "@calcom/ui/components/image-uploader";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
import { DisplayInfo } from "@calcom/web/modules/users/components/UserTable/EditSheet/DisplayInfo";
|
||||
|
||||
import TwoFactor from "@components/auth/TwoFactor";
|
||||
import CustomEmailTextField from "@components/settings/CustomEmailTextField";
|
||||
@@ -719,7 +719,7 @@ const ProfileForm = ({
|
||||
{usersAttributes && usersAttributes?.length > 0 && (
|
||||
<div className="mt-6 flex flex-col">
|
||||
<Label>{t("attributes")}</Label>
|
||||
<div className="flex flex-col stack-y-4">
|
||||
<div className="stack-y-4 flex flex-col">
|
||||
{usersAttributes.map((attribute, index) => (
|
||||
<>
|
||||
<DisplayInfo
|
||||
|
||||
@@ -1,264 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { Controller, useFieldArray, useForm } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useOnboarding } from "@calcom/features/ee/organizations/lib/onboardingStore";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import slugify from "@calcom/lib/slugify";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { CheckboxField } from "@calcom/ui/components/form";
|
||||
import { Form } from "@calcom/ui/components/form";
|
||||
import { TextField } from "@calcom/ui/components/form";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
import { SkeletonText, SkeletonContainer, SkeletonButton } from "@calcom/ui/components/skeleton";
|
||||
|
||||
const schema = z.object({
|
||||
teams: z.array(
|
||||
z.object({
|
||||
name: z.string().trim(),
|
||||
})
|
||||
),
|
||||
moveTeams: z.array(
|
||||
z.object({
|
||||
id: z.number(),
|
||||
shouldMove: z.boolean(),
|
||||
newSlug: z.string().optional(),
|
||||
})
|
||||
),
|
||||
});
|
||||
|
||||
export const AddNewTeamsForm = () => {
|
||||
const { data: teams, isLoading } = trpc.viewer.teams.listOwnedTeams.useQuery();
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<SkeletonContainer as="div" className="stack-y-6">
|
||||
<div className="stack-y-4">
|
||||
<SkeletonText className="h-4 w-32" />
|
||||
<div className="stack-y-2">
|
||||
{[...Array(2)].map((_, i) => (
|
||||
<div key={i} className="flex items-center space-x-2">
|
||||
<SkeletonText className="h-5 w-5" />
|
||||
<SkeletonText className="h-8 w-full" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="stack-y-4">
|
||||
<SkeletonText className="h-4 w-32" />
|
||||
<div className="stack-y-2">
|
||||
{[...Array(3)].map((_, i) => (
|
||||
<SkeletonText key={i} className="h-10 w-full" />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<SkeletonButton className="w-full" />
|
||||
</SkeletonContainer>
|
||||
);
|
||||
}
|
||||
|
||||
return <AddNewTeamsFormChild teams={(teams ?? []).map(({ id, name, slug }) => ({ id, name, slug }))} />;
|
||||
};
|
||||
|
||||
const AddNewTeamsFormChild = ({ teams }: { teams: { id: number; name: string; slug: string | null }[] }) => {
|
||||
const { t } = useLocale();
|
||||
const router = useRouter();
|
||||
const [counter, setCounter] = useState(1);
|
||||
const { useOnboardingStore } = useOnboarding();
|
||||
const { slug: orgSlug, setTeams, teams: teamsFromStore } = useOnboardingStore();
|
||||
const teamsToCreateFromStore = teamsFromStore.filter((team) => !team.isBeingMigrated);
|
||||
const teamsToMigrateFromStore = teamsFromStore.filter((team) => team.isBeingMigrated);
|
||||
const form = useForm({
|
||||
defaultValues: {
|
||||
teams: teamsToCreateFromStore.length ? teamsToCreateFromStore : [{ name: "" }],
|
||||
moveTeams: teams.map((team) => {
|
||||
const teamToMigrateInStore = teamsToMigrateFromStore.find((t) => t.id === team.id);
|
||||
const slugConflictsWithOrg = team.slug === orgSlug;
|
||||
return {
|
||||
id: team.id,
|
||||
// The team with conflicting slug must be moved
|
||||
shouldMove: slugConflictsWithOrg || !!teamToMigrateInStore,
|
||||
newSlug: teamToMigrateInStore?.slug || getSuggestedSlug({ teamSlug: team.slug, orgSlug }),
|
||||
name: team.name,
|
||||
};
|
||||
}),
|
||||
}, // Set initial values
|
||||
resolver: async (data) => {
|
||||
try {
|
||||
const validatedData = await schema.parseAsync(data);
|
||||
return { values: validatedData, errors: {} };
|
||||
} catch (error) {
|
||||
if (error instanceof z.ZodError) {
|
||||
return {
|
||||
values: {
|
||||
teams: [],
|
||||
},
|
||||
errors: error.formErrors.fieldErrors,
|
||||
};
|
||||
}
|
||||
return { values: {}, errors: { teams: { message: "Error validating input" } } };
|
||||
}
|
||||
},
|
||||
});
|
||||
const { register, control, watch, getValues, setValue } = form;
|
||||
const { fields, append, remove } = useFieldArray({
|
||||
control,
|
||||
name: "teams",
|
||||
});
|
||||
|
||||
const handleCounterIncrease = () => {
|
||||
if (counter >= 0 && counter < 5) {
|
||||
setCounter((prevCounter) => prevCounter + 1);
|
||||
append({ name: "" });
|
||||
}
|
||||
};
|
||||
|
||||
const handleRemoveInput = (index: number) => {
|
||||
remove(index);
|
||||
setCounter((prevCounter) => prevCounter - 1);
|
||||
};
|
||||
|
||||
const handleFormSubmit = () => {
|
||||
const fields = getValues("teams");
|
||||
const moveTeams = getValues("moveTeams");
|
||||
|
||||
const teamsBeingMoved = moveTeams.map((team) => {
|
||||
return {
|
||||
id: team.id,
|
||||
isBeingMigrated: team.shouldMove,
|
||||
slug: team.newSlug,
|
||||
name: team.name,
|
||||
};
|
||||
});
|
||||
|
||||
const newTeams = fields
|
||||
.map((team) => {
|
||||
return {
|
||||
id: -1,
|
||||
isBeingMigrated: false,
|
||||
slug: getSuggestedSlug({ teamSlug: team.name, orgSlug }),
|
||||
name: team.name,
|
||||
};
|
||||
})
|
||||
.filter((team) => team.slug !== "");
|
||||
|
||||
setTeams([...teamsBeingMoved, ...newTeams]);
|
||||
router.push(`/settings/organizations/new/onboard-members`);
|
||||
};
|
||||
|
||||
const moveTeams = watch("moveTeams");
|
||||
return (
|
||||
<>
|
||||
<Form form={form} handleSubmit={handleFormSubmit}>
|
||||
{moveTeams.length ? (
|
||||
<>
|
||||
<label className="text-emphasis mb-2 block text-sm font-medium leading-none">
|
||||
Move existing teams
|
||||
</label>
|
||||
<ul className="mb-8 stack-y-4">
|
||||
{moveTeams.map((team, index) => {
|
||||
const currentTeam = teams.find((t) => t.id === team.id);
|
||||
// If the team slug conflicts with the org slug, this team must be moved
|
||||
const slugConflictsWithOrg = currentTeam?.slug === orgSlug;
|
||||
return (
|
||||
<li key={team.id}>
|
||||
<Controller
|
||||
name={`moveTeams.${index}.shouldMove`}
|
||||
render={({ field: { value, onChange } }) => (
|
||||
<CheckboxField
|
||||
defaultValue={value}
|
||||
checked={value || slugConflictsWithOrg}
|
||||
onChange={onChange}
|
||||
description={currentTeam?.name ?? ""}
|
||||
// Must not allow toggling off if the slug conflicts with the org slug
|
||||
disabled={slugConflictsWithOrg}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
{moveTeams[index].shouldMove ? (
|
||||
<TextField
|
||||
placeholder="New Slug"
|
||||
defaultValue={teams.find((t) => t.id === team.id)?.slug ?? ""}
|
||||
{...register(`moveTeams.${index}.newSlug`)}
|
||||
onChange={(e) => {
|
||||
const slug = slugify(e.target.value, true);
|
||||
setValue(`moveTeams.${index}.newSlug`, slug);
|
||||
}}
|
||||
className="mt-2"
|
||||
label=""
|
||||
/>
|
||||
) : null}
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
</>
|
||||
) : null}
|
||||
<label className="text-emphasis mb-2 block text-sm font-medium leading-none">Add New Teams</label>
|
||||
{fields.map((field, index) => (
|
||||
<div className={classNames("relative", index > 0 ? "mb-2" : "")} key={field.id}>
|
||||
<TextField
|
||||
key={field.id}
|
||||
{...register(`teams.${index}.name`)}
|
||||
data-testid={`team.${index}.name`}
|
||||
label=""
|
||||
addOnClassname="bg-transparent p-0 border-l-0"
|
||||
className={index > 0 ? "mb-2" : ""}
|
||||
placeholder={t(`org_team_names_example_${index + 1}`)}
|
||||
addOnSuffix={
|
||||
index > 0 && (
|
||||
<Button
|
||||
color="minimal"
|
||||
className="group/remove mx-2 px-0 hover:bg-transparent"
|
||||
onClick={() => handleRemoveInput(index)}
|
||||
aria-label="Remove Team">
|
||||
<Icon
|
||||
name="x"
|
||||
className="bg-subtle text group-hover/remove:text-inverted group-hover/remove:bg-inverted h-5 w-5 rounded-full p-1"
|
||||
/>
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
minLength={2}
|
||||
maxLength={63}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
{counter === 5 && <p className="text-subtle my-2 text-sm">{t("org_max_team_warnings")}</p>}
|
||||
{counter < 5 && (
|
||||
<Button
|
||||
StartIcon="plus"
|
||||
color="secondary"
|
||||
onClick={handleCounterIncrease}
|
||||
aria-label={t("add_a_team")}
|
||||
className="my-1"
|
||||
data-testId="add_a_team">
|
||||
{t("add_a_team")}
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
EndIcon="arrow-right"
|
||||
type="submit"
|
||||
color="primary"
|
||||
className="mt-6 w-full justify-center"
|
||||
data-testId="continue_or_checkout">
|
||||
{t("continue")}
|
||||
</Button>
|
||||
</Form>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const getSuggestedSlug = ({ teamSlug, orgSlug }: { teamSlug: string | null; orgSlug: string | null }) => {
|
||||
// If there is no orgSlug, we can't suggest a slug
|
||||
if (!teamSlug || !orgSlug) {
|
||||
return teamSlug;
|
||||
}
|
||||
|
||||
return teamSlug.replace(`${orgSlug}-`, "").replace(`-${orgSlug}`, "");
|
||||
};
|
||||
@@ -1,248 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
|
||||
import { setShowNewOrgModalFlag } from "@calcom/features/ee/organizations/hooks/useWelcomeModal";
|
||||
import { useOnboarding } from "@calcom/features/ee/organizations/lib/onboardingStore";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Alert } from "@calcom/ui/components/alert";
|
||||
import { Avatar } from "@calcom/ui/components/avatar";
|
||||
import { Badge } from "@calcom/ui/components/badge";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { TextField } from "@calcom/ui/components/form";
|
||||
import { SkeletonButton, SkeletonContainer, SkeletonText } from "@calcom/ui/components/skeleton";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
import { Tooltip } from "@calcom/ui/components/tooltip";
|
||||
|
||||
type TeamMember = RouterOutputs["viewer"]["teams"]["listMembers"]["members"][number];
|
||||
|
||||
const AddNewTeamMembers = () => {
|
||||
const session = useSession();
|
||||
|
||||
if (session.status === "loading") {
|
||||
return <SkeletonContainer>Loading...</SkeletonContainer>;
|
||||
}
|
||||
return <AddNewTeamMembersForm />;
|
||||
};
|
||||
|
||||
const useOrgCreation = () => {
|
||||
const { t } = useLocale();
|
||||
const session = useSession();
|
||||
const utils = trpc.useUtils();
|
||||
const [serverErrorMessage, setServerErrorMessage] = useState("");
|
||||
const { useOnboardingStore } = useOnboarding();
|
||||
const { reset } = useOnboardingStore();
|
||||
|
||||
// Single mutation for all flows (billing, self-hosted, admin)
|
||||
const intentToCreateOrgMutation = trpc.viewer.organizations.intentToCreateOrg.useMutation({
|
||||
onSuccess: async (data) => {
|
||||
reset({
|
||||
onboardingId: data.organizationOnboardingId,
|
||||
});
|
||||
|
||||
if (data.checkoutUrl) {
|
||||
// Billing enabled - redirect to Stripe
|
||||
window.location.href = data.checkoutUrl;
|
||||
} else if (data.organizationId) {
|
||||
// Self-hosted - org already created, redirect to organizations
|
||||
await utils.viewer.organizations.listCurrent.invalidate();
|
||||
await session.update();
|
||||
reset();
|
||||
// Set flag to show welcome modal (using both query param and sessionStorage for reliability)
|
||||
setShowNewOrgModalFlag();
|
||||
window.location.href = `${window.location.origin}/settings/organizations/profile?newOrganizationModal=true`;
|
||||
} else {
|
||||
// Unexpected state
|
||||
setServerErrorMessage("Unexpected response from server");
|
||||
}
|
||||
},
|
||||
onError: (error) => {
|
||||
setServerErrorMessage(t(error.message));
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
mutation: intentToCreateOrgMutation,
|
||||
mutate: intentToCreateOrgMutation.mutate,
|
||||
isPending: intentToCreateOrgMutation.isPending,
|
||||
errorMessage: serverErrorMessage,
|
||||
};
|
||||
};
|
||||
|
||||
export const AddNewTeamMembersForm = () => {
|
||||
const { t } = useLocale();
|
||||
const { useOnboardingStore, isBillingEnabled } = useOnboarding();
|
||||
const {
|
||||
addInvitedMember,
|
||||
removeInvitedMember,
|
||||
orgOwnerEmail,
|
||||
teams,
|
||||
invitedMembers,
|
||||
logo,
|
||||
bio,
|
||||
name,
|
||||
slug,
|
||||
billingPeriod,
|
||||
seats,
|
||||
pricePerSeat,
|
||||
brandColor,
|
||||
bannerUrl,
|
||||
} = useOnboardingStore();
|
||||
const orgCreation = useOrgCreation();
|
||||
|
||||
const teamIds = teams.filter((team) => team.isBeingMigrated && team.id > 0).map((team) => team.id);
|
||||
|
||||
const results = trpc.useQueries((t) => teamIds.map((teamId) => t.viewer.teams.listMembers({ teamId })));
|
||||
|
||||
const isLoading = results.some((result) => result.isLoading);
|
||||
|
||||
// Combine all members and remove duplicates
|
||||
const uniqueMembers = results
|
||||
.reduce<TeamMember[]>((acc, result) => {
|
||||
if (result.data?.members) {
|
||||
return [...acc, ...result.data.members];
|
||||
}
|
||||
return acc;
|
||||
}, [])
|
||||
.filter((member, index, self) => index === self.findIndex((m) => m.email === member.email));
|
||||
|
||||
const { register, handleSubmit, reset } = useForm<{ email: string }>();
|
||||
|
||||
const onSubmit = handleSubmit((data) => {
|
||||
const parsedEmail = z.string().email().safeParse(data.email);
|
||||
if (!parsedEmail.success) {
|
||||
return;
|
||||
}
|
||||
|
||||
const normalizedEmail = parsedEmail.data.toLowerCase();
|
||||
|
||||
// Check if email exists in either invitedMembers or uniqueMembers
|
||||
const isInvited = invitedMembers.some((member) => member.email.toLowerCase() === normalizedEmail);
|
||||
const isExisting = uniqueMembers?.some((member) => member.email.toLowerCase() === normalizedEmail);
|
||||
|
||||
if (isInvited || isExisting) {
|
||||
showToast(t("member_already_invited"), "error");
|
||||
return;
|
||||
}
|
||||
|
||||
addInvitedMember({ email: normalizedEmail });
|
||||
reset();
|
||||
});
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<SkeletonContainer as="div" className="stack-y-6">
|
||||
<SkeletonText className="h-8 w-full" />
|
||||
<SkeletonText className="h-8 w-full" />
|
||||
<SkeletonButton className="mr-6 h-8 w-20 rounded-md p-5" />
|
||||
</SkeletonContainer>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{orgCreation.errorMessage && (
|
||||
<div className="mb-4">
|
||||
<Alert severity="error" message={orgCreation.errorMessage} />
|
||||
</div>
|
||||
)}
|
||||
<div className="stack-y-6">
|
||||
<div className="flex space-x-3">
|
||||
<form onSubmit={onSubmit} className="flex w-full items-end space-x-2">
|
||||
<div className="grow">
|
||||
<TextField
|
||||
label={t("email")}
|
||||
type="email"
|
||||
{...register("email", { required: true })}
|
||||
placeholder="[email protected]"
|
||||
/>
|
||||
</div>
|
||||
<Button type="submit" StartIcon="plus" color="secondary" data-testid="invite-new-member-button">
|
||||
{t("add")}
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{(invitedMembers.length > 0 || uniqueMembers?.length > 0) && (
|
||||
<ul
|
||||
className="border-subtle divide-subtle max-h-[300px] divide-y overflow-y-auto rounded-md border"
|
||||
data-testid="pending-member-list">
|
||||
{invitedMembers.map((member) => (
|
||||
<li key={member.email} className="flex items-center justify-between px-5 py-2">
|
||||
<div className="flex items-center space-x-3">
|
||||
<Avatar size="sm" alt={member.email} />
|
||||
<div className="flex gap-1">
|
||||
<Tooltip content={member.email}>
|
||||
<span className="text-subtle max-w-[250px] truncate text-sm">{member.email}</span>
|
||||
</Tooltip>
|
||||
<Badge variant="gray">{t("pending")}</Badge>
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
variant="icon"
|
||||
size="sm"
|
||||
color="minimal"
|
||||
StartIcon="x"
|
||||
onClick={() => removeInvitedMember(member.email)}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
{uniqueMembers?.map((member) => (
|
||||
<li key={member.email} className="flex items-center justify-between px-5 py-2">
|
||||
<div className="flex items-center space-x-3">
|
||||
<Avatar size="sm" alt={member.email} imageSrc={member.avatarUrl} />
|
||||
<div className="flex gap-1">
|
||||
<Tooltip content={member.email}>
|
||||
<span className="text-emphasis text-sm font-medium">{member.name || member.email}</span>
|
||||
</Tooltip>
|
||||
{/* TODO: We should show the team name here instead of "migrating from team" */}
|
||||
<Badge variant="green">{t("migrating_from_team")}</Badge>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="mt-3 flex items-center justify-end">
|
||||
<Button
|
||||
data-testid="publish-button"
|
||||
onClick={() => {
|
||||
// Submit ALL data to intentToCreateOrg
|
||||
if (!name || !slug || !orgOwnerEmail) {
|
||||
console.error("Required fields missing", { name, slug, orgOwnerEmail });
|
||||
showToast(t("required_fields_missing"), "error");
|
||||
return;
|
||||
}
|
||||
|
||||
orgCreation.mutate({
|
||||
name,
|
||||
slug,
|
||||
orgOwnerEmail,
|
||||
seats,
|
||||
pricePerSeat,
|
||||
billingPeriod,
|
||||
creationSource: "WEBAPP" as const,
|
||||
logo,
|
||||
bio,
|
||||
brandColor,
|
||||
bannerUrl,
|
||||
teams,
|
||||
invitedMembers,
|
||||
});
|
||||
}}
|
||||
loading={orgCreation.isPending}>
|
||||
{isBillingEnabled ? t("checkout") : t("create")}
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default AddNewTeamMembers;
|
||||
@@ -1,35 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Alert } from "@calcom/ui/components/alert";
|
||||
import { WizardLayout } from "@calcom/ui/components/layout";
|
||||
|
||||
interface OrganizationWizardLayoutProps {
|
||||
children: React.ReactNode;
|
||||
currentStep: number;
|
||||
maxSteps?: number;
|
||||
isOptionalCallback?: () => void;
|
||||
footer?: React.ReactNode;
|
||||
}
|
||||
|
||||
export function OrganizationWizardLayout({
|
||||
children,
|
||||
currentStep,
|
||||
maxSteps = 5,
|
||||
isOptionalCallback,
|
||||
footer,
|
||||
}: OrganizationWizardLayoutProps) {
|
||||
const { t } = useLocale();
|
||||
|
||||
const defaultFooter = <Alert severity="warning" message={t("organization_trial_workspace_warning")} />;
|
||||
|
||||
return (
|
||||
<WizardLayout
|
||||
currentStep={currentStep}
|
||||
maxSteps={maxSteps}
|
||||
isOptionalCallback={isOptionalCallback}
|
||||
footer={footer ?? defaultFooter}>
|
||||
{children}
|
||||
</WizardLayout>
|
||||
);
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import { useOnboarding } from "@calcom/features/ee/organizations/lib/onboardingStore";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
|
||||
const PaymentStatusView = () => {
|
||||
const { t } = useLocale();
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const paymentStatus = searchParams?.get("paymentStatus");
|
||||
const paymentError = searchParams?.get("error");
|
||||
const { useOnboardingStore } = useOnboarding();
|
||||
const [organizationCreated, setOrganizationCreated] = useState<boolean>(false);
|
||||
const { name } = useOnboardingStore();
|
||||
|
||||
const { data: organization } = trpc.viewer.organizations.listCurrent.useQuery(undefined, {
|
||||
refetchInterval: 2000, // Poll every 2 seconds until org is created
|
||||
enabled: !organizationCreated,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (organization) {
|
||||
setOrganizationCreated(true);
|
||||
// Organization is created, redirect to next step
|
||||
router.push(`/settings/organizations?newOrganizationModal=true`);
|
||||
}
|
||||
}, [organization, router, useOnboardingStore]);
|
||||
|
||||
if (paymentStatus === "failed" || paymentError) {
|
||||
return (
|
||||
<div className="flex min-h-[500px] flex-col items-center justify-center stack-y-6 px-4 sm:px-6">
|
||||
<div className="flex h-12 w-12 items-center justify-center rounded-full bg-red-100">
|
||||
<Icon name="x" className="h-6 w-6 text-red-600" />
|
||||
</div>
|
||||
<div className="text-center">
|
||||
<h1 className="font-cal text-emphasis text-2xl">{t("payment_failed")}</h1>
|
||||
<p className="text-default mt-2 text-sm">{paymentError || t("payment_failed_description")}</p>
|
||||
</div>
|
||||
<Button color="secondary" href="/settings/organizations/new/onboard-members">
|
||||
{t("try_again")}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex min-h-[500px] flex-col items-center justify-center stack-y-6 px-4 sm:px-6">
|
||||
<div className="flex h-12 w-12 items-center justify-center rounded-full bg-green-100">
|
||||
<Icon name="check" className="h-6 w-6 text-green-600 dark:text-green-400" />
|
||||
</div>
|
||||
<div className="text-center">
|
||||
<h1 className="font-cal text-emphasis text-2xl">{t("payment_successful")}</h1>
|
||||
<p className="text-default mt-2 text-sm">{t("creating_your_organization", { orgName: name })}</p>
|
||||
<p className="text-subtle mt-1 text-sm">{t("this_may_take_a_few_seconds")}</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default PaymentStatusView;
|
||||
@@ -1,11 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { AboutOrganizationForm } from "@calcom/features/ee/organizations/components";
|
||||
|
||||
import { OrganizationWizardLayout } from "./_components/OrganizationWizardLayout";
|
||||
|
||||
export const LayoutWrapper = ({ children }: { children: React.ReactNode }) => {
|
||||
return <OrganizationWizardLayout currentStep={2}>{children}</OrganizationWizardLayout>;
|
||||
};
|
||||
|
||||
export default AboutOrganizationForm;
|
||||
@@ -1,10 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { AddNewTeamsForm } from "./_components/AddNewTeamsForm";
|
||||
import { OrganizationWizardLayout } from "./_components/OrganizationWizardLayout";
|
||||
|
||||
export const LayoutWrapper = ({ children }: { children: React.ReactNode }) => {
|
||||
return <OrganizationWizardLayout currentStep={3}>{children}</OrganizationWizardLayout>;
|
||||
};
|
||||
|
||||
export default AddNewTeamsForm;
|
||||
@@ -1,27 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { CreateANewOrganizationForm } from "@calcom/features/ee/organizations/components";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Alert } from "@calcom/ui/components/alert";
|
||||
import { useGetUserAttributes } from "@calcom/web/components/settings/platform/hooks/useGetUserAttributes";
|
||||
|
||||
import { OrganizationWizardLayout } from "./_components/OrganizationWizardLayout";
|
||||
|
||||
export const LayoutWrapper = ({ children }: { children: React.ReactNode }) => {
|
||||
const { t } = useLocale();
|
||||
const { isPlatformUser } = useGetUserAttributes();
|
||||
|
||||
if (isPlatformUser) {
|
||||
return (
|
||||
<div className="flex h-full min-h-screen items-center justify-center">
|
||||
<div className="max-w-lg">
|
||||
<Alert severity="warning" title={t("platform_customer_cant_create_organization")} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return <OrganizationWizardLayout currentStep={1}>{children}</OrganizationWizardLayout>;
|
||||
};
|
||||
|
||||
export default CreateANewOrganizationForm;
|
||||
@@ -1,39 +0,0 @@
|
||||
graph TD
|
||||
Start[Start] --> AboutOrg[About Organization Form]
|
||||
AboutOrg -->|Set Name, Logo, Bio| Teams[Add Teams]
|
||||
Teams -->|Create/Migrate Teams| Members[Add Team Members]
|
||||
Members -->|Add Members & Invite| Payment[Payment]
|
||||
Payment -->|Create Payment Intent| StripeCheckout[Stripe Checkout]
|
||||
StripeCheckout -->|Success| PaymentSuccess[Payment Success View]
|
||||
StripeCheckout -->|Failure| Payment
|
||||
|
||||
subgraph "About Organization"
|
||||
AboutOrg -->|Store in onboardingStore| OrgData[Organization Data]
|
||||
OrgData -->|"Name, Logo, Bio"| ValidateSlug[Validate Slug]
|
||||
end
|
||||
|
||||
subgraph "Teams Setup"
|
||||
Teams -->|Store in onboardingStore| TeamData[Teams Data]
|
||||
TeamData -->|"Create New/Migrate"| TeamMembers[Team Members]
|
||||
end
|
||||
|
||||
subgraph "Members Setup"
|
||||
Members -->|Store in onboardingStore| MemberData[Members Data]
|
||||
MemberData -->|"Invited/Migrating"| MembersList[Members List]
|
||||
end
|
||||
|
||||
subgraph "Payment Process"
|
||||
Payment -->|Create Intent| PaymentData[Payment Data]
|
||||
PaymentData -->|"Billing Period, Price/Seat"| StripeSession[Stripe Session]
|
||||
end
|
||||
|
||||
subgraph "Webhook Handling"
|
||||
StripeCheckout -->|invoice.paid| WebhookHandler[Webhook Handler]
|
||||
WebhookHandler -->|Process Payment| OrgCreation[Create Organization]
|
||||
OrgCreation --> Complete[Complete]
|
||||
end
|
||||
|
||||
style Start fill:#f9f,stroke:#333,stroke-width:2px
|
||||
style Complete fill:#9f9,stroke:#333,stroke-width:2px
|
||||
style StripeCheckout fill:#fdd,stroke:#333,stroke-width:2px
|
||||
style WebhookHandler fill:#ddf,stroke:#333,stroke-width:2px
|
||||
@@ -1,10 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import AddNewTeamMembers from "./_components/OnboardMembersView";
|
||||
import { OrganizationWizardLayout } from "./_components/OrganizationWizardLayout";
|
||||
|
||||
export const LayoutWrapper = ({ children }: { children: React.ReactNode }) => {
|
||||
return <OrganizationWizardLayout currentStep={4}>{children}</OrganizationWizardLayout>;
|
||||
};
|
||||
|
||||
export default AddNewTeamMembers;
|
||||
@@ -1,14 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { AdminOnboardingHandover } from "@calcom/features/ee/organizations/components";
|
||||
import { WizardLayout } from "@calcom/ui/components/layout";
|
||||
|
||||
export const LayoutWrapper = ({ children }: { children: React.ReactNode }) => {
|
||||
return (
|
||||
<WizardLayout currentStep={2} maxSteps={2}>
|
||||
{children}
|
||||
</WizardLayout>
|
||||
);
|
||||
};
|
||||
|
||||
export default AdminOnboardingHandover;
|
||||
@@ -1,11 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import PaymentStatusView from "~/settings/organizations/new/_components/PaymentStatusView";
|
||||
|
||||
import { OrganizationWizardLayout } from "./_components/OrganizationWizardLayout";
|
||||
|
||||
export const LayoutWrapper = ({ children }: { children: React.ReactNode }) => {
|
||||
return <OrganizationWizardLayout currentStep={5}>{children}</OrganizationWizardLayout>;
|
||||
};
|
||||
|
||||
export default PaymentStatusView;
|
||||
@@ -1,111 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { useEffect } from "react";
|
||||
|
||||
import { useOnboarding } from "@calcom/features/ee/organizations/lib/onboardingStore";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Alert } from "@calcom/ui/components/alert";
|
||||
import { SkeletonContainer, SkeletonText } from "@calcom/ui/components/skeleton";
|
||||
|
||||
import { OrganizationWizardLayout } from "./_components/OrganizationWizardLayout";
|
||||
|
||||
export const LayoutWrapper = ({ children }: { children: React.ReactNode }) => {
|
||||
return <OrganizationWizardLayout currentStep={1}>{children}</OrganizationWizardLayout>;
|
||||
};
|
||||
|
||||
const ResumeOnboardingView = () => {
|
||||
const { t } = useLocale();
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const onboardingIdParam = searchParams?.get("onboardingId");
|
||||
|
||||
const { dbOnboarding, isLoadingOrgOnboarding, useOnboardingStore } = useOnboarding();
|
||||
const { reset } = useOnboardingStore();
|
||||
|
||||
useEffect(() => {
|
||||
if (isLoadingOrgOnboarding) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!onboardingIdParam) {
|
||||
router.push("/settings/organizations/new");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!dbOnboarding) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (dbOnboarding.isComplete) {
|
||||
router.push("/settings/organizations");
|
||||
return;
|
||||
}
|
||||
|
||||
// Load onboarding data into store
|
||||
reset({
|
||||
onboardingId: dbOnboarding.id,
|
||||
name: dbOnboarding.name,
|
||||
slug: dbOnboarding.slug,
|
||||
orgOwnerEmail: dbOnboarding.orgOwnerEmail,
|
||||
billingPeriod: dbOnboarding.billingPeriod,
|
||||
seats: dbOnboarding.seats,
|
||||
pricePerSeat: dbOnboarding.pricePerSeat,
|
||||
logo: dbOnboarding.logo,
|
||||
bio: dbOnboarding.bio,
|
||||
brandColor: dbOnboarding.brandColor,
|
||||
bannerUrl: dbOnboarding.bannerUrl,
|
||||
});
|
||||
|
||||
// Redirect to next step (About page)
|
||||
router.push("/settings/organizations/new/about");
|
||||
}, [dbOnboarding, isLoadingOrgOnboarding, onboardingIdParam, reset, router]);
|
||||
|
||||
if (isLoadingOrgOnboarding) {
|
||||
return (
|
||||
<SkeletonContainer className="stack-y-4">
|
||||
<SkeletonText className="h-8 w-full" />
|
||||
<SkeletonText className="h-4 w-3/4" />
|
||||
<SkeletonText className="h-4 w-1/2" />
|
||||
</SkeletonContainer>
|
||||
);
|
||||
}
|
||||
|
||||
if (!onboardingIdParam) {
|
||||
return (
|
||||
<Alert
|
||||
data-testid="error"
|
||||
severity="error"
|
||||
title={t("error")}
|
||||
message={t("no_onboarding_id_provided")}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (!dbOnboarding) {
|
||||
return (
|
||||
<Alert data-testid="error" severity="error" title={t("error")} message={t("onboarding_not_found")} />
|
||||
);
|
||||
}
|
||||
|
||||
if (dbOnboarding.isComplete) {
|
||||
return (
|
||||
<Alert
|
||||
data-testid="error"
|
||||
severity="info"
|
||||
title={t("onboarding_already_complete")}
|
||||
message={t("onboarding_already_complete_description")}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
// Loading state while redirecting
|
||||
return (
|
||||
<SkeletonContainer className="stack-y-4">
|
||||
<SkeletonText className="h-8 w-full" />
|
||||
<SkeletonText className="h-4 w-3/4" />
|
||||
</SkeletonContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default ResumeOnboardingView;
|
||||
@@ -1,72 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
|
||||
import { DataTableToolbar } from "@calcom/features/data-table";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { ToggleGroup } from "@calcom/ui/components/form";
|
||||
|
||||
import PendingReportsBadge from "./components/PendingReportsBadge";
|
||||
import { BlockedEntriesTable } from "./components/blocked-entries-table";
|
||||
import { CreateBlocklistEntryModal } from "./components/create-blocklist-entry-modal";
|
||||
import { PendingReportsTable } from "./components/pending-reports-table";
|
||||
|
||||
type ViewType = "blocked" | "pending";
|
||||
|
||||
interface BlocklistTableProps {
|
||||
permissions?: {
|
||||
canRead: boolean;
|
||||
canCreate: boolean;
|
||||
canDelete: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export function BlocklistTable({ permissions }: BlocklistTableProps) {
|
||||
const { t } = useLocale();
|
||||
const [activeView, setActiveView] = useState<ViewType>("blocked");
|
||||
const [showCreateModal, setShowCreateModal] = useState(false);
|
||||
|
||||
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 />
|
||||
</span>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<DataTableToolbar.SearchBar />
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
{permissions?.canCreate && (
|
||||
<Button color="primary" StartIcon="plus" onClick={() => setShowCreateModal(true)}>
|
||||
{t("add")}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{activeView === "blocked" ? (
|
||||
<BlockedEntriesTable permissions={permissions} onAddClick={() => setShowCreateModal(true)} />
|
||||
) : (
|
||||
<PendingReportsTable />
|
||||
)}
|
||||
|
||||
<CreateBlocklistEntryModal isOpen={showCreateModal} onClose={() => setShowCreateModal(false)} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Badge } from "@calcom/ui/components/badge";
|
||||
|
||||
export default function PendingReportsBadge() {
|
||||
const { data: pendingReportsCount } = trpc.viewer.organizations.pendingReportsCount.useQuery();
|
||||
if (!pendingReportsCount) return null;
|
||||
return (
|
||||
<Badge rounded variant="orange" className="ml-1">
|
||||
{pendingReportsCount}
|
||||
</Badge>
|
||||
);
|
||||
}
|
||||
-108
@@ -1,108 +0,0 @@
|
||||
import type { ColumnDef } from "@tanstack/react-table";
|
||||
import { useMemo } from "react";
|
||||
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import { Badge } from "@calcom/ui/components/badge";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import {
|
||||
Dropdown,
|
||||
DropdownItem,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@calcom/ui/components/dropdown";
|
||||
|
||||
type BlocklistEntry = RouterOutputs["viewer"]["organizations"]["listWatchlistEntries"]["rows"][number];
|
||||
|
||||
interface UseBlockedEntriesColumnsProps {
|
||||
t: (key: string) => string;
|
||||
canDelete?: boolean;
|
||||
onViewDetails: (entry: BlocklistEntry) => void;
|
||||
onDelete: (entry: BlocklistEntry) => void;
|
||||
}
|
||||
|
||||
export function useBlockedEntriesColumns({
|
||||
t,
|
||||
canDelete,
|
||||
onViewDetails,
|
||||
onDelete,
|
||||
}: UseBlockedEntriesColumnsProps) {
|
||||
return useMemo<ColumnDef<BlocklistEntry>[]>(
|
||||
() => [
|
||||
{
|
||||
id: "email_slash_domain",
|
||||
header: t("email_slash_domain"),
|
||||
accessorKey: "value",
|
||||
enableHiding: false,
|
||||
cell: ({ row }) => <span className="text-emphasis">{row.original.value}</span>,
|
||||
},
|
||||
{
|
||||
id: "type",
|
||||
header: t("type"),
|
||||
accessorKey: "type",
|
||||
size: 100,
|
||||
cell: ({ row }) => (
|
||||
<Badge variant="blue">{row.original.type === "EMAIL" ? t("email") : t("domain")}</Badge>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "createdBy",
|
||||
header: t("blocked_by"),
|
||||
size: 180,
|
||||
cell: ({ row }) => {
|
||||
const audit = row.original.latestAudit as
|
||||
| { changedByUserId: number | null }
|
||||
| {
|
||||
changedByUser?: { id: number; email: string; name: string | null } | undefined;
|
||||
changedByUserId: number | null;
|
||||
}
|
||||
| null;
|
||||
const email =
|
||||
(audit && "changedByUser" in audit ? audit.changedByUser?.email : undefined) ?? undefined;
|
||||
return <span className="text-default">{email ?? "—"}</span>;
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
header: "",
|
||||
size: 90,
|
||||
minSize: 90,
|
||||
maxSize: 90,
|
||||
enableHiding: false,
|
||||
enableSorting: false,
|
||||
enableResizing: false,
|
||||
cell: ({ row }) => {
|
||||
const entry = row.original;
|
||||
return (
|
||||
<div className="flex items-center justify-end">
|
||||
<Dropdown modal={false}>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button type="button" variant="icon" color="secondary" StartIcon="ellipsis" />
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent>
|
||||
<DropdownMenuItem>
|
||||
<DropdownItem type="button" StartIcon="eye" onClick={() => onViewDetails(entry)}>
|
||||
{t("view_details")}
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
{canDelete && (
|
||||
<DropdownMenuItem>
|
||||
<DropdownItem
|
||||
type="button"
|
||||
color="destructive"
|
||||
StartIcon="trash"
|
||||
onClick={() => onDelete(entry)}>
|
||||
{t("remove_from_blocklist")}
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
</DropdownMenuContent>
|
||||
</Dropdown>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
],
|
||||
[t, canDelete, onViewDetails, onDelete]
|
||||
);
|
||||
}
|
||||
@@ -1,165 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { keepPreviousData } from "@tanstack/react-query";
|
||||
import { getCoreRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
|
||||
import { useMemo, useState } from "react";
|
||||
|
||||
import { DataTableWrapper, useDataTable } from "@calcom/features/data-table";
|
||||
import { IS_CALCOM } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { ConfirmationDialogContent, Dialog, DialogClose } from "@calcom/ui/components/dialog";
|
||||
import { EmptyScreen } from "@calcom/ui/components/empty-screen";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
import { useBlockedEntriesColumns } from "./blocked-entries-columns";
|
||||
import { BlocklistEntryDetailsSheet } from "./blocklist-entry-details-sheet";
|
||||
|
||||
type BlocklistEntry = RouterOutputs["viewer"]["organizations"]["listWatchlistEntries"]["rows"][number];
|
||||
|
||||
interface BlockedEntriesTableProps {
|
||||
permissions?: {
|
||||
canRead: boolean;
|
||||
canCreate: boolean;
|
||||
canDelete: boolean;
|
||||
};
|
||||
onAddClick: () => void;
|
||||
}
|
||||
|
||||
export function BlockedEntriesTable({ permissions, onAddClick }: BlockedEntriesTableProps) {
|
||||
const { t } = useLocale();
|
||||
const { limit, offset, searchTerm } = useDataTable();
|
||||
|
||||
const [showDetailsSheet, setShowDetailsSheet] = useState(false);
|
||||
const [selectedEntry, setSelectedEntry] = useState<BlocklistEntry | null>(null);
|
||||
const [entryToDelete, setEntryToDelete] = useState<BlocklistEntry | null>(null);
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||
|
||||
const { data, isPending } = trpc.viewer.organizations.listWatchlistEntries.useQuery(
|
||||
{
|
||||
limit,
|
||||
offset,
|
||||
searchTerm,
|
||||
},
|
||||
{
|
||||
placeholderData: keepPreviousData,
|
||||
}
|
||||
);
|
||||
|
||||
const utils = trpc.useUtils();
|
||||
|
||||
const deleteWatchlistEntry = trpc.viewer.organizations.deleteWatchlistEntry.useMutation({
|
||||
onSuccess: async () => {
|
||||
await utils.viewer.organizations.listWatchlistEntries.invalidate();
|
||||
showToast(t("blocklist_entry_deleted"), "success");
|
||||
setShowDeleteDialog(false);
|
||||
setEntryToDelete(null);
|
||||
},
|
||||
onError: (error) => {
|
||||
showToast(error.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
const handleViewDetails = (entry: BlocklistEntry) => {
|
||||
setSelectedEntry(entry);
|
||||
setShowDetailsSheet(true);
|
||||
};
|
||||
|
||||
const handleDelete = (entry: BlocklistEntry) => {
|
||||
setEntryToDelete(entry);
|
||||
setShowDeleteDialog(true);
|
||||
};
|
||||
|
||||
const confirmDelete = () => {
|
||||
if (entryToDelete) {
|
||||
deleteWatchlistEntry.mutate({ id: entryToDelete.id });
|
||||
}
|
||||
};
|
||||
|
||||
const columns = useBlockedEntriesColumns({
|
||||
t,
|
||||
canDelete: permissions?.canDelete,
|
||||
onViewDetails: handleViewDetails,
|
||||
onDelete: handleDelete,
|
||||
});
|
||||
|
||||
const totalRowCount = data?.meta?.totalRowCount ?? 0;
|
||||
const flatData = useMemo(() => data?.rows ?? [], [data]);
|
||||
|
||||
const table = useReactTable({
|
||||
data: flatData,
|
||||
columns,
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
getSortedRowModel: getSortedRowModel(),
|
||||
manualPagination: true,
|
||||
pageCount: Math.ceil(totalRowCount / limit),
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<DataTableWrapper
|
||||
table={table}
|
||||
isPending={isPending}
|
||||
variant="default"
|
||||
paginationMode="standard"
|
||||
EmptyView={
|
||||
<EmptyScreen
|
||||
customIcon={<img className="mb-6" src="/slash-icon-cards.svg" />}
|
||||
headline={searchTerm ? t("no_result_found_for", { searchTerm }) : t("pbac_resource_blocklist")}
|
||||
description={t("add_people_to_blocklist")}
|
||||
className="bg-muted mb-16"
|
||||
iconWrapperClassName="bg-default"
|
||||
dashedBorder={false}
|
||||
buttonRaw={
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
StartIcon="plus"
|
||||
onClick={onAddClick}
|
||||
color="primary"
|
||||
disabled={!permissions?.canCreate}>
|
||||
{t("add")}
|
||||
</Button>
|
||||
{IS_CALCOM && (
|
||||
<Button
|
||||
StartIcon="book"
|
||||
color="secondary"
|
||||
onClick={() =>
|
||||
window.open("https://cal.com/help/security/blocklist", "_blank", "noopener,noreferrer")
|
||||
}>
|
||||
{t("docs")}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
}
|
||||
totalRowCount={totalRowCount}
|
||||
/>
|
||||
|
||||
<BlocklistEntryDetailsSheet
|
||||
entry={selectedEntry}
|
||||
isOpen={showDetailsSheet}
|
||||
onClose={() => {
|
||||
setShowDetailsSheet(false);
|
||||
setSelectedEntry(null);
|
||||
}}
|
||||
handleDeleteBlocklistEntry={handleDelete}
|
||||
/>
|
||||
|
||||
<Dialog open={showDeleteDialog} onOpenChange={setShowDeleteDialog}>
|
||||
<ConfirmationDialogContent
|
||||
variety="danger"
|
||||
title={t("remove_value_from_blocklist", { value: entryToDelete?.value })}
|
||||
confirmBtn={
|
||||
<DialogClose color="destructive" onClick={confirmDelete}>
|
||||
{t("remove")}
|
||||
</DialogClose>
|
||||
}>
|
||||
{t("remove_value_from_blocklist_description")}
|
||||
</ConfirmationDialogContent>
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
}
|
||||
-157
@@ -1,157 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { format } from "date-fns";
|
||||
import Link from "next/link";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
import {
|
||||
Sheet,
|
||||
SheetContent,
|
||||
SheetBody,
|
||||
SheetHeader,
|
||||
SheetTitle,
|
||||
SheetFooter,
|
||||
} from "@calcom/ui/components/sheet";
|
||||
import { SkeletonText } from "@calcom/ui/components/skeleton";
|
||||
|
||||
type BlocklistEntry = RouterOutputs["viewer"]["organizations"]["listWatchlistEntries"]["rows"][number];
|
||||
|
||||
interface BlocklistEntryDetailsSheetProps {
|
||||
entry: BlocklistEntry | null;
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
handleDeleteBlocklistEntry: (entry: BlocklistEntry) => void;
|
||||
}
|
||||
|
||||
export function BlocklistEntryDetailsSheet({
|
||||
entry,
|
||||
isOpen,
|
||||
onClose,
|
||||
handleDeleteBlocklistEntry,
|
||||
}: BlocklistEntryDetailsSheetProps) {
|
||||
const { t } = useLocale();
|
||||
|
||||
const { data, isLoading } = trpc.viewer.organizations.getWatchlistEntryDetails.useQuery(
|
||||
{ id: entry?.id ?? "" },
|
||||
{
|
||||
enabled: !!entry?.id && isOpen,
|
||||
}
|
||||
);
|
||||
|
||||
return (
|
||||
<Sheet
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose();
|
||||
}}>
|
||||
<SheetContent className="px-0 pb-0 sm:max-w-xl sm:px-0 sm:pb-0">
|
||||
<SheetHeader className="px-6">
|
||||
<SheetTitle>{entry?.value}</SheetTitle>
|
||||
</SheetHeader>
|
||||
|
||||
<SheetBody className="px-6">
|
||||
{isLoading ? (
|
||||
<div className="mt-3 stack-y-3">
|
||||
<SkeletonText className="h-6 w-32" />
|
||||
<SkeletonText className="h-40 w-full" />
|
||||
</div>
|
||||
) : data?.entry ? (
|
||||
<div className="mt-3 stack-y-6">
|
||||
<div className="bg-subtle rounded-xl p-1">
|
||||
<h2 className="text-default p-5 text-sm font-semibold">{t("details")}</h2>
|
||||
|
||||
<div className="bg-default stack-y-3 rounded-xl p-5">
|
||||
<div>
|
||||
<label className="text-default block text-sm font-semibold">
|
||||
{data.entry.type === "EMAIL" ? t("email") : t("domain")}
|
||||
</label>
|
||||
<p className="text-subtle text-sm">{data.entry.value}</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="text-default block text-sm font-semibold">{t("type")}</label>
|
||||
<p className="text-subtle text-sm">
|
||||
{data.entry.type === "EMAIL" ? t("email") : t("domain")}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="text-default block text-sm font-semibold">{t("blocked_by")}</label>
|
||||
<p className="text-subtle text-sm">{data.auditHistory[0]?.changedByUser?.email || "—"}</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="text-default block text-sm font-semibold">{t("description")}</label>
|
||||
<p className="text-subtle text-sm">
|
||||
{data.entry.description || t("no_description_provided")}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{data.entry.bookingReports && data.entry.bookingReports.length > 0 && (
|
||||
<div>
|
||||
<label className="text-default block text-sm font-semibold">
|
||||
{t("related_booking")}
|
||||
</label>
|
||||
|
||||
{data.entry.bookingReports.map((report) => {
|
||||
return (
|
||||
<Link key={report.booking.uid} href={`/booking/${report.booking.uid}`}>
|
||||
<div className="text-subtle flex items-center gap-1 text-sm">
|
||||
{report.booking.title}
|
||||
<Icon name="external-link" className="h-4 w-4" />
|
||||
</div>
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-subtle rounded-xl p-1">
|
||||
<h2 className="text-default p-5 text-sm font-semibold">{t("history")}</h2>
|
||||
{data.auditHistory.length > 0 ? (
|
||||
<div className="stack-y-3">
|
||||
{data.auditHistory.map((audit) => (
|
||||
<div key={audit.id} className="bg-default border-subtle rounded-xl border p-4">
|
||||
<div className="flex items-start justify-between">
|
||||
<div>
|
||||
<span className="text-default text-sm font-semibold">
|
||||
{audit.changedByUser?.name || audit.changedByUser?.email || "—"}
|
||||
</span>
|
||||
<span className="text-subtle text-sm"> {t("added")}</span>
|
||||
<div className="text-default mt-1 text-sm font-semibold">{audit.value}</div>
|
||||
</div>
|
||||
<span className="text-subtle text-sm">
|
||||
{format(new Date(audit.changedAt), "MMM d, h:mm a")}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-subtle text-sm">{t("no_audit_history")}</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-muted mt-8 text-center">{t("blocklist_entry_not_found")}</div>
|
||||
)}
|
||||
</SheetBody>
|
||||
<SheetFooter className="bg-muted px-6 py-5">
|
||||
<Button
|
||||
type="button"
|
||||
color="secondary"
|
||||
onClick={() => entry && handleDeleteBlocklistEntry(entry)}
|
||||
disabled={!entry}>
|
||||
{t("remove_from_blocklist")}
|
||||
</Button>
|
||||
</SheetFooter>
|
||||
</SheetContent>
|
||||
</Sheet>
|
||||
);
|
||||
}
|
||||
-208
@@ -1,208 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { WatchlistType } from "@calcom/prisma/enums";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { Dialog, DialogContent, DialogFooter, DialogHeader } from "@calcom/ui/components/dialog";
|
||||
import { ToggleGroup } from "@calcom/ui/components/form";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
type BookingReport = RouterOutputs["viewer"]["organizations"]["listBookingReports"]["rows"][number];
|
||||
|
||||
interface BookingReportEntryDetailsModalProps {
|
||||
entry: BookingReport | null;
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
interface FormData {
|
||||
blockType: WatchlistType;
|
||||
}
|
||||
|
||||
export function BookingReportEntryDetailsModal({
|
||||
entry,
|
||||
isOpen,
|
||||
onClose,
|
||||
}: BookingReportEntryDetailsModalProps) {
|
||||
const { t } = useLocale();
|
||||
const utils = trpc.useUtils();
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
reset,
|
||||
formState: { isSubmitting },
|
||||
} = useForm<FormData>({
|
||||
defaultValues: {
|
||||
blockType: WatchlistType.EMAIL,
|
||||
},
|
||||
});
|
||||
|
||||
const addToWatchlist = trpc.viewer.organizations.addToWatchlist.useMutation({
|
||||
onSuccess: async () => {
|
||||
await utils.viewer.organizations.listBookingReports.invalidate();
|
||||
await utils.viewer.organizations.listWatchlistEntries.invalidate();
|
||||
showToast(t("blocklist_entry_created"), "success");
|
||||
onClose();
|
||||
reset();
|
||||
},
|
||||
onError: (error) => {
|
||||
showToast(error.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
const dismissBookingReport = trpc.viewer.organizations.dismissBookingReport.useMutation({
|
||||
onSuccess: async () => {
|
||||
await utils.viewer.organizations.listBookingReports.invalidate();
|
||||
showToast(t("booking_report_dismissed"), "success");
|
||||
onClose();
|
||||
reset();
|
||||
},
|
||||
onError: (error) => {
|
||||
showToast(error.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
const onSubmit = (data: FormData) => {
|
||||
if (!entry) return;
|
||||
|
||||
addToWatchlist.mutate({
|
||||
reportIds: [entry.id],
|
||||
type: data.blockType,
|
||||
});
|
||||
};
|
||||
|
||||
const handleDismiss = () => {
|
||||
if (!entry) return;
|
||||
|
||||
dismissBookingReport.mutate({
|
||||
reportId: entry.id,
|
||||
});
|
||||
};
|
||||
|
||||
const handleGoBack = () => {
|
||||
onClose();
|
||||
reset();
|
||||
};
|
||||
|
||||
const reasonMap: Record<string, string> = {
|
||||
SPAM: t("spam"),
|
||||
DONT_KNOW_PERSON: t("dont_know_person"),
|
||||
OTHER: t("other"),
|
||||
};
|
||||
|
||||
if (!entry) return null;
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={onClose}>
|
||||
<DialogContent enableOverflow>
|
||||
<DialogHeader title={t("review_report") + ` - ${entry.bookerEmail}`} />
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
<div className="stack-y-5">
|
||||
<div className="bg-subtle rounded-xl p-1">
|
||||
<h2 className="text-emphasis px-5 py-4 text-base font-semibold">{t("details")}</h2>
|
||||
<div className="bg-default stack-y-4 rounded-xl p-5">
|
||||
<div>
|
||||
<label className="text-emphasis mb-1 block text-sm font-semibold">{t("email")}</label>
|
||||
<p className="text-subtle text-sm">{entry.bookerEmail}</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="text-emphasis mb-1 block text-sm font-semibold">{t("reason")}</label>
|
||||
<p className="text-subtle text-sm">{reasonMap[entry.reason] || entry.reason}</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="text-emphasis mb-1 block text-sm font-semibold">{t("reported_by")}</label>
|
||||
<p className="text-subtle text-sm">{entry.reporter?.email || "—"}</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="text-emphasis mb-1 block text-sm font-semibold">{t("description")}</label>
|
||||
<p className="text-subtle text-sm">{entry.description || t("no_description_provided")}</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="text-emphasis mb-1 block text-sm font-semibold">
|
||||
{t("related_booking")}
|
||||
</label>
|
||||
<Link href={`/booking/${entry.booking.uid}`}>
|
||||
<div className="text-subtle flex items-center gap-1 text-sm">
|
||||
{entry.booking.title}
|
||||
<Icon name="external-link" className="h-4 w-4" />
|
||||
</div>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2 className="text-emphasis mb-2 text-base font-semibold">
|
||||
{t("what_would_you_like_to_block")}
|
||||
</h2>
|
||||
<Controller
|
||||
name="blockType"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<ToggleGroup
|
||||
value={field.value}
|
||||
onValueChange={(value) => {
|
||||
if (value) field.onChange(value);
|
||||
}}
|
||||
options={[
|
||||
{
|
||||
value: WatchlistType.EMAIL,
|
||||
label: t("block_this_email"),
|
||||
iconLeft: <Icon name="mail" className="h-4 w-4" />,
|
||||
},
|
||||
{
|
||||
value: WatchlistType.DOMAIN,
|
||||
label: t("block_all_from_domain"),
|
||||
iconLeft: <Icon name="globe" className="h-4 w-4" />,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DialogFooter className="mt-6">
|
||||
<div className="flex w-full items-center justify-between">
|
||||
<Button
|
||||
type="button"
|
||||
color="minimal"
|
||||
onClick={handleGoBack}
|
||||
disabled={isSubmitting || addToWatchlist.isPending || dismissBookingReport.isPending}>
|
||||
{t("go_back")}
|
||||
</Button>
|
||||
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
type="button"
|
||||
color="secondary"
|
||||
onClick={handleDismiss}
|
||||
loading={dismissBookingReport.isPending}
|
||||
disabled={isSubmitting || addToWatchlist.isPending || dismissBookingReport.isPending}>
|
||||
{t("dont_block")}
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
loading={isSubmitting || addToWatchlist.isPending}
|
||||
disabled={isSubmitting || addToWatchlist.isPending || dismissBookingReport.isPending}>
|
||||
{t("add_to_blocklist")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
-172
@@ -1,172 +0,0 @@
|
||||
"use client";
|
||||
|
||||
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 { 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 {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
interface FormData {
|
||||
type: WatchlistType;
|
||||
value: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export function CreateBlocklistEntryModal({ isOpen, onClose }: CreateBlocklistEntryModalProps) {
|
||||
const { t } = useLocale();
|
||||
const utils = trpc.useUtils();
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
watch,
|
||||
setValue,
|
||||
reset,
|
||||
formState: { errors, isSubmitting },
|
||||
} = useForm<FormData>({
|
||||
defaultValues: {
|
||||
type: WatchlistType.EMAIL,
|
||||
value: "",
|
||||
description: "",
|
||||
},
|
||||
});
|
||||
|
||||
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();
|
||||
reset();
|
||||
},
|
||||
onError: (error) => {
|
||||
showToast(error.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
const onSubmit = (data: FormData) => {
|
||||
createWatchlistEntry.mutate({
|
||||
type: data.type,
|
||||
value: data.value,
|
||||
description: data.description,
|
||||
});
|
||||
};
|
||||
|
||||
const validateValue = (value: string) => {
|
||||
if (!value) return t("required");
|
||||
|
||||
if (watchType === WatchlistType.EMAIL) {
|
||||
if (!emailRegex.test(value)) {
|
||||
return t("invalid_email_address");
|
||||
}
|
||||
} else if (watchType === WatchlistType.DOMAIN) {
|
||||
if (!domainRegex.test(value)) {
|
||||
return t("invalid_domain_format");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
const typeOptions = [
|
||||
{ label: t("email"), value: WatchlistType.EMAIL, iconLeft: <Icon name="mail" className="h-4 w-4" /> },
|
||||
{ label: t("domain"), value: WatchlistType.DOMAIN, iconLeft: <Icon name="globe" className="h-4 w-4" /> },
|
||||
];
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={onClose}>
|
||||
<DialogContent enableOverflow>
|
||||
<DialogHeader title={t("add_to_blocklist")} />
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
<div className="stack-y-4">
|
||||
<div>
|
||||
<Label htmlFor="type" className="text-emphasis mb-2 block text-sm font-medium">
|
||||
{t("what_would_you_like_to_block")}
|
||||
</Label>
|
||||
<Controller
|
||||
name="type"
|
||||
control={control}
|
||||
rules={{ required: t("field_required") }}
|
||||
render={({ field }) => (
|
||||
<ToggleGroup
|
||||
value={field.value}
|
||||
onValueChange={(value) => {
|
||||
if (value) {
|
||||
field.onChange(value);
|
||||
setValue("value", "");
|
||||
}
|
||||
}}
|
||||
options={typeOptions}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
{errors.type && <p className="text-destructive mt-1 text-sm">{errors.type.message}</p>}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="value" className="text-emphasis mb-2 block text-sm font-medium">
|
||||
{watchType === WatchlistType.EMAIL ? t("email") : t("domain_name")}{" "}
|
||||
</Label>
|
||||
<Controller
|
||||
name="value"
|
||||
control={control}
|
||||
rules={{
|
||||
required: t("field_required"),
|
||||
validate: validateValue,
|
||||
}}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
{...field}
|
||||
placeholder={watchType === WatchlistType.EMAIL ? "[email protected]" : "spammer.com"}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
{errors.value && <p className="text-destructive mt-1 text-sm">{errors.value.message}</p>}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="description" className="text-emphasis mb-2 block text-sm font-medium">
|
||||
{t("description")} <span className="text-muted font-normal">{t("optional")}</span>
|
||||
</Label>
|
||||
<Controller
|
||||
name="description"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<TextArea {...field} placeholder={t("reason_for_adding_to_blocklist")} rows={3} />
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DialogFooter className="mt-6">
|
||||
<Button
|
||||
type="button"
|
||||
color="secondary"
|
||||
onClick={onClose}
|
||||
disabled={isSubmitting || createWatchlistEntry.isPending}>
|
||||
{t("cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
loading={isSubmitting || createWatchlistEntry.isPending}
|
||||
disabled={isSubmitting || createWatchlistEntry.isPending}>
|
||||
{t("add_to_blocklist")}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
-90
@@ -1,90 +0,0 @@
|
||||
import type { ColumnDef } from "@tanstack/react-table";
|
||||
import { useMemo } from "react";
|
||||
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import { Badge } from "@calcom/ui/components/badge";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import {
|
||||
Dropdown,
|
||||
DropdownItem,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@calcom/ui/components/dropdown";
|
||||
|
||||
type BookingReport = RouterOutputs["viewer"]["organizations"]["listBookingReports"]["rows"][number];
|
||||
|
||||
interface UsePendingReportsColumnsProps {
|
||||
t: (key: string) => string;
|
||||
onViewDetails: (entry: BookingReport) => void;
|
||||
}
|
||||
|
||||
export function usePendingReportsColumns({ t, onViewDetails }: UsePendingReportsColumnsProps) {
|
||||
return useMemo<ColumnDef<BookingReport>[]>(
|
||||
() => [
|
||||
{
|
||||
id: "emailOrDomain",
|
||||
header: t("email_slash_domain"),
|
||||
accessorKey: "bookerEmail",
|
||||
enableHiding: false,
|
||||
size: 250,
|
||||
cell: ({ row }) => {
|
||||
const email = row.original.bookerEmail;
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
<span className="text-emphasis font-medium">{email}</span>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "reportedBy",
|
||||
header: t("reported_by"),
|
||||
accessorFn: (row) => row.reporter?.email ?? "-",
|
||||
size: 250,
|
||||
cell: ({ row }) => <span className="text-default">{row.original.reporter?.email ?? "-"}</span>,
|
||||
},
|
||||
{
|
||||
id: "reason",
|
||||
header: t("reason"),
|
||||
size: 150,
|
||||
cell: ({ row }) => {
|
||||
const reason = t(row.original.reason.toLowerCase());
|
||||
const capitalizedReason = reason.charAt(0).toUpperCase() + reason.slice(1);
|
||||
|
||||
return <Badge variant="blue">{capitalizedReason}</Badge>;
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
header: "",
|
||||
size: 90,
|
||||
minSize: 90,
|
||||
maxSize: 90,
|
||||
enableHiding: false,
|
||||
enableSorting: false,
|
||||
enableResizing: false,
|
||||
cell: ({ row }) => {
|
||||
const entry = row.original;
|
||||
return (
|
||||
<div className="flex items-center justify-end">
|
||||
<Dropdown modal={false}>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button type="button" variant="icon" color="secondary" StartIcon="ellipsis" />
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent>
|
||||
<DropdownMenuItem>
|
||||
<DropdownItem type="button" StartIcon="eye" onClick={() => onViewDetails(entry)}>
|
||||
{t("view_details")}
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</Dropdown>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
],
|
||||
[t, onViewDetails]
|
||||
);
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { keepPreviousData } from "@tanstack/react-query";
|
||||
import { getCoreRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
|
||||
import { useMemo, useState } from "react";
|
||||
|
||||
import { DataTableWrapper, useDataTable } from "@calcom/features/data-table";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import { EmptyScreen } from "@calcom/ui/components/empty-screen";
|
||||
|
||||
import { BookingReportEntryDetailsModal } from "./booking-report-entry-details-modal";
|
||||
import { usePendingReportsColumns } from "./pending-reports-columns";
|
||||
|
||||
type BookingReport = RouterOutputs["viewer"]["organizations"]["listBookingReports"]["rows"][number];
|
||||
|
||||
export function PendingReportsTable() {
|
||||
const { t } = useLocale();
|
||||
const { limit, offset, searchTerm } = useDataTable();
|
||||
|
||||
const [showReviewDialog, setShowReviewDialog] = useState(false);
|
||||
const [selectedReport, setSelectedReport] = useState<BookingReport | null>(null);
|
||||
|
||||
const { data, isPending } = trpc.viewer.organizations.listBookingReports.useQuery(
|
||||
{
|
||||
limit,
|
||||
offset,
|
||||
searchTerm,
|
||||
filters: { hasWatchlist: false, status: ["PENDING"] },
|
||||
},
|
||||
{
|
||||
placeholderData: keepPreviousData,
|
||||
}
|
||||
);
|
||||
|
||||
const handleViewDetails = (entry: BookingReport) => {
|
||||
setSelectedReport(entry);
|
||||
setShowReviewDialog(true);
|
||||
};
|
||||
|
||||
const columns = usePendingReportsColumns({
|
||||
t,
|
||||
onViewDetails: handleViewDetails,
|
||||
});
|
||||
|
||||
const totalRowCount = data?.meta?.totalRowCount ?? 0;
|
||||
const flatData = useMemo(() => data?.rows ?? [], [data]);
|
||||
|
||||
const table = useReactTable({
|
||||
data: flatData,
|
||||
columns,
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
getSortedRowModel: getSortedRowModel(),
|
||||
manualPagination: true,
|
||||
pageCount: Math.ceil(totalRowCount / limit),
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<DataTableWrapper
|
||||
table={table}
|
||||
isPending={isPending}
|
||||
variant="default"
|
||||
paginationMode="standard"
|
||||
EmptyView={
|
||||
<EmptyScreen
|
||||
customIcon={<img className="mb-6" src="/slash-icon-cards.svg" />}
|
||||
headline={t("no_pending_reports")}
|
||||
className="bg-muted mb-16"
|
||||
iconWrapperClassName="bg-default"
|
||||
dashedBorder={false}
|
||||
/>
|
||||
}
|
||||
totalRowCount={totalRowCount}
|
||||
/>
|
||||
|
||||
<BookingReportEntryDetailsModal
|
||||
entry={selectedReport}
|
||||
isOpen={showReviewDialog}
|
||||
onClose={() => {
|
||||
setShowReviewDialog(false);
|
||||
setSelectedReport(null);
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
"use client";
|
||||
|
||||
import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner";
|
||||
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import useMeQuery from "@calcom/trpc/react/hooks/useMeQuery";
|
||||
import type { ButtonProps } from "@calcom/ui/components/button";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
|
||||
import { OutOfOfficeTab } from "./OutOfOfficeToggleGroup";
|
||||
|
||||
const CreateNewOutOfOfficeEntryButton = ({
|
||||
size,
|
||||
onClick,
|
||||
...rest
|
||||
}: {
|
||||
size?: ButtonProps["size"];
|
||||
onClick: () => void;
|
||||
"data-testid"?: string;
|
||||
}) => {
|
||||
const { t } = useLocale();
|
||||
const me = useMeQuery();
|
||||
const { data: orgData } = trpc.viewer.organizations.listCurrent.useQuery();
|
||||
const isOrgAdminOrOwner = orgData && checkAdminOrOwner(orgData.user.role);
|
||||
const hasTeamOOOAdminAccess = isOrgAdminOrOwner || me?.data?.isTeamAdminOrOwner;
|
||||
|
||||
const params = useCompatSearchParams();
|
||||
const selectedTab = params?.get("type") ?? OutOfOfficeTab.MINE;
|
||||
|
||||
return (
|
||||
<Button
|
||||
color="primary"
|
||||
size={size ?? "base"}
|
||||
className="flex items-center justify-between px-2 md:px-4"
|
||||
StartIcon="plus"
|
||||
onClick={onClick}
|
||||
data-testid={rest["data-testid"]}
|
||||
disabled={selectedTab === OutOfOfficeTab.TEAM && !hasTeamOOOAdminAccess}>
|
||||
<span className="sr-only md:not-sr-only md:inline">{t("add")}</span>
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
||||
export default CreateNewOutOfOfficeEntryButton;
|
||||
@@ -0,0 +1,516 @@
|
||||
import { useMemo, useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { Dialog } from "@calcom/features/components/controlled-dialog";
|
||||
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
|
||||
import { useDebounce } from "@calcom/lib/hooks/useDebounce";
|
||||
import { useInViewObserver } from "@calcom/lib/hooks/useInViewObserver";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import useMeQuery from "@calcom/trpc/react/hooks/useMeQuery";
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
import { Alert } from "@calcom/ui/components/alert";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { DialogContent, DialogFooter, DialogHeader } from "@calcom/ui/components/dialog";
|
||||
import { DateRangePicker, TextArea, Input, Checkbox } from "@calcom/ui/components/form";
|
||||
import { Label } from "@calcom/ui/components/form";
|
||||
import { Select } from "@calcom/ui/components/form";
|
||||
import { Switch } from "@calcom/ui/components/form";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
import { useHasTeamPlan } from "@calcom/web/modules/billing/hooks/useHasPaidPlan";
|
||||
|
||||
import { UpgradeTeamsBadgeWebWrapper as UpgradeTeamsBadge } from "~/billing/components/UpgradeTeamsBadgeWebWrapper";
|
||||
import { OutOfOfficeTab } from "~/settings/outOfOffice/OutOfOfficeToggleGroup";
|
||||
|
||||
export type { BookingRedirectForm } from "~/settings/outOfOffice/types";
|
||||
import type { BookingRedirectForm } from "~/settings/outOfOffice/types";
|
||||
|
||||
type Option = { value: number; label: string };
|
||||
|
||||
export const CreateOrEditOutOfOfficeEntryModal = ({
|
||||
openModal,
|
||||
closeModal,
|
||||
currentlyEditingOutOfOfficeEntry,
|
||||
}: {
|
||||
openModal: boolean;
|
||||
closeModal: () => void;
|
||||
currentlyEditingOutOfOfficeEntry: BookingRedirectForm | null;
|
||||
}) => {
|
||||
const { t } = useLocale();
|
||||
const utils = trpc.useUtils();
|
||||
const me = useMeQuery();
|
||||
|
||||
const searchParams = useCompatSearchParams();
|
||||
const oooType = searchParams?.get("type") ?? OutOfOfficeTab.MINE;
|
||||
|
||||
const [searchMember, setSearchMember] = useState("");
|
||||
const debouncedSearchMember = useDebounce(searchMember, 500);
|
||||
const oooForMembers = trpc.viewer.teams.legacyListMembers.useInfiniteQuery(
|
||||
{ limit: 10, searchText: debouncedSearchMember, adminOrOwnedTeamsOnly: true },
|
||||
{
|
||||
enabled: oooType === OutOfOfficeTab.TEAM,
|
||||
getNextPageParam: (lastPage) => lastPage.nextCursor,
|
||||
}
|
||||
);
|
||||
const oooMemberListOptions: {
|
||||
value: number;
|
||||
label: string;
|
||||
avatarUrl: string | null;
|
||||
}[] = currentlyEditingOutOfOfficeEntry
|
||||
? [
|
||||
{
|
||||
value: currentlyEditingOutOfOfficeEntry.forUserId || -1,
|
||||
label: currentlyEditingOutOfOfficeEntry.forUserName || "",
|
||||
avatarUrl: currentlyEditingOutOfOfficeEntry.forUserAvatar || "",
|
||||
},
|
||||
]
|
||||
: oooForMembers?.data?.pages
|
||||
.flatMap((page) => page.members)
|
||||
?.filter((member) => me?.data?.id !== member.id)
|
||||
.map((member) => ({
|
||||
value: member.id,
|
||||
label: member.name || member.username || "",
|
||||
avatarUrl: member.avatarUrl,
|
||||
})) || [];
|
||||
const { ref: observerRefMember } = useInViewObserver(() => {
|
||||
if (oooForMembers.hasNextPage && !oooForMembers.isFetching) {
|
||||
oooForMembers.fetchNextPage();
|
||||
}
|
||||
}, document.querySelector('[role="dialog"]'));
|
||||
|
||||
const [searchRedirectMember, setSearchRedirectMember] = useState("");
|
||||
const debouncedSearchRedirect = useDebounce(searchRedirectMember, 500);
|
||||
const redirectMembers = trpc.viewer.teams.legacyListMembers.useInfiniteQuery(
|
||||
{
|
||||
limit: 10,
|
||||
searchText: debouncedSearchRedirect,
|
||||
adminOrOwnedTeamsOnly: oooType === OutOfOfficeTab.TEAM,
|
||||
},
|
||||
{
|
||||
enabled: true,
|
||||
getNextPageParam: (lastPage) => lastPage.nextCursor,
|
||||
}
|
||||
);
|
||||
const redirectToMemberListOptions: {
|
||||
value: number;
|
||||
label: string;
|
||||
avatarUrl: string | null;
|
||||
}[] =
|
||||
redirectMembers?.data?.pages
|
||||
.flatMap((page) => page.members)
|
||||
?.filter((member) =>
|
||||
oooType === OutOfOfficeTab.MINE ? me?.data?.id !== member.id : oooType === OutOfOfficeTab.TEAM
|
||||
)
|
||||
.map((member) => ({
|
||||
value: member.id,
|
||||
label: member.name || member.username || "",
|
||||
avatarUrl: member.avatarUrl,
|
||||
})) || [];
|
||||
const { ref: observerRefRedirect } = useInViewObserver(() => {
|
||||
if (redirectMembers.hasNextPage && !redirectMembers.isFetching) {
|
||||
redirectMembers.fetchNextPage();
|
||||
}
|
||||
}, document.querySelector('[role="dialog"]'));
|
||||
|
||||
const { data: outOfOfficeReasonList, isPending: isReasonListPending } =
|
||||
trpc.viewer.ooo.outOfOfficeReasonList.useQuery();
|
||||
const reasonList = (outOfOfficeReasonList || []).map((reason) => ({
|
||||
label: `${reason.emoji} ${reason.userId === null ? t(reason.reason) : reason.reason}`,
|
||||
value: reason.id,
|
||||
}));
|
||||
|
||||
const [profileRedirect, setProfileRedirect] = useState(!!currentlyEditingOutOfOfficeEntry?.toTeamUserId);
|
||||
|
||||
const { hasTeamPlan } = useHasTeamPlan();
|
||||
|
||||
const {
|
||||
handleSubmit,
|
||||
setValue,
|
||||
control,
|
||||
register,
|
||||
watch,
|
||||
formState: { isSubmitting },
|
||||
getValues,
|
||||
} = useForm<BookingRedirectForm>({
|
||||
defaultValues: currentlyEditingOutOfOfficeEntry
|
||||
? currentlyEditingOutOfOfficeEntry
|
||||
: {
|
||||
dateRange: {
|
||||
startDate: dayjs().startOf("d").toDate(),
|
||||
endDate: dayjs().startOf("d").add(2, "d").toDate(),
|
||||
},
|
||||
startDateOffset: dayjs().utcOffset(),
|
||||
endDateOffset: dayjs().utcOffset(),
|
||||
toTeamUserId: null,
|
||||
reasonId: 1,
|
||||
forUserId: null,
|
||||
showNotePublicly: false,
|
||||
},
|
||||
});
|
||||
|
||||
const watchedTeamUserId = watch("toTeamUserId");
|
||||
const watchForUserId = watch("forUserId");
|
||||
const watchedDateRange = watch("dateRange");
|
||||
const watchedNotes = watch("notes");
|
||||
const hasValidNotes = Boolean(watchedNotes?.trim());
|
||||
|
||||
// Fetch user's holiday settings to show warning if OOO dates overlap with holidays
|
||||
const { data: holidaySettings } = trpc.viewer.holidays.getUserSettings.useQuery({});
|
||||
|
||||
// Check if selected dates overlap with any enabled holidays
|
||||
const overlappingHolidays = useMemo(() => {
|
||||
if (!holidaySettings?.countryCode || !watchedDateRange?.startDate || !watchedDateRange?.endDate) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Filter holidays that are enabled and fall within the date range
|
||||
const startStr = dayjs(watchedDateRange.startDate).format("YYYY-MM-DD");
|
||||
const endStr = dayjs(watchedDateRange.endDate).format("YYYY-MM-DD");
|
||||
|
||||
return (holidaySettings.holidays || [])
|
||||
.filter((h) => h.enabled && h.date >= startStr && h.date <= endStr)
|
||||
.map((h) => ({ date: h.date, holiday: { id: h.id, name: h.name } }));
|
||||
}, [holidaySettings, watchedDateRange]);
|
||||
|
||||
const createOrEditOutOfOfficeEntry = trpc.viewer.ooo.outOfOfficeCreateOrUpdate.useMutation({
|
||||
onSuccess: () => {
|
||||
showToast(
|
||||
currentlyEditingOutOfOfficeEntry
|
||||
? t("success_edited_entry_out_of_office")
|
||||
: t("success_entry_created"),
|
||||
"success"
|
||||
);
|
||||
utils.viewer.ooo.outOfOfficeEntriesList.invalidate();
|
||||
closeModal();
|
||||
},
|
||||
onError: (error) => {
|
||||
showToast(t(error.message), "error");
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={openModal}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) {
|
||||
closeModal();
|
||||
}
|
||||
}}>
|
||||
<DialogContent
|
||||
enableOverflow
|
||||
onOpenAutoFocus={(event) => {
|
||||
event.preventDefault();
|
||||
}}>
|
||||
<form
|
||||
id="create-or-edit-ooo-form"
|
||||
onSubmit={handleSubmit((data) => {
|
||||
if (!data.dateRange.endDate) {
|
||||
showToast(t("end_date_not_selected"), "error");
|
||||
} else {
|
||||
createOrEditOutOfOfficeEntry.mutate({
|
||||
...data,
|
||||
startDateOffset: -1 * data.dateRange.startDate.getTimezoneOffset(),
|
||||
endDateOffset: -1 * data.dateRange.endDate.getTimezoneOffset(),
|
||||
});
|
||||
}
|
||||
})}>
|
||||
<div className="h-full px-1">
|
||||
<DialogHeader
|
||||
title={
|
||||
currentlyEditingOutOfOfficeEntry
|
||||
? t("edit_an_out_of_office")
|
||||
: oooType === "team"
|
||||
? t("create_ooo_dialog_team_title")
|
||||
: t("create_an_out_of_office")
|
||||
}
|
||||
subtitle={
|
||||
oooType === "team"
|
||||
? currentlyEditingOutOfOfficeEntry
|
||||
? t("edit_ooo_dialog_team_subtitle")
|
||||
: t("create_ooo_dialog_team_subtitle")
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
|
||||
{/* In case of Team, Select Member for whom OOO is created */}
|
||||
{oooType === OutOfOfficeTab.TEAM && (
|
||||
<>
|
||||
<div className="mb-4">
|
||||
<Label className="text-emphasis mt-6">{t("select_team_member")}</Label>
|
||||
<div className="mt-2">
|
||||
<Input
|
||||
type="text"
|
||||
placeholder={t("search")}
|
||||
onChange={(e) => setSearchMember(e.target.value)}
|
||||
value={searchMember}
|
||||
disabled={!!currentlyEditingOutOfOfficeEntry}
|
||||
/>
|
||||
<div
|
||||
className={`scroll-bar bg-default mt-2 flex ${
|
||||
currentlyEditingOutOfOfficeEntry ? "h-[45px]" : "h-[150px]"
|
||||
} flex-col gap-0.5 overflow-y-scroll rounded-[10px] border p-1`}>
|
||||
{oooMemberListOptions.map((member) => (
|
||||
<label
|
||||
key={member.value}
|
||||
aria-disabled={!!currentlyEditingOutOfOfficeEntry}
|
||||
data-testid={`ooofor_username_select_${member.value}`}
|
||||
tabIndex={watchForUserId === member.value ? -1 : 0}
|
||||
role="radio"
|
||||
aria-checked={watchForUserId === member.value}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter" || e.key === " ") {
|
||||
e.preventDefault();
|
||||
setValue("forUserId", member.value, { shouldDirty: true });
|
||||
}
|
||||
}}
|
||||
className={classNames(
|
||||
"cursor-not-allowed items-center justify-between gap-0.5 rounded-sm py-2 outline-none",
|
||||
watchForUserId === member.value && "bg-subtle",
|
||||
!currentlyEditingOutOfOfficeEntry &&
|
||||
"hover:bg-subtle focus:bg-subtle focus:ring-emphasis cursor-pointer focus:ring-2"
|
||||
)}>
|
||||
<div className="flex flex-1 items-center space-x-3">
|
||||
<input
|
||||
type="radio"
|
||||
disabled={!!currentlyEditingOutOfOfficeEntry}
|
||||
className="hidden"
|
||||
checked={watchForUserId === member.value}
|
||||
onChange={() => setValue("forUserId", member.value, { shouldDirty: true })}
|
||||
/>
|
||||
<span className="text-emphasis w-full px-2 text-sm">{member.label}</span>
|
||||
</div>
|
||||
</label>
|
||||
))}
|
||||
{!currentlyEditingOutOfOfficeEntry && (
|
||||
<div className="text-default text-center" ref={observerRefMember}>
|
||||
<Button
|
||||
color="minimal"
|
||||
loading={oooForMembers.isFetchingNextPage}
|
||||
disabled={!oooForMembers.hasNextPage}
|
||||
onClick={() => oooForMembers.fetchNextPage()}>
|
||||
{oooForMembers.hasNextPage ? t("load_more_results") : t("no_more_results")}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
<div>
|
||||
<p className="text-emphasis mb-1 block text-sm font-medium capitalize">{t("dates")}</p>
|
||||
<div>
|
||||
<Controller
|
||||
name="dateRange"
|
||||
control={control}
|
||||
render={({ field: { onChange, value } }) => (
|
||||
<DateRangePicker
|
||||
minDate={null}
|
||||
dates={{ startDate: value.startDate, endDate: value.endDate }}
|
||||
onDatesChange={(values) => {
|
||||
onChange(values);
|
||||
}}
|
||||
strictlyBottom={true}
|
||||
allowPastDates={true}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Holiday overlap warning */}
|
||||
{overlappingHolidays.length > 0 && (
|
||||
<Alert
|
||||
className="mt-2"
|
||||
severity="info"
|
||||
title={t("holiday_overlap_info")}
|
||||
message={
|
||||
overlappingHolidays.length === 1
|
||||
? t("holiday_overlap_message_single", {
|
||||
holiday: overlappingHolidays[0].holiday.name,
|
||||
date: dayjs(overlappingHolidays[0].date).format("D MMM"),
|
||||
})
|
||||
: t("holiday_overlap_message_multiple", {
|
||||
count: overlappingHolidays.length,
|
||||
holidays: overlappingHolidays
|
||||
.slice(0, 3)
|
||||
.map((h) => h.holiday.name)
|
||||
.join(", "),
|
||||
})
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Reason Select */}
|
||||
<div className="mt-4 w-full">
|
||||
<div className="">
|
||||
<p className="text-emphasis block text-sm font-medium">{t("reason")}</p>
|
||||
<Controller
|
||||
control={control}
|
||||
name="reasonId"
|
||||
render={({ field: { onChange, value } }) => (
|
||||
<Select<Option>
|
||||
className="mb-0 mt-1 text-white"
|
||||
name="reason"
|
||||
data-testid="reason_select"
|
||||
value={reasonList.find((reason) => reason.value === value)}
|
||||
placeholder={t("ooo_select_reason")}
|
||||
options={reasonList}
|
||||
onChange={(selectedOption) => {
|
||||
if (selectedOption?.value) {
|
||||
onChange(selectedOption.value);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Notes input */}
|
||||
<div className="mt-4">
|
||||
<p className="text-emphasis text-sm font-medium">{t("notes")}</p>
|
||||
<TextArea
|
||||
data-testid="notes_input"
|
||||
className="border-subtle mt-2 h-10 w-full rounded-lg border px-2"
|
||||
placeholder={t("additional_notes")}
|
||||
{...register("notes")}
|
||||
onChange={(e) => {
|
||||
const newNotes = e?.target.value;
|
||||
setValue("notes", newNotes);
|
||||
if (!newNotes?.trim()) {
|
||||
setValue("showNotePublicly", false);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<Controller
|
||||
control={control}
|
||||
name="showNotePublicly"
|
||||
render={({ field: { value, onChange } }) => (
|
||||
<div className="mt-2 flex items-center">
|
||||
<Checkbox
|
||||
id="show-note-publicly"
|
||||
data-testid="show-note-publicly-checkbox"
|
||||
checked={value ?? false}
|
||||
onCheckedChange={onChange}
|
||||
disabled={!hasValidNotes}
|
||||
/>
|
||||
<label
|
||||
htmlFor="show-note-publicly"
|
||||
className={classNames(
|
||||
"ml-2 text-sm",
|
||||
hasValidNotes ? "text-emphasis cursor-pointer" : "text-muted cursor-not-allowed"
|
||||
)}>
|
||||
{t("show_note_publicly_description")}
|
||||
</label>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="bg-cal-muted my-4 rounded-xl p-5">
|
||||
<div className="flex flex-row">
|
||||
<Switch
|
||||
disabled={!hasTeamPlan}
|
||||
data-testid="profile-redirect-switch"
|
||||
checked={profileRedirect}
|
||||
id="profile-redirect-switch"
|
||||
onCheckedChange={(state) => {
|
||||
setProfileRedirect(state);
|
||||
if (!state) {
|
||||
setValue("toTeamUserId", null);
|
||||
}
|
||||
}}
|
||||
label={hasTeamPlan ? t("redirect_team_enabled") : t("redirect_team_disabled")}
|
||||
/>
|
||||
{!hasTeamPlan && (
|
||||
<div className="mx-2" data-testid="upgrade-team-badge">
|
||||
<UpgradeTeamsBadge />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{profileRedirect && (
|
||||
<div className="mb-2">
|
||||
<Label className="text-emphasis mt-6">{t("select_team_member")}</Label>
|
||||
<div className="mt-2">
|
||||
<Input
|
||||
type="text"
|
||||
placeholder={t("search")}
|
||||
onChange={(e) => setSearchRedirectMember(e.target.value)}
|
||||
value={searchRedirectMember}
|
||||
/>
|
||||
<div className="scroll-bar bg-default mt-2 flex h-[150px] flex-col gap-0.5 overflow-y-scroll rounded-[10px] border p-1">
|
||||
{redirectToMemberListOptions
|
||||
.filter((member) => member.value !== getValues("forUserId"))
|
||||
.map((member) => (
|
||||
<label
|
||||
key={member.value}
|
||||
data-testid={`team_username_select_${member.value}`}
|
||||
tabIndex={watchedTeamUserId === member.value ? -1 : 0}
|
||||
role="radio"
|
||||
aria-checked={watchedTeamUserId === member.value}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter" || e.key === " ") {
|
||||
e.preventDefault();
|
||||
setValue("toTeamUserId", member.value, { shouldDirty: true });
|
||||
}
|
||||
}}
|
||||
className={classNames(
|
||||
"hover:bg-subtle focus:bg-subtle focus:ring-emphasis cursor-pointer items-center justify-between gap-0.5 rounded-sm py-2 outline-none focus:ring-2",
|
||||
watchedTeamUserId === member.value && "bg-subtle"
|
||||
)}>
|
||||
<div className="flex flex-1 items-center space-x-3">
|
||||
<input
|
||||
type="radio"
|
||||
className="hidden"
|
||||
checked={watchedTeamUserId === member.value}
|
||||
onChange={() => setValue("toTeamUserId", member.value, { shouldDirty: true })}
|
||||
/>
|
||||
<span className="text-emphasis w-full px-2 text-sm">{member.label}</span>
|
||||
</div>
|
||||
</label>
|
||||
))}
|
||||
<div className="text-default text-center" ref={observerRefRedirect}>
|
||||
<Button
|
||||
color="minimal"
|
||||
loading={redirectMembers.isFetchingNextPage}
|
||||
disabled={!redirectMembers.hasNextPage}
|
||||
onClick={() => redirectMembers.fetchNextPage()}>
|
||||
{redirectMembers.hasNextPage ? t("load_more_results") : t("no_more_results")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<DialogFooter showDivider noSticky>
|
||||
<div className="flex">
|
||||
<Button
|
||||
color="minimal"
|
||||
type="button"
|
||||
onClick={() => {
|
||||
closeModal();
|
||||
}}
|
||||
className="mr-1">
|
||||
{t("cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
form="create-or-edit-ooo-form"
|
||||
color="primary"
|
||||
type="submit"
|
||||
disabled={isSubmitting || isReasonListPending}
|
||||
data-testid="create-or-edit-entry-ooo-redirect">
|
||||
{currentlyEditingOutOfOfficeEntry ? t("save") : t("create")}
|
||||
</Button>
|
||||
</div>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,424 @@
|
||||
"use client";
|
||||
|
||||
import { keepPreviousData } from "@tanstack/react-query";
|
||||
import {
|
||||
createColumnHelper,
|
||||
getCoreRowModel,
|
||||
getFilteredRowModel,
|
||||
useReactTable,
|
||||
} from "@tanstack/react-table";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import {
|
||||
DataTableWrapper,
|
||||
DataTableToolbar,
|
||||
DataTableProvider,
|
||||
ColumnFilterType,
|
||||
useDataTable,
|
||||
useFilterValue,
|
||||
ZDateRangeFilterValue,
|
||||
DataTableFilters,
|
||||
DataTableSegment,
|
||||
} from "@calcom/features/data-table";
|
||||
import { useSegments } from "@calcom/features/data-table/hooks/useSegments";
|
||||
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";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Avatar } from "@calcom/ui/components/avatar";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { EmptyScreen } from "@calcom/ui/components/empty-screen";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
import { SkeletonText } from "@calcom/ui/components/skeleton";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
import { Tooltip } from "@calcom/ui/components/tooltip";
|
||||
|
||||
import CreateNewOutOfOfficeEntryButton from "./CreateNewOutOfOfficeEntryButton";
|
||||
import type { BookingRedirectForm } from "./types";
|
||||
import { OutOfOfficeTab, OutOfOfficeToggleGroup } from "./OutOfOfficeToggleGroup";
|
||||
|
||||
interface OutOfOfficeEntry {
|
||||
id: number;
|
||||
uuid: string;
|
||||
start: Date;
|
||||
end: Date;
|
||||
toUserId: number | null;
|
||||
toUser: {
|
||||
username: string;
|
||||
name: string;
|
||||
} | null;
|
||||
reason: {
|
||||
id: number;
|
||||
emoji: string;
|
||||
reason: string;
|
||||
userId: number;
|
||||
} | null;
|
||||
notes: string | null;
|
||||
showNotePublicly: boolean | null;
|
||||
user: { id: number; avatarUrl: string; username: string; email: string; name: string } | null;
|
||||
canEditAndDelete: boolean;
|
||||
}
|
||||
|
||||
export default function OutOfOfficeEntriesList({
|
||||
onOpenCreateDialog,
|
||||
onOpenEditDialog,
|
||||
}: {
|
||||
onOpenCreateDialog: () => void;
|
||||
onOpenEditDialog: (entry: BookingRedirectForm) => void;
|
||||
}) {
|
||||
const { t } = useLocale();
|
||||
const pathname = usePathname();
|
||||
|
||||
if (!pathname) return null;
|
||||
|
||||
return (
|
||||
<SettingsHeader
|
||||
title={t("out_of_office")}
|
||||
description={t("out_of_office_description")}
|
||||
CTA={
|
||||
<div className="flex gap-2">
|
||||
<OutOfOfficeToggleGroup />
|
||||
<CreateNewOutOfOfficeEntryButton data-testid="add_entry_ooo" onClick={onOpenCreateDialog} />
|
||||
</div>
|
||||
}>
|
||||
<DataTableProvider tableIdentifier={pathname} useSegments={useSegments}>
|
||||
<OutOfOfficeEntriesListContent
|
||||
onOpenCreateDialog={onOpenCreateDialog}
|
||||
onOpenEditDialog={onOpenEditDialog}
|
||||
/>
|
||||
</DataTableProvider>
|
||||
</SettingsHeader>
|
||||
);
|
||||
}
|
||||
|
||||
function OutOfOfficeEntriesListContent({
|
||||
onOpenCreateDialog,
|
||||
onOpenEditDialog,
|
||||
}: {
|
||||
onOpenCreateDialog: () => void;
|
||||
onOpenEditDialog: (entry: BookingRedirectForm) => void;
|
||||
}) {
|
||||
const { t } = useLocale();
|
||||
const tableContainerRef = useRef<HTMLDivElement>(null);
|
||||
const [deletedEntry, setDeletedEntry] = useState(0);
|
||||
|
||||
const { searchTerm } = useDataTable();
|
||||
const searchParams = useCompatSearchParams();
|
||||
const selectedTab = searchParams?.get("type") ?? OutOfOfficeTab.MINE;
|
||||
|
||||
const endDateRange = useFilterValue("dateRange", ZDateRangeFilterValue)?.data;
|
||||
|
||||
const { data, isPending, fetchNextPage, isFetching, refetch, hasNextPage } =
|
||||
trpc.viewer.ooo.outOfOfficeEntriesList.useInfiniteQuery(
|
||||
{
|
||||
limit: 10,
|
||||
fetchTeamMembersEntries: selectedTab === OutOfOfficeTab.TEAM,
|
||||
searchTerm,
|
||||
endDateFilterStartRange: endDateRange?.startDate ?? undefined,
|
||||
endDateFilterEndRange: endDateRange?.endDate ?? undefined,
|
||||
},
|
||||
{
|
||||
getNextPageParam: (lastPage) => lastPage.nextCursor,
|
||||
placeholderData: keepPreviousData,
|
||||
}
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
refetch();
|
||||
}, [deletedEntry, selectedTab, refetch]);
|
||||
|
||||
const totalRowCount = data?.pages?.[0]?.meta?.totalRowCount ?? 0;
|
||||
const flatData = useMemo(
|
||||
() =>
|
||||
isPending || isFetching ? new Array(5).fill(null) : data?.pages?.flatMap((page) => page.rows) ?? [],
|
||||
[data, selectedTab, isPending, isFetching, searchTerm]
|
||||
) as OutOfOfficeEntry[];
|
||||
|
||||
const memoColumns = useMemo(() => {
|
||||
const columnHelper = createColumnHelper<OutOfOfficeEntry>();
|
||||
return [
|
||||
columnHelper.accessor((row) => row, {
|
||||
id: "dateRange",
|
||||
header: t("date_range"),
|
||||
enableColumnFilter: true,
|
||||
enableSorting: false,
|
||||
cell: () => null,
|
||||
filterFn: () => true,
|
||||
meta: {
|
||||
filter: {
|
||||
type: ColumnFilterType.DATE_RANGE,
|
||||
dateRangeOptions: {
|
||||
range: "past",
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
...(selectedTab === OutOfOfficeTab.TEAM
|
||||
? [
|
||||
columnHelper.display({
|
||||
id: "member",
|
||||
header: `Member`,
|
||||
size: 300,
|
||||
cell: ({ row }) => {
|
||||
if (!row.original || !row.original.user || isPending || isFetching) {
|
||||
return <SkeletonText className="h-8 w-full" />;
|
||||
}
|
||||
const { avatarUrl, username, email, name } = row.original.user;
|
||||
const memberName =
|
||||
name ||
|
||||
(() => {
|
||||
const emailName = email.split("@")[0];
|
||||
return emailName.charAt(0).toUpperCase() + emailName.slice(1);
|
||||
})();
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
<Avatar
|
||||
size="sm"
|
||||
alt={username || email}
|
||||
imageSrc={getUserAvatarUrl({
|
||||
avatarUrl,
|
||||
})}
|
||||
/>
|
||||
<div className="">
|
||||
<div
|
||||
data-testid={`ooo-member-${username}-username`}
|
||||
className="text-emphasis text-sm font-medium leading-none">
|
||||
{memberName}
|
||||
</div>
|
||||
<div
|
||||
data-testid={`ooo-member-${username}-email`}
|
||||
className="text-subtle mt-1 text-sm leading-none">
|
||||
{email}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
}),
|
||||
]
|
||||
: []),
|
||||
columnHelper.display({
|
||||
id: "outOfOffice",
|
||||
header: `${t("out_of_office")} (${totalRowCount})`,
|
||||
size: selectedTab === OutOfOfficeTab.TEAM ? 370 : 660,
|
||||
cell: ({ row }) => {
|
||||
const item = row.original;
|
||||
return (
|
||||
<>
|
||||
{row.original && !isPending && !isFetching ? (
|
||||
<div
|
||||
className="flex flex-row justify-between p-2"
|
||||
data-testid={`table-redirect-${item.toUser?.username || "n-a"}`}>
|
||||
<div className="flex flex-row items-center">
|
||||
<div className="flex h-10 w-10 items-center justify-center rounded-full bg-gray-50">
|
||||
{item?.reason?.emoji || "🏝️"}
|
||||
</div>
|
||||
|
||||
<div className="ml-2 flex flex-col">
|
||||
<p className="px-2 font-bold">
|
||||
{dayjs.utc(item.start).format("ll")} - {dayjs.utc(item.end).format("ll")}
|
||||
</p>
|
||||
<p className="px-2">
|
||||
{item.toUser?.username ? (
|
||||
<ServerTrans
|
||||
t={t}
|
||||
i18nKey="ooo_forwarding_to"
|
||||
values={{
|
||||
username: item.toUser?.username,
|
||||
}}
|
||||
components={[<span key="ooo-username" className="text-subtle font-bold" />]}
|
||||
/>
|
||||
) : (
|
||||
<>{t("ooo_not_forwarding")}</>
|
||||
)}
|
||||
</p>
|
||||
{item.notes && (
|
||||
<p className="px-2">
|
||||
<span className="text-subtle">{t("notes")}: </span>
|
||||
<span data-testid={`ooo-entry-note-${item.toUser?.username || "n-a"}`}>
|
||||
{item.notes}
|
||||
</span>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<SkeletonText className="h-8 w-full" />
|
||||
)}
|
||||
</>
|
||||
);
|
||||
},
|
||||
}),
|
||||
columnHelper.display({
|
||||
id: "actions",
|
||||
size: 90,
|
||||
cell: ({ row }) => {
|
||||
const item = row.original;
|
||||
return (
|
||||
<>
|
||||
{row.original && !isPending && !isFetching ? (
|
||||
<div className="flex flex-row items-center justify-end gap-x-2" data-testid="ooo-actions">
|
||||
<Tooltip content={t("edit")}>
|
||||
<Button
|
||||
className="self-center rounded-lg border"
|
||||
type="button"
|
||||
color="secondary"
|
||||
variant="icon"
|
||||
data-testid={`ooo-edit-${item.toUser?.username || "n-a"}`}
|
||||
StartIcon="pencil"
|
||||
onClick={() => {
|
||||
const startDateOffset = -1 * item.start.getTimezoneOffset();
|
||||
const endDateOffset = -1 * item.end.getTimezoneOffset();
|
||||
const outOfOfficeEntryData: BookingRedirectForm = {
|
||||
uuid: item.uuid,
|
||||
dateRange: {
|
||||
startDate: dayjs(item.start).subtract(startDateOffset, "minute").toDate(),
|
||||
endDate: dayjs(item.end).subtract(endDateOffset, "minute").startOf("d").toDate(),
|
||||
},
|
||||
startDateOffset,
|
||||
endDateOffset,
|
||||
toTeamUserId: item.toUserId,
|
||||
reasonId: item.reason?.id ?? 1,
|
||||
notes: item.notes ?? undefined,
|
||||
showNotePublicly: item.showNotePublicly ?? false,
|
||||
forUserId: item.user?.id || null,
|
||||
forUserName:
|
||||
item.user?.name ||
|
||||
(item.user?.email &&
|
||||
(() => {
|
||||
const emailName = item.user?.email.split("@")[0];
|
||||
return emailName.charAt(0).toUpperCase() + emailName.slice(1);
|
||||
})()),
|
||||
forUserAvatar: item.user?.avatarUrl,
|
||||
toUserName: item.toUser?.name || item.toUser?.username,
|
||||
};
|
||||
onOpenEditDialog(outOfOfficeEntryData);
|
||||
}}
|
||||
disabled={isPending || isFetching || !item.canEditAndDelete}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Tooltip content={t("delete")}>
|
||||
<Button
|
||||
className="self-center rounded-lg border"
|
||||
type="button"
|
||||
color="destructive"
|
||||
variant="icon"
|
||||
disabled={
|
||||
deleteOutOfOfficeEntryMutation.isPending ||
|
||||
isPending ||
|
||||
isFetching ||
|
||||
!item.canEditAndDelete
|
||||
}
|
||||
StartIcon="trash-2"
|
||||
data-testid={`ooo-delete-${item.toUser?.username || "n-a"}`}
|
||||
onClick={() => {
|
||||
deleteOutOfOfficeEntryMutation.mutate({
|
||||
outOfOfficeUid: item.uuid,
|
||||
userId: selectedTab === OutOfOfficeTab.TEAM ? item.user?.id : undefined,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</Tooltip>
|
||||
</div>
|
||||
) : (
|
||||
<SkeletonText className="h-8 w-full" />
|
||||
)}
|
||||
</>
|
||||
);
|
||||
},
|
||||
}),
|
||||
];
|
||||
}, [selectedTab, isPending, isFetching, onOpenEditDialog, t]);
|
||||
|
||||
const table = useReactTable({
|
||||
data: flatData,
|
||||
columns: memoColumns,
|
||||
initialState: {
|
||||
columnVisibility: {
|
||||
dateRange: false,
|
||||
},
|
||||
},
|
||||
enableRowSelection: false,
|
||||
manualPagination: true,
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
getFilteredRowModel: getFilteredRowModel(),
|
||||
});
|
||||
|
||||
const deleteOutOfOfficeEntryMutation = trpc.viewer.ooo.outOfOfficeEntryDelete.useMutation({
|
||||
onSuccess: () => {
|
||||
showToast(t("success_deleted_entry_out_of_office"), "success");
|
||||
setDeletedEntry((previousValue) => previousValue + 1);
|
||||
},
|
||||
onError: () => {
|
||||
showToast(`An error occurred`, "error");
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<DataTableWrapper
|
||||
testId="ooo-list-data-table"
|
||||
rowClassName={selectedTab === OutOfOfficeTab.MINE ? "hidden" : ""}
|
||||
table={table}
|
||||
isPending={isPending}
|
||||
hasNextPage={hasNextPage}
|
||||
fetchNextPage={fetchNextPage}
|
||||
isFetching={isFetching}
|
||||
totalRowCount={totalRowCount}
|
||||
tableContainerRef={tableContainerRef}
|
||||
paginationMode="infinite"
|
||||
ToolbarLeft={
|
||||
<>
|
||||
<DataTableToolbar.SearchBar />
|
||||
<DataTableFilters.FilterBar table={table} />
|
||||
</>
|
||||
}
|
||||
ToolbarRight={
|
||||
<>
|
||||
<DataTableFilters.ClearFiltersButton />
|
||||
<DataTableSegment.SaveButton />
|
||||
<DataTableSegment.Select />
|
||||
</>
|
||||
}
|
||||
EmptyView={
|
||||
<EmptyScreen
|
||||
className="mt-6"
|
||||
headline={selectedTab === OutOfOfficeTab.TEAM ? t("ooo_team_empty_title") : t("ooo_empty_title")}
|
||||
description={
|
||||
selectedTab === OutOfOfficeTab.TEAM
|
||||
? t("ooo_team_empty_description")
|
||||
: t("ooo_empty_description")
|
||||
}
|
||||
buttonRaw={<CreateNewOutOfOfficeEntryButton size="sm" onClick={onOpenCreateDialog} />}
|
||||
customIcon={
|
||||
<div className="mt-4 h-[102px]">
|
||||
<div className="flex h-full flex-col items-center justify-center p-2 md:mt-0 md:p-0">
|
||||
<div className="relative">
|
||||
<div className="dark:bg-darkgray-50 absolute -left-3 -top-3 -z-20 h-[70px] w-[70px] -rotate-24 rounded-3xl border-2 border-[#e5e7eb] p-8 opacity-40 dark:opacity-80">
|
||||
<div className="w-12" />
|
||||
</div>
|
||||
<div className="dark:bg-darkgray-50 absolute -top-3 left-3 -z-10 h-[70px] w-[70px] rotate-24 rounded-3xl border-2 border-[#e5e7eb] p-8 opacity-60 dark:opacity-90">
|
||||
<div className="w-12" />
|
||||
</div>
|
||||
<div className="dark:bg-darkgray-50 text-inverted relative z-0 flex h-[70px] w-[70px] items-center justify-center rounded-3xl border-2 border-[#e5e7eb] bg-white">
|
||||
<Icon name="clock" size={28} className="text-black" />
|
||||
<div className="dark:bg-darkgray-50 absolute right-4 top-5 h-[12px] w-[12px] rotate-56 bg-white text-lg font-bold" />
|
||||
<span className="absolute right-4 top-3 font-sans text-sm font-extrabold text-black">
|
||||
z
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
"use client";
|
||||
|
||||
import { usePathname, useRouter } from "next/navigation";
|
||||
import { useCallback, useMemo } from "react";
|
||||
|
||||
import { useCompatSearchParams } from "@calcom/embed-core/src/useCompatSearchParams";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Select, ToggleGroup } from "@calcom/ui/components/form";
|
||||
|
||||
export enum OutOfOfficeTab {
|
||||
MINE = "mine",
|
||||
TEAM = "team",
|
||||
HOLIDAYS = "holidays",
|
||||
}
|
||||
|
||||
export const OutOfOfficeToggleGroup = () => {
|
||||
const { t } = useLocale();
|
||||
const searchParams = useCompatSearchParams();
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
|
||||
const createQueryString = useCallback(
|
||||
(name: string, value: string) => {
|
||||
const params = new URLSearchParams(searchParams ?? undefined);
|
||||
params.set(name, value);
|
||||
|
||||
return params.toString();
|
||||
},
|
||||
[searchParams]
|
||||
);
|
||||
|
||||
const selectedTab = searchParams?.get("type") ?? OutOfOfficeTab.MINE;
|
||||
|
||||
const tabOptions = useMemo(
|
||||
() => [
|
||||
{ value: OutOfOfficeTab.MINE, label: t("my_ooo") },
|
||||
{ value: OutOfOfficeTab.TEAM, label: t("team_ooo") },
|
||||
{ value: OutOfOfficeTab.HOLIDAYS, label: t("holidays") },
|
||||
],
|
||||
[t]
|
||||
);
|
||||
|
||||
const handleTabChange = useCallback(
|
||||
(value: string | null) => {
|
||||
if (!value) return;
|
||||
const newQuery = createQueryString("type", value);
|
||||
router.push(`${pathname}?${newQuery}`);
|
||||
},
|
||||
[createQueryString, pathname, router]
|
||||
);
|
||||
|
||||
const selectedOption = useMemo(
|
||||
() => tabOptions.find((opt) => opt.value === selectedTab) ?? tabOptions[0],
|
||||
[selectedTab, tabOptions]
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* Mobile: Select dropdown */}
|
||||
<div className="md:hidden">
|
||||
<Select
|
||||
className="w-[120px]"
|
||||
value={selectedOption}
|
||||
onChange={(option) => handleTabChange(option?.value ?? null)}
|
||||
options={tabOptions}
|
||||
/>
|
||||
</div>
|
||||
{/* Desktop: Toggle group */}
|
||||
<ToggleGroup
|
||||
className="hidden md:flex"
|
||||
defaultValue={selectedTab}
|
||||
onValueChange={handleTabChange}
|
||||
options={tabOptions}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,14 @@
|
||||
export type BookingRedirectForm = {
|
||||
dateRange: { startDate: Date; endDate: Date };
|
||||
startDateOffset: number;
|
||||
endDateOffset: number;
|
||||
toTeamUserId: number | null;
|
||||
reasonId: number;
|
||||
notes?: string;
|
||||
showNotePublicly?: boolean;
|
||||
uuid?: string | null;
|
||||
forUserId: number | null;
|
||||
forUserName?: string;
|
||||
forUserAvatar?: string;
|
||||
toUserName?: string;
|
||||
};
|
||||
@@ -3,7 +3,6 @@
|
||||
import { usePathname } from "next/navigation";
|
||||
|
||||
import { Dialog } from "@calcom/features/components/controlled-dialog";
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
@@ -17,6 +16,7 @@ import NoPlatformPlan from "@components/settings/platform/dashboard/NoPlatformPl
|
||||
import { useGetUserAttributes } from "@components/settings/platform/hooks/useGetUserAttributes";
|
||||
|
||||
import { CtaRow } from "~/settings/billing/billing-view";
|
||||
import Shell from "~/shell/Shell";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
@@ -89,7 +89,7 @@ export default function PlatformBillingUpgrade() {
|
||||
subtitle={t("manage_billing_description")}
|
||||
isPlatformUser={true}>
|
||||
<>
|
||||
<div className="border-subtle stack-y-6 rounded-lg border px-6 py-8 text-sm sm:stack-y-8">
|
||||
<div className="border-subtle stack-y-6 sm:stack-y-8 rounded-lg border px-6 py-8 text-sm">
|
||||
<CtaRow
|
||||
title={t("view_and_manage_billing_details")}
|
||||
description={t("view_and_edit_billing_details")}>
|
||||
|
||||
@@ -2,15 +2,16 @@
|
||||
|
||||
import { useMemo, useState } from "react";
|
||||
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
import { PlatformManagedUsersTable } from "@calcom/features/users/components/UserTable/PlatformManagedUsersTable";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Label } from "@calcom/ui/components/form";
|
||||
import { Select } from "@calcom/ui/components/form";
|
||||
import { Skeleton, SkeletonContainer, SkeletonText } from "@calcom/ui/components/skeleton";
|
||||
import { PlatformManagedUsersTable } from "@calcom/web/modules/users/components/UserTable/PlatformManagedUsersTable";
|
||||
|
||||
import { useOAuthClients } from "@lib/hooks/settings/platform/oauth-clients/useOAuthClients";
|
||||
|
||||
import Shell from "~/shell/Shell";
|
||||
|
||||
type OAuthClientOption = { label: string; value: string };
|
||||
|
||||
const ManagedUsersView = () => {
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
import { useParams } from "next/navigation";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
import { ErrorCode } from "@calcom/lib/errorCodes";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { PERMISSIONS_GROUPED_MAP } from "@calcom/platform-constants";
|
||||
@@ -17,6 +16,8 @@ import { useGetUserAttributes } from "@components/settings/platform/hooks/useGet
|
||||
import type { FormValues } from "@components/settings/platform/oauth-clients/oauth-client-form";
|
||||
import { OAuthClientForm as EditOAuthClientForm } from "@components/settings/platform/oauth-clients/oauth-client-form";
|
||||
|
||||
import Shell from "~/shell/Shell";
|
||||
|
||||
export default function EditOAuthClient() {
|
||||
const { t } = useLocale();
|
||||
const router = useRouter();
|
||||
@@ -81,7 +82,7 @@ export default function EditOAuthClient() {
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{(!Boolean(clientId) || (isFetched && !data)) && <p>{t("oauth_client_not_found")}</p>}
|
||||
{(!clientId || (isFetched && !data)) && <p>{t("oauth_client_not_found")}</p>}
|
||||
{isFetched && !!data && (
|
||||
<EditOAuthClientForm
|
||||
defaultValues={{
|
||||
|
||||
+4
-3
@@ -3,10 +3,8 @@
|
||||
import { useParams } from "next/navigation";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
import { WebhookForm } from "@calcom/features/webhooks/components";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { DEFAULT_WEBHOOK_VERSION } from "@calcom/features/webhooks/lib/interface/IWebhookRepository";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { WebhookTriggerEvents } from "@calcom/prisma/enums";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
@@ -19,6 +17,9 @@ import {
|
||||
import NoPlatformPlan from "@components/settings/platform/dashboard/NoPlatformPlan";
|
||||
import { useGetUserAttributes } from "@components/settings/platform/hooks/useGetUserAttributes";
|
||||
|
||||
import Shell from "~/shell/Shell";
|
||||
import { WebhookForm } from "~/webhooks/components";
|
||||
|
||||
export default function EditOAuthClientWebhooks() {
|
||||
const { t } = useLocale();
|
||||
const router = useRouter();
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
import { ErrorCode } from "@calcom/lib/errorCodes";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { PERMISSION_MAP } from "@calcom/platform-constants";
|
||||
@@ -16,6 +15,8 @@ import { useGetUserAttributes } from "@components/settings/platform/hooks/useGet
|
||||
import type { FormValues } from "@components/settings/platform/oauth-clients/oauth-client-form";
|
||||
import { OAuthClientForm } from "@components/settings/platform/oauth-clients/oauth-client-form";
|
||||
|
||||
import Shell from "~/shell/Shell";
|
||||
|
||||
export default function CreateOAuthClient() {
|
||||
const router = useRouter();
|
||||
const { t } = useLocale();
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
"use client";
|
||||
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
|
||||
import NoPlatformPlan from "@components/settings/platform/dashboard/NoPlatformPlan";
|
||||
import { useGetUserAttributes } from "@components/settings/platform/hooks/useGetUserAttributes";
|
||||
import { PlatformPricing } from "@components/settings/platform/pricing/platform-pricing";
|
||||
|
||||
import Shell from "~/shell/Shell";
|
||||
|
||||
export default function PlatformPlans() {
|
||||
const { t } = useLocale();
|
||||
const { isUserLoading, isUserBillingDataLoading, isPlatformUser, isPaidUser, userBillingData, userOrgId } =
|
||||
|
||||
@@ -4,7 +4,6 @@ import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { useState, useEffect, useCallback } from "react";
|
||||
|
||||
import Shell from "@calcom/features/shell/Shell";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
@@ -18,6 +17,8 @@ import { OAuthClientsList } from "@components/settings/platform/dashboard/oauth-
|
||||
import { useGetUserAttributes } from "@components/settings/platform/hooks/useGetUserAttributes";
|
||||
import { PlatformPricing } from "@components/settings/platform/pricing/platform-pricing";
|
||||
|
||||
import Shell from "~/shell/Shell";
|
||||
|
||||
const queryClient = new QueryClient();
|
||||
|
||||
export default function Platform() {
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider";
|
||||
import { TeamEventTypeForm } from "@calcom/features/ee/teams/components/TeamEventTypeForm";
|
||||
import { useCreateEventType } from "@calcom/features/eventtypes/hooks/useCreateEventType";
|
||||
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
@@ -11,6 +10,7 @@ import { trpc } from "@calcom/trpc/react";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { WizardLayout } from "@calcom/ui/components/layout";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
import { TeamEventTypeForm } from "@calcom/web/modules/ee/teams/components/TeamEventTypeForm";
|
||||
|
||||
type CreateTeamEventTypeProps = {
|
||||
permissions: { canCreateEventType: boolean };
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import AddNewTeamMembers from "@calcom/features/ee/teams/components/AddNewTeamMembers";
|
||||
import { WizardLayout } from "@calcom/ui/components/layout";
|
||||
import AddNewTeamMembers from "@calcom/web/modules/ee/teams/components/AddNewTeamMembers";
|
||||
|
||||
export const LayoutWrapper = ({ children }: { children: React.ReactNode }) => (
|
||||
<WizardLayout currentStep={2} maxSteps={3}>
|
||||
|
||||
@@ -4,12 +4,12 @@ import { useRouter } from "next/navigation";
|
||||
import React from "react";
|
||||
import { z } from "zod";
|
||||
|
||||
import { CreateANewTeamForm } from "@calcom/features/ee/teams/components";
|
||||
import { HOSTED_CAL_FEATURES } from "@calcom/lib/constants";
|
||||
import { getSafeRedirectUrl } from "@calcom/lib/getSafeRedirectUrl";
|
||||
import { useParamsWithFallback } from "@calcom/lib/hooks/useParamsWithFallback";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import { WizardLayout } from "@calcom/ui/components/layout";
|
||||
import { CreateANewTeamForm } from "@calcom/web/modules/ee/teams/components/CreateANewTeamForm";
|
||||
|
||||
const querySchema = z.object({
|
||||
returnTo: z.string().optional(),
|
||||
|
||||
Reference in new issue
Block a user