diff --git a/apps/web/pages/event-types/index.tsx b/apps/web/pages/event-types/index.tsx index 233c77a057..d8545e1fc8 100644 --- a/apps/web/pages/event-types/index.tsx +++ b/apps/web/pages/event-types/index.tsx @@ -7,6 +7,7 @@ import React, { Fragment, useEffect, useState } from "react"; import CreateEventTypeButton from "@calcom/features/eventtypes/components/CreateEventTypeButton"; import { APP_NAME, CAL_URL, WEBAPP_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import isCalcom from "@calcom/lib/isCalcom"; import { RouterOutputs, trpc, TRPCClientError } from "@calcom/trpc/react"; import { Badge, @@ -28,6 +29,7 @@ import { showToast, Switch, Tooltip, + TipBanner, } from "@calcom/ui"; import { withQuery } from "@lib/QueryCell"; @@ -587,6 +589,7 @@ const EventTypesPage = () => { customLoader={} success={({ data }) => ( <> + {isCalcom && } {data.eventTypeGroups.map((group, index) => ( {/* hide list heading when there is only one (current user) */} @@ -605,7 +608,6 @@ const EventTypesPage = () => { /> ))} - {data.eventTypeGroups.length === 0 && } diff --git a/apps/web/public/team-banner-background-small.jpg b/apps/web/public/team-banner-background-small.jpg new file mode 100644 index 0000000000..f9ce29dac0 Binary files /dev/null and b/apps/web/public/team-banner-background-small.jpg differ diff --git a/packages/ui/index.tsx b/packages/ui/index.tsx index 6830c765da..dcd715be96 100644 --- a/packages/ui/index.tsx +++ b/packages/ui/index.tsx @@ -55,6 +55,7 @@ export { Swatch, Switch, VerticalTabs, + TipBanner, } from "./v2"; export type { AlertProps } from "./v2"; export { getReactSelectProps, Segment, SegmentOption } from "./v2/core"; @@ -119,4 +120,4 @@ 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"; +export { default as Tips } from "./v2/core/Tips"; diff --git a/packages/ui/v2/modules/tips/Tips.tsx b/packages/ui/v2/core/Tips.tsx similarity index 54% rename from packages/ui/v2/modules/tips/Tips.tsx rename to packages/ui/v2/core/Tips.tsx index 4a903d4ae6..ae51429faf 100644 --- a/packages/ui/v2/modules/tips/Tips.tsx +++ b/packages/ui/v2/core/Tips.tsx @@ -1,10 +1,12 @@ import { useAutoAnimate } from "@formkit/auto-animate/react"; import { useEffect, useState } from "react"; +import { WEBAPP_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { localStorage } from "@calcom/lib/webstorage"; +import { Button, Icon } from "@calcom/ui"; -import Card from "../../core/Card"; +import Card from "./Card"; export const tips = [ { @@ -57,20 +59,30 @@ export const tips = [ }, ]; -export default function Tips() { - const [animationRef] = useAutoAnimate(); +function useLocalList(storageKey: string, initialValue: T[]) { + const [list, setList] = useState(initialValue); - const { t } = useLocale(); - - const [list, setList] = useState([]); + /** + This use effect is used to filter out the items that have been removed from the list + we get this from local storage and then we reverse the list so that the newest items + are at the top. This is done so that the items are displayed in the order they were + added + **/ + useEffect(() => { + const reversedList = initialValue.slice(0).reverse(); + const removedListString = localStorage.getItem(storageKey) || ""; + const removedListIds = removedListString.split(",").map((id) => parseInt(id, 10)); + const filteredList = reversedList.filter((tip) => removedListIds.indexOf(tip.id) === -1); + setList(() => [...filteredList]); + }, [initialValue, storageKey]); const handleRemoveItem = (id: number) => { setList((currentItems) => { - const items = localStorage.getItem("removedTipsIds") || ""; + const items = localStorage.getItem(storageKey) || ""; const itemToRemoveIndex = currentItems.findIndex((item) => item.id === id); localStorage.setItem( - "removedTipsIds", + storageKey, `${currentItems[itemToRemoveIndex].id.toString()}${items.length > 0 ? `,${items.split(",")}` : ""}` ); currentItems.splice(itemToRemoveIndex, 1); @@ -78,14 +90,20 @@ export default function Tips() { }); }; - 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]); - }, []); + return { + list, + handleRemoveItem, + }; +} +export default function Tips() { + //const [animationRef] = useAutoAnimate(); + + const { t } = useLocale(); + + const { list, handleRemoveItem } = useLocalList("removedTipsIds", tips); + const baseOriginalList = list.slice(0).reverse(); + return (
); } + +export function TipBanner() { + const { t } = useLocale(); + const [animationRef] = useAutoAnimate(); + + const bannerTips = [ + { + id: 1, + img: "/team-banner-background-small.jpg", + title: t("calcom_is_better_with_team"), + subtitle: t("add_your_team_members"), + href: `${WEBAPP_URL}/settings/teams/new`, + learnMoreHref: "https://go.cal.com/teams-video", + }, + ]; + const { list, handleRemoveItem } = useLocalList("removedBannerIds", bannerTips); + + return ( +
+ {list.map((tip) => { + return ( +
+
+

{tip.title}

+

{tip.subtitle}

+
+ + {tip.learnMoreHref && ( + + )} +
+ +
+
+ ); + })} +
+ ); +} diff --git a/packages/ui/v2/core/index.ts b/packages/ui/v2/core/index.ts index 16e81e93c3..3b6cf54392 100644 --- a/packages/ui/v2/core/index.ts +++ b/packages/ui/v2/core/index.ts @@ -56,3 +56,4 @@ export { default as Switch } from "./Switch"; export { default as Tooltip } from "./Tooltip"; export { default as VerticalDivider } from "./VerticalDivider"; export { default as WizardForm } from "./WizardForm"; +export { TipBanner } from "./Tips"; diff --git a/packages/ui/v2/modules/tips/index.ts b/packages/ui/v2/modules/tips/index.ts deleted file mode 100644 index a9d8373d86..0000000000 --- a/packages/ui/v2/modules/tips/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as Tips } from "./Tips";