diff --git a/client/src/components/map/ObjectParameter.tsx b/client/src/components/map/ObjectParameter.tsx index 340ae85..22a2dfc 100644 --- a/client/src/components/map/ObjectParameter.tsx +++ b/client/src/components/map/ObjectParameter.tsx @@ -5,43 +5,6 @@ import { IObjectParam, IParam } from '../../interfaces/objects' import TCBParameter from './TCBParameter' import TableValue from './TableValue' -export function formatNumericValue(format: string, value: string) { - // Extract precision and scale from the format string - const regex = /numeric\((\d+),(\d+)\)/; - const match = format.match(regex); - if (!match) return value; // return original if format is not correct - - const precision = parseInt(match[1], 10); // Total number of digits - const scale = parseInt(match[2], 10); // Number of digits after the decimal point - - // Convert value to a number and handle cases like empty value or invalid input - const numericValue = parseFloat(value); - - if (isNaN(numericValue)) { - return '0'.padStart(precision - scale, '0') + '.' + '0'.repeat(scale); // fallback in case of invalid value - } - - // Ensure the value has the correct number of digits after the decimal point (scale) - let formattedValue = numericValue.toFixed(scale); - - // Ensure the total length doesn't exceed the precision - const totalDigits = formattedValue.replace('.', '').length; - - if (totalDigits > precision) { - // Truncate the value if it exceeds the total precision - formattedValue = numericValue.toPrecision(precision); - } - - // Pad with leading zeros if necessary (if it's an integer and the precision is greater than the scale) - const [integerPart, decimalPart] = formattedValue.split('.'); - - // Ensure the integer part doesn't exceed the precision - const paddedInteger = integerPart.padStart(precision - scale, '0'); - - // Reassemble the number - return `${paddedInteger}.${decimalPart.padEnd(scale, '0')}`; -} - interface ObjectParameterProps { showLabel?: boolean, param: IObjectParam, diff --git a/client/src/pages/auth/SignIn.tsx b/client/src/pages/auth/SignIn.tsx index dc5ae0b..ff166ed 100644 --- a/client/src/pages/auth/SignIn.tsx +++ b/client/src/pages/auth/SignIn.tsx @@ -1,5 +1,5 @@ import { useForm, SubmitHandler } from 'react-hook-form'; -import { AxiosResponse } from 'axios'; +import { AxiosError, AxiosResponse } from 'axios'; import { ApiResponse, LoginFormData } from '../../interfaces/auth'; import { login, setUserData } from '../../store/auth'; import { useNavigate } from 'react-router-dom'; @@ -39,10 +39,14 @@ const SignIn = () => { login(token) navigate('/'); - } catch (error: any) { - setError('password', { - message: error?.response?.data?.detail - }) + } catch (error: unknown) { + if ((error as AxiosError).response?.data) { + const err = (error as AxiosError).response?.data + setError('password', { + message: (err as { detail: string })?.detail + }) + } + } };