-
Notifications
You must be signed in to change notification settings - Fork 258
/
Copy pathBuyCreditsButton.tsx
58 lines (55 loc) · 1.66 KB
/
BuyCreditsButton.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import React from 'react';
import type { ReactElement } from 'react';
import { CoinIcon, PlusIcon } from '../icons';
import { Button, ButtonSize, ButtonVariant } from '../buttons/Button';
import Link from '../utilities/Link';
import { webappUrl } from '../../lib/constants';
import { anchorDefaultRel } from '../../lib/strings';
import { isIOSNative } from '../../lib/func';
import { LogEvent, Origin } from '../../lib/log';
import { useLogContext } from '../../contexts/LogContext';
type BuyCreditsButtonProps = {
onPlusClick: () => void;
hideBuyButton?: boolean;
};
export const BuyCreditsButton = ({
onPlusClick,
hideBuyButton,
}: BuyCreditsButtonProps): ReactElement => {
const renderBuyButton = !isIOSNative() && !hideBuyButton;
const { logEvent } = useLogContext();
const trackBuyCredits = () => {
logEvent({
event_name: LogEvent.StartBuyingCredits,
extra: JSON.stringify({ origin: Origin.Award }),
});
onPlusClick();
};
return (
<div className="flex items-center rounded-10 bg-surface-float">
<Link href={`${webappUrl}/earnings`} passHref>
<Button
tag="a"
target="_blank"
rel={anchorDefaultRel}
variant={ButtonVariant.Tertiary}
icon={<CoinIcon />}
size={ButtonSize.Small}
>
20
</Button>
</Link>
{renderBuyButton ? (
<>
<div className="h-[1.375rem] w-px bg-border-subtlest-tertiary" />
<Button
variant={ButtonVariant.Tertiary}
icon={<PlusIcon />}
size={ButtonSize.Small}
onClick={trackBuyCredits}
/>
</>
) : null}
</div>
);
};