* fix * move event types components to web * update import paths * mv apps components * migrate form builder * fix * mv sso * fix * mv * update import paths * update import paths * mv * mv * mv * fix * update Booker * fix * fix * fix * fix * mv video * mv embed components to web * update import paths * mv calendar weekly view components * update import paths * fix * fixp * fix * fix * fix * fix: update FormBuilder imports to use @calcom/features/form-builder Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: update broken import paths after file migrations Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: correct import paths for platform atoms and moved components Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: apply CSS type fixes and add missing atoms exports Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: resolve type errors in test files after component migrations Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: resolve remaining type errors in test files Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix * migrate * fix: resolve type errors in test and mock files - Add missing bookingForm, bookerFormErrorRef, instantConnectCooldownMs to Booker.test.tsx bookings prop - Add all required BookerEvent properties to event.mock.ts - Add vi import from vitest to all mock files - Fix date parameter types in packages/dayjs/__mocks__/index.ts - Add verificationCode and setVerificationCode to test-utils.tsx mock store - Remove children.type access in Section.tsx mock to fix type error - Fix lint issues: remove unused React imports, use import type where needed, add return types - Add biome-ignore comments for pre-existing lint warnings in test files Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * migrate * migrate * migrate * update import paths * update import paths * update import paths * fix * migrate data table * migrate data table * fix * fix * fix * migrate insights components * migrate insights components * fix * mv * update import paths * fix * fix * fix * fix * fix * fix: resolve type errors in test mocks - Booker.test.tsx: Add all required UseFormReturn methods to bookingForm mock - event.mock.ts: Fix entity, subsetOfHosts, instantMeetingParameters, fieldTranslations, image types - dayjs/__mocks__/index.ts: Use Object.assign for proper typing of mock properties - Section.tsx: Change 'class' to 'className' in JSX with biome-ignore comment Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: add missing hasDataErrors and dataErrors to bookings.errors mock Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: add missing loadingStates properties to bookings mock Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: add missing slots properties (setTentativeSelectedTimeslots, tentativeSelectedTimeslots, slotReservationId) Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: update quickAvailabilityChecks to include utcEndIso and use valid status type Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: add missing bookerForm properties (formName, beforeVerifyEmail, formErrors) Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: add missing UseFormReturn properties to bookerForm.bookingForm mock Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: add hasFormErrors and formErrors to bookerForm.formErrors mock Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: add hasFormErrors and formErrors to bookerForm.errors mock Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: add missing isError property to mockEvent Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: use complete BookerEvent mock in Booker.test.tsx Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: use branded bookingFields type in event mock Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: add missing schedule mock properties (isError, isSuccess, isLoading, dataUpdatedAt) Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * revert * fix * fix * fix * fix build * fix * fix * fix * fix: correct AddMembersWithSwitch test wrapper to use initial assignAllTeamMembers value - Fixed test wrapper to initialize useState with componentProps.assignAllTeamMembers instead of hardcoded false, allowing tests to properly test different states - Updated test expectations for ALL_TEAM_MEMBERS_ENABLED_AND_SEGMENT_NOT_APPLICABLE state to match actual component behavior (toggle should be present and checked) - Fixed 'should show Segment when toggled on' test to start with assignAllTeamMembers: false to properly test the flow of enabling it - Added explicit types to satisfy biome lint requirements Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * fix: use JSX.Element instead of React.JSX.Element for type compatibility Co-Authored-By: benny@cal.com <sldisek783@gmail.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
202 lines
7.2 KiB
TypeScript
202 lines
7.2 KiB
TypeScript
"use client";
|
|
|
|
import { Suspense } from "react";
|
|
|
|
import dayjs from "@calcom/dayjs";
|
|
import { Dialog } from "@calcom/features/components/controlled-dialog";
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import type { RouterOutputs } from "@calcom/trpc/react";
|
|
import { trpc } from "@calcom/trpc/react";
|
|
import type { PartialReference } from "@calcom/types/EventManager";
|
|
import { DialogContent, DialogFooter, DialogHeader, DialogClose } from "@calcom/ui/components/dialog";
|
|
import { SkeletonText } from "@calcom/ui/components/skeleton";
|
|
|
|
type BookingItem = RouterOutputs["viewer"]["bookings"]["get"]["bookings"][number];
|
|
type Session = RouterOutputs["viewer"]["calVideo"]["getMeetingInformation"]["data"][number];
|
|
type Participant = Session["participants"][number];
|
|
|
|
interface IMeetingSessionDetailsDialog {
|
|
booking?: BookingItem;
|
|
isOpenDialog: boolean;
|
|
setIsOpenDialog: React.Dispatch<React.SetStateAction<boolean>>;
|
|
timeFormat: number | null;
|
|
}
|
|
|
|
const MeetingSessionDetailsSkeleton = () => {
|
|
return (
|
|
<div className="flex flex-col gap-4">
|
|
{[...Array(2)].map((_, index) => (
|
|
<div key={index} className="border-subtle flex w-full flex-col rounded-md border p-4">
|
|
<div className="mb-3">
|
|
<SkeletonText className="h-5 w-24" />
|
|
<SkeletonText className="mt-1 h-4 w-32" />
|
|
</div>
|
|
<div className="grid grid-cols-2 gap-4 text-sm">
|
|
{[...Array(4)].map((_, i) => (
|
|
<div key={i}>
|
|
<SkeletonText className="h-4 w-16" />
|
|
<SkeletonText className="mt-1 h-4 w-24" />
|
|
</div>
|
|
))}
|
|
</div>
|
|
<div className="mt-4">
|
|
<SkeletonText className="mb-2 h-5 w-20" />
|
|
<div className="stack-y-2">
|
|
{[...Array(2)].map((_, i) => (
|
|
<div key={i} className="border-subtle rounded border p-2 text-sm">
|
|
<div className="flex justify-between">
|
|
<SkeletonText className="h-4 w-24" />
|
|
<SkeletonText className="h-4 w-16" />
|
|
</div>
|
|
<SkeletonText className="mt-1 h-3 w-32" />
|
|
</div>
|
|
))}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
const MeetingSessionDetailsList = ({ roomName }: { roomName: string }) => {
|
|
const { t } = useLocale();
|
|
|
|
const { data: meetingInfo, isLoading } = trpc.viewer.calVideo.getMeetingInformation.useQuery(
|
|
{ roomName },
|
|
{
|
|
suspense: true,
|
|
}
|
|
);
|
|
|
|
if (isLoading) {
|
|
return <MeetingSessionDetailsSkeleton />;
|
|
}
|
|
|
|
if (!meetingInfo || !meetingInfo.data || meetingInfo.data.length === 0) {
|
|
return <p className="font-semibold">{t("no_meeting_sessions_found")}</p>;
|
|
}
|
|
|
|
const formatDuration = (totalSeconds: number) => {
|
|
if (!totalSeconds) {
|
|
return t("ongoing");
|
|
}
|
|
const minutes = Math.floor(totalSeconds / 60);
|
|
const seconds = totalSeconds % 60;
|
|
|
|
const parts = [];
|
|
if (minutes > 0) {
|
|
parts.push(`${minutes} ${t("minutes")}`);
|
|
}
|
|
if (seconds > 0) {
|
|
parts.push(`${seconds} ${t("seconds")}`);
|
|
}
|
|
return parts.join(" ");
|
|
};
|
|
|
|
return (
|
|
<div className="flex flex-col gap-4">
|
|
{meetingInfo.data.map((session: Session, index: number) => (
|
|
<div key={session.id} className="border-subtle flex w-full flex-col rounded-md border p-4">
|
|
<div className="mb-3">
|
|
<h3 className="text-sm font-semibold">
|
|
{t("meeting_session")} {index + 1}
|
|
</h3>
|
|
<p className="text-subtle text-sm">
|
|
{t("session_id")}: {session.id}
|
|
</p>
|
|
</div>
|
|
|
|
<div className="grid grid-cols-2 gap-4 text-sm">
|
|
<div>
|
|
<span className="font-medium">{t("start_time")}:</span>
|
|
<p className="text-subtle">
|
|
{session.start_time
|
|
? dayjs(session.start_time * 1000).format("MMM D, YYYY h:mm A")
|
|
: t("not_available")}
|
|
</p>
|
|
</div>
|
|
|
|
<div>
|
|
<span className="font-medium">{t("duration")}:</span>
|
|
<p className="text-subtle">
|
|
{session.duration ? formatDuration(session.duration) : t("ongoing")}
|
|
</p>
|
|
</div>
|
|
|
|
<div>
|
|
<span className="font-medium">{t("max_participants")}:</span>
|
|
<p className="text-subtle">{session.max_participants || t("unlimited")}</p>
|
|
</div>
|
|
|
|
<div>
|
|
<span className="font-medium">{t("status")}:</span>
|
|
<p className="text-subtle">{session.ongoing ? t("ongoing") : t("ended")}</p>
|
|
</div>
|
|
</div>
|
|
|
|
{session.participants && session.participants.length > 0 && (
|
|
<div className="mt-4">
|
|
<h4 className="mb-2 text-sm font-medium">{t("participants")}:</h4>
|
|
<div className="stack-y-2">
|
|
{session.participants.map((participant: Participant) => (
|
|
<div key={participant.participant_id} className="border-subtle rounded border p-2 text-sm">
|
|
<div className="flex justify-between">
|
|
<span className="font-medium">{participant.user_name || t("anonymous_user")}</span>
|
|
<span className="text-subtle">
|
|
{participant.join_time ? dayjs(participant.join_time * 1000).format("h:mm A") : ""}
|
|
</span>
|
|
</div>
|
|
<p className="text-subtle text-xs">
|
|
{t("user_id")}: {participant.user_id || t("not_available")}
|
|
</p>
|
|
<p className="text-subtle text-xs">
|
|
{t("participant_id")}: {participant.participant_id}
|
|
</p>
|
|
{participant.duration && (
|
|
<p className="text-subtle text-xs">
|
|
{t("session_duration")}: {formatDuration(participant.duration)}
|
|
</p>
|
|
)}
|
|
</div>
|
|
))}
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
))}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export const MeetingSessionDetailsDialog = (props: IMeetingSessionDetailsDialog) => {
|
|
const { t, i18n } = useLocale();
|
|
const { isOpenDialog, setIsOpenDialog, booking, timeFormat } = props;
|
|
|
|
const roomName =
|
|
booking?.references?.find((reference: PartialReference) => reference.type === "daily_video")?.meetingId ??
|
|
undefined;
|
|
|
|
const subtitle = `${booking?.title} - ${dayjs(booking?.startTime).format("ddd")} ${dayjs(
|
|
booking?.startTime
|
|
).format("D")}, ${dayjs(booking?.startTime).format("MMM")}`;
|
|
|
|
return (
|
|
<Dialog open={isOpenDialog} onOpenChange={setIsOpenDialog}>
|
|
<DialogContent enableOverflow>
|
|
<DialogHeader title={t("meeting_session_details")} subtitle={subtitle} />
|
|
{roomName ? (
|
|
<Suspense fallback={<MeetingSessionDetailsSkeleton />}>
|
|
<MeetingSessionDetailsList roomName={roomName} />
|
|
</Suspense>
|
|
) : (
|
|
<p className="font-semibold">{t("no_meeting_sessions_found")}</p>
|
|
)}
|
|
<DialogFooter>
|
|
<DialogClose className="border" />
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
</Dialog>
|
|
);
|
|
};
|