Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Boilerplate to send an email" #8

Merged
merged 1 commit into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ To get started with Beacon, ensure you have the following prerequisites installe
Clone the repository and install the dependencies:

```bash
git clone https://github.com/foundersandcoders/lift-frontend-v2.git
cd lift-frontend-v2
git clone https://github.com/yourusername/beacon.git
cd beacon
npm install
```

Expand Down
6 changes: 5 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ const AppContent: React.FC = () => {
// MainPage and Header receives the username from context.
<>
<Header />
{ data.username ? (<MainPage />) : (<LoginPage onSubmit={handleLoginSubmit} />) }
{data.username ? (
<MainPage />
) : (
<LoginPage onSubmit={handleLoginSubmit} />
)}
</>
);
};
Expand Down
13 changes: 8 additions & 5 deletions src/api/resend/utils/emailSender.ts → src/api/emailApi.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { Email } from "../../../../types/emails";
import { Resend } from 'resend';
const resendKey = import.meta.env.VITE_RESEND_KEY;
const resend = new Resend(resendKey);
const RESEND_KEY = import.meta.env.VITE_RESEND_KEY;
import { Resend } from "resend";
import { Email } from "../../types/emails";

const resend = new Resend(RESEND_KEY);

export async function sendEmail(email: Email) {
try {
const { data, error } = await resend.emails.send(email);
if (error) { throw new Error(error.message) };

if (error) throw new Error(error.message);

return data;
} catch (error) {
console.error("Error sending email:", error);
Expand Down
32 changes: 0 additions & 32 deletions src/api/resend/routes/sendTest.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/components/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ const LoginPage: React.FC<LoginPageProps> = ({ onSubmit }) => {
<div className='min-h-screen flex items-center justify-center p-4 bg-gray-50'>
<div className='bg-white shadow-lg rounded-lg p-8 max-w-md w-full'>
<h1 className='text-3xl font-bold mb-6 text-center'>Welcome!</h1>

<p className='mb-6 text-center text-gray-700'>
Please enter your name and, optionally, your line manager's email to
continue.
</p>

<form onSubmit={handleSubmit} className='space-y-4'>
<Input
placeholder='Enter your name'
Expand Down
2 changes: 0 additions & 2 deletions src/components/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ const MainPage: React.FC = () => {
<h1 className='text-3xl font-bold mb-8 text-center'>
Statement builder for {username}
</h1>

<div className='container mx-auto px-4'>
<StatementList username={username} />
</div>

{/* Floating Buttons Container */}
<div className='fixed bottom-8 right-8 flex items-center space-x-4'>
{/* Email Button on the left */}
Expand Down
70 changes: 38 additions & 32 deletions src/components/ShareEmailModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ import {
} from '../components/ui/dialog';
import { Button } from '../components/ui/button';
import { useEntries } from '../hooks/useEntries';
import { POST } from '../api/resend/routes/sendTest';

const ShareEmailModal: React.FC<{ onClose: () => void }> = ({ onClose }) => {
const { data } = useEntries();
const managerEmail = data.managerEmail;

// Only include public statements that are not resolved.
const publicStatements = data.entries.filter(
(entry) => entry.isPublic && !entry.isResolved
Expand All @@ -27,49 +25,57 @@ const ShareEmailModal: React.FC<{ onClose: () => void }> = ({ onClose }) => {
<DialogTitle className='text-lg font-bold'>
Sharing with: {managerEmail || 'No manager email set'}
</DialogTitle>

<DialogDescription className='mt-2'>
Below are your public, unresolved statements and their pending
actions:
</DialogDescription>

<div className='mt-4 space-y-4'>
{publicStatements.length > 0 ? (
publicStatements.map((entry) => (<div
key={entry.id}
className='p-4 border rounded bg-white shadow-sm'
>
<p className='text-base font-semibold'>{entry.input}</p>
{entry.actions && entry.actions.length > 0 && (
<div className='mt-2 space-y-2'>
{entry.actions
.filter((action) => !action.completed)
.map((action) => (
<div
key={action.id}
className='pl-4 border-l-2 border-gray-300'
>
<p className='text-sm'>{action.action}</p>
{action.byDate && action.byDate.trim() !== '' && (
<p className='text-xs text-gray-500'>
Due: {action.byDate}
</p>
)}
</div>
))}
</div>
)}
</div>))
publicStatements.map((entry) => (
<div
key={entry.id}
className='p-4 border rounded bg-white shadow-sm'
>
<p className='text-base font-semibold'>{entry.input}</p>
{entry.actions && entry.actions.length > 0 && (
<div className='mt-2 space-y-2'>
{entry.actions
.filter((action) => !action.completed)
.map((action) => (
<div
key={action.id}
className='pl-4 border-l-2 border-gray-300'
>
<p className='text-sm'>{action.action}</p>
{action.byDate && action.byDate.trim() !== '' && (
<p className='text-xs text-gray-500'>
Due: {action.byDate}
</p>
)}
</div>
))}
</div>
)}
</div>
))
) : (
<p className='text-gray-600'>
No public unresolved statements available.
</p>
)}
</div>

<DialogFooter className='mt-4 flex justify-end space-x-4'>
<Button variant='pink' onClick={() => { POST() }}> Send </Button>
<Button variant='pink' onClick={onClose}> Close </Button>
<Button
variant='pink'
onClick={() => {
/* placeholder for Send */
}}
>
Send
</Button>
<Button variant='pink' onClick={onClose}>
Close
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
Expand Down
17 changes: 0 additions & 17 deletions src/components/emails/TestEmail.tsx

This file was deleted.

17 changes: 10 additions & 7 deletions types/emails.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
export interface Email {
from: string, /* app email address */
to: string[], /* array containing employer email */
subject: string, /* derp */
html: string /* email body */
}
// app email address
from: string,

export interface EmailProps {
firstName: string;
// array containing employer email
to: string[],

// derp
subject: string,

// email body
html: string
}