* Fix breadcrumb colors

* HorizontalTabs

* Team List Item WIP

* Horizontal Tabs

* Cards

* Remove team list item WIP

* Login Page

* Add welcome back i118n

* EventType page work

* Update EventType Icons

* WIP Availability

* Horizontal Tab Work

* Add build command for in root

* Update build DIr/command

* Add Edit Button + change buttons to v2

* Availablitiy page

* Fix IPAD

* Make mobile look a little nicer

* WIP bookingshell

* Remove list items from breaking build

* Mian bulk of Booking Page.

* Few updates to components

* Fix chormatic feedback

* Fix banner

* Fix Empty Screen

* Text area + embded window fixes

* Semi fix avatar

* Troubleshoot container + Active on count

* Improve mobile

* NITS

* Fix padding on input

* Fix icons

* Starting to move event types settings to tabs

* Begin migration to single page form

* Single page tabs

* Limits Page

* Advanced tab

* Add RHF to dependancies

* Most of advanced tab

* Solved RHF mismtach

* Build fixes

* RHF conditionals fixes

* Improved legibility

* Major refactor/organisation into optional V2 UI

* Portal EditLocationModal

* Fix dialoug form

* Update imports

* Auto Animate + custom inputs WIP

* Custom Inputs

* WIP Apps

* Fixing stories imports

* Stripe app

* Remove duplicate dialog

* Remove duplicate dialog

* Fix embed URL

* Fix app toggles + number of active apps

* Fix container padding on disabledBorder prop

* Removes strict

* EventType Team page WIP

* Fix embed

* NIT

* Add Darkmode gray color

* V2 Shell WIP

* Fix headings on shell V2

* Fix mobile layout with V2 shell

* V2 create event type button

* Checked Team Select

* Hidden to happen on save - not on toggle

* Team Attendee Select animation

* Fix scheduling type and remove multi select label

* Fix overflow on teams url

* Even Type move order handles

* Fix Embed TS errors

* Fix TS errors

* Fix Eslint errors

* Fix TS errors for UI

* Fix ESLINT error

* added SidebarCard for promo to v2 and storybook (#3906)

Co-authored-by: Julian Benegas <[email protected]>
Co-authored-by: Alan <[email protected]>
Co-authored-by: sean-brydon <[email protected]>

* Tooltip Provider - Wrapper due to dep upgrade

* public event type list darkmode

* V2 Color changes to public booking

* Remove unused component

* Fix typecheck

* Removed extra buttons on create ET dialog

* ET edit page refactoring

* Avoids form wrapping the whole Shell

* Nitpicks

Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: zomars <[email protected]>
Co-authored-by: Hariom Balhara <[email protected]>
Co-authored-by: Julian Benegas <[email protected]>
Co-authored-by: Alan <[email protected]>
This commit is contained in:
authored and GitHub committed 2022-08-24 14:18:42 -06:00
1 parent c17e949cd6
commit 436f88a48e
152 files changed
+11222 -4049

No files matched your search

@@ -8,8 +8,8 @@ import z from "zod";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import showToast from "@calcom/lib/notification";
import Button from "@calcom/ui/v2/Button";
import { Form, TextField } from "@calcom/ui/v2/form/fields";
import Button from "@calcom/ui/v2/core/Button";
import { Form, TextField } from "@calcom/ui/v2/core/form/fields";
const formSchema = z.object({
api_key: z.string(),
+1
View File
@@ -19,6 +19,7 @@
"@calcom/office365video": "*",
"@calcom/trpc": "*",
"@calcom/zoomvideo": "*",
"@calcom/ui": "*",
"lodash": "^4.17.21"
},
"devDependencies": {
+75 -53
View File
@@ -11,14 +11,23 @@ module.exports = {
theme: {
fontFamily: {
cal: ['"Cal Sans"', "sans-serif"],
mono: ["Roboto Mono", "monospace"],
sans: ['"Inter var"', "sans-serif"],
},
extend: {
colors: {
/* your primary brand color */
brandcontrast: "var(--brand-text-color)",
darkmodebrand: "var(--brand-color-dark-mode)",
darkmodebrandcontrast: "var(--brand-text-color-dark-mode)",
bookinglightest: "var(--booking-lightest-color)",
bookinglighter: "var(--booking-lighter-color)",
bookinglight: "var(--booking-light-color)",
bookingmedian: "var(--booking-median-color)",
bookingdark: "var(--booking-dark-color)",
bookingdarker: "var(--booking-darker-color)",
bookinghighlight: "var(--booking-highlight-color)",
black: "#111111",
brand: {
// TODO: To be shared between Storybook for v2 UI components and web
// Figure out a way to automate this for self hosted users
// Goto https://javisperez.github.io/tailwindcolorshades to generate your brand color
50: "#d1d5db",
@@ -33,28 +42,17 @@ module.exports = {
900: "#080c13",
DEFAULT: "var(--brand-color)",
},
brandcontrast: "var(--brand-text-color)",
darkmodebrand: "var(--brand-color-dark-mode)",
darkmodebrandcontrast: "var(--brand-text-color-dark-mode)",
bookinglightest: "var(--booking-lightest-color)",
bookinglighter: "var(--booking-lighter-color)",
bookinglight: "var(--booking-light-color)",
bookingmedian: "var(--booking-median-color)",
bookingdark: "var(--booking-dark-color)",
bookingdarker: "var(--booking-darker-color)",
bookinghighlight: "var(--booking-highlight-color)",
black: "#111111",
gray: {
50: "#F8F8F8",
100: "#F5F5F5",
200: "#E1E1E1",
300: "#CFCFCF",
400: "#ACACAC",
500: "#888888",
600: "#494949",
700: "#3E3E3E",
800: "#313131",
900: "#292929",
50: "#F9FAFB",
100: "#F3F4F6",
200: "#E5E7EB",
300: "#D1D5DB",
400: "#9CA3AF",
500: "#6B7280",
600: "#4B5563",
700: "#374151",
800: "#1F2937",
900: "#111827",
},
neutral: {
50: "#F8F8F8",
@@ -93,40 +91,64 @@ module.exports = {
900: "#223B41",
},
red: {
50: "#FEF2F2",
100: "#FEE2E2",
200: "#FECACA",
300: "#FCA5A5",
400: "#F87171",
500: "#EF4444",
600: "#DC2626",
700: "#B91C1C",
800: "#991B1B",
900: "#7F1D1D",
50: "#FFF5F5",
100: "#FFE3E2",
200: "#FFC9C9",
300: "#FEA8A8",
400: "#FF8787",
500: "#FF6B6B",
600: "#FA5352",
700: "#F03E3F",
800: "#E03130",
900: "#C92B2B",
},
orange: {
50: "#FFF7ED",
100: "#FFEDD5",
200: "#FED7AA",
300: "#FDBA74",
400: "#FB923C",
500: "#F97316",
600: "#EA580C",
700: "#C2410C",
800: "#9A3412",
900: "#7C2D12",
50: "#FFF4E5",
100: "#FFE8CC",
200: "#FFD8A8",
300: "#FFBF78",
400: "#FFA94E",
500: "#FF922B",
600: "#FD7E14",
700: "#F76706",
800: "#E8580C",
900: "#D94810",
},
green: {
50: "#ECFDF5",
100: "#D1FAE5",
200: "#A7F3D0",
300: "#6EE7B7",
400: "#34D399",
500: "#10B981",
600: "#059669",
700: "#047857",
800: "#065F46",
900: "#064E3B",
50: "#EBFCEE",
100: "#D2F9D9",
200: "#B1F2BA",
300: "#8CE99A",
400: "#69DB7C",
500: "#51CF66",
600: "#40C057",
700: "#36B24D",
800: "#2F9E44",
900: "#2B8A3E",
},
blue: {
50: "#E7F5FF",
100: "#D0EBFF",
200: "#A4D8FF",
300: "#74C0FC",
400: "#4DABF7",
500: "#339AF0",
600: "#238BE6",
700: "#1C7ED7",
800: "#1971C2",
900: "#1763AB",
},
darkgray: {
50: "#101010",
100: "#1c1c1c",
200: "#2b2b2b",
300: "#444444",
400: "#575757",
500: "#767676",
600: "#a5a5a5",
700: "#d6d6d6",
800: "#e8e8e8",
900: "#f3f4f6",
},
},
fontFamily: {
@@ -11,7 +11,7 @@ import { ClipboardCopyIcon } from "@calcom/ui/Icon";
import Switch from "@calcom/ui/Switch";
import { Tooltip } from "@calcom/ui/Tooltip";
import { Form, TextField } from "@calcom/ui/form/fields";
import DatePicker from "@calcom/ui/v2/form/DatePicker";
import { DatePicker } from "@calcom/ui/v2";
import LicenseRequired from "../../common/components/LicenseRequired";
import type { TApiKeys } from "./ApiKeyListItem";
@@ -1,11 +1,10 @@
import { Trans } from "react-i18next";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import ConfirmationDialogContent from "@calcom/ui/ConfirmationDialogContent";
import { Dialog, DialogTrigger } from "@calcom/ui/Dialog";
import { Icon, BadgeCheckIcon } from "@calcom/ui/Icon";
import { useLocale } from "@lib/hooks/useLocale";
export default function LicenseBanner() {
const { t } = useLocale();
/*
@@ -1,10 +1,9 @@
import dayjs from "@calcom/dayjs";
import { TRIAL_LIMIT_DAYS } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import useMeQuery from "@calcom/trpc/react/hooks/useMeQuery";
import Button from "@calcom/ui/Button";
import { TRIAL_LIMIT_DAYS } from "@lib/config/constants";
import { useLocale } from "@lib/hooks/useLocale";
import useMeQuery from "@lib/hooks/useMeQuery";
const TrialBanner = () => {
const { t } = useLocale();
const query = useMeQuery();
@@ -6,7 +6,7 @@ import { inferQueryOutput, trpc } from "@calcom/trpc/react";
import Select from "@calcom/ui/form/Select";
import TimezoneSelect, { ITimezone } from "@calcom/ui/form/TimezoneSelect";
import { Avatar } from "@calcom/ui/v2";
import DatePicker from "@calcom/ui/v2/form/DatePicker";
import DatePicker from "@calcom/ui/v2/core/form/DatePicker";
import LicenseRequired from "../../common/components/LicenseRequired";
import TeamAvailabilityTimes from "./TeamAvailabilityTimes";
@@ -7,8 +7,8 @@ import { CAL_URL } from "@calcom/lib/constants";
import { inferQueryOutput, trpc } from "@calcom/trpc/react";
import Select from "@calcom/ui/form/Select";
import TimezoneSelect, { ITimezone } from "@calcom/ui/form/TimezoneSelect";
import Avatar from "@calcom/ui/v2/Avatar";
import DatePicker from "@calcom/ui/v2/form/DatePicker";
import { Avatar } from "@calcom/ui/v2";
import DatePicker from "@calcom/ui/v2/core/form/DatePicker";
import TeamAvailabilityTimes from "./TeamAvailabilityTimes";
+20
View File
@@ -0,0 +1,20 @@
type BrowserInfo = {
url: string;
path: string;
referrer: string;
title: string;
query: string;
};
export const getBrowserInfo = (): Partial<BrowserInfo> => {
if (!process.browser) {
return {};
}
return {
url: window.document.location?.href ?? undefined,
path: window.document.location?.pathname ?? undefined,
referrer: window.document?.referrer ?? undefined,
title: window.document.title ?? undefined,
query: window.document.location?.search,
};
};
+25
View File
@@ -0,0 +1,25 @@
import { useEffect, useState } from "react";
const useResponsive = () => {
const [width, setWidth] = useState(window.innerWidth);
const handleWindowSizeChange = () => {
setWidth(window.innerWidth);
};
useEffect(() => {
window.addEventListener("resize", handleWindowSizeChange);
return () => {
window.removeEventListener("resize", handleWindowSizeChange);
};
}, []);
return {
isSm: width <= 640,
isMd: width > 640 && width <= 768,
isLg: width > 768 && width <= 1024,
isXl: width > 1024 && width <= 1280,
is2xl: width > 1280 && width < 1536,
};
};
export default useResponsive;
+39
View File
@@ -0,0 +1,39 @@
import { DefaultSeoProps, NextSeoProps } from "next-seo";
import { SEO_IMG_DEFAULT, SEO_IMG_OGIMG } from "@calcom/lib/constants";
export type HeadSeoProps = {
title: string;
description: string;
siteName?: string;
name?: string;
url?: string;
username?: string;
canonical?: string;
nextSeoProps?: NextSeoProps;
};
const seoImages = {
default: SEO_IMG_DEFAULT,
ogImage: SEO_IMG_OGIMG,
};
export const getSeoImage = (key: keyof typeof seoImages): string => {
return seoImages[key];
};
export const seoConfig: {
headSeo: Required<Pick<HeadSeoProps, "siteName">>;
defaultNextSeo: DefaultSeoProps;
} = {
headSeo: {
siteName: "Cal.com",
},
defaultNextSeo: {
twitter: {
handle: "@calcom",
site: "@calcom",
cardType: "summary_large_image",
},
},
} as const;
+1
View File
@@ -1,6 +1,7 @@
import { NextApiRequest, NextApiResponse } from "next";
import { CollectOpts, EventHandler } from "next-collect";
import { useCollector } from "next-collect/client";
// Importing types so we're not directly importing next/server
import type { NextRequest, NextResponse } from "next/server";
import { CONSOLE_URL } from "./constants";
@@ -52,6 +52,13 @@ export const availabilityRouter = createProtectedRouter()
name: true,
availability: true,
timeZone: true,
eventType: {
select: {
_count: true,
id: true,
eventName: true,
},
},
},
});
if (!schedule || schedule.userId !== user.id) {
+2 -2
View File
@@ -3,9 +3,9 @@
"display": "React Library",
"extends": "./base.json",
"compilerOptions": {
"lib": ["ES2015"],
"lib": ["dom", "dom.iterable", "esnext"],
"module": "ESNext",
"target": "ES6",
"target": "ES5",
"jsx": "react-jsx"
},
"include": [".", "../types/next-auth.d.ts"],
+1 -2
View File
@@ -28,10 +28,9 @@ import Dropdown, {
} from "@calcom/ui/Dropdown";
import { CollectionIcon, Icon } from "@calcom/ui/Icon";
import Loader from "@calcom/ui/Loader";
import { HeadSeo } from "@calcom/ui/v2/core/head-seo";
import { useViewerI18n } from "@calcom/web/components/I18nLanguageHandler";
import { HeadSeo } from "@components/seo/head-seo";
/* TODO: Get this from endpoint */
import pkg from "../../apps/web/package.json";
import ErrorBoundary from "./ErrorBoundary";
+3
View File
@@ -7,6 +7,7 @@
"license": "MIT",
"scripts": {
"lint": "eslint .",
"type-check": "tsc --pretty --noEmit",
"lint:fix": "eslint . --fix",
"lint:report": "eslint . --format json --output-file ../../lint-results/ui.json"
},
@@ -14,12 +15,14 @@
"@calcom/lib": "*",
"@calcom/trpc": "*",
"@radix-ui/react-dialog": "^0.1.0",
"@radix-ui/react-portal": "^0.1.0",
"@radix-ui/react-select": "^0.1.1",
"downshift": "^6.1.7",
"next": "^12.2.5",
"react": "^18.2.0",
"react-colorful": "^5.5.1",
"react-feather": "^2.0.10",
"react-hook-form": "^7.33.1",
"react-icons": "^4.4.0",
"react-query": "^3.39.2",
"react-select": "^5.4.0"
+7 -1
View File
@@ -3,6 +3,12 @@
"compilerOptions": {
"resolveJsonModule": true
},
"include": ["."],
"include": [
"../../apps/web/next-env.d.ts",
"../types/*.d.ts",
"../types/next-auth.d.ts",
"**/*.ts",
"**/*.tsx"
],
"exclude": ["dist", "build", "node_modules"]
}
-9
View File
@@ -1,9 +0,0 @@
import React from "react";
import classNames from "@calcom/lib/classNames";
type Props = { children: React.ReactNode; combined?: boolean };
export default function ButtonGroup({ children, combined = false }: Props) {
return <div className={classNames("flex", !combined && "space-x-2")}>{children}</div>;
}
-66
View File
@@ -1,66 +0,0 @@
import { ReactNode } from "react";
import classNames from "@calcom/lib/classNames";
import Button from "./Button";
export type BaseCardProps = {
image: string;
variant: keyof typeof cardTypeByVariant;
imageProps?: JSX.IntrinsicElements["img"];
title: string;
description: string;
containerProps?: JSX.IntrinsicElements["div"];
actionButton?: {
href: string;
child: ReactNode;
};
};
const cardTypeByVariant = {
AppStore: {
image: "w-10 h-auto",
card: "p-5 w-64",
},
ProfileCard: {
image: "w-9 h-auto rounded-full mb-4s",
card: "w-80 p-4 hover:bg-gray-100",
actionButton: "",
},
};
export function Card({
image,
title,
description,
variant,
actionButton,
containerProps,
imageProps,
}: BaseCardProps) {
return (
<div
className={classNames(
containerProps?.className,
cardTypeByVariant[variant].card,
"border-1 rounded-md border-gray-200 bg-white"
)}
{...containerProps}>
<img
src={image}
// Stops eslint complaining - not smart enough to realise it comes from ...imageProps
alt={imageProps?.alt}
className={classNames(imageProps?.className, cardTypeByVariant[variant].image, "mb-4")}
{...imageProps}
/>
<span className="text-base font-bold leading-5 text-gray-900 ">{title}</span>
<p className="pt-1 text-sm font-normal leading-[18px] text-gray-500">{description}</p>
{variant === "AppStore" && (
<Button color="secondary" href={actionButton?.href} size="lg" className="mt-10 w-full">
{/* Force it to be centered as this usecase of a button is off - doesnt meet normal sizes */}
<div className="mx-auto">{actionButton?.child}</div>
</Button>
)}
</div>
);
}
File renamed without changes.
@@ -9,7 +9,7 @@ import { Maybe } from "@trpc/server";
export type AvatarProps = {
className?: string;
size: "sm" | "lg";
size: "sm" | "md" | "lg";
imageSrc?: Maybe<string>;
title?: string;
alt: string;
@@ -17,9 +17,15 @@ export type AvatarProps = {
accepted?: boolean;
};
const sizesPropsBySize = {
sm: "w-6",
md: "w-8",
lg: "w-16",
};
export default function Avatar(props: AvatarProps) {
const { imageSrc, gravatarFallbackMd5, size, alt, title } = props;
const rootClass = classNames("rounded-full", props.size === "sm" ? "w-6" : "w-16", "h-auto");
const rootClass = classNames("rounded-full", sizesPropsBySize[props.size], "h-auto");
const avatar = (
<AvatarPrimitive.Root className={classNames("relative inline-block overflow-hidden ")}>
<AvatarPrimitive.Image src={imageSrc ?? undefined} alt={alt} className={rootClass} />
File renamed without changes.
@@ -8,7 +8,7 @@ export const badgeClassNameByVariant = {
orange: "bg-orange-100 text-orange-800",
success: "bg-green-100 text-green-800",
green: "bg-green-100 text-green-800",
gray: "bg-gray-200 text-gray-800",
gray: "bg-gray-200 text-gray-800 dark:bg-transparent dark:text-darkgray-800",
blue: "bg-blue-100 text-blue-800",
red: "bg-red-100 text-red-800",
error: "bg-red-100 text-red-800",
@@ -67,3 +67,5 @@ export const BreadcrumbContainer = () => {
setBreadcrumbs(allBreadcrumbs);
}, [router.asPath]);
};
export default Breadcrumb;
@@ -22,7 +22,7 @@ export type ButtonBaseProps = {
/** Action that happens when the button is clicked */
onClick?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
/**Left aligned icon*/
StartIcon?: Icon;
StartIcon?: Icon | React.ElementType;
/**Right aligned icon */
EndIcon?: Icon;
shallow?: boolean;
@@ -42,7 +42,7 @@ const variantClassName = {
"border border-transparent text-white bg-brand-500 hover:bg-brand-400 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-brand-500",
secondary: "border border-gray-200 text-brand-900 bg-white hover:bg-gray-100",
minimal:
"text-gray-700 bg-transparent hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-offset-1 focus:bg-gray-100 focus:ring-brand-900",
"text-gray-700 bg-transparent hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-offset-1 focus:bg-gray-100 focus:ring-brand-900 dark:text-darkgray-900",
destructive:
"text-gray-700 bg-transparent hover:bg-red-100 hover:text-red-700 focus:outline-none focus:ring-2 focus:ring-offset-1 focus:bg-red-100 focus:ring-red-700",
};
+15
View File
@@ -0,0 +1,15 @@
import React from "react";
import classNames from "@calcom/lib/classNames";
type Props = { children: React.ReactNode; combined?: boolean; containerProps?: JSX.IntrinsicElements["div"] };
export default function ButtonGroup({ children, combined = false, containerProps }: Props) {
return (
<div
{...containerProps}
className={classNames("flex", !combined && "space-x-2", containerProps?.className)}>
{children}
</div>
);
}
+150
View File
@@ -0,0 +1,150 @@
import Link from "next/link";
import { ReactNode } from "react";
import React from "react";
import classNames from "@calcom/lib/classNames";
import { Badge } from "./Badge";
import Button from "./Button";
export type BaseCardProps = {
image?: string;
variant: keyof typeof cardTypeByVariant;
imageProps?: JSX.IntrinsicElements["img"];
title: string;
description: ReactNode;
containerProps?: JSX.IntrinsicElements["div"];
actionButton?: {
href?: string;
child: ReactNode;
onClick?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
};
learnMore?: {
href: string;
text: string;
};
mediaLink?: string;
thumbnailUrl?: string;
};
const cardTypeByVariant = {
AppStore: {
image: "w-10 h-auto",
card: "p-5 w-64",
title: "text-base",
description: "text-sm leading-[18px] text-gray-500 font-normal",
},
ProfileCard: {
image: "w-9 h-auto rounded-full mb-4s",
card: "w-80 p-4 hover:bg-gray-100",
title: "text-base",
description: "text-sm leading-[18px] text-gray-500 font-normal",
},
SidebarCard: {
image: "w-9 h-auto rounded-full mb-4s",
card: "w-full p-3 border border-gray-200",
title: "text-sm font-cal",
description: "text-xs text-gray-600 line-clamp-2",
},
};
export function Card({
image,
title,
description,
variant,
actionButton,
containerProps,
imageProps,
mediaLink,
thumbnailUrl,
learnMore,
}: BaseCardProps) {
return (
<div
className={classNames(
containerProps?.className,
cardTypeByVariant[variant].card,
"border-1 rounded-md border-gray-200 bg-white"
)}
{...containerProps}>
{image && (
<img
src={image}
// Stops eslint complaining - not smart enough to realise it comes from ...imageProps
alt={imageProps?.alt}
className={classNames(imageProps?.className, cardTypeByVariant[variant].image, "mb-4")}
{...imageProps}
/>
)}
<h5
title={title}
className={classNames(
cardTypeByVariant[variant].title,
"line-clamp-1 font-bold leading-5 text-gray-900"
)}>
{title}
</h5>
{description && (
<p
title={description.toString()}
className={classNames(cardTypeByVariant[variant].description, "pt-1")}>
{description}
</p>
)}
{variant === "SidebarCard" && (
<a
target="_blank"
rel="noreferrer"
href={mediaLink}
className="group relative my-3 flex aspect-video items-center overflow-hidden rounded">
<div className="absolute inset-0 bg-black bg-opacity-50 transition-opacity group-hover:bg-opacity-40" />
<svg
className="absolute top-1/2 left-1/2 h-8 w-8 -translate-x-1/2 -translate-y-1/2 transform rounded-full text-white shadow-lg hover:-mt-px"
viewBox="0 0 32 32"
fill="none"
xmlns="http://www.w3.org/2000/svg">
<path
d="M16 32C24.8366 32 32 24.8366 32 16C32 7.16344 24.8366 0 16 0C7.16344 0 0 7.16344 0 16C0 24.8366 7.16344 32 16 32Z"
fill="white"
/>
<path
d="M12.1667 8.5L23.8334 16L12.1667 23.5V8.5Z"
fill="#111827"
stroke="#111827"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
<img alt="play feature video" src={thumbnailUrl} />
</a>
)}
{variant === "AppStore" && (
<Button color="secondary" href={actionButton?.href} size="lg" className="mt-10 w-full">
{/* Force it to be centered as this usecase of a button is off - doesnt meet normal sizes */}
<div className="mx-auto">{actionButton?.child}</div>
</Button>
)}
{variant === "SidebarCard" && (
<div className="mt-2 flex items-center justify-between">
{learnMore && (
<Link href={learnMore.href}>
<a target="_blank" rel="noreferrer" className="text-xs font-medium">
{learnMore.text}
</a>
</Link>
)}
<button
className="p-0 text-xs font-normal text-gray-600 hover:text-gray-800"
color="minimal"
onClick={actionButton?.onClick}>
{actionButton?.child}
</button>
</div>
)}
</div>
);
}
export default Card;
@@ -62,14 +62,17 @@ export function Dialog(props: DialogProps) {
}
type DialogContentProps = React.ComponentProps<typeof DialogPrimitive["Content"]> & {
size?: "xl" | "lg";
type?: "creation" | "confirmation";
type: "creation" | "confirmation";
title?: string;
description?: string;
description?: string | undefined;
closeText?: string;
actionDisabled?: boolean;
actionText?: string;
Icon?: Icon;
// If this is set it allows you to overide the action buttons. Usefull if you need to use formcontext
useOwnActionButtons?: boolean;
actionOnClick?: () => void;
actionOnClose?: () => void;
};
export const DialogContent = React.forwardRef<HTMLDivElement, DialogContentProps>(
@@ -110,15 +113,25 @@ export const DialogContent = React.forwardRef<HTMLDivElement, DialogContentProps
</div>
</div>
)}
<DialogFooter>
<DialogClose asChild>
{/* This will require the i18n string passed in */}
<Button color="minimal">{props.closeText ?? "Close"}</Button>
</DialogClose>
<Button color="primary" disabled={props.actionDisabled} onClick={props.actionOnClick}>
{props.actionText}
</Button>
</DialogFooter>
{!props.useOwnActionButtons && (
<DialogFooter>
<DialogClose asChild>
{/* This will require the i18n string passed in */}
<Button color="minimal" onClick={props.actionOnClose}>
{props.closeText ?? "Close"}
</Button>
</DialogClose>
{props.actionOnClick ? (
<Button color="primary" disabled={props.actionDisabled} onClick={props.actionOnClick}>
{props.actionText}
</Button>
) : (
<Button color="primary" type="submit" disabled={props.actionDisabled}>
{props.actionText}
</Button>
)}
</DialogFooter>
)}
</DialogPrimitive.Content>
</DialogPrimitive.Portal>
)
File renamed without changes.
@@ -22,7 +22,7 @@ export default function EmptyScreen({
}) {
return (
<>
<div className="min-h-80 my-6 flex max-w-[640px] flex-col items-center justify-center rounded-sm border border-dashed p-7 lg:p-20">
<div className="min-h-80 my-6 flex w-full flex-col items-center justify-center rounded-sm border border-dashed p-7 lg:p-20">
<div className="flex h-[72px] w-[72px] items-center justify-center rounded-full bg-gray-200 dark:bg-white">
<Icon className="inline-block h-10 w-10 text-white dark:bg-gray-900 dark:text-gray-600" />
</div>
+21
View File
@@ -0,0 +1,21 @@
import React from "react";
import { SVGComponent } from "@calcom/types/SVGComponent";
interface LinkIconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
Icon: SVGComponent;
}
export default function LinkIconButton(props: LinkIconButtonProps) {
return (
<div className="-ml-2">
<button
type="button"
{...props}
className="text-md flex items-center rounded-sm px-2 py-1 text-sm font-medium text-gray-700 hover:bg-gray-200 hover:text-gray-900">
<props.Icon className="h-4 w-4 text-neutral-500 ltr:mr-2 rtl:ml-2" />
{props.children}
</button>
</div>
);
}
File renamed without changes.
File renamed without changes.
+11
View File
@@ -0,0 +1,11 @@
import React, { Fragment, ReactNode } from "react";
import ReactDOM from "react-dom";
export const Portal = (props: { children: React.ReactNode }) => {
const portalContainer = document.getElementById("Portal");
// This should never be the case as it lives in _document.tsx
if (!portalContainer) return null;
return ReactDOM.createPortal(<Fragment>{props.children}</Fragment>, portalContainer);
};
@@ -27,14 +27,16 @@ import Dropdown, {
} from "@calcom/ui/Dropdown";
import { CollectionIcon, Icon } from "@calcom/ui/Icon";
/* TODO: Migate this */
import { HeadSeo } from "../../../apps/web/components/seo/head-seo";
/* TODO: Get this from endpoint */
import pkg from "../../../apps/web/package.json";
import ErrorBoundary from "../ErrorBoundary";
import { KBarContent, KBarRoot, KBarTrigger } from "../Kbar";
import Logo from "../Logo";
import pkg from "../../../../apps/web/package.json";
import ErrorBoundary from "../../ErrorBoundary";
import { KBarRoot, KBarContent, KBarTrigger } from "../../Kbar";
import Logo from "../../Logo";
import Tips from "../modules/tips/Tips";
import Card from "./Card";
import HeadSeo from "./head-seo";
/* TODO: Migate this */
export const ONBOARDING_INTRODUCED_AT = dayjs("September 1 2021").toISOString();
@@ -406,7 +408,7 @@ const navigation: NavigationItemType[] = [
},
{
name: "settings",
href: "/v2/settings",
href: "/settings",
icon: Icon.FiSettings,
},
];
@@ -443,7 +445,9 @@ const NavigationItem: React.FC<{
const router = useRouter();
const current = isChild ? item.href === router.asPath : router.asPath.startsWith(item.href);
const shouldDisplayNavigationItem = useShouldDisplayNavigationItem(props.item);
if (!shouldDisplayNavigationItem) return null;
return (
<Fragment>
<Link href={item.href}>
@@ -561,6 +565,8 @@ function SideBarContainer() {
}
function SideBar() {
const [visible, setVisible] = useState(true);
const { t } = useLocale();
return (
<aside className="hidden w-14 flex-col border-r border-gray-100 bg-gray-50 px-2 md:flex lg:w-56 lg:flex-shrink-0 lg:px-4">
<div className="flex h-0 flex-1 flex-col overflow-y-auto pt-3 pb-4 lg:pt-5">
@@ -582,6 +588,9 @@ function SideBar() {
</Link>
<Navigation />
</div>
<Tips />
<TrialBanner />
<div data-testid="user-dropdown-trigger">
<span className="hidden lg:inline">
@@ -598,10 +607,33 @@ function SideBar() {
function MainContainer(props: LayoutProps) {
return (
<main className="relative z-0 flex flex-1 flex-row overflow-y-auto bg-white focus:outline-none">
<main className="relative z-0 flex flex-1 flex-col overflow-y-auto bg-white focus:outline-none lg:px-12 lg:py-8">
{/* show top navigation for md and smaller (tablet and phones) */}
<TopNavContainer />
<ErrorBoundary>{props.children}</ErrorBoundary>
<ErrorBoundary>
{props.heading && (
<div
className={classNames(props.large && "bg-gray-100 py-8", "flex items-center px-2 pt-4 md:p-0")}>
{props.HeadingLeftIcon && <div className="ltr:mr-4">{props.HeadingLeftIcon}</div>}
<div className="mb-4 w-full">
<>
{props.heading && (
<h1 className="font-cal mb-1 text-xl font-bold capitalize tracking-wide text-black">
{props.heading}
</h1>
)}
{props.subtitle && (
<p className="text-sm text-neutral-500 ltr:mr-4 rtl:ml-4">{props.subtitle}</p>
)}
</>
</div>
{props.CTA && <div className="mb-4 flex-shrink-0">{props.CTA}</div>}
</div>
)}
<div className={classNames("", props.flexChildrenContainer && "flex flex-1 flex-col")}>
{props.children}
</div>
</ErrorBoundary>
{/* show bottom navigation for md and smaller (tablet and phones) */}
<MobileNavigationContainer />
<LicenseBanner />
File renamed without changes.
File renamed without changes.
File renamed without changes.
+103
View File
@@ -0,0 +1,103 @@
import React, { FC } from "react";
import { SVGComponent } from "@calcom/types/SVGComponent";
import { Icon } from "@calcom/ui/Icon";
import { DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, Button } from "@calcom/ui/v2";
import Dropdown from "@calcom/ui/v2/core/Dropdown";
export type ActionType = {
id: string;
icon?: SVGComponent;
iconClassName?: string;
label: string;
disabled?: boolean;
color?: "primary" | "secondary";
} & (
| { href: string; onClick?: never; actions?: never }
| { href?: never; onClick: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void; actions?: never }
| { actions?: ActionType[]; href?: never; onClick?: never }
);
interface Props {
actions: ActionType[];
}
const defaultAction = (e: React.MouseEvent<HTMLElement, MouseEvent>) => {
e.stopPropagation();
};
const DropdownActions = ({
actions,
actionTrigger,
}: {
actions: ActionType[];
actionTrigger?: React.ReactNode;
}) => {
return (
<Dropdown>
{!actionTrigger ? (
<DropdownMenuTrigger asChild>
<Button type="button" color="minimal" size="icon" StartIcon={Icon.FiMoreHorizontal} />
</DropdownMenuTrigger>
) : (
<DropdownMenuTrigger asChild className="">
{actionTrigger}
</DropdownMenuTrigger>
)}
<DropdownMenuContent portalled>
{actions.map((action) => (
<DropdownMenuItem key={action.id} className="focus-visible:outline-none">
<Button
type="button"
color="minimal"
href={action.href}
StartIcon={action.icon}
onClick={action.onClick || defaultAction}
data-testid={action.id}>
{action.label}
</Button>
</DropdownMenuItem>
))}
</DropdownMenuContent>
</Dropdown>
);
};
const TableActions: FC<Props> = ({ actions }) => {
const mobileActions = actions.flatMap((action) => {
if (action.actions) {
return action.actions;
}
return action;
});
return (
<>
<div className="hidden flex-row items-center space-x-2 rtl:space-x-reverse md:flex md:flex-row md:items-center">
{actions.map((action) => {
const button = (
<Button
key={action.id}
data-testid={action.id}
href={action.href}
onClick={action.onClick || defaultAction}
StartIcon={action.icon}
{...(action?.actions ? { EndIcon: Icon.FiChevronDown } : null)}
disabled={action.disabled}
color={action.color || "secondary"}>
{action.label}
</Button>
);
if (!action.actions) {
return button;
}
return <DropdownActions key={action.id} actions={action.actions} actionTrigger={button} />;
})}
</div>
<div className="inline-block text-left md:hidden">
<DropdownActions actions={mobileActions} />
</div>
</>
);
};
export default TableActions;
+52
View File
@@ -0,0 +1,52 @@
import classNames from "classnames";
import { components } from "react-select";
import BaseSelect, {
allTimezones,
ITimezoneOption,
ITimezone,
Props as SelectProps,
} from "react-timezone-select";
import { InputComponent } from "./form/Select";
function TimezoneSelect({ className, ...props }: SelectProps) {
return (
<BaseSelect
theme={(theme) => ({
...theme,
borderRadius: 6,
colors: {
...theme.colors,
primary: "var(--brand-color)",
primary50: "rgba(209 , 213, 219, var(--tw-bg-opacity))",
primary25: "rgba(244, 245, 246, var(--tw-bg-opacity))",
},
})}
styles={{
option: (provided, state) => ({
...provided,
color: state.isSelected ? "var(--brand-text-color)" : "black",
":active": {
backgroundColor: state.isSelected ? "" : "var(--brand-color)",
color: "var(--brand-text-color)",
},
}),
}}
timezones={{
...allTimezones,
"America/Asuncion": "Asuncion",
}}
components={{
...components,
IndicatorSeparator: () => null,
Input: InputComponent,
}}
className={classNames("text-sm", className)}
{...props}
/>
);
}
export default TimezoneSelect;
export type { ITimezone, ITimezoneOption };
@@ -7,12 +7,14 @@ export function Tooltip({
open,
defaultOpen,
onOpenChange,
side = "top",
...props
}: {
children: React.ReactNode;
content: React.ReactNode;
open?: boolean;
defaultOpen?: boolean;
side?: "top" | "right" | "bottom" | "left";
onOpenChange?: (open: boolean) => void;
}) {
return (
@@ -24,7 +26,7 @@ export function Tooltip({
<TooltipPrimitive.Trigger asChild>{children}</TooltipPrimitive.Trigger>
<TooltipPrimitive.Content
className="-mt-2 rounded-md bg-gray-900 px-2 py-1 text-xs font-semibold text-white shadow-lg"
side="top"
side={side}
align="center"
{...props}>
{content}
@@ -1,8 +1,7 @@
import { useRouter } from "next/router";
import classNames from "@calcom/lib/classNames";
import Button from "@calcom/ui/v2/Button";
import Stepper from "@calcom/ui/v2/Stepper";
import { Button, Stepper } from "@calcom/ui/v2";
type DefaultStep = {
title: string;
File renamed without changes.
@@ -3,7 +3,7 @@ import { useEffect } from "react";
import { HexColorInput, HexColorPicker } from "react-colorful";
import { isValidHexCode, fallBackHex } from "@calcom/lib/CustomBranding";
import Swatch from "@calcom/ui/v2/Swatch";
import { Swatch } from "@calcom/ui/v2";
type Handler = (event: MouseEvent | Event) => void;
function useEventListener<
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -13,9 +13,9 @@ import {
import classNames from "@calcom/lib/classNames";
import { getErrorFromUnknown } from "@calcom/lib/errors";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import showToast from "@calcom/ui/v2/notfications";
import { showToast } from "@calcom/ui/v2";
import { Alert } from "../Alert";
import { Alert } from "../../../Alert";
type InputProps = Omit<JSX.IntrinsicElements["input"], "name"> & { name: string };
@@ -25,7 +25,7 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(function Input(pro
{...props}
ref={ref}
className={classNames(
"my-[7px] block h-9 w-full rounded-md border border-gray-300 py-2 px-3 shadow-sm hover:border-gray-400 focus:border-neutral-300 focus:outline-none focus:ring-2 focus:ring-neutral-800 focus:ring-offset-1 sm:text-sm",
"mb-[7px] block h-9 w-full rounded-md border border-gray-300 py-2 px-3 shadow-sm hover:border-gray-400 focus:border-neutral-300 focus:outline-none focus:ring-2 focus:ring-neutral-800 focus:ring-offset-1 sm:text-sm",
props.className
)}
/>
@@ -34,7 +34,7 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(function Input(pro
export function Label(props: JSX.IntrinsicElements["label"]) {
return (
<label {...props} className={classNames("block text-sm font-medium text-gray-700", props.className)}>
<label {...props} className={classNames("block pb-2 text-sm font-medium text-gray-700", props.className)}>
{props.children}
</label>
);
@@ -50,6 +50,9 @@ function HintsOrErrors<T extends FieldValues = FieldValues>(props: {
if (!methods) return null;
const { formState } = methods;
const { hintErrors, fieldName, t } = props;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const fieldErrors: FieldErrors<T> | undefined = formState.errors[fieldName];
if (!hintErrors && fieldErrors && !fieldErrors.message) {
@@ -209,7 +212,7 @@ const InputField = forwardRef<HTMLInputElement, InputFieldProps>(function InputF
"flex h-full flex-col justify-center px-3 text-sm",
props.error && "text-red-900"
)}>
<span>{addOnLeading || addOnSuffix}</span>
<span className="whitespace-nowrap">{addOnLeading || addOnSuffix}</span>
</div>
</div>
<Input
@@ -345,6 +348,7 @@ const PlainForm = <T extends FieldValues>(props: FormProps<T>, ref: Ref<HTMLForm
ref={ref}
onSubmit={(event) => {
event.preventDefault();
event.stopPropagation();
form
.handleSubmit(handleSubmit)(event)
.catch((err) => {
@@ -3,3 +3,4 @@ export * from "./fields";
export { default as Checkbox } from "./Checkbox";
export { default as DatePicker } from "./DatePicker";
export { default as Select } from "./Select";
export { default as FormStep } from "./FormStep";
@@ -4,7 +4,7 @@ import React from "react";
import classNames from "@calcom/lib/classNames";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { RadioArea, RadioAreaGroup } from "@calcom/ui/v2/form/radio-area/RadioAreaGroup";
import { RadioArea, RadioAreaGroup } from "@calcom/ui/v2/core/form/radio-area/RadioAreaGroup";
interface OptionProps
extends Pick<React.OptionHTMLAttributes<HTMLOptionElement>, "value" | "label" | "className"> {
@@ -1,2 +1,3 @@
export * as RadioGroup from "./RadioAreaGroup";
export { default as Select } from "./Select";
export * as Radio from "./Radio";
+106
View File
@@ -0,0 +1,106 @@
import merge from "lodash/merge";
import { NextSeo, NextSeoProps } from "next-seo";
import React from "react";
import { getBrowserInfo } from "@calcom/lib/browser/browser.utils";
import { seoConfig, getSeoImage, HeadSeoProps } from "@calcom/lib/next-seo.config";
/**
* Build full seo tags from title, desc, canonical and url
*/
const buildSeoMeta = (pageProps: {
title: string;
description: string;
image: string;
siteName?: string;
url?: string;
canonical?: string;
}): NextSeoProps => {
const { title, description, image, canonical, siteName = seoConfig.headSeo.siteName } = pageProps;
return {
title: title,
canonical: canonical,
openGraph: {
site_name: siteName,
type: "website",
title: title,
description: description,
images: [
{
url: image,
},
],
},
additionalMetaTags: [
{
property: "name",
content: title,
},
{
property: "description",
content: description,
},
{
name: "description",
content: description,
},
{
property: "image",
content: image,
},
],
};
};
const constructImage = (name: string, description: string, username: string): string => {
return (
encodeURIComponent("Meet **" + name + "** <br>" + description).replace(/'/g, "%27") +
".png?md=1&images=https%3A%2F%2Fcal.com%2Flogo-white.svg&images=" +
(process.env.NEXT_PUBLIC_WEBSITE_URL || process.env.NEXT_PUBLIC_WEBAPP_URL) +
"/" +
username +
"/avatar.png"
);
};
export const HeadSeo = (props: HeadSeoProps): JSX.Element => {
const defaultUrl = getBrowserInfo()?.url;
const image = getSeoImage("default");
const {
title,
description,
name = null,
username = null,
siteName,
canonical = defaultUrl,
nextSeoProps = {},
} = props;
const truncatedDescription = description.length > 24 ? description.substring(0, 23) + "..." : description;
const pageTitle = title + " | Cal.com";
let seoObject = buildSeoMeta({
title: pageTitle,
image,
description: truncatedDescription,
canonical,
siteName,
});
if (name && username) {
const pageImage = getSeoImage("ogImage") + constructImage(name, truncatedDescription, username);
seoObject = buildSeoMeta({
title: pageTitle,
description: truncatedDescription,
image: pageImage,
canonical,
siteName,
});
}
const seoProps: NextSeoProps = merge(nextSeoProps, seoObject);
return <NextSeo {...seoProps} />;
};
export default HeadSeo;
@@ -1,23 +1,28 @@
export * from "./Alert";
export { default as Avatar } from "./Avatar";
export { default as AvatarGroup } from "./AvatarGroup";
export { default as Badge } from "./Badge";
export { default as Banner } from "./banner";
export * from "./Breadcrumb";
export { default as Button } from "./Button";
export * from "./Button";
export { default as ButtonGroup } from "./ButtonGroup";
export * from "./Card";
export { default as ColorPicker } from "./colorpicker";
export * as Dialog from "./Dialog";
export * from "./Dialog";
export { default as Dropdown } from "./Dropdown";
export * from "./Dropdown";
export { default as EmptyScreen } from "./EmptyScreen";
export { default as Checkbox } from "./form/Checkbox";
export { default as DatePicker } from "./form/DatePicker";
export { default as FormStep } from "./form/FormStep";
export * from "./form/radio-area/";
export { default as Select } from "./form/Select";
export { default as Loader } from "./Loader";
export * from "./navigation/tabs/";
export { default as Notifcations } from "./notfications";
export { default as PageHeader } from "./PageHeader";
export * from "./skeleton";
export { default as Shell } from "./Shell";
export { default as Stepper } from "./Stepper";
export { default as Swatch } from "./Swatch";
export { default as Switch } from "./Switch";
export { default as Tooltip } from "./Tooltip";
export { default as WizardForm } from "./WizardForm";
export { default as Banner } from "./banner";
export { default as ColorPicker } from "./colorpicker";
export * from "./form";
export { default as showToast } from "./notfications";
export { default as LinkIconButton } from "./LinkIconButton";
export * from "./skeleton";
export * from "./navigation/tabs";
export * from "./Portal";
@@ -0,0 +1,49 @@
import React, { ComponentProps } from "react";
import { Icon } from "@calcom/ui";
import { VerticalTabs, VerticalTabItemProps, HorizontalTabs } from "@calcom/ui/v2/core/navigation/tabs";
import Shell from "../Shell";
const tabs: VerticalTabItemProps[] = [
{
name: "upcoming",
href: "/bookings/upcoming",
icon: Icon.FiCalendar,
},
{
name: "Unconfirmed",
href: "/bookings/unconfirmed",
icon: Icon.FiInbox,
},
{
name: "past",
href: "/bookings/past",
icon: Icon.FiSunset,
},
{
name: "cancelled",
href: "/bookings/cancelled",
icon: Icon.FiSlash,
},
];
export default function BookingLayout({
children,
...rest
}: { children: React.ReactNode } & ComponentProps<typeof Shell>) {
return (
<Shell {...rest}>
<div className="flex flex-col p-2 md:p-0 xl:flex-row ">
<div className="hidden xl:block">
<VerticalTabs tabs={tabs} />
</div>
<div className="block xl:hidden">
<HorizontalTabs tabs={tabs} />
</div>
<main className="w-full">{children}</main>
</div>
</Shell>
);
}
export const getLayout = (page: React.ReactElement) => <BookingLayout>{page}</BookingLayout>;
@@ -1,6 +1,6 @@
import React, { ComponentProps } from "react";
import { Icon } from "../../Icon";
import { Icon } from "../../../Icon";
import Shell from "../Shell";
import VerticalTabs from "../navigation/tabs/VerticalTabs";
@@ -52,8 +52,8 @@ const HorizontalTabItem = ({ name, href, tabName, ...props }: HorizontalTabItemP
<a
onClick={onClick}
className={classNames(
isCurrent ? "bg-gray-200 text-gray-900" : " text-gray-600 hover:bg-gray-100 hover:text-gray-900",
"mb-2 items-center rounded-md py-[10px] px-4 text-sm font-medium leading-4 md:mb-0",
isCurrent ? "bg-gray-200 text-gray-900" : " text-gray-600 hover:bg-gray-100 hover:text-gray-900 ",
"mb-2 inline-flex items-center justify-center rounded-md py-[10px] px-4 text-sm font-medium leading-4 md:mb-0",
props.disabled && "pointer-events-none !opacity-30"
)}
aria-current={isCurrent ? "page" : undefined}>
@@ -6,7 +6,7 @@ export default function showToast(message: string, variant: "success" | "warning
case "success":
toast.custom(
() => (
<div className="bg-brand-500 mt-2 flex h-9 items-center space-x-2 rounded-md p-3 text-sm font-semibold text-white shadow-md">
<div className="bg-brand-500 mb-2 flex h-9 items-center space-x-2 rounded-md p-3 text-sm font-semibold text-white shadow-md">
<Check className="h-4 w-4" />
<p>{message}</p>
</div>
@@ -17,7 +17,7 @@ export default function showToast(message: string, variant: "success" | "warning
case "error":
toast.custom(
() => (
<div className="mt-2 flex h-9 items-center space-x-2 rounded-md bg-red-100 p-3 text-sm font-semibold text-red-900 shadow-md">
<div className="mb-2 flex h-9 items-center space-x-2 rounded-md bg-red-100 p-3 text-sm font-semibold text-red-900 shadow-md">
<Info className="h-4 w-4" />
<p>{message}</p>
</div>
@@ -28,7 +28,7 @@ export default function showToast(message: string, variant: "success" | "warning
case "warning":
toast.custom(
() => (
<div className="bg-brand-500 mt-2 flex h-9 items-center space-x-2 rounded-md p-3 text-sm font-semibold text-white shadow-md">
<div className="bg-brand-500 mb-2 flex h-9 items-center space-x-2 rounded-md p-3 text-sm font-semibold text-white shadow-md">
<Info className="h-4 w-4" />
<p>{message}</p>
</div>
@@ -39,7 +39,7 @@ export default function showToast(message: string, variant: "success" | "warning
default:
toast.custom(
() => (
<div className="bg-brand-500 mt-2 flex h-9 items-center space-x-2 rounded-md p-3 text-sm font-semibold text-white shadow-md">
<div className="bg-brand-500 mb-2 flex h-9 items-center space-x-2 rounded-md p-3 text-sm font-semibold text-white shadow-md">
<Check className="h-4 w-4" />
<p>{message}</p>
</div>
File renamed without changes.
+2
View File
@@ -0,0 +1,2 @@
export * from "./core";
export * from "./modules";
+61
View File
@@ -0,0 +1,61 @@
import { signIn } from "next-auth/react";
import { Dispatch, SetStateAction } from "react";
import { useFormContext } from "react-hook-form";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry";
import { trpc } from "@calcom/trpc/react";
import { Button } from "@calcom/ui/v2";
interface Props {
email: string;
samlTenantID: string;
samlProductID: string;
hostedCal: boolean;
setErrorMessage: Dispatch<SetStateAction<string | null>>;
}
export default function SAMLLogin(props: Props) {
const { t } = useLocale();
const methods = useFormContext();
const telemetry = useTelemetry();
const mutation = trpc.useMutation("viewer.public.samlTenantProduct", {
onSuccess: async (data) => {
await signIn("saml", {}, { tenant: data.tenant, product: data.product });
},
onError: (err) => {
props.setErrorMessage(err.message);
},
});
return (
<div className="mt-5">
<Button
color="secondary"
data-testid="saml"
className="flex w-full justify-center"
onClick={async (event) => {
event.preventDefault();
// track Google logins. Without personal data/payload
telemetry.event(telemetryEventTypes.googleLogin, collectPageParameters());
if (!props.hostedCal) {
await signIn("saml", {}, { tenant: props.samlTenantID, product: props.samlProductID });
} else {
if (props.email.length === 0) {
props.setErrorMessage(t("saml_email_required"));
return;
}
// hosted solution, fetch tenant and product from the backend
mutation.mutate({
email: methods.getValues("email"),
});
}
}}>
{t("signin_with_saml")}
</Button>
</div>
);
}
+1
View File
@@ -0,0 +1 @@
export { default as SAMLLogin } from "./SAMLLogin";
@@ -0,0 +1,84 @@
import { useRouter } from "next/router";
import { useForm } from "react-hook-form";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { HttpError } from "@calcom/lib/http-error";
import { trpc } from "@calcom/trpc/react";
import { Dialog, DialogClose, DialogContent, DialogTrigger } from "@calcom/ui/Dialog";
import { Icon } from "@calcom/ui/Icon";
import { Form } from "@calcom/ui/form/fields";
import { Button, showToast } from "@calcom/ui/v2";
export function NewScheduleButton({ name = "new-schedule" }: { name?: string }) {
const router = useRouter();
const { t } = useLocale();
const form = useForm<{
name: string;
}>();
const { register } = form;
const createMutation = trpc.useMutation("viewer.availability.schedule.create", {
onSuccess: async ({ schedule }) => {
await router.push("/availability/" + schedule.id);
showToast(t("schedule_created_successfully", { scheduleName: schedule.name }), "success");
},
onError: (err) => {
if (err instanceof HttpError) {
const message = `${err.statusCode}: ${err.message}`;
showToast(message, "error");
}
if (err.data?.code === "UNAUTHORIZED") {
const message = `${err.data.code}: You are not able to create this event`;
showToast(message, "error");
}
},
});
return (
<Dialog name={name} clearQueryParamsOnClose={["copy-schedule-id"]}>
<DialogTrigger asChild>
<Button data-testid={name} StartIcon={Icon.FiPlus}>
{t("new_schedule_btn")}
</Button>
</DialogTrigger>
<DialogContent>
<div className="mb-8">
<h3 className="text-lg font-bold leading-6 text-gray-900" id="modal-title">
{t("add_new_schedule")}
</h3>
</div>
<Form
form={form}
handleSubmit={(values) => {
createMutation.mutate(values);
}}>
<div className="mt-3 space-y-2">
<label htmlFor="label" className="block text-sm font-medium text-gray-700">
{t("name")}
</label>
<div className="mt-1">
<input
type="text"
id="name"
required
className="block w-full rounded-sm border-gray-300 text-sm"
placeholder={t("default_schedule_name")}
{...register("name")}
/>
</div>
</div>
<div className="mt-8 flex flex-row-reverse gap-x-2">
<Button type="submit" loading={createMutation.isLoading}>
{t("continue")}
</Button>
<DialogClose asChild>
<Button color="secondary">{t("cancel")}</Button>
</DialogClose>
</div>
</Form>
</DialogContent>
</Dialog>
);
}
@@ -0,0 +1,331 @@
import classNames from "classnames";
import React, { useCallback, useEffect, useMemo, useState } from "react";
import { Controller, useFieldArray, useFormContext } from "react-hook-form";
import { GroupBase, Props } from "react-select";
import dayjs, { Dayjs, ConfigType } from "@calcom/dayjs";
import { defaultDayRange } from "@calcom/lib/availability";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { weekdayNames } from "@calcom/lib/weekday";
import useMeQuery from "@calcom/trpc/react/hooks/useMeQuery";
import { TimeRange } from "@calcom/types/schedule";
import Dropdown, { DropdownMenuContent } from "@calcom/ui/Dropdown";
import { Icon } from "@calcom/ui/Icon";
import { Switch } from "@calcom/ui/v2";
import { Tooltip, Button, Select } from "@calcom/ui/v2";
/** Begin Time Increments For Select */
const increment = 15;
type Option = {
readonly label: string;
readonly value: number;
};
/**
* Creates an array of times on a 15 minute interval from
* 00:00:00 (Start of day) to
* 23:45:00 (End of day with enough time for 15 min booking)
*/
const useOptions = () => {
// Get user so we can determine 12/24 hour format preferences
const query = useMeQuery();
const { timeFormat } = query.data || { timeFormat: null };
const [filteredOptions, setFilteredOptions] = useState<Option[]>([]);
const options = useMemo(() => {
const end = dayjs().utc().endOf("day");
let t: Dayjs = dayjs().utc().startOf("day");
const options: Option[] = [];
while (t.isBefore(end)) {
options.push({
value: t.toDate().valueOf(),
label: dayjs(t)
.utc()
.format(timeFormat === 12 ? "h:mma" : "HH:mm"),
});
t = t.add(increment, "minutes");
}
return options;
}, [timeFormat]);
const filter = useCallback(
({ offset, limit, current }: { offset?: ConfigType; limit?: ConfigType; current?: ConfigType }) => {
if (current) {
const currentOption = options.find((option) => option.value === dayjs(current).toDate().valueOf());
if (currentOption) setFilteredOptions([currentOption]);
} else
setFilteredOptions(
options.filter((option) => {
const time = dayjs(option.value);
return (!limit || time.isBefore(limit)) && (!offset || time.isAfter(offset));
})
);
},
[options]
);
return { options: filteredOptions, filter };
};
type TimeRangeFieldProps = {
name: string;
className?: string;
};
const LazySelect = ({
value,
min,
max,
...props
}: Omit<Props<Option, false, GroupBase<Option>>, "value"> & {
value: ConfigType;
min?: ConfigType;
max?: ConfigType;
}) => {
// Lazy-loaded options, otherwise adding a field has a noticable redraw delay.
const { options, filter } = useOptions();
useEffect(() => {
filter({ current: value });
}, [filter, value]);
return (
<Select
options={options}
onMenuOpen={() => {
if (min) filter({ offset: min });
if (max) filter({ limit: max });
}}
value={options.find((option) => option.value === dayjs(value).toDate().valueOf())}
onMenuClose={() => filter({ current: value })}
{...props}
/>
);
};
const TimeRangeField = ({ name, className }: TimeRangeFieldProps) => {
const { watch } = useFormContext();
const minEnd = watch(`${name}.start`);
const maxStart = watch(`${name}.end`);
return (
<div className={classNames("flex flex-grow items-center space-x-3", className)}>
<Controller
name={`${name}.start`}
render={({ field: { onChange, value } }) => {
return (
<LazySelect
className="w-[120px]"
value={value}
max={maxStart}
onChange={(option) => {
onChange(new Date(option?.value as number));
}}
/>
);
}}
/>
<span>-</span>
<Controller
name={`${name}.end`}
render={({ field: { onChange, value } }) => (
<LazySelect
className="flex-grow sm:w-[120px]"
value={value}
min={minEnd}
onChange={(option) => {
onChange(new Date(option?.value as number));
}}
/>
)}
/>
</div>
);
};
type ScheduleBlockProps = {
day: number;
weekday: string;
name: string;
};
const CopyTimes = ({ disabled, onApply }: { disabled: number[]; onApply: (selected: number[]) => void }) => {
const [selected, setSelected] = useState<number[]>([]);
const { i18n, t } = useLocale();
return (
<div className="m-4 space-y-2 py-4">
<p className="h6 text-xs font-medium uppercase text-neutral-400">Copy times to</p>
<ol className="space-y-2">
{weekdayNames(i18n.language).map((weekday, num) => (
<li key={weekday}>
<label className="flex w-full items-center justify-between">
<span>{weekday}</span>
<input
value={num}
defaultChecked={disabled.includes(num)}
disabled={disabled.includes(num)}
onChange={(e) => {
if (e.target.checked && !selected.includes(num)) {
setSelected(selected.concat([num]));
} else if (!e.target.checked && selected.includes(num)) {
setSelected(selected.slice(selected.indexOf(num), 1));
}
}}
type="checkbox"
className="inline-block rounded-sm border-gray-300 text-neutral-900 focus:ring-neutral-500 disabled:text-neutral-400"
/>
</label>
</li>
))}
</ol>
<div className="pt-2">
<Button className="w-full justify-center" color="primary" onClick={() => onApply(selected)}>
{t("apply")}
</Button>
</div>
</div>
);
};
export const DayRanges = ({
name,
defaultValue = [defaultDayRange],
}: {
name: string;
defaultValue?: TimeRange[];
}) => {
const { setValue, watch } = useFormContext();
// XXX: Hack to make copying times work; `fields` is out of date until save.
const watcher = watch(name);
const { t } = useLocale();
const { fields, replace, append, remove } = useFieldArray({
name,
});
useEffect(() => {
if (defaultValue.length && !fields.length) {
replace(defaultValue);
}
}, [replace, defaultValue, fields.length]);
const handleAppend = () => {
// FIXME: Fix type-inference, can't get this to work. @see https://github.com/react-hook-form/react-hook-form/issues/4499
const nextRangeStart = dayjs((fields[fields.length - 1] as unknown as TimeRange).end);
const nextRangeEnd = dayjs(nextRangeStart).add(1, "hour");
if (nextRangeEnd.isBefore(nextRangeStart.endOf("day"))) {
return append({
start: nextRangeStart.toDate(),
end: nextRangeEnd.toDate(),
});
}
};
return (
<div className="space-y-2">
{fields.map((field, index) => (
<div key={field.id} className="flex items-center rtl:space-x-reverse">
<div className="flex flex-grow space-x-1 sm:flex-grow-0">
<TimeRangeField name={`${name}.${index}`} />
<Button
type="button"
size="icon"
color="minimal"
StartIcon={Icon.FiTrash}
onClick={() => remove(index)}
/>
</div>
{index === 0 && (
<div className="absolute top-2 right-0 text-right sm:relative sm:top-0 sm:flex-grow">
<Tooltip content={t("add_time_availability") as string}>
<Button
className="text-neutral-400"
type="button"
color="minimal"
size="icon"
StartIcon={Icon.FiPlus}
onClick={handleAppend}
/>
</Tooltip>
<Dropdown>
<Tooltip content={t("duplicate") as string}>
<Button
type="button"
color="minimal"
size="icon"
StartIcon={Icon.FiCopy}
onClick={handleAppend}
/>
</Tooltip>
<DropdownMenuContent>
<CopyTimes
disabled={[parseInt(name.substring(name.lastIndexOf(".") + 1), 10)]}
onApply={(selected) =>
selected.forEach((day) => {
// TODO: Figure out why this is different?
// console.log(watcher, fields);
setValue(name.substring(0, name.lastIndexOf(".") + 1) + day, watcher);
})
}
/>
</DropdownMenuContent>
</Dropdown>
</div>
)}
</div>
))}
</div>
);
};
const ScheduleBlock = ({ name, day, weekday }: ScheduleBlockProps) => {
const { t } = useLocale();
const form = useFormContext();
const watchAvailable = form.watch(`${name}.${day}`, []);
return (
<fieldset className="relative flex flex-col justify-between space-y-2 py-5 sm:flex-row sm:space-y-0">
<label
className={classNames(
"flex space-x-2 rtl:space-x-reverse",
!watchAvailable.length ? "w-full" : "w-1/3"
)}>
<div className={classNames(!watchAvailable.length ? "w-1/3" : "w-full", "flex items-center")}>
<Switch
checked={watchAvailable.length}
onCheckedChange={(value) => {
form.setValue(`${name}.${day}`, value ? [defaultDayRange] : []);
}}
/>
<span className="ml-3 text-sm font-medium leading-4 text-gray-900">{weekday}</span>
</div>
{!watchAvailable.length && (
<div className="flex-grow text-right text-sm text-gray-500 sm:flex-shrink">
{t("no_availability")}
</div>
)}
</label>
{!!watchAvailable.length && (
<div className="flex-grow">
<DayRanges name={`${name}.${day}`} defaultValue={[]} />
</div>
)}
</fieldset>
);
};
const Schedule = ({ name }: { name: string }) => {
const { i18n } = useLocale();
return (
<fieldset className="divide-y divide-gray-200">
{weekdayNames(i18n.language).map((weekday, num) => (
<ScheduleBlock key={num} name={name} weekday={weekday} day={num} />
))}
</fieldset>
);
};
export default Schedule;
@@ -0,0 +1,77 @@
import Link from "next/link";
import { Fragment } from "react";
import { availabilityAsString } from "@calcom/lib/availability";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Availability } from "@calcom/prisma/client";
import { inferQueryOutput } from "@calcom/trpc/react";
import { Icon } from "@calcom/ui";
import { Button, Badge } from "@calcom/ui/v2";
import Dropdown, {
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "@calcom/ui/v2/core/Dropdown";
export function ScheduleListItem({
schedule,
deleteFunction,
isDeleting = false,
}: {
schedule: inferQueryOutput<"viewer.availability.list">["schedules"][number];
deleteFunction: ({ scheduleId }: { scheduleId: number }) => void;
isDeleting: boolean;
}) {
const { t, i18n } = useLocale();
return (
<li key={schedule.id}>
<div className="flex items-center justify-between py-5 hover:bg-neutral-50 ltr:pl-4 rtl:pr-4 sm:ltr:pl-0 sm:rtl:pr-0">
<div className="group flex w-full items-center justify-between hover:bg-neutral-50 sm:px-6">
<Link href={"/availability/" + schedule.id}>
<a className="flex-grow truncate text-sm" title={schedule.name}>
<div>
<span className="truncate pr-2 font-semibold text-gray-900">{schedule.name}</span>
{schedule.isDefault && <Badge variant="green">{t("default")}</Badge>}
</div>
<p className="mt-1 hidden text-base leading-4 text-gray-600 lg:block">
{schedule.availability.map((availability: Availability) => (
<Fragment key={availability.id}>
{availabilityAsString(availability, i18n.language)}
<br />
</Fragment>
))}
</p>
</a>
</Link>
</div>
<Button color="secondary" href={"/availability/" + schedule.id}>
Edit
</Button>
<Dropdown>
<DropdownMenuTrigger className="focus:bg-transparent focus:ring-0">
<Button color="secondary" size="icon" StartIcon={Icon.FiMoreHorizontal} />
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuItem>
<Button
disabled={isDeleting}
onClick={() => {
deleteFunction({
scheduleId: schedule.id,
});
}}
type="button"
color="destructive"
className="w-full font-normal"
StartIcon={isDeleting ? undefined : Icon.FiTrash}
loading={isDeleting}>
{isDeleting ? t("deleting") : t("delete_schedule")}
</Button>
</DropdownMenuItem>
</DropdownMenuContent>
</Dropdown>
</div>
</li>
);
}
@@ -0,0 +1,3 @@
export * from "./NewScheduleButton";
export { default as Schedule } from "./Schedule";
export * from "./ScheduleListItem";
@@ -39,10 +39,12 @@ export const Day = ({
return (
<button
className={classNames(
"disabled:text-bookinglighter absolute top-0 left-0 right-0 bottom-0 mx-auto w-full rounded-md border-2 border-transparent text-center font-medium hover:bg-gray-300 disabled:cursor-default disabled:border-transparent disabled:font-light dark:hover:border-white disabled:dark:border-transparent",
"disabled:text-bookinglighter absolute top-0 left-0 right-0 bottom-0 mx-auto w-full rounded-md border-2 border-transparent text-center font-medium hover:bg-gray-300 disabled:cursor-default disabled:border-transparent disabled:font-light dark:hover:border-white disabled:dark:border-transparent",
active
? "dark:bg-darkmodebrand dark:text-darkmodebrandcontrast border-brand-800 border-2 bg-gray-300"
: !props.disabled && "bg-gray-100 dark:bg-gray-600 dark:text-white"
? "dark:bg-darkmodebrand dark:text-darkmodebrandcontrast border-2 bg-gray-300"
: !props.disabled
? "dark:bg-darkgray-200 bg-gray-100 dark:text-white"
: "dark:hover:bg-darkgray-300"
)}
data-testid="day"
data-disabled={props.disabled}
@@ -161,7 +163,9 @@ const DatePicker = ({
</div>
<div className="border-bookinglightest mb-2 grid grid-cols-7 gap-4 border-t border-b text-center dark:border-gray-800 md:mb-0 md:border-0">
{weekdayNames(locale, weekStart, "short").map((weekDay) => (
<div key={weekDay} className="text-bookinglight my-4 text-xs uppercase tracking-widest">
<div
key={weekDay}
className="text-bookinglight dark:text-darkgray-900 my-4 text-xs uppercase tracking-widest">
{weekDay}
</div>
))}
+1
View File
@@ -0,0 +1 @@
export * from "./DatePicker";
@@ -0,0 +1,68 @@
import autoAnimate from "@formkit/auto-animate";
import React, { useEffect, useRef } from "react";
import { Props } from "react-select";
import { classNames } from "@calcom/lib";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Icon } from "@calcom/ui/Icon";
import { Avatar, Select } from "../..";
type CheckedSelectOption = {
avatar: string;
label: string;
value: string;
disabled?: boolean;
};
export const CheckedTeamSelect = ({
options = [],
value = [],
...props
}: Omit<Props<CheckedSelectOption, true>, "value" | "onChange"> & {
value?: readonly CheckedSelectOption[];
onChange: (value: readonly CheckedSelectOption[]) => void;
}) => {
const { t } = useLocale();
const animationRef = useRef(null);
useEffect(() => {
animationRef.current && autoAnimate(animationRef.current);
}, [animationRef]);
return (
<>
<Select
styles={{
option: (styles, { isDisabled }) => ({
...styles,
backgroundColor: isDisabled ? "#F5F5F5" : "inherit",
}),
}}
name={props.name}
placeholder={props.placeholder || t("select")}
isSearchable={false}
options={options}
value={value}
isMulti
{...props}
/>
{/* This class name conditional looks a bit odd but it allows a seemless transition when using autoanimate
- Slides down from the top instead of just teleporting in from nowhere*/}
<ul className={classNames("mt-3 rounded-md", value.length >= 1 && "border")} ref={animationRef}>
{value.map((option) => (
<li key={option.value} className="flex border-b py-2 px-3">
<Avatar size="sm" imageSrc={option.avatar} alt={option.label} />
<p className="my-auto ml-3 text-sm text-gray-900">{option.label}</p>
<Icon.FiX
onClick={() => props.onChange(value.filter((item) => item.value !== option.value))}
className="my-auto ml-auto"
/>
</li>
))}
</ul>
</>
);
};
export default CheckedTeamSelect;
@@ -0,0 +1,369 @@
import { zodResolver } from "@hookform/resolvers/zod";
import { SchedulingType } from "@prisma/client";
import { useSession } from "next-auth/react";
import { useRouter } from "next/router";
import { useEffect } from "react";
import { useForm } from "react-hook-form";
import type { z } from "zod";
import classNames from "@calcom/lib/classNames";
import { WEBAPP_URL } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { HttpError } from "@calcom/lib/http-error";
import slugify from "@calcom/lib/slugify";
import { createEventTypeInput } from "@calcom/prisma/zod/custom/eventtype";
import { trpc } from "@calcom/trpc/react";
import { Alert } from "@calcom/ui/Alert";
import { Icon } from "@calcom/ui/Icon";
import { Form, InputLeading, TextAreaField, TextField } from "@calcom/ui/form/fields";
import { Dialog, DialogClose, DialogContent, Button, Avatar, showToast } from "@calcom/ui/v2";
import Dropdown, {
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@calcom/ui/v2/core/Dropdown";
import * as RadioArea from "@calcom/ui/v2/core/form/radio-area/RadioAreaGroup";
// this describes the uniform data needed to create a new event type on Profile or Team
export interface EventTypeParent {
teamId: number | null | undefined; // if undefined, then it's a profile
name?: string | null;
slug?: string | null;
image?: string | null;
}
interface CreateEventTypeBtnProps {
// set true for use on the team settings page
canAddEvents: boolean;
// set true when in use on the team settings page
isIndividualTeam?: boolean;
// EventTypeParent can be a profile (as first option) or a team for the rest.
options: EventTypeParent[];
}
export default function CreateEventTypeButton(props: CreateEventTypeBtnProps) {
const { t } = useLocale();
const router = useRouter();
// URL encoded params
const teamId: number | undefined =
typeof router.query.teamId === "string" && router.query.teamId
? parseInt(router.query.teamId)
: undefined;
const pageSlug = router.query.eventPage || props.options[0].slug;
const hasTeams = !!props.options.find((option) => option.teamId);
const type: string = typeof router.query.type == "string" && router.query.type ? router.query.type : "";
const form = useForm<z.infer<typeof createEventTypeInput>>({
resolver: zodResolver(createEventTypeInput),
});
const { setValue, watch, register } = form;
useEffect(() => {
if (!router.isReady) return;
const title: string =
typeof router.query.title === "string" && router.query.title ? router.query.title : "";
const length: number =
typeof router.query.length === "string" && router.query.length ? parseInt(router.query.length) : 15;
const description: string =
typeof router.query.description === "string" && router.query.description
? router.query.description
: "";
const slug: string = typeof router.query.slug === "string" && router.query.slug ? router.query.slug : "";
setValue("title", title);
setValue("length", length);
setValue("description", description);
setValue("slug", slug);
// If query params change, update the form
}, [router.isReady, router.query, setValue]);
useEffect(() => {
const subscription = watch((value, { name, type }) => {
if (name === "title" && type === "change") {
if (value.title) setValue("slug", slugify(value.title));
else setValue("slug", "");
}
});
return () => subscription.unsubscribe();
}, [watch, setValue]);
const createMutation = trpc.useMutation("viewer.eventTypes.create", {
onSuccess: async ({ eventType }) => {
await router.replace("/event-types/" + eventType.id);
showToast(t("event_type_created_successfully", { eventTypeTitle: eventType.title }), "success");
},
onError: (err) => {
if (err instanceof HttpError) {
const message = `${err.statusCode}: ${err.message}`;
showToast(message, "error");
}
if (err.data?.code === "BAD_REQUEST") {
const message = `${err.data.code}: URL already exists.`;
showToast(message, "error");
}
if (err.data?.code === "UNAUTHORIZED") {
const message = `${err.data.code}: You are not able to create this event`;
showToast(message, "error");
}
},
});
// inject selection data into url for correct router history
const openModal = (option: EventTypeParent) => {
const query = {
...router.query,
dialog: "new-eventtype",
eventPage: option.slug,
teamId: option.teamId,
};
if (!option.teamId) {
delete query.teamId;
}
router.push(
{
pathname: router.pathname,
query,
},
undefined,
{ shallow: true }
);
};
return (
<Dialog
name="new-eventtype"
clearQueryParamsOnClose={["eventPage", "teamId", "type", "description", "title", "length", "slug"]}>
{!hasTeams || props.isIndividualTeam ? (
<Button
onClick={() => openModal(props.options[0])}
data-testid="new-event-type"
StartIcon={Icon.FiPlus}
disabled={!props.canAddEvents}>
{t("new")}
</Button>
) : (
<Dropdown>
<DropdownMenuTrigger asChild>
<Button EndIcon={Icon.FiChevronDown}>{t("new_event_type_btn")}</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuLabel>{t("new_event_subtitle")}</DropdownMenuLabel>
<DropdownMenuSeparator className="h-px bg-gray-200" />
{props.options.map((option) => (
<DropdownMenuItem
key={option.slug}
className="cursor-pointer px-3 py-2 hover:bg-neutral-100 focus:outline-none"
onSelect={() => openModal(option)}>
<Avatar
alt={option.name || ""}
imageSrc={option.image || `${WEBAPP_URL}/${option.slug}/avatar.png`} // if no image, use default avatar
size="sm"
className="inline ltr:mr-2 rtl:ml-2"
/>
{option.name ? option.name : option.slug}
</DropdownMenuItem>
))}
</DropdownMenuContent>
</Dropdown>
)}
<DialogContent type="creation" className="overflow-y-auto" useOwnActionButtons>
<div className="mb-4">
<h3 className="text-lg font-bold leading-6 text-gray-900" id="modal-title">
{teamId ? t("add_new_team_event_type") : t("add_new_event_type")}
</h3>
<div>
<p className="text-sm text-gray-500">{t("new_event_type_to_book_description")}</p>
</div>
</div>
<Form
form={form}
handleSubmit={(values) => {
createMutation.mutate(values);
}}>
<div className="mt-3 space-y-4">
{teamId && (
<TextField
type="hidden"
labelProps={{ style: { display: "none" } }}
{...register("teamId", { valueAsNumber: true })}
value={teamId}
/>
)}
<TextField label={t("title")} placeholder={t("quick_chat")} {...register("title")} />
{process.env.NEXT_PUBLIC_WEBSITE_URL !== undefined &&
process.env.NEXT_PUBLIC_WEBSITE_URL?.length >= 21 ? (
<TextField
label={`${t("url")}: ${process.env.NEXT_PUBLIC_WEBSITE_URL}`}
required
addOnLeading={<InputLeading>/{pageSlug}/</InputLeading>}
{...register("slug")}
/>
) : (
<TextField
label={t("url")}
required
addOnLeading={
<InputLeading>
{process.env.NEXT_PUBLIC_WEBSITE_URL}/{pageSlug}/
</InputLeading>
}
{...register("slug")}
/>
)}
<TextAreaField
label={t("description")}
placeholder={t("quick_video_meeting")}
{...register("description")}
/>
<div className="relative">
<TextField
type="number"
required
min="10"
placeholder="15"
label={t("length")}
className="pr-20"
{...register("length", { valueAsNumber: true })}
/>
<div className="absolute inset-y-0 right-0 mt-1.5 flex items-center pt-4 pr-3 text-sm text-gray-400">
{t("minutes")}
</div>
</div>
{teamId && (
<div className="mb-4">
<label htmlFor="schedulingType" className="block text-sm font-bold text-gray-700">
{t("scheduling_type")}
</label>
{form.formState.errors.schedulingType && (
<Alert
className="mt-1"
severity="error"
message={form.formState.errors.schedulingType.message}
/>
)}
<RadioArea.Group
{...register("schedulingType")}
onChange={(val) => form.setValue("schedulingType", val as SchedulingType)}
className="relative mt-1 flex space-x-6 rounded-sm rtl:space-x-reverse">
<RadioArea.Item
value={SchedulingType.COLLECTIVE}
defaultChecked={type === SchedulingType.COLLECTIVE}
className="w-1/2 text-sm">
<strong className="mb-1 block">{t("collective")}</strong>
<p>{t("collective_description")}</p>
</RadioArea.Item>
<RadioArea.Item
value={SchedulingType.ROUND_ROBIN}
defaultChecked={type === SchedulingType.ROUND_ROBIN}
className="w-1/2 text-sm">
<strong className="mb-1 block">{t("round_robin")}</strong>
<p>{t("round_robin_description")}</p>
</RadioArea.Item>
</RadioArea.Group>
</div>
)}
</div>
<div className="mt-8 flex flex-row-reverse gap-x-2">
<Button type="submit" loading={createMutation.isLoading}>
{t("continue")}
</Button>
<DialogClose asChild>
<Button color="secondary">{t("cancel")}</Button>
</DialogClose>
</div>
</Form>
</DialogContent>
</Dialog>
);
}
type CreateEventTypeTrigger = {
isIndividualTeam?: boolean;
// EventTypeParent can be a profile (as first option) or a team for the rest.
options: EventTypeParent[];
hasTeams: boolean;
// set true for use on the team settings page
canAddEvents: boolean;
openModal: (option: EventTypeParent) => void;
};
export function CreateEventTypeTrigger(props: CreateEventTypeTrigger) {
const { t } = useLocale();
return (
<>
{!props.hasTeams || props.isIndividualTeam ? (
<Button
onClick={() => props.openModal(props.options[0])}
data-testid="new-event-type"
StartIcon={Icon.FiPlus}
disabled={!props.canAddEvents}>
{t("new_event_type_btn")}
</Button>
) : (
<Dropdown>
<DropdownMenuTrigger asChild>
<Button EndIcon={Icon.FiChevronDown}>{t("new_event_type_btn")}</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuLabel>{t("new_event_subtitle")}</DropdownMenuLabel>
<DropdownMenuSeparator className="h-px bg-gray-200" />
{props.options.map((option) => (
<CreateEventTeamsItem
key={option.slug}
option={option}
openModal={() => props.openModal(option)}
/>
))}
</DropdownMenuContent>
</Dropdown>
)}
</>
);
}
function CreateEventTeamsItem(props: {
openModal: (option: EventTypeParent) => void;
option: EventTypeParent;
}) {
const session = useSession();
const membershipQuery = trpc.useQuery([
"viewer.teams.getMembershipbyUser",
{
memberId: session.data?.user?.id as number,
teamId: props.option.teamId as number,
},
]);
const isDisabled = membershipQuery.data?.role === "MEMBER";
return (
<DropdownMenuItem
key={props.option.slug}
className={classNames(
"cursor-pointer px-3 py-2 focus:outline-none",
isDisabled ? "cursor-default !text-gray-300" : "hover:bg-neutral-100"
)}
disabled={isDisabled}
onSelect={() => props.openModal(props.option)}>
<Avatar
alt={props.option.name || ""}
imageSrc={props.option.image}
size="sm"
className="inline ltr:mr-2 rtl:ml-2"
/>
{props.option.name ? props.option.name : props.option.slug}
</DropdownMenuItem>
);
}
@@ -0,0 +1,42 @@
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Icon } from "@calcom/ui";
import { Badge, Button, ButtonGroup } from "@calcom/ui/v2";
type Props = {
required?: boolean;
question?: string;
type?: string;
editOnClick: () => void;
deleteOnClick: () => void;
};
function CustomInputItem({ required, deleteOnClick, editOnClick, type, question }: Props) {
const { t } = useLocale();
return (
<li className="border-1 flex border border-gray-200 bg-white px-6 py-4 first:rounded-t-md last:rounded-b-md only:rounded-md xl:ml-7 ">
<div className="flex flex-col">
<div className="flex items-center">
<span className="pr-2 text-sm font-semibold leading-none text-black">{question}</span>
<Badge variant="default" color="gray">
{required ? t("required") : t("optional")}
</Badge>
</div>
<p className="text-sm leading-normal text-gray-600">{type}</p>
</div>
<ButtonGroup containerProps={{ className: "ml-auto" }}>
<Button color="secondary" onClick={editOnClick}>
{t("edit")}
</Button>
<Button
StartIcon={Icon.FiTrash}
size="icon"
color="destructive"
onClick={deleteOnClick}
className="border border-gray-200"
/>
</ButtonGroup>
</li>
);
}
export default CustomInputItem;
@@ -0,0 +1,126 @@
import classNames from "classnames";
import React, { useEffect, useState } from "react";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { Select } from "@calcom/ui/v2";
interface Props {
onChange: (value: { externalId: string; integration: string }) => void;
isLoading?: boolean;
hidePlaceholder?: boolean;
/** The external Id of the connected calendar */
value: string | undefined;
maxWidth?: number;
}
const DestinationCalendarSelector = ({
onChange,
isLoading,
value,
hidePlaceholder,
maxWidth,
}: Props): JSX.Element | null => {
const { t } = useLocale();
const query = trpc.useQuery(["viewer.connectedCalendars"]);
const [selectedOption, setSelectedOption] = useState<{ value: string; label: string } | null>(null);
// Extra styles to show prefixed text in react-select
const content = (hidePlaceholder = false) => {
if (!hidePlaceholder) {
return {
alignItems: "center",
display: "flex",
":before": {
content: `'${t("select_destination_calendar")}:'`,
display: "block",
marginRight: 8,
},
};
}
return {};
};
useEffect(() => {
const selected = query.data?.connectedCalendars
.map((connected) => connected.calendars ?? [])
.flat()
.find((cal) => cal.externalId === value);
if (selected) {
setSelectedOption({
value: `${selected.integration}:${selected.externalId}`,
label: selected.name || "",
});
}
}, [query.data?.connectedCalendars, value]);
if (!query.data?.connectedCalendars.length) {
return null;
}
const options =
query.data.connectedCalendars.map((selectedCalendar) => ({
key: selectedCalendar.credentialId,
label: `${selectedCalendar.integration.title} (${selectedCalendar.primary?.name})`,
options: (selectedCalendar.calendars ?? [])
.filter((cal) => cal.readOnly === false)
.map((cal) => ({
label: cal.name || "",
value: `${cal.integration}:${cal.externalId}`,
})),
})) ?? [];
return (
<div className="relative" title={`${t("select_destination_calendar")}: ${selectedOption?.label || ""}`}>
<Select
name="primarySelectedCalendar"
placeholder={!hidePlaceholder ? `${t("select_destination_calendar")}:` : undefined}
options={options}
styles={{
placeholder: (styles) => ({ ...styles, ...content(hidePlaceholder) }),
singleValue: (styles) => ({ ...styles, ...content(hidePlaceholder) }),
option: (defaultStyles, state) => ({
...defaultStyles,
backgroundColor: state.isSelected
? state.isFocused
? "var(--brand-color)"
: "var(--brand-color)"
: state.isFocused
? "var(--brand-color-dark-mode)"
: "var(--brand-text-color)",
}),
control: (defaultStyles) => {
return {
...defaultStyles,
"@media only screen and (min-width: 640px)": {
...(defaultStyles["@media only screen and (min-width: 640px)"] as object),
maxWidth,
},
};
},
}}
isSearchable={false}
className={classNames(
"mt-1 mb-2 block w-full min-w-0 flex-1 rounded-none rounded-r-sm border-gray-300 text-sm"
)}
onChange={(option) => {
setSelectedOption(option);
if (!option) {
return;
}
/* Split only the first `:`, since Apple uses the full URL as externalId */
const [integration, externalId] = option.value.split(/:(.+)/);
onChange({
integration,
externalId,
});
}}
isLoading={isLoading}
value={selectedOption}
/>
</div>
);
};
export default DestinationCalendarSelector;
@@ -0,0 +1,104 @@
import { Prisma, SchedulingType } from "@prisma/client";
import { useMemo } from "react";
import { FormattedNumber, IntlProvider } from "react-intl";
import { classNames, parseRecurringEvent } from "@calcom/lib";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { baseEventTypeSelect } from "@calcom/prisma/selects";
import { Icon } from "@calcom/ui";
import { Badge } from "@calcom/ui/v2";
const eventTypeData = Prisma.validator<Prisma.EventTypeArgs>()({
select: baseEventTypeSelect,
});
type EventType = Prisma.EventTypeGetPayload<typeof eventTypeData>;
export type EventTypeDescriptionProps = {
eventType: EventType;
className?: string;
};
export const EventTypeDescription = ({ eventType, className }: EventTypeDescriptionProps) => {
const { t } = useLocale();
const recurringEvent = useMemo(
() => parseRecurringEvent(eventType.recurringEvent),
[eventType.recurringEvent]
);
return (
<>
<div className={classNames("text-neutral-500 dark:text-white", className)}>
{eventType.description && (
<h2 className="dark:text-darkgray-800 max-w-[280px] overflow-hidden text-ellipsis py-2 text-sm leading-none text-gray-600 opacity-60 sm:max-w-[500px]">
{eventType.description.substring(0, 100)}
{eventType.description.length > 100 && "..."}
</h2>
)}
<ul className="mt-2 flex flex-wrap space-x-2 sm:flex-nowrap">
<li>
<Badge variant="gray" size="lg" StartIcon={Icon.FiClock}>
{eventType.length}m
</Badge>
</li>
{eventType.schedulingType ? (
<li>
<Badge variant="gray" size="lg" StartIcon={Icon.FiUser}>
{eventType.schedulingType === SchedulingType.ROUND_ROBIN && t("round_robin")}
{eventType.schedulingType === SchedulingType.COLLECTIVE && t("collective")}
</Badge>
</li>
) : (
<li>
<Badge variant="gray" size="lg" StartIcon={Icon.FiUser}>
{t("1_on_1")}
</Badge>
</li>
)}
{recurringEvent?.count && recurringEvent.count > 0 && (
<li className="hidden xl:block">
<Badge variant="gray" size="lg" StartIcon={Icon.FiRefreshCw}>
{t("repeats_up_to", {
count: recurringEvent.count,
})}
</Badge>
</li>
)}
{eventType.price > 0 && (
<li>
<Badge variant="gray" size="lg" StartIcon={Icon.FiCreditCard}>
<IntlProvider locale="en">
<FormattedNumber
value={eventType.price / 100.0}
style="currency"
currency={eventType.currency.toUpperCase()}
/>
</IntlProvider>
</Badge>
</li>
)}
{eventType.requiresConfirmation && (
<li className="hidden xl:block">
<Badge variant="gray" size="lg" StartIcon={Icon.FiClipboard}>
{t("requires_confirmation")}
</Badge>
</li>
)}
{/* TODO: Maybe add a tool tip to this? */}
{eventType.requiresConfirmation || (recurringEvent?.count && recurringEvent.count) ? (
<li className="block xl:hidden">
<Badge variant="gray" size="lg" StartIcon={Icon.FiPlus}>
<p>{[eventType.requiresConfirmation, recurringEvent?.count].filter(Boolean).length}</p>
</Badge>
</li>
) : (
<></>
)}
</ul>
</div>
</>
);
};
export default EventTypeDescription;
@@ -0,0 +1,4 @@
export { default as CreateEventType } from "./CreateEventType";
export { default as DestinationCalendarSelector } from "./DestinationCalendarSelector";
export { default as CustomInputItem } from "./CustomInputItem";
export { default as CheckedTeamSelect } from "./CheckedTeamSelect";
+4
View File
@@ -0,0 +1,4 @@
export * from "./auth";
export * from "./availability";
export * from "./booker";
export * from "./event-types";
@@ -0,0 +1,127 @@
import { MembershipRole } from "@prisma/client";
import Link from "next/link";
import { useRouter } from "next/router";
import React from "react";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { TeamWithMembers } from "@calcom/lib/server/queries/teams";
import { trpc } from "@calcom/trpc/react";
import ConfirmationDialogContent from "@calcom/ui/ConfirmationDialogContent";
import { Icon } from "@calcom/ui/Icon";
import { Dialog, DialogTrigger, LinkIconButton, showToast } from "@calcom/ui/v2";
import CreateEventTypeButton from "../event-types/CreateEventType";
export default function TeamSettingsRightSidebar(props: { team: TeamWithMembers; role: MembershipRole }) {
const { t } = useLocale();
const utils = trpc.useContext();
const router = useRouter();
const permalink = `${process.env.NEXT_PUBLIC_WEBSITE_URL}/team/${props.team?.slug}`;
const deleteTeamMutation = trpc.useMutation("viewer.teams.delete", {
async onSuccess() {
await utils.invalidateQueries(["viewer.teams.get"]);
router.push(`/settings/teams`);
showToast(t("your_team_updated_successfully"), "success");
},
});
const acceptOrLeaveMutation = trpc.useMutation("viewer.teams.acceptOrLeave", {
onSuccess: () => {
utils.invalidateQueries(["viewer.teams.list"]);
router.push(`/settings/teams`);
},
});
function deleteTeam() {
if (props.team?.id) deleteTeamMutation.mutate({ teamId: props.team.id });
}
function leaveTeam() {
if (props.team?.id)
acceptOrLeaveMutation.mutate({
teamId: props.team.id,
accept: false,
});
}
return (
<div className="space-y-6 px-2">
{(props.role === MembershipRole.OWNER || props.role === MembershipRole.ADMIN) && (
<CreateEventTypeButton
isIndividualTeam
canAddEvents={true}
options={[
{
teamId: props.team?.id,
name: props.team?.name,
slug: props.team?.slug,
image: props.team?.logo,
},
]}
/>
)}
<div className="space-y-1">
<Link href={permalink} passHref={true}>
<a target="_blank">
<LinkIconButton Icon={Icon.FiExternalLink}>{t("preview")}</LinkIconButton>
</a>
</Link>
<LinkIconButton
Icon={Icon.FiLink}
onClick={() => {
navigator.clipboard.writeText(permalink);
showToast("Copied to clipboard", "success");
}}>
{t("copy_link_team")}
</LinkIconButton>
{props.role === "OWNER" ? (
<Dialog>
<DialogTrigger asChild>
<LinkIconButton
onClick={(e) => {
e.stopPropagation();
}}
Icon={Icon.FiTrash}>
{t("disband_team")}
</LinkIconButton>
</DialogTrigger>
<ConfirmationDialogContent
variety="danger"
title={t("disband_team")}
confirmBtnText={t("confirm_disband_team")}
onConfirm={deleteTeam}>
{t("disband_team_confirmation_message")}
</ConfirmationDialogContent>
</Dialog>
) : (
<Dialog>
<DialogTrigger asChild>
<LinkIconButton
Icon={Icon.FiLogOut}
onClick={(e) => {
e.stopPropagation();
}}>
{t("leave_team")}
</LinkIconButton>
</DialogTrigger>
<ConfirmationDialogContent
variety="danger"
title={t("leave_team")}
confirmBtnText={t("confirm_leave_team")}
onConfirm={leaveTeam}>
{t("leave_team_confirmation_message")}
</ConfirmationDialogContent>
</Dialog>
)}
</div>
{props.team?.id && props.role !== MembershipRole.MEMBER && (
<Link href={`/settings/teams/${props.team.id}/availability`}>
<div className="mt-5 hidden space-y-1 sm:block">
<LinkIconButton Icon={Icon.FiClock}>View Availability</LinkIconButton>
<p className="mt-2 text-sm text-gray-500">See your team members availability at a glance.</p>
</div>
</Link>
)}
</div>
);
}
+108
View File
@@ -0,0 +1,108 @@
import autoAnimate from "@formkit/auto-animate";
import { useEffect, useState, useRef } from "react";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { localStorage } from "@calcom/lib/webstorage";
import Card from "../../core/Card";
const tips = [
{
id: 1,
thumbnailUrl: "https://img.youtube.com/vi/60HJt8DOVNo/0.jpg",
mediaLink: "https://www.youtube.com/watch?v=60HJt8DOVNo",
title: "Dynamic booking links",
description: "Booking link that allows people to quickly schedule meetings.",
href: "https://cal.com/blog/cal-v-1-9",
},
{
id: 2,
thumbnailUrl: "https://img.youtube.com/vi/EAc46SPL6iA/0.jpg",
mediaLink: "https://youtu.be/EAc46SPL6iA",
title: "How to set up Teams",
description: "Learn how to use round-robin and collective events.",
href: "https://docs.cal.com/deep-dives/event-types",
},
{
id: 3,
thumbnailUrl: "https://img.youtube.com/vi/c7ZKFuLy1fg/0.jpg",
mediaLink: "https://youtu.be/c7ZKFuLy1fg",
title: "Routing Forms, Workflows",
description: "Ask screening questions of potential bookers to connect them with the right person",
href: "https://cal.com/blog/cal-v-1-8",
},
];
export default function Tips() {
const animationRef = useRef(null);
useEffect(() => {
animationRef.current && autoAnimate(animationRef.current, { duration: 250, easing: "ease-out" });
}, [animationRef]);
const { t } = useLocale();
const [list, setList] = useState<typeof tips>([]);
const handleRemoveItem = (id: number) => {
setList((currentItems) => {
const items = localStorage.getItem("removedTipsIds") || "";
const itemToRemoveIndex = currentItems.findIndex((item) => item.id === id);
localStorage.setItem(
"removedTipsIds",
`${currentItems[itemToRemoveIndex].id.toString()}${items.length > 0 ? `,${items.split(",")}` : ""}`
);
currentItems.splice(itemToRemoveIndex, 1);
return [...currentItems];
});
};
useEffect(() => {
const reversedTips = tips.slice(0).reverse();
const removedTipsString = localStorage.getItem("removedTipsIds") || "";
const removedTipsIds = removedTipsString.split(",").map((id) => parseInt(id, 10));
const filteredTips = reversedTips.filter((tip) => removedTipsIds.indexOf(tip.id) === -1);
setList(() => [...filteredTips]);
}, []);
const baseOriginalList = list.slice(0).reverse();
return (
<div
className="mb-4 hidden lg:grid"
ref={animationRef}
style={{
gridTemplateColumns: "1fr",
}}>
{list.map((tip, index) => {
return (
<div
className="relative"
style={{
gridRowStart: 1,
gridColumnStart: 1,
}}
key={tip.id}>
<div
className="relative"
style={{
transform: `scale(${1 - baseOriginalList.indexOf(tip) / 20})`,
top: -baseOriginalList.indexOf(tip) * 10,
opacity: `${1 - baseOriginalList.indexOf(tip) / 7}`,
}}>
<Card
variant="SidebarCard"
thumbnailUrl={tip.thumbnailUrl}
mediaLink={tip.mediaLink}
title={tip.title}
description={tip.description}
learnMore={{ href: tip.href, text: t("learn_more") }}
actionButton={{ onClick: () => handleRemoveItem(tip.id), child: t("dismiss") }}
/>
</div>
</div>
);
})}
</div>
);
}
+1
View File
@@ -0,0 +1 @@
export { default as Tips } from "./Tips";