From c01dd671fe99d2986bb0a799b6c64a14d82dd663 Mon Sep 17 00:00:00 2001 From: "partho.kunda" Date: Sat, 3 Aug 2024 00:35:07 +0600 Subject: [PATCH] Fix File Formatting - pass Prettier check --- src/components/expense-form.tsx | 17 ++++++++--------- src/lib/schemas.ts | 17 ++++++++--------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/components/expense-form.tsx b/src/components/expense-form.tsx index dd5df809..df901536 100644 --- a/src/components/expense-form.tsx +++ b/src/components/expense-form.tsx @@ -44,6 +44,7 @@ import { import { cn } from '@/lib/utils' import { zodResolver } from '@hookform/resolvers/zod' import { Save } from 'lucide-react' +import Mexp from 'math-expression-evaluator' import Link from 'next/link' import { useSearchParams } from 'next/navigation' import { useState } from 'react' @@ -52,7 +53,6 @@ import { match } from 'ts-pattern' import { DeletePopup } from './delete-popup' import { extractCategoryFromTitle } from './expense-form-actions' import { Textarea } from './ui/textarea' -import Mexp from 'math-expression-evaluator' const mexp = new Mexp() @@ -331,7 +331,7 @@ export function ExpenseForm({ inputMode="decimal" placeholder="0.00" onChange={(event) => { - let v = (event.target.value) + let v = event.target.value if (v === '') { setEvaluatedAmount('0') } else { @@ -360,11 +360,11 @@ export function ExpenseForm({ -
-
- {' = ' + evaluatedAmount} -
- {!isIncome && ( +
+
+ {' = ' + evaluatedAmount} +
+ {!isIncome && ( - Reimbursement + Reimbursement - )} /> )} diff --git a/src/lib/schemas.ts b/src/lib/schemas.ts index 2a19fc19..e6bfc272 100644 --- a/src/lib/schemas.ts +++ b/src/lib/schemas.ts @@ -1,6 +1,6 @@ import { SplitMode } from '@prisma/client' -import * as z from 'zod' import Mexp from 'math-expression-evaluator' +import * as z from 'zod' const mexp = new Mexp() @@ -54,15 +54,14 @@ export const expenseFormSchema = z [ z.number(), z.string().transform((value, ctx) => { - let valueAsNumber = NaN; + let valueAsNumber = NaN try { - valueAsNumber = - Number( - mexp - .eval(value) - .toFixed(2) - .replace(/\.?0+$/, '') // replace trailing zeros - ) + valueAsNumber = Number( + mexp + .eval(value) + .toFixed(2) + .replace(/\.?0+$/, ''), // replace trailing zeros + ) } finally { if (Number.isNaN(valueAsNumber)) ctx.addIssue({