diff --git a/app/routes/_auth+/forgot-password/index.tsx b/app/routes/_auth+/forgot-password/index.tsx index cd51bcc..9d77710 100644 --- a/app/routes/_auth+/forgot-password/index.tsx +++ b/app/routes/_auth+/forgot-password/index.tsx @@ -31,7 +31,6 @@ export async function action({ request }: DataFunctionArgs) { const formData = await request.formData() const submission = parse(formData, { schema: forgotPasswordSchema, - acceptMultipleErrors: () => true, }) if (submission.intent !== 'submit') { return json({ status: 'idle', submission } as const) diff --git a/app/routes/_auth+/forgot-password_.verify.tsx b/app/routes/_auth+/forgot-password_.verify.tsx index 72bff3e..7cfb579 100644 --- a/app/routes/_auth+/forgot-password_.verify.tsx +++ b/app/routes/_auth+/forgot-password_.verify.tsx @@ -97,7 +97,7 @@ async function validate(request: Request, body: FormData | URLSearchParams) { return } }), - acceptMultipleErrors: () => true, + async: true, }) diff --git a/app/routes/_auth+/onboarding.tsx b/app/routes/_auth+/onboarding.tsx index 046f2d4..f5f0611 100644 --- a/app/routes/_auth+/onboarding.tsx +++ b/app/routes/_auth+/onboarding.tsx @@ -103,7 +103,7 @@ export async function action({ request }: DataFunctionArgs) { } }) }, - acceptMultipleErrors: () => true, + async: true, }) if (submission.intent !== 'submit') { @@ -169,7 +169,10 @@ export default function OnboardingPage() {
true, }) if (submission.intent !== 'submit') { return json({ status: 'idle', submission } as const) diff --git a/app/routes/_auth+/signup/index.tsx b/app/routes/_auth+/signup/index.tsx index 188c709..1d41897 100644 --- a/app/routes/_auth+/signup/index.tsx +++ b/app/routes/_auth+/signup/index.tsx @@ -31,12 +31,10 @@ 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) { @@ -70,7 +68,7 @@ export async function action({ request }: DataFunctionArgs) { } }) }, - acceptMultipleErrors: () => true, + async: true, }) if (submission.intent !== 'submit') { diff --git a/app/routes/_auth+/signup_.verify.tsx b/app/routes/_auth+/signup_.verify.tsx index f2c1e4c..8bce949 100644 --- a/app/routes/_auth+/signup_.verify.tsx +++ b/app/routes/_auth+/signup_.verify.tsx @@ -87,7 +87,7 @@ async function validate(request: Request, body: URLSearchParams | FormData) { return } }), - acceptMultipleErrors: () => true, + async: true, }) if (submission.intent !== 'submit') { diff --git a/app/routes/admin+/_horses+/horses.edit.$horseId.tsx b/app/routes/admin+/_horses+/horses.edit.$horseId.tsx index d4cc999..7aadcef 100644 --- a/app/routes/admin+/_horses+/horses.edit.$horseId.tsx +++ b/app/routes/admin+/_horses+/horses.edit.$horseId.tsx @@ -9,7 +9,12 @@ import { DialogFooter, } from '~/components/ui/dialog.tsx' import { Icon } from '~/components/ui/icon.tsx' -import { CheckboxField, Field, TextareaField, ErrorList } from '~/components/forms.tsx' +import { + CheckboxField, + Field, + TextareaField, + ErrorList, +} from '~/components/forms.tsx' import { Form, useLoaderData, @@ -49,18 +54,17 @@ export async function action({ request, params }: DataFunctionArgs) { const submission = await parse(formData, { async: true, schema: horseFormSchema, - acceptMultipleErrors: () => true, }) if (submission.intent !== 'submit') { - return json({ status: 'idle', submission, conflictEvents: []} as const) + return json({ status: 'idle', submission, conflictEvents: [] } as const) } if (!submission.value) { return json( { status: 'error', submission, - conflictEvents: [] + conflictEvents: [], } as const, { status: 400 }, ) @@ -284,11 +288,8 @@ export default function EditHorse() {
    {conflictEvents - ? conflictEvents.map((e) => { - const date = format( - new Date(e.start), - 'MMMM do, yyyy', - ) + ? conflictEvents.map(e => { + const date = format(new Date(e.start), 'MMMM do, yyyy') const link = `/calendar/${e.id}` return ( <> diff --git a/app/routes/admin+/_users+/users.edit.$userId.tsx b/app/routes/admin+/_users+/users.edit.$userId.tsx index dfc145e..318763b 100644 --- a/app/routes/admin+/_users+/users.edit.$userId.tsx +++ b/app/routes/admin+/_users+/users.edit.$userId.tsx @@ -41,7 +41,7 @@ import { format } from 'date-fns' const editUserSchema = z.object({ name: nameSchema.optional(), username: usernameSchema, - email: emailSchema.optional(), + email: emailSchema.optional(), mailingList: checkboxSchema(), phone: phoneSchema, birthdate: optionalDateSchema, @@ -73,7 +73,6 @@ export async function action({ request, params }: DataFunctionArgs) { const submission = await parse(formData, { async: true, schema: editUserSchema, - acceptMultipleErrors: () => true, }) if (submission.intent !== 'submit') { @@ -106,9 +105,9 @@ export async function action({ request, params }: DataFunctionArgs) { const roleConnectArray = [] const roleDisconnectArray = [] if (isInstructor) { - roleConnectArray.push({ name: 'instructor'}) + roleConnectArray.push({ name: 'instructor' }) } else { - roleDisconnectArray.push({ name: 'instructor'}) + roleDisconnectArray.push({ name: 'instructor' }) } if (isHorseLeader) { roleConnectArray.push({ name: 'horseLeader' }) @@ -116,9 +115,9 @@ export async function action({ request, params }: DataFunctionArgs) { roleDisconnectArray.push({ name: 'horseLeader' }) } if (isLessonAssistant) { - roleConnectArray.push({ name: 'lessonAssistant'}) + roleConnectArray.push({ name: 'lessonAssistant' }) } else { - roleDisconnectArray.push({ name: 'lessonAssistant'}) + roleDisconnectArray.push({ name: 'lessonAssistant' }) } const updatedUser = await prisma.user.update({ @@ -127,7 +126,7 @@ export async function action({ request, params }: DataFunctionArgs) { name, username, phone, - mailingList : mailingList ?? false, + mailingList: mailingList ?? false, birthdate: birthdate ?? null, height: height ?? null, yearsOfExperience: yearsOfExperience ?? null, @@ -211,7 +210,7 @@ export default function EditUser() { if (role.name === 'instructor') { isInstructor = true } - } + } return ( @@ -251,7 +250,7 @@ export default function EditUser() { disabled: true, }} errors={fields.email.errors} - /> + /> -
    -

    - -
    + +
    + />
    diff --git a/app/routes/resources+/delete-image.test.tsx b/app/routes/resources+/delete-image.test.tsx index 25419eb..6537fe0 100644 --- a/app/routes/resources+/delete-image.test.tsx +++ b/app/routes/resources+/delete-image.test.tsx @@ -105,7 +105,7 @@ test('validates the form', async () => { status: 'error', submission: { error: { - imageId: 'Required', + imageId: ['Required'], }, intent: 'submit', payload: { diff --git a/app/routes/resources+/delete-image.tsx b/app/routes/resources+/delete-image.tsx index 87da90a..ee795ea 100644 --- a/app/routes/resources+/delete-image.tsx +++ b/app/routes/resources+/delete-image.tsx @@ -15,7 +15,6 @@ export async function action({ request }: DataFunctionArgs) { const formData = await request.formData() const submission = parse(formData, { schema: DeleteFormSchema, - acceptMultipleErrors: () => true, }) if (!submission.value) { return json( diff --git a/app/routes/resources+/event-register.tsx b/app/routes/resources+/event-register.tsx index b258990..f304e4b 100644 --- a/app/routes/resources+/event-register.tsx +++ b/app/routes/resources+/event-register.tsx @@ -4,7 +4,10 @@ import { parse } from '@conform-to/zod' import { json, type DataFunctionArgs } from '~/remix.ts' import { prisma } from '~/utils/db.server.ts' import { sendEmail } from '~/utils/email.server.ts' -import { RegistrationEmail, RegistrationNoticeForAdmins } from './registration-emails.server.tsx' +import { + RegistrationEmail, + RegistrationNoticeForAdmins, +} from './registration-emails.server.tsx' import { UnregistrationEmail } from './unregistration-emails.server.tsx' import { createEvent, type DateArray } from 'ics' import type { User, Event } from '@prisma/client' @@ -31,7 +34,6 @@ export async function action({ request }: DataFunctionArgs) { const formData = await request.formData() const submission = parse(formData, { schema: EventRegistrationSchema, - acceptMultipleErrors: () => true, }) if (!submission.value || submission.intent !== 'submit') { @@ -96,7 +98,6 @@ export async function action({ request }: DataFunctionArgs) { ) } - if (submission.value.role == 'lessonAssistants') { if (!user.roles.find(role => role.name === 'lessonAssistant')) { throw json({ error: 'Missing permissions' }, { status: 403 }) @@ -126,7 +127,7 @@ export async function action({ request }: DataFunctionArgs) { const invite = generateInvite(event) - if (invite === "") { + if (invite === '') { console.error( 'There was an error generating an invite for the following event:', JSON.stringify(event), @@ -134,13 +135,12 @@ export async function action({ request }: DataFunctionArgs) { return json( { status: 'error', - message: "Error generating event invite", + message: 'Error generating event invite', submission, } as const, { status: 500 }, ) } - sendEmail({ to: user.email, @@ -174,7 +174,6 @@ export async function action({ request }: DataFunctionArgs) { } function generateInvite(event: Event) { - const year = event.start.getFullYear() const month = event.start.getMonth() + 1 // JS Date months are 0 indexed) const day = event.start.getDate() @@ -182,33 +181,39 @@ function generateInvite(event: Event) { const minute = event.start.getMinutes() const duration = differenceInMinutes(event.end, event.start) - - const endDate = new Date(event.start.getTime() + duration * 60000); + + const endDate = new Date(event.start.getTime() + duration * 60000) let icalEvent = { - start: [year, month, day, hour, minute] as DateArray, - end: [endDate.getFullYear(), endDate.getMonth() + 1, endDate.getDate(), endDate.getHours(), endDate.getMinutes()] as DateArray, - // duration: { minutes: duration }, // Not sure this is used - title: event.title, - organizer: { name: 'Volunteer Coordinator', email: siteEmailAddress }, - }; + start: [year, month, day, hour, minute] as DateArray, + end: [ + endDate.getFullYear(), + endDate.getMonth() + 1, + endDate.getDate(), + endDate.getHours(), + endDate.getMinutes(), + ] as DateArray, + // duration: { minutes: duration }, // Not sure this is used + title: event.title, + organizer: { name: 'Volunteer Coordinator', email: siteEmailAddress }, + } const invite = createEvent(icalEvent) if (invite.error) { - console.error((invite.error)); - return ""; + console.error(invite.error) + return '' } // Log the event as a string - console.log("Calendar invite: " + invite.value); - + console.log('Calendar invite: ' + invite.value) + // Check if invite.value is a string if (typeof invite.value === 'string') { // Convert to a buffer - const inviteBuffer = Buffer.from(invite.value); + const inviteBuffer = Buffer.from(invite.value) return inviteBuffer } - return ""; + return '' } async function notifyAdmins({ @@ -218,10 +223,10 @@ async function notifyAdmins({ user, }: { event: Event - role: 'cleaningCrew' | 'lessonAssistants' | 'sideWalkers' | 'horseLeaders', - action: 'register' | 'unregister'; - user: User; - }) { + role: 'cleaningCrew' | 'lessonAssistants' | 'sideWalkers' | 'horseLeaders' + action: 'register' | 'unregister' + user: User +}) { const admins = await prisma.user.findMany({ where: { roles: { some: { name: 'admin' } } }, }) @@ -230,11 +235,14 @@ async function notifyAdmins({ sendEmail({ to: admin.email, subject: `${user.name} ${action}ed as a volunteer for ${event.title}`, - react: , + react: ( + + ), }).then(result => { if (result.status == 'error') { // TODO: think through this case and how to handle it properly diff --git a/app/routes/resources+/login.tsx b/app/routes/resources+/login.tsx index 93a99ef..4bddac2 100644 --- a/app/routes/resources+/login.tsx +++ b/app/routes/resources+/login.tsx @@ -30,7 +30,6 @@ export async function action({ request }: DataFunctionArgs) { const formData = await request.formData() const submission = parse(formData, { schema: loginFormSchema, - acceptMultipleErrors: () => true, }) if (submission.intent !== 'submit') { return json({ status: 'idle', submission } as const) diff --git a/app/routes/resources+/theme/index.tsx b/app/routes/resources+/theme/index.tsx index 9bdcf10..a8ba00d 100644 --- a/app/routes/resources+/theme/index.tsx +++ b/app/routes/resources+/theme/index.tsx @@ -27,7 +27,6 @@ export async function action({ request }: DataFunctionArgs) { const formData = await request.formData() const submission = parse(formData, { schema: ThemeFormSchema, - acceptMultipleErrors: () => true, }) if (!submission.value) { return json( diff --git a/app/routes/resources+/verify.tsx b/app/routes/resources+/verify.tsx index d6e27a4..44832f5 100644 --- a/app/routes/resources+/verify.tsx +++ b/app/routes/resources+/verify.tsx @@ -97,7 +97,6 @@ export async function action({ request }: DataFunctionArgs) { return } }), - acceptMultipleErrors: () => true, async: true, }) if (submission.intent !== 'submit') { diff --git a/app/routes/settings+/profile.two-factor.verify.tsx b/app/routes/settings+/profile.two-factor.verify.tsx index 0d422af..5c64654 100644 --- a/app/routes/settings+/profile.two-factor.verify.tsx +++ b/app/routes/settings+/profile.two-factor.verify.tsx @@ -93,7 +93,7 @@ export async function action({ request }: DataFunctionArgs) { } }) }, - acceptMultipleErrors: () => true, + async: true, }) if (submission.intent !== 'submit') { diff --git a/app/utils/user-validation.ts b/app/utils/user-validation.ts index d3d5b21..54f1d43 100644 --- a/app/utils/user-validation.ts +++ b/app/utils/user-validation.ts @@ -55,8 +55,8 @@ export const heightSchema = z heightInches: z .number({ invalid_type_error: 'Inches must be a number' }) .int({ message: 'Inches must be an integer' }) - .min(0, { message: 'Inches must be between 0 and 12' }) - .max(12, { message: 'Inches must be between 0 and 12' }) + .min(0, { message: 'Inches must be between 0 and 11' }) + .max(11, { message: 'Inches must be between 0 and 11' }) .optional() .transform(val => { if (val === undefined) return null diff --git a/package-lock.json b/package-lock.json index 722a4e1..6275e1b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,7 +7,7 @@ "name": "evs-635a", "hasInstallScript": true, "dependencies": { - "@conform-to/react": "^0.9.1", + "@conform-to/react": "^0.7.0", "@conform-to/zod": "^0.9.1", "@headlessui/react": "^1.7.15", "@prisma/client": "^4.16.0", @@ -2053,16 +2053,16 @@ "license": "MIT" }, "node_modules/@conform-to/dom": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/@conform-to/dom/-/dom-0.9.1.tgz", - "integrity": "sha512-+T6QgpLDPZ29j4y5nWW61WMe8qj0cQBymyzbi5sq1f3CcBO3wBbR0VPI7mbm+rLoErHWM3ghhdNlIkw0UPoLLA==" + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/@conform-to/dom/-/dom-0.7.4.tgz", + "integrity": "sha512-Cct89jWhJA+hfCth+9mphnwBVmFRx5caHtQp+0f+iK/UQKYgYMaK15JqtfNV8aHHXlrpWcSJ99x6iUgwYVQaLA==" }, "node_modules/@conform-to/react": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/@conform-to/react/-/react-0.9.1.tgz", - "integrity": "sha512-SibYHk86IFh60LRPk4aJHJOgyLTgb3JYphKvG4vcemyuntdOwncd5YM/GDoccVzeCTmJi4Os/fDtOOAaDcSa9w==", + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/@conform-to/react/-/react-0.7.4.tgz", + "integrity": "sha512-r3HNOIW3GBBjHWIvqoalKxAoTtQFiphVClYtdLBblEgxnStRjEaIkEP+JfktlEulYiVqL+935e9CV7U2v/Uxzw==", "dependencies": { - "@conform-to/dom": "0.9.1" + "@conform-to/dom": "0.7.4" }, "peerDependencies": { "react": ">=16.8" @@ -19068,16 +19068,16 @@ "dev": true }, "@conform-to/dom": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/@conform-to/dom/-/dom-0.9.1.tgz", - "integrity": "sha512-+T6QgpLDPZ29j4y5nWW61WMe8qj0cQBymyzbi5sq1f3CcBO3wBbR0VPI7mbm+rLoErHWM3ghhdNlIkw0UPoLLA==" + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/@conform-to/dom/-/dom-0.7.4.tgz", + "integrity": "sha512-Cct89jWhJA+hfCth+9mphnwBVmFRx5caHtQp+0f+iK/UQKYgYMaK15JqtfNV8aHHXlrpWcSJ99x6iUgwYVQaLA==" }, "@conform-to/react": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/@conform-to/react/-/react-0.9.1.tgz", - "integrity": "sha512-SibYHk86IFh60LRPk4aJHJOgyLTgb3JYphKvG4vcemyuntdOwncd5YM/GDoccVzeCTmJi4Os/fDtOOAaDcSa9w==", + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/@conform-to/react/-/react-0.7.4.tgz", + "integrity": "sha512-r3HNOIW3GBBjHWIvqoalKxAoTtQFiphVClYtdLBblEgxnStRjEaIkEP+JfktlEulYiVqL+935e9CV7U2v/Uxzw==", "requires": { - "@conform-to/dom": "0.9.1" + "@conform-to/dom": "0.7.4" } }, "@conform-to/zod": { diff --git a/package.json b/package.json index eb0d49f..9028d6d 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "/server-build" ], "dependencies": { - "@conform-to/react": "^0.9.1", + "@conform-to/react": "^0.7.0", "@conform-to/zod": "^0.9.1", "@headlessui/react": "^1.7.15", "@prisma/client": "^4.16.0", @@ -57,8 +57,8 @@ "@remix-run/router": "^1.6.3", "@remix-run/server-runtime": "^1.18.0", "@sentry/remix": "^7.54.0", - "@tanstack/react-table": "^8.9.2", "@tailwindcss/typography": "^0.5.10", + "@tanstack/react-table": "^8.9.2", "address": "^1.2.2", "autoprefixer": "^10.4.14", "bcryptjs": "^2.4.3",