Skip to content

Commit

Permalink
fix typecheck issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Taldrain committed Jan 28, 2024
1 parent f88c7a0 commit 9337074
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 19 deletions.
3 changes: 2 additions & 1 deletion app/components/AmountDisplay/AmountDisplay.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Settings } from "@prisma/client";
import { useLoaderData } from "@remix-run/react";

import { formatBalance, getAmount } from '~/utils/number';
Expand All @@ -9,7 +10,7 @@ interface AmountDisplayType {
}

function AmountDisplay({ amount, isPositive }: AmountDisplayType) {
const { userSettings } = useLoaderData();
const { userSettings } = useLoaderData() as { userSettings: Settings }

const color = isPositive ? 'text-green-500' : 'text-red-500';

Expand Down
3 changes: 2 additions & 1 deletion app/components/DateDisplay/DateDisplay.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Settings } from "@prisma/client";
import { useLoaderData } from "@remix-run/react";

import { getUserLocale } from '~/utils/userSettings';
Expand All @@ -8,7 +9,7 @@ type DateDisplayProps = {
}

function DateDisplay({ date, type }: DateDisplayProps) {
const { userSettings } = useLoaderData();
const { userSettings } = useLoaderData() as { userSettings: Settings }
// `day` and `week` date type share the same display
let options: any = { dateStyle: 'full' };
if (type === 'year') {
Expand Down
6 changes: 3 additions & 3 deletions app/routes/_auth.login.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { LoaderArgs, ActionArgs } from '@remix-run/node';
import type { LoaderFunctionArgs, ActionFunctionArgs } from '@remix-run/node';
import { json, redirect } from "@remix-run/node";
import { Form, useNavigation, useActionData, useSearchParams } from "@remix-run/react";

Expand All @@ -18,7 +18,7 @@ function validateEmail(email: unknown) {
}
}

export async function loader({ request }: LoaderArgs) {
export async function loader({ request }: LoaderFunctionArgs) {
const userId = await getUserId(request);
if (userId !== null) {
throw redirect('/dashboard/');
Expand All @@ -28,7 +28,7 @@ export async function loader({ request }: LoaderArgs) {
}

// most of the login process is inspired from the kentcdodds.com website
export async function action({ request }: ActionArgs) {
export async function action({ request }: ActionFunctionArgs) {
const form = await request.formData();
const email = form.get('email');
const redirectTo = `${form.get('redirectTo')}` || '/dashboard/';
Expand Down
4 changes: 2 additions & 2 deletions app/routes/_auth.magic.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { LoaderArgs } from '@remix-run/node';
import type { LoaderFunctionArgs } from '@remix-run/node';
import { json, redirect } from '@remix-run/node';
import { Link, useLoaderData } from '@remix-run/react';

import { verifyLoginToken, TokenExpiredError } from '~/utils/jwt.server';
import { getUser, createUser } from '~/utils/queries.server';
import { createUserSession } from '~/utils/session.server';

export async function loader({ request }: LoaderArgs) {
export async function loader({ request }: LoaderFunctionArgs) {
const url = new URL(request.url);
const token = url.searchParams.get('token');

Expand Down
4 changes: 2 additions & 2 deletions app/routes/_landing._index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { LoaderArgs } from "@remix-run/node";
import type { LoaderFunctionArgs } from "@remix-run/node";
import { Link, useLoaderData } from '@remix-run/react';

import{ getUserId } from '~/utils/session.server';
import landing from "~/images/landing.png";

export const loader = async({ request }: LoaderArgs) => {
export const loader = async({ request }: LoaderFunctionArgs) => {
const userId = await getUserId(request);

return ({
Expand Down
6 changes: 3 additions & 3 deletions app/routes/dashboard.balance.$type.$date.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Fragment } from 'react';
import type { LoaderArgs, ActionArgs } from "@remix-run/node";
import type { LoaderFunctionArgs, ActionFunctionArgs } from "@remix-run/node";
import type { Punctual, Recurrent } from '@prisma/client';
import { redirect } from '@remix-run/node';
import { useLoaderData, useParams, useSearchParams } from "@remix-run/react";
Expand Down Expand Up @@ -43,7 +43,7 @@ import {
computeNewAmount,
} from '~/utils/entry';

export const action = async ({ request }: ActionArgs) => {
export const action = async ({ request }: ActionFunctionArgs) => {
const formData = Object.fromEntries(await request.formData());
const userId = await requireUserId(request);
const url = new URL(request.url);
Expand Down Expand Up @@ -144,7 +144,7 @@ export const action = async ({ request }: ActionArgs) => {
return null;
};

export const loader = async ({ request, params }: LoaderArgs) => {
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
const userId = await requireUserId(request);
invariant(params.type, 'Expected params.type');
invariant(params.date, 'Expected params.date');
Expand Down
6 changes: 3 additions & 3 deletions app/routes/dashboard.settings.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ActionArgs, LoaderArgs } from "@remix-run/node";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
import { Form, useNavigation, useLoaderData } from "@remix-run/react";

import Button from '~/components/Button';
Expand All @@ -24,7 +24,7 @@ function validateLocale(locale: unknown) {
}
}

export const action = async ({ request }: ActionArgs) => {
export const action = async ({ request }: ActionFunctionArgs) => {
const formData = Object.fromEntries(await request.formData());
const userId = await requireUserId(request);

Expand All @@ -48,7 +48,7 @@ export const action = async ({ request }: ActionArgs) => {
return null;
}

export const loader = async ({ request }: LoaderArgs) => {
export const loader = async ({ request }: LoaderFunctionArgs) => {
const userId = await requireUserId(request);
const settings = await getSettings(userId);
const user = await getUserById(userId);
Expand Down
4 changes: 2 additions & 2 deletions app/routes/dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Fragment } from 'react';
import type { LoaderArgs } from "@remix-run/node";
import type { LoaderFunctionArgs } from "@remix-run/node";
import { Outlet, useLoaderData } from "@remix-run/react";

import AppBar from '~/components/AppBar';
Expand All @@ -9,7 +9,7 @@ import { getSettings } from '~/utils/queries.server';
import { getUserLocale } from '~/utils/userSettings';
import { localizeDateFns } from '~/utils/l10n';

export const loader = async ({ request }: LoaderArgs) => {
export const loader = async ({ request }: LoaderFunctionArgs) => {
const userId = await requireUserId(request);
const settings = await getSettings(userId);

Expand Down
4 changes: 2 additions & 2 deletions app/routes/logout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { ActionArgs } from '@remix-run/node';
import type { ActionFunctionArgs } from '@remix-run/node';
import { redirect } from '@remix-run/node';

import { deleteSession } from '~/utils/session.server';

export async function action({ request }: ActionArgs) {
export async function action({ request }: ActionFunctionArgs) {
return deleteSession(request);
}

Expand Down

0 comments on commit 9337074

Please sign in to comment.