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 empty states for select code modal #147

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

### Improvements

- [#147](https://github.com/alleslabs/celatone-frontend/pull/147) Add empty state for select code modal
- [#140](https://github.com/alleslabs/celatone-frontend/pull/140) Add placeholder texts to upload&instantiate, save code, and save&edit contract
- [#139](https://github.com/alleslabs/celatone-frontend/pull/139) Fix Date to Dayjs
- [#135](https://github.com/alleslabs/celatone-frontend/pull/135) Invalidate queries after update/clear admin tx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import { IoList } from "react-icons/io5";

import { useCodeListData } from "lib/pages/codes/data";

import { CodeTableReadOnly } from "./CodeTableReadOnly";
import { MySavedCodeContent } from "./MySavedCodeContent";
import { MyStoredCodeContent } from "./MyStoredCodeContent";

interface CodeSelectModalButtonProps {
onCodeSelect: (code: string) => void;
Expand Down Expand Up @@ -67,9 +68,9 @@ export const CodeSelectModalButton = ({
<Text variant="body1" fontWeight={700} ml="24px" mb="16px">
My Stored Codes
</Text>
<CodeTableReadOnly
onCodeSelect={handleSelect}
codes={storedCodes}
<MyStoredCodeContent
storedCodes={storedCodes}
handleSelect={handleSelect}
/>
<Text
variant="body1"
Expand All @@ -80,7 +81,10 @@ export const CodeSelectModalButton = ({
>
Saved Codes
</Text>
<CodeTableReadOnly onCodeSelect={handleSelect} codes={savedCodes} />
<MySavedCodeContent
savedCodes={savedCodes}
handleSelect={handleSelect}
/>
</ModalBody>
</ModalContent>
</Modal>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Flex } from "@chakra-ui/react";

import { EmptyState } from "lib/components/state/EmptyState";
import type { CodeInfo } from "lib/types";

import { CodeTableReadOnly } from "./CodeTableReadOnly";

interface MySavedCodeContentProps {
handleSelect: (code: string) => void;
savedCodes: CodeInfo[];
}

export const MySavedCodeContent = ({
handleSelect,
savedCodes,
}: MySavedCodeContentProps) => {
if (!savedCodes.length) {
return (
<Flex
py="64px"
direction="column"
borderY="1px solid"
borderColor="divider.main"
>
<EmptyState message="You don’t have any saved codes in this device." />
</Flex>
);
}
return <CodeTableReadOnly onCodeSelect={handleSelect} codes={savedCodes} />;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { Flex, Text } from "@chakra-ui/react";
import { useWallet } from "@cosmos-kit/react";

import { ConnectWalletBtn } from "lib/components/button";
import { EmptyState } from "lib/components/state/EmptyState";
import type { CodeInfo } from "lib/types";

import { CodeTableReadOnly } from "./CodeTableReadOnly";

interface MyStoredCodeContentProps {
handleSelect: (code: string) => void;
storedCodes: CodeInfo[];
}

export const MyStoredCodeContent = ({
handleSelect,
storedCodes,
}: MyStoredCodeContentProps) => {
const { address } = useWallet();
if (!address) {
return (
<Flex
align="center"
py="64px"
direction="column"
gap={2}
borderY="1px solid"
borderColor="divider.main"
>
<Text variant="body1" color="gray.500">
Connect your wallet to upload and see your stored Codes.
</Text>
<ConnectWalletBtn />
</Flex>
);
}

if (!storedCodes.length) {
return (
<Flex
py="64px"
direction="column"
borderY="1px solid"
borderColor="divider.main"
>
<EmptyState message="You don’t have any stored codes." />
</Flex>
);
}
return <CodeTableReadOnly onCodeSelect={handleSelect} codes={storedCodes} />;
};