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

Lets go! #64

Merged
merged 30 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
22b4474
responsive navbar
parkerdavis1 Jul 19, 2023
9ea44d0
Store emails in all lowercase
parkerdavis1 Jul 27, 2023
73cfdd0
Fix test to compare lowercase emails
parkerdavis1 Jul 27, 2023
bc24e61
Allow sending email to multiple people
parkerdavis1 Dec 5, 2023
db2941e
Bring in react-big-calendar styles
parkerdavis1 Dec 5, 2023
9b5dc49
Mostly working basic email page
parkerdavis1 Dec 6, 2023
c6f32eb
Remove ability to email multiple people
parkerdavis1 Dec 6, 2023
b421ff6
Remove xsm
parkerdavis1 Dec 6, 2023
c78472b
Add email to admin menu, lightly format email
parkerdavis1 Dec 7, 2023
2bcc809
Merge pull request #62 from parkerdavis1/email-notifications
gregv Dec 7, 2023
a095416
Merge pull request #61 from parkerdavis1/dev
gregv Dec 7, 2023
3cc195c
Schema update, user profile email checkbox
parkerdavis1 Dec 7, 2023
3db9902
Status submit button, reset form, # of recipients, profile mail toggl…
parkerdavis1 Dec 8, 2023
ef0465a
Add check for mailingList opt-in before emailing
parkerdavis1 Dec 8, 2023
aca27f7
Merge branch 'opportunity-hack:dev' into email-notifications
parkerdavis1 Dec 8, 2023
fb62ab8
Revert some changes, remove email opt-in from test
parkerdavis1 Dec 8, 2023
b1af2d6
Combat flaky test
parkerdavis1 Dec 8, 2023
161c913
Merge pull request #63 from parkerdavis1/email-notifications
gregv Dec 22, 2023
7ea7ac2
Admin to allow for seeing mailingList
gregv Dec 22, 2023
d2c7bcf
Cal updates
gregv Dec 22, 2023
85f1505
Show 20 users per page
gregv Dec 22, 2023
d2e6211
Spruce up email a tad
gregv Dec 22, 2023
736cc99
Doc update for new db migration
gregv Dec 22, 2023
d0474b5
package
gregv Dec 22, 2023
a53bb60
Fixing type issue
gregv Dec 22, 2023
51c01d9
Adding upcoming events into email directly
gregv Dec 22, 2023
e73eec4
Be sure to only include non-private events
gregv Dec 22, 2023
86226ac
Merge pull request #39 from parkerdavis1/email-lowercase
gregv Dec 22, 2023
79c928e
Merge branch 'dev' into navbar
gregv Dec 22, 2023
10d41b9
Merge pull request #26 from parkerdavis1/navbar
gregv Dec 22, 2023
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
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"@remix-run/server-runtime",
"@remix-run/router",
"react-router"
]
],
"editor.formatOnSave": true
}
15 changes: 10 additions & 5 deletions app/components/ui/data_table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,17 @@ export function DataTable<TData, TValue>({
data,
columns,
getCoreRowModel: getCoreRowModel(),
getPaginationRowModel: getPaginationRowModel(),
autoResetPageIndex: false,
})
getPaginationRowModel: getPaginationRowModel(),
initialState: {
pagination: {
pageSize: 20, // Set the default page size to 20
}
}

});

return (
<div>
<div>
<div className="rounded-md border">
<Table>
<TableHeader>
Expand Down Expand Up @@ -90,7 +95,7 @@ export function DataTable<TData, TValue>({
<div className="flex w-[250px] items-center justify-center text-sm font-medium">
Page {table.getState().pagination.pageIndex + 1} of{' '}
{table.getPageCount()}{' '}
<span className="ml-4">(10 rows per page)</span>
<span className="ml-4">(20 rows per page)</span>
</div>
<Button
variant="outline"
Expand Down
1 change: 1 addition & 0 deletions app/components/ui/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 22 additions & 21 deletions app/components/ui/icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,25 @@ export function Icon({
}

type IconName =
| 'arrow-right'
| 'avatar'
| 'calendar'
| 'camera'
| 'caret-sort'
| 'check'
| 'cross-1'
| 'dots-vertical'
| 'exit'
| 'gear'
| 'horse'
| 'laptop'
| 'lock-closed'
| 'lock-open-1'
| 'moon'
| 'pencil-1'
| 'pencil-2'
| 'person'
| 'plus'
| 'sun'
| 'trash'
| "arrow-right"
| "avatar"
| "calendar"
| "camera"
| "caret-sort"
| "check"
| "cross-1"
| "dots-vertical"
| "email"
| "exit"
| "gear"
| "horse"
| "laptop"
| "lock-closed"
| "lock-open-1"
| "moon"
| "pencil-1"
| "pencil-2"
| "person"
| "plus"
| "sun"
| "trash"
4 changes: 3 additions & 1 deletion app/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { Prisma } from '@prisma/client'

export const siteName = 'The Barn Volunteer Portal'
export const siteEmailAddress = '[email protected]'
export const siteEmailAddressWithName = siteName + ' <[email protected]>'
export const siteEmailAddressWithName =
siteName + ' <[email protected]>'
export const siteBaseUrl = 'https://thebarn.trottrack.org'

export const volunteerTypes = [
{
Expand Down
41 changes: 26 additions & 15 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,19 @@ function App() {
)
if (user) {
nav = (
<div className="flex items-center gap-1">
<Button asChild className="mx-auto pr-4" size="sm" variant="default">
<Link to="/calendar" className="flex gap-2 pr-1">
<Icon className="text-body-md" name="calendar" />
Calendar
</Link>
</Button>
{userIsAdmin ? <AdminDropdown /> : null}
<UserDropdown />
<div className="flex grow items-center justify-between gap-1 sm:justify-end">
<div className="flex items-center justify-start gap-1">
<Button asChild className="px-4" size="sm" variant="default">
<Link to="/calendar" className="flex gap-2">
<Icon className="text-body-md" name="calendar" />
<span className="xsm:inline hidden">Calendar</span>
</Link>
</Button>
{userIsAdmin ? <AdminDropdown /> : null}
</div>
<div className="shrink-0">
<UserDropdown />
</div>
</div>
)
}
Expand All @@ -184,8 +188,8 @@ function App() {
</head>
<body className="flex h-full flex-col justify-between bg-background text-foreground">
<header className="container mx-auto py-6">
<nav className="flex justify-between">
<Link to="/">
<nav className="flex justify-center sm:justify-between">
<Link to="/" className="hidden sm:block">
<div className="font-light">Equestrian</div>
<div className="font-bold">Volunteer Scheduler</div>
</Link>
Expand Down Expand Up @@ -229,9 +233,9 @@ function UserDropdown() {
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button asChild variant="secondary" className="min-w-[8rem]">
<Button asChild variant="secondary" className="gap-2 px-2">
<Link
to={`/users/${user.username}`}
to={`/settings/profile`}
// this is for progressive enhancement
onClick={e => e.preventDefault()}
>
Expand All @@ -240,7 +244,7 @@ function UserDropdown() {
alt={user.name ?? user.username}
src={getUserImgSrc(user.imageId)}
/>
<span className="text-body-sm font-bold">
<span className="text-body-sm font-bold hidden sm:inline">
{user.name ?? user.username}
</span>
</Link>
Expand Down Expand Up @@ -281,7 +285,7 @@ function AdminDropdown() {
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button asChild variant="secondary" className="min-w-[8rem]">
<Button asChild variant="secondary" className="gap-2">
<Link
to="/admin/users"
// this is for progressive enhancement
Expand All @@ -308,6 +312,13 @@ function AdminDropdown() {
</Icon>
</Link>
</DropdownMenuItem>
<DropdownMenuItem asChild>
<Link prefetch="intent" to={`/admin/email`}>
<Icon className="text-body-md" name="email">
Email
</Icon>
</Link>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenuPortal>
</DropdownMenu>
Expand Down
33 changes: 4 additions & 29 deletions app/routes/_auth+/onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,8 @@ export async function action({ request }: DataFunctionArgs) {
{ status: 400 },
)
}
const {
username,
name,
password,
phone,
// TODO: add user to mailing list if they agreed to it
// agreeToMailingList,
remember,
redirectTo,
} = submission.value
const { username, name, password, phone, remember, redirectTo } =
submission.value

const session = await signup({ email, username, password, name, phone })

Expand Down Expand Up @@ -175,11 +167,7 @@ export default function OnboardingPage() {
</p>
</div>
<Spacer size="xs" />
<Form
method="POST"
className="mx-auto w-full max-w-sm"
{...form.props}
>
<Form method="POST" className="mx-auto w-full max-w-sm" {...form.props}>
<Field
labelProps={{ htmlFor: fields.username.id, children: 'Username' }}
inputProps={{
Expand Down Expand Up @@ -233,15 +221,14 @@ export default function OnboardingPage() {
htmlFor: fields.agreeToTermsOfServiceAndPrivacyPolicy.id,
children: (
<>
Do you agree to our{' '}
I agree to the{' '}
<Link to="/tos" target="_blank" className="underline">
Terms of Service
</Link>{' '}
and{' '}
<Link to="/privacy" target="_blank" className="underline">
Privacy Policy
</Link>
?
</>
),
}}
Expand All @@ -252,18 +239,6 @@ export default function OnboardingPage() {
errors={fields.agreeToTermsOfServiceAndPrivacyPolicy.errors}
/>

<CheckboxField
labelProps={{
htmlFor: fields.agreeToMailingList.id,
children:
'Would you like to recieve emails about upcoming opportunities to volunteer?',
}}
buttonProps={conform.input(fields.agreeToMailingList, {
type: 'checkbox',
})}
errors={fields.agreeToMailingList.errors}
/>

<CheckboxField
labelProps={{
htmlFor: fields.remember.id,
Expand Down
30 changes: 21 additions & 9 deletions app/routes/_auth+/signup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ export const verificationType = 'onboarding'

const signupSchema = z.object({
email: emailSchema,
signupPassword: z.string().min(1, { message: "Please fill this in with the password given to you by the volunteer coordinator." }),
signupPassword: z
.string()
.min(1, {
message:
'Please fill this in with the password given to you by the volunteer coordinator.',
}),
})

export async function action({ request }: DataFunctionArgs) {
Expand All @@ -52,12 +57,14 @@ export async function action({ request }: DataFunctionArgs) {
return
}

const validSignupPassword = await verifySignupPassword(data.signupPassword)
const validSignupPassword = await verifySignupPassword(
data.signupPassword,
)
if (!validSignupPassword) {
ctx.addIssue({
path: ['signupPassword'],
code: z.ZodIssueCode.custom,
message: 'Incorrect signup password'
message: 'Incorrect signup password',
})
return
}
Expand Down Expand Up @@ -118,11 +125,12 @@ export async function action({ request }: DataFunctionArgs) {
if (response.status === 'success') {
return redirect(redirectTo.pathname + redirectTo.search)
} else {
submission.error[''] = 'There was an error sending the email.' + response.error;
if ( response.error?.message ){
submission.error[''] += ' ' + response.error.message;
submission.error[''] =
'There was an error sending the email.' + response.error
if (response.error?.message) {
submission.error[''] += ' ' + response.error.message
}

return json(
{
status: 'error',
Expand Down Expand Up @@ -158,7 +166,8 @@ export default function SignupRoute() {
<div className="text-center">
<h1 className="text-4xl sm:text-h1">Let's saddle up!</h1>
<p className="mt-3 text-body-md text-muted-foreground">
Please enter your email and the secret password given to you by the volunteer coordinator.
Please enter your email and the secret password given to you by the
volunteer coordinator.
</p>
</div>
<Form
Expand All @@ -179,7 +188,10 @@ export default function SignupRoute() {
htmlFor: fields.signupPassword.id,
children: 'Secret',
}}
inputProps={{ ...conform.input(fields.signupPassword), autoFocus: true, type: "password" }}
inputProps={{
...conform.input(fields.signupPassword),
autoFocus: true,
}}
errors={fields.signupPassword.errors}
/>
<ErrorList errors={form.errors} id={form.errorId} />
Expand Down
43 changes: 43 additions & 0 deletions app/routes/admin+/_email+/CustomEmail.server.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Container, Html, Link, Tailwind, Text } from '@react-email/components'
import tailwindConfig from '../../../../tailwind.config.ts'
import { siteBaseUrl, siteName } from '~/data.ts'

export function CustomEmail({ upcomingEvents, message }: { upcomingEvents: any[], message: string }) {
return (
<Tailwind config={tailwindConfig}>
<Html lang="en" dir="ltr">
<Container style={{ backgroundColor: '#F8F8F8', padding: '20px', borderRadius: '5px' }}>
<h1 style={{ color: '#333', fontSize: '24px', marginBottom: '20px' }}>
<Text>A Message from {siteName}</Text>
</h1>
<p style={{ color: '#555', fontSize: '16px', marginBottom: '10px' }}>
<Text>{message}</Text>
</p>
<p style={{ color: '#555', fontSize: '16px', marginBottom: '10px' }}>
<Link href={siteBaseUrl + "/calendar"} style={{ color: '#007BFF', textDecoration: 'none' }}>
View upcoming events
</Link>
{
// List out upcoming events with event.title
// Render event.start and event.end with a date format
upcomingEvents.map(event => {
return (
<div key={event.title}>
<Text>
🐴 {event.title} {event.start.toLocaleString()} - {event.end.toLocaleTimeString()}
</Text>
</div>
)
}
)




}
</p>
</Container>
</Html>
</Tailwind>
)
}
Loading
Loading