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

Function UpgradeToPlus

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

Source from the content-addressed store, hash-verified

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

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