No more modules folder 🔥 (#6158)

Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
sean-brydonandPeer Richelsen authored and GitHub committed 2022-12-22 19:06:26 +00:00
1 parent 2fe9c782d4
commit 9d0cf6be0b
26 files changed
+29 -44

No files matched your search

File renamed without changes.
+2
View File
@@ -0,0 +1,2 @@
export { List, ListItem, ListItemText, ListItemTitle } from "./List";
export type { ListItemProps, ListProps } from "./List";
+1 -7
View File
@@ -46,8 +46,6 @@ export { default as TimezoneChangeDialog } from "./TimezoneChangeDialog";
// export { default as Tooltip } from "./Tooltip";
export {
Alert,
CheckedTeamSelect,
CustomInputItem,
EmptyScreen,
HorizontalTabs,
SettingsToggle,
@@ -58,6 +56,7 @@ export {
SkeletonText,
Swatch,
Switch,
Card,
VerticalTabs,
} from "./v2";
export type { AlertProps } from "./v2";
@@ -118,8 +117,3 @@ export type { ITimezone, ITimezoneOption } from "./v2/core/TimezoneSelect";
export { Tooltip } from "./v2/core/Tooltip";
export { default as VerticalDivider } from "./v2/core/VerticalDivider";
export { default as WizardForm } from "./v2/core/WizardForm";
export { default as SAMLLogin } from "./v2/modules/auth/SAMLLogin";
export { default as DatePicker } from "./v2/modules/booker/DatePicker";
export { EventTypeDescriptionLazy } from "./v2/modules/event-types";
export { EventTypeDescription } from "./v2/modules/event-types/EventTypeDescription";
export { default as Tips } from "./v2/modules/tips/Tips";
+1 -1
View File
@@ -12,6 +12,7 @@ import UnconfirmedBookingBadge from "@calcom/features/bookings/UnconfirmedBookin
import ImpersonatingBanner from "@calcom/features/ee/impersonation/components/ImpersonatingBanner";
import HelpMenuItem from "@calcom/features/ee/support/components/HelpMenuItem";
import { TeamsUpgradeBanner } from "@calcom/features/ee/teams/components";
import { Tips } from "@calcom/features/tips";
import CustomBranding from "@calcom/lib/CustomBranding";
import classNames from "@calcom/lib/classNames";
import {
@@ -40,7 +41,6 @@ import {
Icon,
showToast,
TimezoneChangeDialog,
Tips,
} from "../..";
/* TODO: Get this from endpoint */
-1
View File
@@ -1,3 +1,2 @@
/* TODO: Make this index explicit */
export * from "./core";
export * from "./modules";
@@ -1,7 +0,0 @@
# To all Cal.com contributors
All these components should live in `packages/features`
With love,
zomars 💕
-74
View File
@@ -1,74 +0,0 @@
import { signIn } from "next-auth/react";
import { Dispatch, SetStateAction } from "react";
import { useFormContext } from "react-hook-form";
import z from "zod";
import { HOSTED_CAL_FEATURES } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry";
import { trpc } from "@calcom/trpc/react";
import { Button, Icon } from "../../..";
interface Props {
samlTenantID: string;
samlProductID: string;
setErrorMessage: Dispatch<SetStateAction<string | null>>;
}
const schema = z.object({
email: z.string().email({ message: "Please enter a valid email" }),
});
export default function SAMLLogin({ samlTenantID, samlProductID, setErrorMessage }: Props) {
const { t } = useLocale();
const methods = useFormContext();
const telemetry = useTelemetry();
const mutation = trpc.viewer.public.samlTenantProduct.useMutation({
onSuccess: async (data) => {
await signIn("saml", {}, { tenant: data.tenant, product: data.product });
},
onError: (err) => {
setErrorMessage(t(err.message));
},
});
return (
<Button
StartIcon={Icon.FiLock}
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 (!HOSTED_CAL_FEATURES) {
await signIn("saml", {}, { tenant: samlTenantID, product: samlProductID });
return;
}
// Hosted solution, fetch tenant and product from the backend
const email = methods.getValues("email");
const parsed = schema.safeParse({ email });
if (!parsed.success) {
const {
fieldErrors: { email },
} = parsed.error.flatten();
setErrorMessage(email ? email[0] : null);
return;
}
mutation.mutate({
email,
});
}}>
{t("signin_with_saml")}
</Button>
);
}
-1
View File
@@ -1 +0,0 @@
export { default as SAMLLogin } from "./SAMLLogin";
@@ -1,261 +0,0 @@
import { ChevronLeftIcon, ChevronRightIcon } from "@heroicons/react/solid";
import dayjs, { Dayjs } from "@calcom/dayjs";
import { useEmbedStyles } from "@calcom/embed-core/embed-iframe";
import classNames from "@calcom/lib/classNames";
import { daysInMonth, yyyymmdd } from "@calcom/lib/date-fns";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { weekdayNames } from "@calcom/lib/weekday";
import { Button, Icon } from "@calcom/ui";
import { SkeletonText } from "../../..";
export type DatePickerProps = {
/** which day of the week to render the calendar. Usually Sunday (=0) or Monday (=1) - default: Sunday */
weekStart?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
/** Fires whenever a selected date is changed. */
onChange: (date: Dayjs) => void;
/** Fires when the month is changed. */
onMonthChange?: (date: Dayjs) => void;
/** which date is currently selected (not tracked from here) */
selected?: Dayjs | null;
/** defaults to current date. */
minDate?: Dayjs;
/** Furthest date selectable in the future, default = UNLIMITED */
maxDate?: Dayjs;
/** locale, any IETF language tag, e.g. "hu-HU" - defaults to Browser settings */
locale: string;
/** Defaults to [], which dates are not bookable. Array of valid dates like: ["2022-04-23", "2022-04-24"] */
excludedDates?: string[];
/** defaults to all, which dates are bookable (inverse of excludedDates) */
includedDates?: string[];
/** allows adding classes to the container */
className?: string;
/** Shows a small loading spinner next to the month name */
isLoading?: boolean;
};
export const Day = ({
date,
active,
disabled,
...props
}: JSX.IntrinsicElements["button"] & {
active: boolean;
date: Dayjs;
}) => {
const enabledDateButtonEmbedStyles = useEmbedStyles("enabledDateButton");
const disabledDateButtonEmbedStyles = useEmbedStyles("disabledDateButton");
return (
<button
type="button"
style={disabled ? { ...disabledDateButtonEmbedStyles } : { ...enabledDateButtonEmbedStyles }}
className={classNames(
"disabled:text-bookinglighter dark:hover:border-darkmodebrand absolute top-0 left-0 right-0 bottom-0 mx-auto w-full rounded-md border-2 border-transparent text-center font-medium disabled:cursor-default disabled:border-transparent disabled:font-light disabled:dark:border-transparent",
active
? "dark:bg-darkmodebrand dark:text-darkmodebrandcontrast bg-brand text-brandcontrast border-2"
: !disabled
? "dark:bg-darkgray-200 bg-gray-100 hover:bg-gray-300 dark:text-white"
: ""
)}
data-testid="day"
data-disabled={disabled}
disabled={disabled}
{...props}>
{date.date()}
{date.isToday() && (
<span className="absolute left-0 right-0 bottom-0 h-2/5 align-middle text-4xl leading-[0rem]">.</span>
)}
</button>
);
};
const NoAvailabilityOverlay = ({
month,
nextMonthButton,
}: {
month: string | null;
nextMonthButton: () => void;
}) => {
const { t } = useLocale();
return (
<div className="dark:border-darkgray-300 dark:bg-darkgray-200 absolute top-40 left-1/2 -mt-10 w-max -translate-x-1/2 -translate-y-1/2 transform rounded-md border border-gray-200 bg-gray-50 p-8 shadow-sm">
<h4 className="mb-4 font-medium text-gray-900 dark:text-white">
{t("no_availability_in_month", { month: month })}
</h4>
<Button onClick={nextMonthButton} color="primary" EndIcon={Icon.FiArrowRight}>
{t("view_next_month")}
</Button>
</div>
);
};
const Days = ({
minDate = dayjs.utc(),
excludedDates = [],
browsingDate,
weekStart,
DayComponent = Day,
selected,
month,
nextMonthButton,
...props
}: Omit<DatePickerProps, "locale" | "className" | "weekStart"> & {
DayComponent?: React.FC<React.ComponentProps<typeof Day>>;
browsingDate: Dayjs;
weekStart: number;
month: string | null;
nextMonthButton: () => void;
}) => {
// Create placeholder elements for empty days in first week
const weekdayOfFirst = browsingDate.day();
const currentDate = minDate.utcOffset(browsingDate.utcOffset());
const availableDates = (includedDates: string[] | undefined) => {
const dates = [];
const lastDateOfMonth = browsingDate.date(daysInMonth(browsingDate));
for (
let date = currentDate;
date.isBefore(lastDateOfMonth) || date.isSame(lastDateOfMonth, "day");
date = date.add(1, "day")
) {
// even if availableDates is given, filter out the passed included dates
if (includedDates && !includedDates.includes(yyyymmdd(date))) {
continue;
}
dates.push(yyyymmdd(date));
}
return dates;
};
const includedDates = currentDate.isSame(browsingDate, "month")
? availableDates(props.includedDates)
: props.includedDates;
const days: (Dayjs | null)[] = Array((weekdayOfFirst - weekStart + 7) % 7).fill(null);
for (let day = 1, dayCount = daysInMonth(browsingDate); day <= dayCount; day++) {
const date = browsingDate.set("date", day);
days.push(date);
}
return (
<>
{days.map((day, idx) => (
<div key={day === null ? `e-${idx}` : `day-${day.format()}`} className="relative w-full pt-[100%]">
{day === null ? (
<div key={`e-${idx}`} />
) : props.isLoading ? (
<button
className="dark:bg-darkgray-200 absolute top-0 left-0 right-0 bottom-0 mx-auto flex w-full items-center justify-center rounded-sm border-transparent bg-gray-50 text-center text-gray-400 opacity-50 dark:text-gray-400"
key={`e-${idx}`}
disabled>
<SkeletonText className="h-4 w-5" />
</button>
) : (
<DayComponent
date={day}
onClick={() => {
props.onChange(day);
setTimeout(() => {
window.scrollTo({
top: 360,
behavior: "smooth",
});
}, 500);
}}
disabled={
(includedDates && !includedDates.includes(yyyymmdd(day))) ||
excludedDates.includes(yyyymmdd(day))
}
active={selected ? yyyymmdd(selected) === yyyymmdd(day) : false}
/>
)}
</div>
))}
{!props.isLoading && includedDates && includedDates?.length === 0 && (
<NoAvailabilityOverlay month={month} nextMonthButton={nextMonthButton} />
)}
</>
);
};
const DatePicker = ({
weekStart = 0,
className,
locale,
selected,
onMonthChange,
...passThroughProps
}: DatePickerProps & Partial<React.ComponentProps<typeof Days>>) => {
const browsingDate = passThroughProps.browsingDate || dayjs().startOf("month");
const { i18n } = useLocale();
const changeMonth = (newMonth: number) => {
if (onMonthChange) {
onMonthChange(browsingDate.add(newMonth, "month"));
}
};
const month = browsingDate
? new Intl.DateTimeFormat(i18n.language, { month: "long" }).format(
new Date(browsingDate.year(), browsingDate.month())
)
: null;
return (
<div className={className}>
<div className="mb-4 flex justify-between text-xl font-light">
<span className="w-1/2 dark:text-white">
{browsingDate ? (
<>
<strong className="text-bookingdarker text-base font-semibold dark:text-white">{month}</strong>{" "}
<span className="text-bookinglight text-sm font-medium">{browsingDate.format("YYYY")}</span>
</>
) : (
<SkeletonText className="h-8 w-24" />
)}
</span>
<div className="text-black dark:text-white">
<button
type="button"
onClick={() => changeMonth(-1)}
className={classNames(
"group p-1 opacity-50 hover:opacity-100 ltr:mr-2 rtl:ml-2",
!browsingDate.isAfter(dayjs()) && "disabled:text-bookinglighter hover:opacity-50"
)}
disabled={!browsingDate.isAfter(dayjs())}
data-testid="decrementMonth">
<ChevronLeftIcon className="h-5 w-5" />
</button>
<button
type="button"
className="group p-1 opacity-50 hover:opacity-100"
onClick={() => changeMonth(+1)}
data-testid="incrementMonth">
<ChevronRightIcon className="h-5 w-5" />
</button>
</div>
</div>
<div className="border-bookinglightest mb-2 grid grid-cols-7 gap-4 border-t border-b text-center dark:border-neutral-900 md:mb-0 md:border-0">
{weekdayNames(locale, weekStart, "short").map((weekDay) => (
<div
key={weekDay}
className="text-bookinglight dark:text-darkgray-900 my-4 text-xs uppercase tracking-widest">
{weekDay}
</div>
))}
</div>
<div className="relative grid grid-cols-7 gap-1 text-center">
<Days
weekStart={weekStart}
selected={selected}
{...passThroughProps}
browsingDate={browsingDate}
month={month}
nextMonthButton={() => changeMonth(+1)}
/>
</div>
</div>
);
};
export default DatePicker;
-1
View File
@@ -1 +0,0 @@
export * from "./DatePicker";
@@ -1,63 +0,0 @@
import { useAutoAnimate } from "@formkit/auto-animate/react";
import { Props } from "react-select";
import { classNames } from "@calcom/lib";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Avatar, Icon, 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] = useAutoAnimate<HTMLUListElement>();
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, index) => (
<li key={option.value} className={`flex py-2 px-3 ${index === value.length - 1 ? "" : "border-b"}`}>
<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;
@@ -1,42 +0,0 @@
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Badge, Button, ButtonGroup, Icon } from "../../..";
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="flex rounded-b-md border-t border-gray-200 bg-white px-6 py-4 first:rounded-t-md first:border-0">
<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" withDot={false}>
{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="h-[36px] border border-gray-200"
/>
</ButtonGroup>
</li>
);
}
export default CustomInputItem;
@@ -1,120 +0,0 @@
import { Prisma, SchedulingType } from "@prisma/client";
import { useMemo } from "react";
import { FormattedNumber, IntlProvider } from "react-intl";
import { z } from "zod";
import { classNames, parseRecurringEvent } from "@calcom/lib";
import getStripeAppData from "@calcom/lib/getStripeAppData";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { baseEventTypeSelect } from "@calcom/prisma";
import { EventTypeModel } from "@calcom/prisma/zod";
import { Badge, Icon } from "../../..";
export type EventTypeDescriptionProps = {
eventType: Pick<
z.infer<typeof EventTypeModel>,
Exclude<keyof typeof baseEventTypeSelect, "recurringEvent"> | "metadata"
> & {
recurringEvent: Prisma.JsonValue;
};
className?: string;
};
export const EventTypeDescription = ({ eventType, className }: EventTypeDescriptionProps) => {
const { t } = useLocale();
const recurringEvent = useMemo(
() => parseRecurringEvent(eventType.recurringEvent),
[eventType.recurringEvent]
);
const stripeAppData = getStripeAppData(eventType);
return (
<>
<div className={classNames("dark:text-darkgray-800 text-neutral-500", className)}>
{eventType.description && (
<p className="dark:text-darkgray-800 max-w-[280px] break-words py-1 text-sm text-gray-500 sm:max-w-[500px]">
{eventType.description.substring(0, 300)}
{eventType.description.length > 300 && "..."}
</p>
)}
<ul className="mt-2 flex flex-wrap space-x-2 sm:flex-nowrap">
{eventType.metadata?.multipleDuration ? (
eventType.metadata.multipleDuration.map((dur, idx) => (
<li key={idx}>
<Badge variant="gray" size="lg" StartIcon={Icon.FiClock}>
{dur}m
</Badge>
</li>
))
) : (
<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>
)}
{stripeAppData.price > 0 && (
<li>
<Badge variant="gray" size="lg" StartIcon={Icon.FiCreditCard}>
<IntlProvider locale="en">
<FormattedNumber
value={stripeAppData.price / 100.0}
style="currency"
currency={stripeAppData.currency.toUpperCase()}
/>
</IntlProvider>
</Badge>
</li>
)}
{eventType.requiresConfirmation && (
<li className="hidden xl:block">
<Badge variant="gray" size="lg" StartIcon={Icon.FiClipboard}>
{eventType.metadata?.requiresConfirmationThreshold
? t("may_require_confirmation")
: 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;
@@ -1,103 +0,0 @@
import { components, GroupBase, Props, ValueContainerProps } from "react-select";
import { Icon, Select } from "../../..";
const LimitedChipsContainer = <Option, IsMulti extends boolean, Group extends GroupBase<Option>>({
children,
...props
}: ValueContainerProps<Option, IsMulti, Group>) => {
if (!props.hasValue) {
return <components.ValueContainer {...props}>{children as React.ReactNode[]}</components.ValueContainer>;
}
const CHIPS_LIMIT = 2;
// TODO:: fix the following ts error
// @ts-expect-error: @see children is an array but identified as object resulting in the error
const [chips, other] = children;
const overflowCounter = chips.slice(CHIPS_LIMIT).length;
const displayChips = chips.slice(overflowCounter, overflowCounter + CHIPS_LIMIT);
return (
<components.ValueContainer {...props}>
{displayChips}
{overflowCounter > 0 && (
<span className="flex items-center justify-center rounded-md bg-gray-100 py-[5px] px-2 text-[14px] font-medium leading-4 text-gray-700">
<>
<Icon.FiPlus className="mr-1 inline h-3 w-3 stroke-[3px]" /> <span>{overflowCounter} more</span>
</>
</span>
)}
{other}
</components.ValueContainer>
);
};
export const MultiDropdownSelect = ({ options = [], value = [], ...props }: Props) => {
// const { t } = useLocale();
return (
<Select
styles={{
multiValue: (styles) => {
return {
...styles,
backgroundColor: "#F3F4F6",
color: "#374151",
borderRadius: "6px",
padding: "5px 8px",
gap: "8px",
fontSize: "14px",
fontWeight: "500",
margin: "0px",
lineHeight: "16px",
};
},
multiValueLabel: (styles) => ({
...styles,
paddingLeft: "0px",
fontSize: "14px",
padding: "0",
}),
multiValueRemove: (base) => ({
...base,
color: "#4B5563",
padding: "0",
":hover": {
background: "transparent",
},
"> svg": {
width: "16px",
height: "17px",
},
}),
control: (base) => ({
...base,
// Brute force to remove focus outline of input
"& .cal-multiselect__input": {
borderWidth: 0,
boxShadow: "none",
caretColor: "transparent",
},
}),
valueContainer: (base) => ({
...base,
display: "flex",
gap: "4px",
paddingLeft: "5px",
padding: "0px",
height: "36px",
}),
}}
className="cal-multiselect"
classNamePrefix="cal-multiselect"
placeholder="Select"
defaultValue={value}
options={options}
hideSelectedOptions={false}
isMulti
components={{ ValueContainer: LimitedChipsContainer }}
{...props}
/>
);
};
export default MultiDropdownSelect;
@@ -1,5 +0,0 @@
import dynamic from "next/dynamic";
export { default as CheckedTeamSelect } from "./CheckedTeamSelect";
export { default as CustomInputItem } from "./CustomInputItem";
export const EventTypeDescriptionLazy = dynamic(() => import("./EventTypeDescription"));
-3
View File
@@ -1,3 +0,0 @@
export * from "./auth";
export * from "./booker";
export * from "./event-types";
-127
View File
@@ -1,127 +0,0 @@
import { useAutoAnimate } from "@formkit/auto-animate/react";
import { useEffect, useState } from "react";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { localStorage } from "@calcom/lib/webstorage";
import Card from "../../core/Card";
export const tips = [
{
id: 1,
thumbnailUrl: "https://img.youtube.com/vi/60HJt8DOVNo/0.jpg",
mediaLink: "https://go.cal.com/dynamic-video",
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://go.cal.com/teams-video",
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://go.cal.com/routing-video",
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",
},
{
id: 4,
thumbnailUrl: "https://img.youtube.com/vi/zGr_s-fG84k/0.jpg",
mediaLink: "https://go.cal.com/confirmation-video",
title: "Requires Confirmation",
description: "Learn how to be in charge of your bookings",
href: "https://docs.cal.com/deep-dives/event-types#opt-in-booking",
},
{
id: 5,
thumbnailUrl: "https://img.youtube.com/vi/0v_nQtpxC_4/0.jpg",
mediaLink: "https://go.cal.com/payments-video",
title: "Accept Payments",
description: "Charge for your time with Cal.com's Stripe App",
href: "https://app.cal.com/apps/stripe",
},
{
id: 6,
thumbnailUrl: "https://img.youtube.com/vi/yGiZo1Ry5-8/0.jpg",
mediaLink: "https://go.cal.com/recurring-video",
title: "Recurring Bookings",
description: "Learn how to create a recurring schedule",
href: "https://go.cal.com/recurring-video",
},
];
export default function Tips() {
const [animationRef] = useAutoAnimate<HTMLDivElement>();
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) => {
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
@@ -1 +0,0 @@
export { default as Tips } from "./Tips";