2023-02-16 22:39:57 +00:00
|
|
|
import type { FC, ReactNode } from "react";
|
|
|
|
import { useEffect } from "react";
|
2022-10-12 08:39:14 +00:00
|
|
|
|
2022-12-05 12:12:14 +00:00
|
|
|
import dayjs from "@calcom/dayjs";
|
2023-02-17 19:53:31 +00:00
|
|
|
import classNames from "@calcom/lib/classNames";
|
2022-10-12 08:39:14 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2023-05-02 11:44:05 +00:00
|
|
|
import { SchedulingType } from "@calcom/prisma/enums";
|
2023-01-23 23:08:01 +00:00
|
|
|
import { Badge } from "@calcom/ui";
|
2023-04-12 15:26:31 +00:00
|
|
|
import { CheckSquare, Clock } from "@calcom/ui/components/icon";
|
2022-11-28 18:14:01 +00:00
|
|
|
|
|
|
|
import useRouterQuery from "@lib/hooks/useRouterQuery";
|
2022-10-12 08:39:14 +00:00
|
|
|
|
|
|
|
import { UserAvatars } from "@components/booking/UserAvatars";
|
|
|
|
import EventTypeDescriptionSafeHTML from "@components/eventtype/EventTypeDescriptionSafeHTML";
|
|
|
|
|
|
|
|
import type { AvailabilityPageProps } from "../../pages/[user]/[type]";
|
|
|
|
import type { BookPageProps } from "../../pages/[user]/book";
|
|
|
|
import type { DynamicAvailabilityPageProps } from "../../pages/d/[link]/[slug]";
|
|
|
|
import type { HashLinkPageProps } from "../../pages/d/[link]/book";
|
|
|
|
import type { AvailabilityTeamPageProps } from "../../pages/team/[slug]/[type]";
|
|
|
|
import type { TeamBookingPageProps } from "../../pages/team/[slug]/book";
|
|
|
|
import { AvailableEventLocations } from "./AvailableEventLocations";
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
profile:
|
|
|
|
| AvailabilityPageProps["profile"]
|
|
|
|
| HashLinkPageProps["profile"]
|
|
|
|
| TeamBookingPageProps["profile"]
|
|
|
|
| BookPageProps["profile"]
|
|
|
|
| AvailabilityTeamPageProps["profile"]
|
|
|
|
| DynamicAvailabilityPageProps["profile"];
|
|
|
|
eventType:
|
|
|
|
| AvailabilityPageProps["eventType"]
|
|
|
|
| HashLinkPageProps["eventType"]
|
|
|
|
| TeamBookingPageProps["eventType"]
|
|
|
|
| BookPageProps["eventType"]
|
|
|
|
| AvailabilityTeamPageProps["eventType"]
|
|
|
|
| DynamicAvailabilityPageProps["eventType"];
|
|
|
|
isBookingPage?: boolean;
|
|
|
|
children: ReactNode;
|
|
|
|
isMobile?: boolean;
|
2022-10-17 13:47:11 +00:00
|
|
|
rescheduleUid?: string;
|
2022-10-12 08:39:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const BookingDescription: FC<Props> = (props) => {
|
|
|
|
const { profile, eventType, isBookingPage = false, children } = props;
|
2022-12-05 12:12:14 +00:00
|
|
|
const { date: bookingDate } = useRouterQuery("date");
|
2022-10-12 08:39:14 +00:00
|
|
|
const { t } = useLocale();
|
2023-03-09 10:12:37 +00:00
|
|
|
const { duration, setQuery: setDuration } = useRouterQuery("duration");
|
2022-12-21 17:23:02 +00:00
|
|
|
|
2022-11-28 18:14:01 +00:00
|
|
|
useEffect(() => {
|
2022-12-21 17:23:02 +00:00
|
|
|
if (
|
2023-03-09 10:12:37 +00:00
|
|
|
!duration ||
|
|
|
|
isNaN(Number(duration)) ||
|
|
|
|
(eventType.metadata?.multipleDuration &&
|
|
|
|
!eventType.metadata?.multipleDuration.includes(Number(duration)))
|
2022-12-21 17:23:02 +00:00
|
|
|
) {
|
2023-03-09 10:12:37 +00:00
|
|
|
setDuration(eventType.length);
|
2022-11-28 18:14:01 +00:00
|
|
|
}
|
2022-12-21 17:23:02 +00:00
|
|
|
}, [duration, setDuration, eventType.length, eventType.metadata?.multipleDuration]);
|
|
|
|
|
2022-12-05 12:12:14 +00:00
|
|
|
let requiresConfirmation = eventType?.requiresConfirmation;
|
|
|
|
let requiresConfirmationText = t("requires_confirmation");
|
|
|
|
const rcThreshold = eventType?.metadata?.requiresConfirmationThreshold;
|
|
|
|
if (rcThreshold) {
|
|
|
|
if (isBookingPage) {
|
|
|
|
if (dayjs(bookingDate).diff(dayjs(), rcThreshold.unit) > rcThreshold.time) {
|
|
|
|
requiresConfirmation = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
requiresConfirmationText = t("requires_confirmation_threshold", {
|
|
|
|
...rcThreshold,
|
|
|
|
unit: rcThreshold.unit.slice(0, -1),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2022-10-12 08:39:14 +00:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<UserAvatars
|
|
|
|
profile={profile}
|
|
|
|
users={eventType.users}
|
|
|
|
showMembers={eventType.schedulingType !== SchedulingType.ROUND_ROBIN}
|
2023-01-11 15:00:46 +00:00
|
|
|
size="sm"
|
2022-10-12 08:39:14 +00:00
|
|
|
truncateAfter={3}
|
|
|
|
/>
|
2023-06-22 22:25:37 +00:00
|
|
|
<h2 className="text-default mb-2 mt-1 break-words text-sm font-medium ">
|
feat: Organizations (#8993)
* Initial commit
* Adding feature flag
* feat: Orgs Schema Changing `scopedMembers` to `orgUsers` (#9209)
* Change scopedMembers to orgMembers
* Change to orgUsers
* Letting duplicate slugs for teams to support orgs
* Covering null on unique clauses
* Supporting having the orgId in the session cookie
* feat: organization event type filter (#9253)
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Missing changes to support orgs schema changes
* feat: Onboarding process to create an organization (#9184)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Making sure we check requestedSlug now
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* feat: [CAL-1816] Organization subdomain support (#9345)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* Covering users and subteams, excluding non-org users
* Unpublished teams shows correctly
* Create subdomain in Vercel
* feedback
* Renaming Vercel env vars
* Vercel domain check before creation
* Supporting cal-staging.com
* Change to have vercel detect it
* vercel domain check data message error
* Remove check domain
* Making sure we check requestedSlug now
* Feedback and unneeded code
* Reverting unneeded changes
* Unneeded changes
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Vercel subdomain creation in PROD only
* Making sure we let localhost still work
* Feedback
* Type check fixes
* feat: Organization branding in side menu (#9279)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Org branding provider used in shell sidebar
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Using org avatar (temp)
* Not showing org logo if not set
* User onboarding with org branding (slug)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Feedback
* Org public profile
* Public profiles for team event types
* Added setup profile alert
* Using org avatar on subteams avatar
* Making sure we show the set up profile on org only
* Profile username availability rely on org hook
* Update apps/web/pages/team/[slug].tsx
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Update apps/web/pages/team/[slug].tsx
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* feat: Organization support for event types page (#9449)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Org branding provider used in shell sidebar
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Using org avatar (temp)
* Not showing org logo if not set
* User onboarding with org branding (slug)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Feedback
* Org public profile
* Public profiles for team event types
* Added setup profile alert
* Using org avatar on subteams avatar
* Processing orgs and children as profile options
* Reverting change not belonging to this PR
* Making sure we show the set up profile on org only
* Removing console.log
* Comparing memberships to choose the highest one
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Type errors
* Refactor and type fixes
* Update orgDomains.ts
* Feedback
* Reverting
* NIT
* fix issue getting org slug from domain
* Improving orgDomains util
* Host comes with port
* Update useRouterQuery.ts
* Feedback
* Feedback
* Feedback
* Feedback: SSR for user event-types to have org context
* chore: Cache node_modules (#9492)
* Adding check for cache hit
* Adding a separate install step first
* Put the restore cache steps back
* Revert the uses type for restoring cache
* Added step to restore nm cache
* Removed the cache-hit check
* Comments and naming
* Removed extra install command
* Updated the name of the linting step to be more clear
* Removes the need for useEffect here
* Feedback
* Feedback
* Cookie domain needs a dot
* Type fix
* Update apps/web/public/static/locales/en/common.json
Co-authored-by: Omar López <zomars@me.com>
* Update packages/emails/src/templates/OrganizationAccountVerifyEmail.tsx
* Feedback
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: Efraín Rochín <roae.85@gmail.com>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
2023-06-14 21:40:20 +00:00
|
|
|
{eventType.team?.parent?.name} {profile.name}
|
|
|
|
</h2>
|
2023-04-05 18:14:46 +00:00
|
|
|
<h1 className="font-cal text-emphasis mb-6 break-words text-2xl font-semibold leading-none">
|
2022-10-12 08:39:14 +00:00
|
|
|
{eventType.title}
|
|
|
|
</h1>
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className=" text-default flex flex-col space-y-4 text-sm font-medium">
|
2022-10-12 08:39:14 +00:00
|
|
|
{eventType?.description && (
|
|
|
|
<div
|
|
|
|
className={classNames(
|
2023-03-10 13:02:48 +00:00
|
|
|
"scroll-bar scrollbar-track-w-20 -mx-5 flex max-h-[180px] overflow-y-scroll px-5 ",
|
2023-04-05 18:14:46 +00:00
|
|
|
isBookingPage && "text-default text-sm font-medium"
|
2022-10-12 08:39:14 +00:00
|
|
|
)}>
|
2023-04-05 18:14:46 +00:00
|
|
|
{/* TODO: Fix colors when token is introdcued to DS */}
|
2023-03-10 13:02:48 +00:00
|
|
|
<div className="max-w-full flex-shrink break-words [&_a]:text-blue-500 [&_a]:underline [&_a]:hover:text-blue-600">
|
2022-10-27 08:04:33 +00:00
|
|
|
<EventTypeDescriptionSafeHTML eventType={eventType} />
|
|
|
|
</div>
|
2022-10-12 08:39:14 +00:00
|
|
|
</div>
|
|
|
|
)}
|
2022-12-05 12:12:14 +00:00
|
|
|
{requiresConfirmation && (
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className={classNames("items-top flex", isBookingPage && "text-default text-sm font-medium")}>
|
2022-10-12 08:39:14 +00:00
|
|
|
<div>
|
2023-04-12 15:26:31 +00:00
|
|
|
<CheckSquare className="ml-[2px] inline-block h-4 w-4 ltr:mr-[10px] rtl:ml-[10px] " />
|
2022-10-12 08:39:14 +00:00
|
|
|
</div>
|
2022-12-05 12:12:14 +00:00
|
|
|
{requiresConfirmationText}
|
2022-10-12 08:39:14 +00:00
|
|
|
</div>
|
|
|
|
)}
|
2022-10-19 15:54:18 +00:00
|
|
|
<AvailableEventLocations
|
|
|
|
locations={eventType.locations as AvailabilityPageProps["eventType"]["locations"]}
|
|
|
|
/>
|
2022-11-28 18:14:01 +00:00
|
|
|
<div
|
2022-10-12 08:39:14 +00:00
|
|
|
className={classNames(
|
2022-11-28 18:14:01 +00:00
|
|
|
"flex flex-nowrap text-sm font-medium",
|
2023-04-05 18:14:46 +00:00
|
|
|
isBookingPage && "text-default",
|
2023-01-22 12:36:07 +00:00
|
|
|
!eventType.metadata?.multipleDuration && "items-center"
|
2022-10-12 08:39:14 +00:00
|
|
|
)}>
|
2023-04-12 15:26:31 +00:00
|
|
|
<Clock
|
2022-11-28 18:14:01 +00:00
|
|
|
className={classNames(
|
2023-04-13 18:08:09 +00:00
|
|
|
"ml-[2px] inline-block h-4 w-4 ltr:mr-[10px] rtl:ml-[10px]",
|
2022-11-28 18:14:01 +00:00
|
|
|
isBookingPage && "mt-[2px]"
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
{eventType.metadata?.multipleDuration !== undefined ? (
|
|
|
|
!isBookingPage ? (
|
|
|
|
<ul className="-mt-1 flex flex-wrap gap-1">
|
|
|
|
{eventType.metadata.multipleDuration.map((dur, idx) => (
|
|
|
|
<li key={idx}>
|
|
|
|
<Badge
|
|
|
|
variant="gray"
|
|
|
|
className={classNames(
|
|
|
|
duration === dur.toString()
|
2023-04-11 15:21:24 +00:00
|
|
|
? "bg-emphasis border-emphasis text-emphasis "
|
|
|
|
: "bg-subtle text-default border-transparent ",
|
|
|
|
"cursor-pointer border"
|
2022-11-28 18:14:01 +00:00
|
|
|
)}
|
|
|
|
onClick={() => {
|
|
|
|
setDuration(dur);
|
|
|
|
}}>
|
|
|
|
{dur} {t("minute_timeUnit")}
|
|
|
|
</Badge>
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
) : (
|
|
|
|
`${duration} ${t("minutes")}`
|
|
|
|
)
|
|
|
|
) : (
|
|
|
|
`${eventType.length} ${t("minutes")}`
|
|
|
|
)}
|
|
|
|
</div>
|
2022-10-12 08:39:14 +00:00
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default BookingDescription;
|