-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a mailing list subscription upsell on front-page and settings (#264)
- Loading branch information
Showing
13 changed files
with
380 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@srcbook/api': patch | ||
'@srcbook/web': patch | ||
'srcbook': patch | ||
--- | ||
|
||
Added an upsell to subscribe to our mailing list + ability to update in settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,3 +38,6 @@ srcbook/lib/**/* | |
|
||
# turbo | ||
**/.turbo | ||
|
||
# Aide | ||
*.code-workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE `config` ADD `subscription_email` text; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
{ | ||
"version": "6", | ||
"dialect": "sqlite", | ||
"id": "a8c6d627-368f-4e6d-bdd9-42ffb1d8a8b2", | ||
"prevId": "e99407eb-2c92-4d3c-8864-bd760846d61b", | ||
"tables": { | ||
"config": { | ||
"name": "config", | ||
"columns": { | ||
"base_dir": { | ||
"name": "base_dir", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"default_language": { | ||
"name": "default_language", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false, | ||
"default": "'typescript'" | ||
}, | ||
"openai_api_key": { | ||
"name": "openai_api_key", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": false, | ||
"autoincrement": false | ||
}, | ||
"anthropic_api_key": { | ||
"name": "anthropic_api_key", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": false, | ||
"autoincrement": false | ||
}, | ||
"enabled_analytics": { | ||
"name": "enabled_analytics", | ||
"type": "integer", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false, | ||
"default": true | ||
}, | ||
"srcbook_installation_id": { | ||
"name": "srcbook_installation_id", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false, | ||
"default": "'kkoge7ntqjmhgn1l5ljmkdsfpg'" | ||
}, | ||
"ai_provider": { | ||
"name": "ai_provider", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false, | ||
"default": "'openai'" | ||
}, | ||
"ai_model": { | ||
"name": "ai_model", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": false, | ||
"autoincrement": false, | ||
"default": "'gpt-4o'" | ||
}, | ||
"ai_base_url": { | ||
"name": "ai_base_url", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": false, | ||
"autoincrement": false | ||
}, | ||
"subscription_email": { | ||
"name": "subscription_email", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": false, | ||
"autoincrement": false | ||
} | ||
}, | ||
"indexes": {}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": {}, | ||
"uniqueConstraints": {} | ||
}, | ||
"secrets": { | ||
"name": "secrets", | ||
"columns": { | ||
"id": { | ||
"name": "id", | ||
"type": "integer", | ||
"primaryKey": true, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"name": { | ||
"name": "name", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"value": { | ||
"name": "value", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
} | ||
}, | ||
"indexes": { | ||
"secrets_name_unique": { | ||
"name": "secrets_name_unique", | ||
"columns": [ | ||
"name" | ||
], | ||
"isUnique": true | ||
} | ||
}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": {}, | ||
"uniqueConstraints": {} | ||
} | ||
}, | ||
"enums": {}, | ||
"_meta": { | ||
"schemas": {}, | ||
"tables": {}, | ||
"columns": {} | ||
}, | ||
"internal": { | ||
"indexes": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { useState } from 'react'; | ||
import { X, Mailbox } from 'lucide-react'; | ||
import { Card, CardContent } from '@/components/ui/card'; | ||
import { Input } from '@/components/ui/input'; | ||
import { Button } from '@/components/ui/button'; | ||
import { toast } from 'sonner'; | ||
import { subscribeToMailingList } from '@/lib/server'; | ||
import { useSettings } from '@/components/use-settings'; | ||
|
||
export default function MailingListCard() { | ||
const { subscriptionEmail, updateConfig } = useSettings(); | ||
const [isVisible, setIsVisible] = useState(!subscriptionEmail); | ||
const [email, setEmail] = useState(''); | ||
const [subscribed, setSubscribed] = useState(false); | ||
|
||
const handleClose = async () => { | ||
await updateConfig({ subscriptionEmail: 'dismissed' }); | ||
setIsVisible(false); | ||
}; | ||
|
||
const handleSubmit: React.FormEventHandler<HTMLFormElement> = async (e) => { | ||
e.preventDefault(); | ||
try { | ||
const response = await subscribeToMailingList(email); | ||
if (response.success) { | ||
setSubscribed(true); | ||
await updateConfig({ subscriptionEmail: email }); | ||
setTimeout(() => { | ||
setIsVisible(false); | ||
}, 3000); | ||
} else { | ||
toast.error('There was an error subscribing to the mailing list. Please try again later.'); | ||
} | ||
} catch (error) { | ||
toast.error('There was an error subscribing to the mailing list. Please try again later.'); | ||
console.error('Subscription error:', error); | ||
} | ||
}; | ||
|
||
if (!isVisible) return null; | ||
|
||
return ( | ||
<Card className="fixed bottom-6 left-6 w-[460px] shadow-lg z-30"> | ||
<div className="relative"> | ||
<button | ||
className="absolute top-2 right-2 hover:bg-muted p-1 rounded-sm" | ||
onClick={handleClose} | ||
> | ||
<X className="h-4 w-4" /> | ||
<span className="sr-only">Close</span> | ||
</button> | ||
<CardContent className="p-6"> | ||
<div className="flex flex-col gap-2"> | ||
<Mailbox size={24} /> | ||
{subscribed ? ( | ||
<> | ||
<h1 className="mt-2 text-lg font-medium">Thank you for subscribing!</h1> | ||
<p>We'll keep you updated with the latest news and features.</p> | ||
</> | ||
) : ( | ||
<> | ||
<h1 className="mt-2 text-lg font-medium">Join our mailing list!</h1> | ||
<p className=""> | ||
Get the latest updates, early access features, and expert tips delivered to your | ||
inbox. | ||
</p> | ||
<form onSubmit={handleSubmit} className="flex gap-1 py-3"> | ||
<Input | ||
type="email" | ||
placeholder="Email" | ||
className="" | ||
value={email} | ||
onChange={(e) => setEmail(e.target.value)} | ||
/> | ||
<Button type="submit">Subscribe</Button> | ||
</form> | ||
</> | ||
)} | ||
</div> | ||
</CardContent> | ||
</div> | ||
</Card> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import * as React from 'react'; | ||
|
||
import { cn } from '@/lib/utils'; | ||
|
||
const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>( | ||
({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn('rounded-xl border bg-card text-card-foreground shadow', className)} | ||
{...props} | ||
/> | ||
), | ||
); | ||
Card.displayName = 'Card'; | ||
|
||
const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>( | ||
({ className, ...props }, ref) => ( | ||
<div ref={ref} className={cn('flex flex-col space-y-1.5 p-6', className)} {...props} /> | ||
), | ||
); | ||
CardHeader.displayName = 'CardHeader'; | ||
|
||
const CardTitle = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLHeadingElement>>( | ||
({ className, ...props }, ref) => ( | ||
// eslint-disable-next-line jsx-a11y/heading-has-content | ||
<h3 | ||
ref={ref} | ||
className={cn('font-semibold leading-none tracking-tight', className)} | ||
{...props} | ||
/> | ||
), | ||
); | ||
CardTitle.displayName = 'CardTitle'; | ||
|
||
const CardDescription = React.forwardRef< | ||
HTMLParagraphElement, | ||
React.HTMLAttributes<HTMLParagraphElement> | ||
>(({ className, ...props }, ref) => ( | ||
<p ref={ref} className={cn('text-sm text-muted-foreground', className)} {...props} /> | ||
)); | ||
CardDescription.displayName = 'CardDescription'; | ||
|
||
const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>( | ||
({ className, ...props }, ref) => ( | ||
<div ref={ref} className={cn('p-6 pt-0', className)} {...props} /> | ||
), | ||
); | ||
CardContent.displayName = 'CardContent'; | ||
|
||
const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>( | ||
({ className, ...props }, ref) => ( | ||
<div ref={ref} className={cn('flex items-center p-6 pt-0', className)} {...props} /> | ||
), | ||
); | ||
CardFooter.displayName = 'CardFooter'; | ||
|
||
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.