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

Fix add network manual #1069

Merged
merged 2 commits into from
Aug 5, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Bug fixes

- [#1069](https://github.com/alleslabs/celatone-frontend/pull/1069) Fix add custom minitia network manually
- [#1065](https://github.com/alleslabs/celatone-frontend/pull/1065) Fix zod url validation to allow only http and https in add custom minitia page
- [#1064](https://github.com/alleslabs/celatone-frontend/pull/1064) Fix cancel button in add custom minitia page
- [#1068](https://github.com/alleslabs/celatone-frontend/pull/1068) Add fetching bech32 prefix from lcd and disable close success modal on overlay click
Expand Down
2 changes: 1 addition & 1 deletion src/lib/app-provider/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export enum CELATONE_QUERY_KEYS {
ACCOUNT_DATA = "CELATONE_QUERY_ACCOUNT_DATA",
ACCOUNT_TYPE = "CELATONE_QUERY_ACCOUNT_TYPE",
ACCOUNT_TYPE_LCD = "CELATONE_QUERY_ACCOUNT_TYPE_LCD",
ACCOUNT_BECH_32 = "CELATONE_QUERY_ACCOUNT_BECH_32",
ACCOUNT_BECH_32_LCD = "CELATONE_QUERY_ACCOUNT_BECH_32_LCD",
// ASSET
ASSET_INFOS = "CELATONE_QUERY_ASSET_INFOS",
// BLOCK
Expand Down
12 changes: 6 additions & 6 deletions src/lib/app-provider/hooks/useRestrictedInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ export function useRestrictedInput(
export interface RestrictedNumberInputParams {
type?: "decimal" | "integer";
maxDecimalPoints?: number;
maxIntegerPoinsts?: number;
maxIntegerPoints?: number;
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
}

// eslint-disable-next-line sonarjs/cognitive-complexity
export function useRestrictedNumberInput({
type = "decimal",
maxDecimalPoints,
maxIntegerPoinsts,
maxDecimalPoints = 6,
maxIntegerPoints = 7,
onChange: _onChange,
}: RestrictedNumberInputParams): RestrictedInputReturn {
const { onKeyPress: restrictCharacters } = useRestrictedInput(
Expand All @@ -65,14 +65,14 @@ export function useRestrictedNumberInput({
(nextValue: string): boolean => {
return (
Number.isNaN(+nextValue) ||
(typeof maxIntegerPoinsts === "number" &&
new RegExp(`^[0-9]{${maxIntegerPoinsts + 1},}`).test(nextValue)) ||
(typeof maxIntegerPoints === "number" &&
new RegExp(`^[0-9]{${maxIntegerPoints + 1},}`).test(nextValue)) ||
(type === "decimal" &&
typeof maxDecimalPoints === "number" &&
new RegExp(`\\.[0-9]{${maxDecimalPoints + 1},}$`).test(nextValue))
);
},
[maxDecimalPoints, maxIntegerPoinsts, type]
[maxDecimalPoints, maxIntegerPoints, type]
);

const onKeyPress = useCallback(
Expand Down
12 changes: 4 additions & 8 deletions src/lib/components/forms/ControllerInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface ControllerInputProps<T extends FieldValues>
};
restrictedNumberInputParams?: Pick<
RestrictedNumberInputParams,
"maxDecimalPoints" | "maxIntegerPoinsts"
"maxDecimalPoints" | "maxIntegerPoints"
>;
}

Expand All @@ -63,10 +63,7 @@ export const ControllerInput = <T extends FieldValues>({
helperAction,
textAlign = "left",
cta,
restrictedNumberInputParams = {
maxIntegerPoinsts: 7,
maxDecimalPoints: 6,
},
restrictedNumberInputParams,
...componentProps
}: ControllerInputProps<T>) => {
const watcher = useWatch({
Expand Down Expand Up @@ -103,14 +100,13 @@ export const ControllerInput = <T extends FieldValues>({

const decimalHandlers = useRestrictedNumberInput({
type: "decimal",
maxIntegerPoinsts: restrictedNumberInputParams.maxIntegerPoinsts,
maxDecimalPoints: restrictedNumberInputParams.maxDecimalPoints,
onChange: field.onChange,
...restrictedNumberInputParams,
});

const numberHandlers = useRestrictedNumberInput({
type: "integer",
maxIntegerPoinsts: 7,
maxIntegerPoints: 7,
maxDecimalPoints: 0,
onChange: field.onChange,
});
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/forms/NumberInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const NumberInput = ({

const handlers = useRestrictedNumberInput({
type: "integer",
maxIntegerPoinsts: 7,
maxIntegerPoints: 7,
maxDecimalPoints: 0,
onChange: inputOnChange,
});
Expand Down
2 changes: 1 addition & 1 deletion src/lib/services/account/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const useAccountBech32 = (
endpoint: string
): UseQueryResult<AccountBech32LcdResponse> =>
useQuery(
[CELATONE_QUERY_KEYS.ACCOUNT_BECH_32],
[CELATONE_QUERY_KEYS.ACCOUNT_BECH_32_LCD],
async () => getAccountBech32Lcd(endpoint),
{
retry: 1,
Expand Down