Skip to content

Commit

Permalink
loadflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jamal-khey committed Oct 7, 2024
1 parent ae3bdfa commit 9722783
Showing 1 changed file with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ import { useForm } from 'react-hook-form';
import { yupResolver } from '@hookform/resolvers/yup';
import { toFormValuesLimitReductions } from './common/limitreductions/limit-reductions-form-util';

const CountrySelector = ({ value, label, callback }) => {
const CountrySelector = ({
value,
label,
callback,
}: {
value: string[];
label: string;
callback: (value: string[]) => void;
}) => {
const { translate, countryCodes } = useLocalizedCountries();

return (
Expand Down Expand Up @@ -89,6 +97,15 @@ export const DoubleEditor = ({
gt = undefined,
le = undefined,
lt = undefined,
}: {
initValue: string;
label: string;
callback: (value: string) => void;
checkIsTwoDigitAfterDecimal?: boolean;
ge?: number;
gt?: number;
le?: number;
lt?: number;
}) => {
const [value, setValue] = useState(initValue);
const [doubleError, setDoubleError] = useState(false);
Expand All @@ -110,9 +127,9 @@ export const DoubleEditor = ({
}, [value, initValue, callback, doubleError]);

const checkValue = useCallback(
(newValue) => {
(newValue: string) => {
const FloatRE = checkIsTwoDigitAfterDecimal ? /^(\d*\.{0,1}\d{0,2}$)/ : /^-?\d*[.,]?\d*$/;
const outputTransformFloatString = (value) => {
const outputTransformFloatString = (value: string) => {
return value?.replace(',', '.') || '';
};
const m = FloatRE.exec(newValue);
Expand Down Expand Up @@ -172,14 +189,14 @@ function makeComponentsFor(defParams, localParams, allParams, setter, provider)
));
}

function getValue(param, key) {
function getValue(param: any, key: string) {
if (!param || param[key] === undefined) {
return null;
}
return param[key];
}

function makeComponentFor(defParam, key, localParams, allParams, setter, provider) {
function makeComponentFor(defParam: any, key: string, localParams: any, allParams: any, setter: any, provider: any) {
function updateValues(newval) {
localParams = { ...localParams, [key]: newval }; // single value update made
let newParams = { ...allParams }; // but we send/update all params to the back
Expand Down

0 comments on commit 9722783

Please sign in to comment.