feat: dub refer embed (#20258)
* feat: dub refer embed * review fix * review fix * @dub/embed-core seems not needed * @dub/embed-core can stay in web * move refer page out of main-nav * update yarn lock * use loading.tsx --------- Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: hbjORbj <[email protected]>
This commit is contained in:
11 files changed
+634
-112
No files matched your search
@@ -1,8 +1,6 @@
|
||||
import type { User as UserAuth } from "next-auth";
|
||||
import { useState } from "react";
|
||||
|
||||
import { IS_CALCOM } from "@calcom/lib/constants";
|
||||
import { useCopy } from "@calcom/lib/hooks/useCopy";
|
||||
import { IS_DUB_REFERRALS_ENABLED } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
|
||||
@@ -20,8 +18,6 @@ export function useBottomNavItems({
|
||||
user,
|
||||
}: BottomNavItemsProps): NavigationItemType[] {
|
||||
const { t } = useLocale();
|
||||
const [isReferalLoading, setIsReferalLoading] = useState(false);
|
||||
const { fetchAndCopyToClipboard } = useCopy();
|
||||
|
||||
return [
|
||||
{
|
||||
@@ -40,31 +36,11 @@ export function useBottomNavItems({
|
||||
},
|
||||
icon: "copy",
|
||||
},
|
||||
IS_CALCOM
|
||||
IS_DUB_REFERRALS_ENABLED
|
||||
? {
|
||||
name: "copy_referral_link",
|
||||
href: "",
|
||||
onClick: (e: { preventDefault: () => void }) => {
|
||||
e.preventDefault();
|
||||
setIsReferalLoading(true);
|
||||
// Create an artificial delay to show the loading state so it doesn't flicker if this request is fast
|
||||
setTimeout(() => {
|
||||
fetchAndCopyToClipboard(
|
||||
fetch("/api/generate-referral-link", {
|
||||
method: "POST",
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => res.shortLink),
|
||||
{
|
||||
onSuccess: () => showToast(t("link_copied"), "success"),
|
||||
onFailure: () => showToast("Copy to clipboard failed", "error"),
|
||||
}
|
||||
);
|
||||
setIsReferalLoading(false);
|
||||
}, 1000);
|
||||
},
|
||||
name: "earn_20_percent_affiliate",
|
||||
href: "/refer",
|
||||
icon: "gift",
|
||||
isLoading: isReferalLoading,
|
||||
}
|
||||
: null,
|
||||
isAdmin
|
||||
|
||||
@@ -210,4 +210,8 @@ export const DIRECTORY_IDS_TO_LOG = process.env.DIRECTORY_IDS_TO_LOG?.split(",")
|
||||
|
||||
export const IS_PLAIN_CHAT_ENABLED =
|
||||
!!process.env.NEXT_PUBLIC_PLAIN_CHAT_ID && process.env.NEXT_PUBLIC_PLAIN_CHAT_ID !== "";
|
||||
|
||||
export const IS_DUB_REFERRALS_ENABLED =
|
||||
!!process.env.NEXT_PUBLIC_DUB_PROGRAM_ID && process.env.NEXT_PUBLIC_DUB_PROGRAM_ID !== "";
|
||||
|
||||
export const CAL_VIDEO_MEETING_LINK_FOR_TESTING = process.env.CAL_VIDEO_MEETING_LINK_FOR_TESTING;
|
||||
Reference in new issue
Block a user