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

Improve contract selection #508

Merged
merged 3 commits into from
Aug 29, 2023
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 @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Features

- [#508](https://github.com/alleslabs/celatone-frontend/pull/508) Add auto focus, enter key listener on contract selection
- [#492](https://github.com/alleslabs/celatone-frontend/pull/492) Add jsonschema actions on contract detail page
- [#486](https://github.com/alleslabs/celatone-frontend/pull/486) Switch to schema tab when available and prefill,expand,and scroll to the prefill msg
- [#483](https://github.com/alleslabs/celatone-frontend/pull/483) Add json schema functionality to execute page
Expand Down
30 changes: 21 additions & 9 deletions src/lib/components/select-contract/SelectContractInstantiator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import { useQuery } from "@tanstack/react-query";
import type { AxiosError } from "axios";
import { useState } from "react";
import type { KeyboardEvent } from "react";

import { CustomIcon } from "../icon";
import {
Expand Down Expand Up @@ -56,6 +57,8 @@ export const SelectContractInstantiator = ({

const { getContractLists } = useContractStore();

const isMobile = useMobile();

// TODO - Revisit false case
const { instantiatedListInfo, isLoading } = useInstantiatedByMe(true);
const contractLists = [instantiatedListInfo, ...getContractLists()];
Expand Down Expand Up @@ -98,7 +101,21 @@ export const SelectContractInstantiator = ({
setListSlug(slug);
};

const isMobile = useMobile();
const handleSubmit = () => {
const err = validateContractAddress(searchContract);
if (err !== null) setInvalid(err);
else {
AmpTrack(AmpEvent.USE_CONTRACT_MODAL_SEARCH);
refetch();
}
};

const handleKeydown = (event: KeyboardEvent<HTMLInputElement>) => {
if (event.key === "Enter") {
handleSubmit();
}
};

return (
<>
<Button
Expand Down Expand Up @@ -151,20 +168,15 @@ export const SelectContractInstantiator = ({
}}
placeholder={`ex. ${exampleContractAddress}`}
size="lg"
autoFocus
onKeyDown={handleKeydown}
/>
<Button
height="56px"
minW="72px"
isDisabled={searchContract.length === 0}
isLoading={isFetching || isRefetching}
onClick={() => {
const err = validateContractAddress(searchContract);
if (err !== null) setInvalid(err);
else {
AmpTrack(AmpEvent.USE_CONTRACT_MODAL_SEARCH);
refetch();
}
}}
onClick={handleSubmit}
>
Submit
</Button>
Expand Down