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: default list #166

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

### Bug fixes

- [#166](https://github.com/alleslabs/celatone-frontend/pull/166) Change default list when editing contract information
- [#164](https://github.com/alleslabs/celatone-frontend/pull/164) Add observer in code details page
- [#151](https://github.com/alleslabs/celatone-frontend/pull/151) Fix state reset on clicking wallet button
- [#158](https://github.com/alleslabs/celatone-frontend/pull/158) Change dayjs back to Date type as it is incompatible with mobx storage
Expand Down
5 changes: 2 additions & 3 deletions src/lib/components/modal/contract/AddToOtherList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { MdBookmark } from "react-icons/md";
import { ExplorerLink } from "lib/components/ExplorerLink";
import { ListSelection } from "lib/components/forms/ListSelection";
import { ActionModal } from "lib/components/modal/ActionModal";
import { DEFAULT_LIST } from "lib/data";
import { useHandleContractSave } from "lib/hooks/useHandleSave";
import type { ContractLocalInfo } from "lib/stores/contract";
import type { LVPair } from "lib/types";
Expand All @@ -18,7 +17,7 @@ interface AddToOtherListProps {

export const AddToOtherList = observer(
({ contractLocalInfo, triggerElement }: AddToOtherListProps) => {
const [contractLists, setContractLists] = useState<LVPair[]>(DEFAULT_LIST);
const [contractLists, setContractLists] = useState<LVPair[]>([]);

const handleSave = useHandleContractSave({
title: "Action Complete!",
Expand All @@ -30,7 +29,7 @@ export const AddToOtherList = observer(

useEffect(() => {
setContractLists(
contractLocalInfo.lists?.length ? contractLocalInfo.lists : DEFAULT_LIST
contractLocalInfo.lists?.length ? contractLocalInfo.lists : []
);
}, [contractLocalInfo.lists]);

Expand Down
6 changes: 4 additions & 2 deletions src/lib/components/modal/contract/ContractDetailsTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { ExplorerLink } from "lib/components/ExplorerLink";
import { ActionModal } from "lib/components/modal/ActionModal";
import type { OffchainDetail } from "lib/components/OffChainForm";
import { OffChainForm } from "lib/components/OffChainForm";
import { DEFAULT_LIST } from "lib/data";
import { useHandleContractSave } from "lib/hooks/useHandleSave";
import type { ContractLocalInfo } from "lib/stores/contract";
import type { LVPair } from "lib/types";
Expand All @@ -17,25 +16,28 @@ interface ContractDetailsTemplateProps {
subtitle?: string;
contractLocalInfo: ContractLocalInfo;
triggerElement: JSX.Element;
defaultList?: LVPair[];
}
export const ContractDetailsTemplate = ({
title,
subtitle,
contractLocalInfo,
triggerElement,
defaultList = [],
}: ContractDetailsTemplateProps) => {
const defaultValues = useMemo(() => {
return {
name: contractLocalInfo.name ?? "",
description: getDescriptionDefault(contractLocalInfo.description),
tags: getTagsDefault(contractLocalInfo.tags),
lists: contractLocalInfo.lists ?? DEFAULT_LIST,
lists: contractLocalInfo.lists ?? defaultList,
};
}, [
contractLocalInfo.description,
contractLocalInfo.lists,
contractLocalInfo.name,
contractLocalInfo.tags,
defaultList,
]);

const {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/components/modal/contract/SaveContractDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DEFAULT_LIST } from "lib/data";
import type { ContractLocalInfo } from "lib/stores/contract";

import { ContractDetailsTemplate } from "./ContractDetailsTemplate";
Expand All @@ -14,5 +15,6 @@ export const SaveContractDetails = ({
title="Save Contract Details"
contractLocalInfo={contractLocalInfo}
triggerElement={triggerElement}
defaultList={DEFAULT_LIST}
/>
);
1 change: 1 addition & 0 deletions src/lib/components/state/ZeroState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const ActionSection = ({ list, handleAction }: ActionSectionProps) =>
<Flex align="center">
Save existing contracts to the list with
<SaveNewContract
key={list.value}
list={list}
buttonProps={{
variant: "outline-primary",
Expand Down