forked from CaliCastle/cali.so
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9cfeabb
commit 7a2c193
Showing
10 changed files
with
199 additions
and
66 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
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,39 @@ | ||
import { Card, Text, TextInput, Title } from '@tremor/react' | ||
|
||
export default function CreateNewsletterPage() { | ||
return ( | ||
<> | ||
<Title>Create a newsletter</Title> | ||
|
||
<Card className="mt-6"> | ||
<form> | ||
<div className="flex flex-col space-y-3"> | ||
<Text>Subject</Text> | ||
<TextInput name="subject" required /> | ||
</div> | ||
<div className="flex flex-col space-y-3"> | ||
<Text>Sent at</Text> | ||
<input type="datetime-local" name="sent_at" required /> | ||
</div> | ||
<div className="flex flex-col space-y-3"> | ||
<label | ||
htmlFor="body" | ||
className="block text-sm font-medium leading-6 text-zinc-800 dark:text-zinc-200" | ||
> | ||
Body | ||
</label> | ||
<div className="mt-2"> | ||
<textarea | ||
rows={20} | ||
name="body" | ||
id="body" | ||
className="block w-full rounded-md border-0 py-1.5 text-zinc-900 shadow-sm ring-1 ring-inset ring-zinc-300 placeholder:text-zinc-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 dark:text-zinc-100 dark:ring-zinc-700 sm:text-sm sm:leading-6" | ||
defaultValue={''} | ||
/> | ||
</div> | ||
</div> | ||
</form> | ||
</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,65 @@ | ||
import { | ||
Card, | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableHead, | ||
TableHeaderCell, | ||
TableRow, | ||
Title, | ||
} from '@tremor/react' | ||
import { parseDateTime } from '@zolplay/utils' | ||
import { desc, sql } from 'drizzle-orm' | ||
|
||
import { Button } from '~/components/ui/Button' | ||
import { db } from '~/db' | ||
import { newsletters } from '~/db/schema' | ||
|
||
export default async function AdminNewslettersPage() { | ||
const { | ||
rows: [count], | ||
} = await db.execute<{ today_count: number }>( | ||
sql`SELECT | ||
(SELECT COUNT(*) FROM newsletters) as total` | ||
) | ||
const nl = await db | ||
.select() | ||
.from(newsletters) | ||
.limit(100) | ||
.orderBy(desc(newsletters.sentAt)) | ||
|
||
return ( | ||
<> | ||
<Title className="mb-3"> | ||
Total newsletters{' '} | ||
{typeof count === 'object' && 'total' in count && ( | ||
<span>{count.total}</span> | ||
)} | ||
</Title> | ||
<Button href="newsletters/new">New</Button> | ||
|
||
<Card className="mt-6"> | ||
<Table className="mt-5"> | ||
<TableHead> | ||
<TableRow> | ||
<TableHeaderCell>Subject</TableHeaderCell> | ||
<TableHeaderCell>Time</TableHeaderCell> | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{nl.map((newsletter) => ( | ||
<TableRow key={newsletter.id}> | ||
<TableCell>{newsletter.subject}</TableCell> | ||
<TableCell> | ||
{parseDateTime({ date: newsletter.sentAt })?.format( | ||
'YYYY-MM-DD HH:mm' | ||
)} | ||
</TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
</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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.