Skip to content

Commit

Permalink
Fix type errors and tests, downgrade conform/react
Browse files Browse the repository at this point in the history
  • Loading branch information
parkerdavis1 committed Jan 5, 2024
1 parent 3021af6 commit d06c8e0
Show file tree
Hide file tree
Showing 18 changed files with 94 additions and 91 deletions.
1 change: 0 additions & 1 deletion app/routes/_auth+/forgot-password/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/routes/_auth+/forgot-password_.verify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ async function validate(request: Request, body: FormData | URLSearchParams) {
return
}
}),
acceptMultipleErrors: () => true,

async: true,
})

Expand Down
7 changes: 5 additions & 2 deletions app/routes/_auth+/onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export async function action({ request }: DataFunctionArgs) {
}
})
},
acceptMultipleErrors: () => true,

async: true,
})
if (submission.intent !== 'submit') {
Expand Down Expand Up @@ -169,7 +169,10 @@ export default function OnboardingPage() {
<Spacer size="xs" />
<Form method="POST" className="mx-auto w-full max-w-sm" {...form.props}>
<Field
labelProps={{ htmlFor: fields.username.id, children: 'Username (Cannot be an email address)' }}
labelProps={{
htmlFor: fields.username.id,
children: 'Username (Cannot be an email address)',
}}
inputProps={{
...conform.input(fields.username),
autoComplete: 'username',
Expand Down
1 change: 0 additions & 1 deletion app/routes/_auth+/reset-password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export async function action({ request }: DataFunctionArgs) {
const formData = await request.formData()
const submission = parse(formData, {
schema: resetPasswordSchema,
acceptMultipleErrors: () => true,
})
if (submission.intent !== 'submit') {
return json({ status: 'idle', submission } as const)
Expand Down
12 changes: 5 additions & 7 deletions app/routes/_auth+/signup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -70,7 +68,7 @@ export async function action({ request }: DataFunctionArgs) {
}
})
},
acceptMultipleErrors: () => true,

async: true,
})
if (submission.intent !== 'submit') {
Expand Down
2 changes: 1 addition & 1 deletion app/routes/_auth+/signup_.verify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async function validate(request: Request, body: URLSearchParams | FormData) {
return
}
}),
acceptMultipleErrors: () => true,

async: true,
})
if (submission.intent !== 'submit') {
Expand Down
19 changes: 10 additions & 9 deletions app/routes/admin+/_horses+/horses.edit.$horseId.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 },
)
Expand Down Expand Up @@ -284,11 +288,8 @@ export default function EditHorse() {
<AlertDescription>
<ul className="mt-2 flex flex-col gap-2">
{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 (
<>
Expand Down
27 changes: 13 additions & 14 deletions app/routes/admin+/_users+/users.edit.$userId.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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') {
Expand Down Expand Up @@ -106,19 +105,19 @@ 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' })
} else {
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({
Expand All @@ -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,
Expand Down Expand Up @@ -211,7 +210,7 @@ export default function EditUser() {
if (role.name === 'instructor') {
isInstructor = true
}
}
}

return (
<Dialog open={open} onOpenChange={setOpen}>
Expand Down Expand Up @@ -251,7 +250,7 @@ export default function EditUser() {
disabled: true,
}}
errors={fields.email.errors}
/>
/>
<Field
className="col-span-6 sm:col-span-3"
labelProps={{ htmlFor: fields.phone.id, children: 'Phone' }}
Expand Down Expand Up @@ -296,7 +295,7 @@ export default function EditUser() {
}}
errors={fields.yearsOfExperience.errors}
/>
<TextareaField
<TextareaField
className="col-span-6"
labelProps={{
htmlFor: fields.notes.id,
Expand All @@ -308,7 +307,7 @@ export default function EditUser() {
errors={fields.notes.errors}
/>
<div className="col-span-6">
<CheckboxField
<CheckboxField
labelProps={{
htmlFor: fields.mailingList.id,
children: 'Subscribed to Mailing List',
Expand All @@ -323,8 +322,8 @@ export default function EditUser() {
/>
</div>
<hr className="col-span-6" />
<div className="col-span-6 grid grid-col-1 mt-4">

<div className="grid-col-1 col-span-6 mt-4 grid">
<CheckboxField
labelProps={{
htmlFor: fields.isInstructor.id,
Expand Down Expand Up @@ -363,7 +362,7 @@ export default function EditUser() {
defaultChecked: isHorseLeader,
}}
errors={fields.isHorseLeader.errors}
/>
/>
</div>
</div>
<DialogFooter className="mt-4">
Expand Down
2 changes: 1 addition & 1 deletion app/routes/resources+/delete-image.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ test('validates the form', async () => {
status: 'error',
submission: {
error: {
imageId: 'Required',
imageId: ['Required'],
},
intent: 'submit',
payload: {
Expand Down
1 change: 0 additions & 1 deletion app/routes/resources+/delete-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading

0 comments on commit d06c8e0

Please sign in to comment.