Skip to content

Commit

Permalink
Merge pull request #251 from alleslabs/refactor/tables
Browse files Browse the repository at this point in the history
Refactor: tables
  • Loading branch information
songwongtp committed Mar 23, 2023
2 parents 9dc24ce + dd1315b commit df9dde1
Show file tree
Hide file tree
Showing 59 changed files with 1,062 additions and 1,391 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Improvements

- [#251](https://github.com/alleslabs/celatone-frontend/pull/251) Refactor Code and Contract tables into general components
- [#252](https://github.com/alleslabs/celatone-frontend/pull/252) Refactor Empty State image source logic
- [#249](https://github.com/alleslabs/celatone-frontend/pull/249) Change code table format in select code draw and add CW2 info
- [#247](https://github.com/alleslabs/celatone-frontend/pull/247) Refactor hover logic of copier icon
Expand Down
29 changes: 18 additions & 11 deletions src/lib/components/select-code/CodeSelectDrawerButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ import { CustomTab } from "../CustomTab";
import { FilterByPermission } from "../forms";
import { CustomIcon } from "../icon";
import InputWithIcon from "../InputWithIcon";
import { MySavedCodesTable, MyStoredCodesTable } from "../table";
import type { PermissionFilterValue } from "lib/hooks";
import { useMyCodesData } from "lib/model/code";
import { AmpEvent, AmpTrack } from "lib/services/amplitude";

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

interface CodeFilterState {
keyword: string;
permissionValue: PermissionFilterValue;
Expand Down Expand Up @@ -66,11 +64,13 @@ export const CodeSelectDrawerButton = ({
isSavedCodesLoading,
} = useMyCodesData(keyword, permissionValue);

const handleSelect = (code: string) => {
onCodeSelect(code);
const handleSelect = (codeId: number) => {
onCodeSelect(codeId.toString());
onClose();
};

const isSearching = !!keyword || permissionValue !== "all";

return (
<>
<Button
Expand Down Expand Up @@ -122,17 +122,24 @@ export const CodeSelectDrawerButton = ({
</TabList>
<TabPanels>
<TabPanel p={0}>
<MyStoredCodeContent
storedCodes={stored}
handleSelect={handleSelect}
<MyStoredCodesTable
codes={stored}
isLoading={isStoredCodesLoading}
onRowSelect={handleSelect}
emptyMessage="You don’t have any stored codes in this device."
disconnectedMessage="to see your stored code."
isSearching={isSearching}
isReadOnly
/>
</TabPanel>
<TabPanel p={0}>
<MySavedCodeContent
savedCodes={saved}
handleSelect={handleSelect}
<MySavedCodesTable
codes={saved}
isLoading={isSavedCodesLoading}
onRowSelect={handleSelect}
emptyMessage="You don’t have any saved codes in this device."
isSearching={isSearching}
isReadOnly
/>
</TabPanel>
</TabPanels>
Expand Down
96 changes: 0 additions & 96 deletions src/lib/components/select-code/CodesReadOnlyTable.tsx

This file was deleted.

27 changes: 0 additions & 27 deletions src/lib/components/select-code/MySavedCodeContent.tsx

This file was deleted.

45 changes: 0 additions & 45 deletions src/lib/components/select-code/MyStoredCodeContent.tsx

This file was deleted.

Loading

2 comments on commit df9dde1

@vercel
Copy link

@vercel vercel bot commented on df9dde1 Mar 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on df9dde1 Mar 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.