Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
toddkao committed Sep 13, 2024
1 parent 36c8464 commit 0ea913c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
10 changes: 1 addition & 9 deletions packages/widget-v2/src/pages/SwapPage/SwapPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,9 @@ export const SwapPage = () => {
const setSwapDirection = useSetAtom(swapDirectionAtom);
const [{ data: assets }] = useAtom(skipAssetsAtom);
const [{ data: chains }] = useAtom(skipChainsAtom);
const { isLoading: isRouteLoading, isError: isRouteError, error: routeError, dataUpdatedAt } = useAtomValue(skipRouteAtom);
const { isLoading: isRouteLoading, isError: isRouteError, error: routeError } = useAtomValue(skipRouteAtom);
const swapFlowSettings = useModal(SwapPageSettings);
const tokenAndChainSelectorFlow = useModal(TokenAndChainSelectorModal);
const [isWaitingForNewRouteRequest, setIsWaitingForNewRouteRequest] = useAtom(isWaitingForNewRouteRequestAtom);

// useEffect(() => {
// if (dataUpdatedAt) {
// console.log(dataUpdatedAt);
// setIsWaitingForNewRouteRequest(false);
// }
// }, [dataUpdatedAt, setIsWaitingForNewRouteRequest]);

const sourceDetails = useGetAssetDetails({
assetDenom: sourceAsset?.denom,
Expand Down
13 changes: 8 additions & 5 deletions packages/widget-v2/src/stories/Widget.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ import { defaultTheme, lightTheme, Theme } from "@/widget/theme";
import NiceModal from "@ebay/nice-modal-react";
import { styled } from "styled-components";
import { ReactElement, useEffect } from "react";
import { destinationAssetAtom, sourceAssetAtom } from "@/state/swapPage";
import { useAtom } from "jotai";
import { destinationAssetAtom, sourceAssetAmount, sourceAssetAtom } from "@/state/swapPage";
import { useAtom, useSetAtom } from "jotai";
import { skipAssetsAtom } from "@/state/skipClient";

type Props = SwapWidgetProps & { theme: Theme; button?: ReactElement };

export const Widget = (props: Props) => {
const [, setSourceAsset] = useAtom(sourceAssetAtom);
const [, setDestinationAsset] = useAtom(destinationAssetAtom);
const setSourceAsset = useSetAtom(sourceAssetAtom);
const setDestinationAsset = useSetAtom(destinationAssetAtom);
const setSourceAssetAmount = useSetAtom(sourceAssetAmount);


const [{ data: assets }] = useAtom(skipAssetsAtom);

Expand All @@ -24,7 +26,8 @@ export const Widget = (props: Props) => {
useEffect(() => {
setSourceAsset(sourceAsset);
setDestinationAsset(destinationAsset);
}, [destinationAsset, setDestinationAsset, setSourceAsset, sourceAsset]);
setSourceAssetAmount("1");
}, [destinationAsset, setDestinationAsset, setSourceAsset, setSourceAssetAmount, sourceAsset]);

return <SwapWidget {...props} key={props.theme.primary.background.normal} />;
};
Expand Down

0 comments on commit 0ea913c

Please sign in to comment.