Skip to content

Commit

Permalink
Merge pull request #64 from opportunity-hack/dev
Browse files Browse the repository at this point in the history
Lets go!
  • Loading branch information
gregv authored Dec 22, 2023
2 parents fb2d8b9 + 10d41b9 commit fc37424
Show file tree
Hide file tree
Showing 25 changed files with 3,557 additions and 8,430 deletions.
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

0 comments on commit fc37424

Please sign in to comment.