Skip to content

Commit

Permalink
import as data
Browse files Browse the repository at this point in the history
  • Loading branch information
hakimLyon committed Oct 16, 2024
1 parent b4d40b6 commit cb2f5c9
Show file tree
Hide file tree
Showing 22 changed files with 51 additions and 56 deletions.
4 changes: 2 additions & 2 deletions app/root.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
data as dataResponse,
data,
type LoaderFunctionArgs,
type HeadersFunction,
type LinksFunction,
Expand Down Expand Up @@ -117,7 +117,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
const { toast, headers: toastHeaders } = await getToast(request)
const honeyProps = honeypot.getInputProps()

return dataResponse(
return data(
{
user,
requestInfo: {
Expand Down
6 changes: 3 additions & 3 deletions app/routes/_auth+/forgot-password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { type SEOHandle } from '@nasa-gcn/remix-seo'
import * as E from '@react-email/components'
import {
data as dataResponse,
data,
redirect,
type ActionFunctionArgs,
type MetaFunction,
Expand Down Expand Up @@ -54,7 +54,7 @@ export async function action({ request }: ActionFunctionArgs) {
async: true,
})
if (submission.status !== 'success') {
return dataResponse(
return data(
{ result: submission.reply() },
{ status: submission.status === 'error' ? 400 : 200 },
)
Expand Down Expand Up @@ -84,7 +84,7 @@ export async function action({ request }: ActionFunctionArgs) {
if (response.status === 'success') {
return redirect(redirectTo.toString())
} else {
return dataResponse(
return data(
{ result: submission.reply({ formErrors: [response.error.message] }) },
{ status: 500 },
)
Expand Down
4 changes: 2 additions & 2 deletions app/routes/_auth+/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getFormProps, getInputProps, useForm } from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { type SEOHandle } from '@nasa-gcn/remix-seo'
import {
data as dataResponse,
data,
type ActionFunctionArgs,
type LoaderFunctionArgs,
type MetaFunction,
Expand Down Expand Up @@ -64,7 +64,7 @@ export async function action({ request }: ActionFunctionArgs) {
})

if (submission.status !== 'success' || !submission.value.session) {
return dataResponse(
return data(
{ result: submission.reply({ hideFields: ['password'] }) },
{ status: submission.status === 'error' ? 400 : 200 },
)
Expand Down
4 changes: 2 additions & 2 deletions app/routes/_auth+/onboarding.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getFormProps, getInputProps, useForm } from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import {
data as dataResponse,
data,
redirect,
type LoaderFunctionArgs,
type ActionFunctionArgs,
Expand Down Expand Up @@ -93,7 +93,7 @@ export async function action({ request }: ActionFunctionArgs) {
})

if (submission.status !== 'success' || !submission.value.session) {
return dataResponse(
return data(
{ result: submission.reply() },
{ status: submission.status === 'error' ? 400 : 200 },
)
Expand Down
4 changes: 2 additions & 2 deletions app/routes/_auth+/onboarding_.$provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import {
redirect,
data as dataResponse,
data,
type ActionFunctionArgs,
type LoaderFunctionArgs,
type MetaFunction,
Expand Down Expand Up @@ -143,7 +143,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
})

if (submission.status !== 'success') {
return dataResponse(
return data(
{ result: submission.reply() },
{ status: submission.status === 'error' ? 400 : 200 },
)
Expand Down
4 changes: 2 additions & 2 deletions app/routes/_auth+/reset-password.server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { invariant } from '@epic-web/invariant'
import { data as dataResponse, redirect } from '@remix-run/node'
import { data, redirect } from '@remix-run/node'
import { prisma } from '#app/utils/db.server.ts'
import { verifySessionStorage } from '#app/utils/verification.server.ts'
import { resetPasswordUsernameSessionKey } from './reset-password.tsx'
Expand All @@ -18,7 +18,7 @@ export async function handleVerification({ submission }: VerifyFunctionArgs) {
// we don't want to say the user is not found if the email is not found
// because that would allow an attacker to check if an email is registered
if (!user) {
return dataResponse(
return data(
{ result: submission.reply({ fieldErrors: { code: ['Invalid code'] } }) },
{ status: 400 },
)
Expand Down
4 changes: 2 additions & 2 deletions app/routes/_auth+/reset-password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getFormProps, getInputProps, useForm } from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { type SEOHandle } from '@nasa-gcn/remix-seo'
import {
data as dataResponse,
data,
redirect,
type ActionFunctionArgs,
type LoaderFunctionArgs,
Expand Down Expand Up @@ -51,7 +51,7 @@ export async function action({ request }: ActionFunctionArgs) {
schema: ResetPasswordSchema,
})
if (submission.status !== 'success') {
return dataResponse(
return data(
{ result: submission.reply() },
{ status: submission.status === 'error' ? 400 : 200 },
)
Expand Down
6 changes: 3 additions & 3 deletions app/routes/_auth+/signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { type SEOHandle } from '@nasa-gcn/remix-seo'
import * as E from '@react-email/components'
import {
data as dataResponse,
data,
redirect,
type ActionFunctionArgs,
type MetaFunction,
Expand Down Expand Up @@ -56,7 +56,7 @@ export async function action({ request }: ActionFunctionArgs) {
async: true,
})
if (submission.status !== 'success') {
return dataResponse(
return data(
{ result: submission.reply() },
{ status: submission.status === 'error' ? 400 : 200 },
)
Expand All @@ -78,7 +78,7 @@ export async function action({ request }: ActionFunctionArgs) {
if (response.status === 'success') {
return redirect(redirectTo.toString())
} else {
return dataResponse(
return data(
{
result: submission.reply({ formErrors: [response.error.message] }),
},
Expand Down
4 changes: 2 additions & 2 deletions app/routes/_auth+/verify.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type Submission } from '@conform-to/react'
import { parseWithZod } from '@conform-to/zod'
import { data as dataResponse } from '@remix-run/node'
import { data } from '@remix-run/node'
import { z } from 'zod'
import { handleVerification as handleChangeEmailVerification } from '#app/routes/settings+/profile.change-email.server.tsx'
import { twoFAVerificationType } from '#app/routes/settings+/profile.two-factor.tsx'
Expand Down Expand Up @@ -161,7 +161,7 @@ export async function validateRequest(
})

if (submission.status !== 'success') {
return dataResponse(
return data(
{ result: submission.reply() },
{ status: submission.status === 'error' ? 400 : 200 },
)
Expand Down
4 changes: 2 additions & 2 deletions app/routes/resources+/theme-switch.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useForm, getFormProps } from '@conform-to/react'
import { parseWithZod } from '@conform-to/zod'
import { invariantResponse } from '@epic-web/invariant'
import { data as dataResponse, type ActionFunctionArgs } from '@remix-run/node'
import { data, type ActionFunctionArgs } from '@remix-run/node'
import { redirect, useFetcher, useFetchers } from '@remix-run/react'
import { ServerOnly } from 'remix-utils/server-only'
import { z } from 'zod'
Expand Down Expand Up @@ -32,7 +32,7 @@ export async function action({ request }: ActionFunctionArgs) {
if (redirectTo) {
return redirect(redirectTo, responseInit)
} else {
return dataResponse({ result: submission.reply() }, responseInit)
return data({ result: submission.reply() }, responseInit)
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/routes/settings+/profile.change-email.server.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { invariant } from '@epic-web/invariant'
import * as E from '@react-email/components'
import { data as dataResponse } from '@remix-run/node'
import { data } from '@remix-run/node'
import {
requireRecentVerification,
type VerifyFunctionArgs,
Expand All @@ -26,7 +26,7 @@ export async function handleVerification({
)
const newEmail = verifySession.get(newEmailAddressSessionKey)
if (!newEmail) {
return dataResponse(
return data(
{
result: submission.reply({
formErrors: [
Expand Down
6 changes: 3 additions & 3 deletions app/routes/settings+/profile.change-email.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getFormProps, getInputProps, useForm } from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { type SEOHandle } from '@nasa-gcn/remix-seo'
import {
data as dataResponse,
data,
redirect,
type ActionFunctionArgs,
type LoaderFunctionArgs,
Expand Down Expand Up @@ -70,7 +70,7 @@ export async function action({ request }: ActionFunctionArgs) {
})

if (submission.status !== 'success') {
return dataResponse(
return data(
{ result: submission.reply() },
{ status: submission.status === 'error' ? 400 : 200 },
)
Expand All @@ -97,7 +97,7 @@ export async function action({ request }: ActionFunctionArgs) {
},
})
} else {
return dataResponse(
return data(
{ result: submission.reply({ formErrors: [response.error.message] }) },
{ status: 500 },
)
Expand Down
6 changes: 3 additions & 3 deletions app/routes/settings+/profile.connections.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { invariantResponse } from '@epic-web/invariant'
import { type SEOHandle } from '@nasa-gcn/remix-seo'
import {
data as dataResponse,
data,
type LoaderFunctionArgs,
type ActionFunctionArgs,
type SerializeFrom,
Expand Down Expand Up @@ -81,7 +81,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
})
}

return dataResponse(
return data(
{
connections,
canDeleteConnections: await userCanDeleteConnections(userId),
Expand Down Expand Up @@ -120,7 +120,7 @@ export async function action({ request }: ActionFunctionArgs) {
title: 'Deleted',
description: 'Your connection has been deleted.',
})
return dataResponse({ status: 'success' } as const, { headers: toastHeaders })
return data({ status: 'success' } as const, { headers: toastHeaders })
}

export default function Connections() {
Expand Down
4 changes: 2 additions & 2 deletions app/routes/settings+/profile.index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { invariantResponse } from '@epic-web/invariant'
import { type SEOHandle } from '@nasa-gcn/remix-seo'
import {
data as dataResponse,
data,
type LoaderFunctionArgs,
type ActionFunctionArgs,
} from '@remix-run/node'
Expand Down Expand Up @@ -194,7 +194,7 @@ async function profileUpdateAction({ userId, formData }: ProfileActionArgs) {
}),
})
if (submission.status !== 'success') {
return dataResponse(
return data(
{ result: submission.reply() },
{ status: submission.status === 'error' ? 400 : 200 },
)
Expand Down
4 changes: 2 additions & 2 deletions app/routes/settings+/profile.password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getFormProps, getInputProps, useForm } from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { type SEOHandle } from '@nasa-gcn/remix-seo'
import {
data as dataResponse,
data,
redirect,
type LoaderFunctionArgs,
type ActionFunctionArgs,
Expand Down Expand Up @@ -83,7 +83,7 @@ export async function action({ request }: ActionFunctionArgs) {
),
})
if (submission.status !== 'success') {
return dataResponse(
return data(
{
result: submission.reply({
hideFields: ['currentPassword', 'newPassword', 'confirmNewPassword'],
Expand Down
4 changes: 2 additions & 2 deletions app/routes/settings+/profile.password_.create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getFormProps, getInputProps, useForm } from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { type SEOHandle } from '@nasa-gcn/remix-seo'
import {
data as dataResponse,
data,
redirect,
type LoaderFunctionArgs,
type ActionFunctionArgs,
Expand Down Expand Up @@ -50,7 +50,7 @@ export async function action({ request }: ActionFunctionArgs) {
schema: CreatePasswordForm,
})
if (submission.status !== 'success') {
return dataResponse(
return data(
{
result: submission.reply({
hideFields: ['password', 'confirmPassword'],
Expand Down
4 changes: 2 additions & 2 deletions app/routes/settings+/profile.photo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { invariantResponse } from '@epic-web/invariant'
import { type SEOHandle } from '@nasa-gcn/remix-seo'
import {
data as dataResponse,
data,
redirect,
unstable_createMemoryUploadHandler,
unstable_parseMultipartFormData,
Expand Down Expand Up @@ -96,7 +96,7 @@ export async function action({ request }: ActionFunctionArgs) {
})

if (submission.status !== 'success') {
return dataResponse(
return data(
{ result: submission.reply() },
{ status: submission.status === 'error' ? 400 : 200 },
)
Expand Down
4 changes: 2 additions & 2 deletions app/routes/settings+/profile.two-factor.verify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getFormProps, getInputProps, useForm } from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { type SEOHandle } from '@nasa-gcn/remix-seo'
import {
data as dataResponse,
data,
redirect,
type LoaderFunctionArgs,
type ActionFunctionArgs,
Expand Down Expand Up @@ -102,7 +102,7 @@ export async function action({ request }: ActionFunctionArgs) {
})

if (submission.status !== 'success') {
return dataResponse(
return data(
{ result: submission.reply() },
{ status: submission.status === 'error' ? 400 : 200 },
)
Expand Down
4 changes: 2 additions & 2 deletions app/routes/users+/$username_+/__note-editor.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { parseWithZod } from '@conform-to/zod'
import { createId as cuid } from '@paralleldrive/cuid2'
import {
unstable_createMemoryUploadHandler as createMemoryUploadHandler,
data as dataResponse,
data,
unstable_parseMultipartFormData as parseMultipartFormData,
redirect,
type ActionFunctionArgs,
Expand Down Expand Up @@ -88,7 +88,7 @@ export async function action({ request }: ActionFunctionArgs) {
})

if (submission.status !== 'success') {
return dataResponse(
return data(
{ result: submission.reply() },
{ status: submission.status === 'error' ? 400 : 200 },
)
Expand Down
4 changes: 2 additions & 2 deletions app/routes/users+/$username_+/notes.$noteId.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getFormProps, useForm } from '@conform-to/react'
import { parseWithZod } from '@conform-to/zod'
import { invariantResponse } from '@epic-web/invariant'
import {
data as dataResponse,
data,
type LoaderFunctionArgs,
type ActionFunctionArgs,
} from '@remix-run/node'
Expand Down Expand Up @@ -67,7 +67,7 @@ export async function action({ request }: ActionFunctionArgs) {
schema: DeleteFormSchema,
})
if (submission.status !== 'success') {
return dataResponse(
return data(
{ result: submission.reply() },
{ status: submission.status === 'error' ? 400 : 200 },
)
Expand Down
Loading

0 comments on commit cb2f5c9

Please sign in to comment.