diff --git a/.env.example b/.env.example index d2474a2fb..ce19179a3 100644 --- a/.env.example +++ b/.env.example @@ -6,11 +6,10 @@ DATABASE_URL="postgresql://postgres:postgres@localhost:5432/zerodotemail" # Change this to a random string, use `openssl rand -hex 32` to generate a 32 character string BETTER_AUTH_SECRET=my-better-auth-secret BETTER_AUTH_URL=http://localhost:3000 -BETTER_AUTH_TRUSTED_ORIGINS=http://localhost:3000 COOKIE_DOMAIN="localhost" -# Change to your project's client ID and secret, these work with localhost:3000 and localhost:3001 +# Change to your project's client ID and secret, these work with localhost:8787 GOOGLE_CLIENT_ID= GOOGLE_CLIENT_SECRET= diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 502088e22..73e8faf0a 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -32,6 +32,7 @@ Thank you for your interest in contributing to 0.email! We're excited to have yo - Clone the repository and install dependencies: `bun install` - Start the database locally: `bun docker:up` - Copy `.env.example` to `.env` in project root + - Setup cloudflare with `bun run cf-install`, you will need to run this everytime there is a `.env` change - Set up your Google OAuth credentials (see [README.md](../README.md)) - Initialize the database: `bun db:push` diff --git a/README.md b/README.md index 383ff7cb2..33a3d7ddd 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ You can set up Zero in two ways: cp .env.example .env ``` - Configure your environment variables (see below) + - Setup cloudflare with `bun run cf-install`, you will need to run this everytime there is a `.env` change - Start the database with the provided docker compose setup: `bun docker:up` - Initialize the database: `bun db:push` @@ -148,7 +149,7 @@ bun install - Create OAuth 2.0 credentials (Web application type) - Add authorized redirect URIs: - Development: - - `http://localhost:3000/api/auth/callback/google` + - `http://localhost:8787/api/auth/callback/google` - Production: - `https://your-production-url/api/auth/callback/google` - Add to `.env`: @@ -210,7 +211,7 @@ Zero uses PostgreSQL for storing data. Here's how to set it up: 2. **Set Up Database Connection** - Make sure your database connection string is in `.env` file. + Make sure your database connection string is in `.env` file. And you have ran `bun run cf-install` to sync the latest env. For local development use: diff --git a/apps/mail/components/create/email-composer.tsx b/apps/mail/components/create/email-composer.tsx index 017543905..c8ae3dc5f 100644 --- a/apps/mail/components/create/email-composer.tsx +++ b/apps/mail/components/create/email-composer.tsx @@ -104,11 +104,14 @@ export function EmailComposer({ const [draftId, setDraftId] = useState(urlDraftId ?? null); const [aiGeneratedMessage, setAiGeneratedMessage] = useState(null); const [aiIsLoading, setAiIsLoading] = useState(false); + const [isGeneratingSubject, setIsGeneratingSubject] = useState(false); const trpc = useTRPC(); const { mutateAsync: aiCompose } = useMutation(trpc.ai.compose.mutationOptions()); const { mutateAsync: createDraft } = useMutation(trpc.drafts.create.mutationOptions()); - + const { mutateAsync: generateEmailSubject } = useMutation( + trpc.ai.generateEmailSubject.mutationOptions(), + ); useEffect(() => { if (isComposeOpen === 'true' && toInputRef.current) { toInputRef.current.focus(); @@ -355,6 +358,13 @@ export function EmailComposer({ } }; + const handleGenerateSubject = async () => { + setIsGeneratingSubject(true); + const { subject } = await generateEmailSubject({ message: editor.getText() }); + setValue('subject', subject); + setIsGeneratingSubject(false); + }; + useEffect(() => { if (urlDraftId !== draftId) { setDraftId(urlDraftId ?? null); @@ -661,11 +671,31 @@ export function EmailComposer({ setHasUnsavedChanges(true); }} /> + {/* Message Content */}
-
+
@@ -853,9 +883,8 @@ export function EmailComposer({