Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update dependencies #22

Merged
merged 3 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions app/utils/date.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import {

import { localizeDateFns } from './l10n';

beforeAll(() => {
beforeAll(async () => {
// the week will start a monday
localizeDateFns('fr-FR');
await localizeDateFns('fr-FR');
});

test('formatDate returns a date in the yyyy-MM-dd format', () => {
Expand Down
4 changes: 2 additions & 2 deletions app/utils/entry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import {

import { localizeDateFns } from './l10n';

beforeAll(() => {
beforeAll(async () => {
// the week will start a monday
localizeDateFns('fr-FR');
await localizeDateFns('fr-FR');
});

function dummyRecurrentEntry(startDate: Date, endDate: Date | null, amount: number, isPositive: boolean, recurrence: string): Recurrent {
Expand Down
3 changes: 2 additions & 1 deletion app/utils/jwt.server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { JwtPayload } from 'jsonwebtoken'
import { sign, verify, JsonWebTokenError, TokenExpiredError } from 'jsonwebtoken';
import pkg from 'jsonwebtoken'
const { sign, verify, JsonWebTokenError, TokenExpiredError } = pkg;

const jwtSecret = process.env.JWT_SECRET;
if (!jwtSecret) {
Expand Down
6 changes: 3 additions & 3 deletions app/utils/l10n.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { setDefaultOptions } from 'date-fns';

function localizeDateFns(locale: string) {
async function localizeDateFns(locale: string) {
if (locale === 'fr-FR') {
const { fr } = require('date-fns/locale');
const { fr } = await import('date-fns/locale');
setDefaultOptions({ locale: fr });

return;
}

const { enUS } = require('date-fns/locale');
const { enUS } = await import('date-fns/locale');
setDefaultOptions({ locale: enUS });
}

Expand Down
Loading
Loading