MCPcopy Create free account
hub / github.com/dailydotdev/apps / UpgradeToPlus

Function UpgradeToPlus

packages/shared/src/components/UpgradeToPlus.tsx:30–97  ·  view source on GitHub ↗
({
  className,
  color,
  size,
  iconOnly = false,
  target,
  variant,
  label,
  iconClassName,
  ...attrs
}: Props)

Source from the content-addressed store, hash-verified

28} & WithClassNameProps;
29
30export const UpgradeToPlus = ({
31 className,
32 color,
33 size,
34 iconOnly = false,
35 target,
36 variant,
37 label,
38 iconClassName,
39 ...attrs
40}: Props): ReactElement | null => {
41 const { isLoggedIn, showLogin } = useAuthContext();
42 const isLaptop = useViewSize(ViewSize.Laptop);
43 const isLaptopXL = useViewSize(ViewSize.LaptopXL);
44 const isFullCTAText = !isLaptop || isLaptopXL;
45 const { isPlus, logSubscriptionEvent } = usePlusSubscription();
46 const { isActive: isSaleActive } = usePlusSale();
47 const ctaCopy = { full: plusCta, short: plusCtaShort };
48 const content = label ?? (isFullCTAText ? ctaCopy.full : ctaCopy.short);
49 const showSaleLabel = isSaleActive && !iconOnly;
50 const defaultColor = ButtonColor.Bacon;
51
52 const onClick = useCallback(
53 (e: React.MouseEvent) => {
54 if (!isLoggedIn) {
55 e.preventDefault();
56 showLogin({ trigger: AuthTriggers.Plus });
57 return;
58 }
59
60 logSubscriptionEvent({
61 event_name: LogEvent.UpgradeSubscription,
62 target_id: target,
63 });
64 },
65 [isLoggedIn, logSubscriptionEvent, showLogin, target],
66 );
67
68 if (isPlus) {
69 return null;
70 }
71
72 return (
73 <Link passHref href={plusUrl}>
74 <Button
75 tag="a"
76 className={classNames(!iconOnly && 'flex-1', className)}
77 icon={<DevPlusIcon className={iconClassName} />}
78 size={size}
79 color={defaultColor}
80 variant={ButtonVariant.Primary}
81 onClick={onClick}
82 aria-label={iconOnly ? label : undefined}
83 {...(variant && { variant, color })}
84 {...attrs}
85 >
86 {showSaleLabel ? (
87 <>

Callers

nothing calls this directly

Calls 4

useAuthContextFunction · 0.90
useViewSizeFunction · 0.90
usePlusSubscriptionFunction · 0.90
usePlusSaleFunction · 0.90

Tested by

no test coverage detected