From 820caa4cf9a9f4b287739f87fa401213b7eadeb1 Mon Sep 17 00:00:00 2001 From: Daniel Haselhan Date: Mon, 9 Dec 2024 10:53:23 -0800 Subject: [PATCH] fix: Allow negative symbol in transaction amount input --- .../layouts/MainLayout/components/UserProfileActions.jsx | 1 - .../views/Transactions/components/TransactionDetails.jsx | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/layouts/MainLayout/components/UserProfileActions.jsx b/frontend/src/layouts/MainLayout/components/UserProfileActions.jsx index f5f7dbc68..37ebd0557 100644 --- a/frontend/src/layouts/MainLayout/components/UserProfileActions.jsx +++ b/frontend/src/layouts/MainLayout/components/UserProfileActions.jsx @@ -38,7 +38,6 @@ export const UserProfileActions = () => { refetchInterval: 60000 // Automatically refetch every 1 minute (60000ms) }) const notificationsCount = notificationsData?.count || 0 - console.log(notificationsData) // Call refetch whenever the route changes useEffect(() => { diff --git a/frontend/src/views/Transactions/components/TransactionDetails.jsx b/frontend/src/views/Transactions/components/TransactionDetails.jsx index 0c3b51199..81fdd1b3b 100644 --- a/frontend/src/views/Transactions/components/TransactionDetails.jsx +++ b/frontend/src/views/Transactions/components/TransactionDetails.jsx @@ -244,8 +244,11 @@ export const TransactionDetails = ({ transactionId, isEditable }) => { helperText={errors.complianceUnits?.message} value={formattedValue} onChange={(e) => { - // Remove all non-digit characters - const numericValue = e.target.value.replace(/\D/g, '') + // Remove all non-digit characters (other than - at the front) + const numericValue = e.target.value.replace( + /(?!^-)[^0-9]/g, + '' + ) // Update the form state with the raw number onChange(numericValue) }}