a tool for shared writing and social publishing
1import { SubscribeWithHandle } from "./HandleSubscribe";
2import { EmailSubscribe } from "./EmailSubscribe";
3import { Modal } from "components/Modal";
4import { ButtonPrimary } from "components/Buttons";
5import { PostPubInfo } from "app/lish/[did]/[publication]/[rkey]/PostPubInfo";
6import { ManageSubscription } from "./ManageSubscribe";
7
8export const SubscribeButton = (props: {
9 autoFocus?: boolean;
10 newsletterMode: boolean;
11 user: {
12 loggedIn: boolean;
13 email: string | undefined;
14 handle: string | undefined;
15 subscribed: boolean;
16 };
17}) => {
18 return (
19 <Modal
20 className="px-0! py-3! sm:py-4! w-[1000px] sm:max-w-md max-w-full"
21 asChild
22 trigger={
23 props.user.subscribed ? (
24 <ManageSubscription {...props} />
25 ) : (
26 <ButtonPrimary compact className="text-sm">
27 Subscribe
28 </ButtonPrimary>
29 )
30 }
31 >
32 <PostPubInfo autoFocus {...props} />
33 </Modal>
34 );
35};
36
37export const SubscribeInput = (props: {
38 autoFocus?: boolean;
39 newsletterMode: boolean;
40 user: {
41 loggedIn: boolean;
42 email: string | undefined;
43 handle: string | undefined;
44 subscribed: boolean;
45 };
46}) => {
47 if (props.user.subscribed) {
48 return <ManageSubscription {...props} />;
49 }
50 if (props.newsletterMode) {
51 return <EmailSubscribe user={props.user} autoFocus={props.autoFocus} />;
52 } else
53 return (
54 <SubscribeWithHandle user={props.user} autoFocus={props.autoFocus} />
55 );
56};