Skip to content

Commit

Permalink
feat(dashboard): add refetch functionality to AssetDialog for updated…
Browse files Browse the repository at this point in the history
… asset data
  • Loading branch information
panteleymonchuk committed Dec 18, 2024
1 parent 146dee8 commit 7aaa4b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions apps/wallet-dashboard/app/(protected)/assets/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function AssetsDashboardPage(): React.JSX.Element {
const [selectedAsset, setSelectedAsset] = useState<IotaObjectData | null>(null);
const [selectedCategory, setSelectedCategory] = useState<AssetCategory>(AssetCategory.Visual);
const account = useCurrentAccount();
const { data, isFetching, fetchNextPage, hasNextPage } = useGetOwnedObjects(
const { data, isFetching, fetchNextPage, hasNextPage, refetch } = useGetOwnedObjects(
account?.address,
undefined,
OBJECTS_PER_REQ,
Expand Down Expand Up @@ -79,7 +79,11 @@ export default function AssetsDashboardPage(): React.JSX.Element {
fetchNextPage={fetchNextPage}
/>
{selectedAsset && (
<AssetDialog onClose={() => setSelectedAsset(null)} asset={selectedAsset} />
<AssetDialog
onClose={() => setSelectedAsset(null)}
asset={selectedAsset}
refetchAssets={refetch}
/>
)}
</div>
</Panel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { DialogLayout } from '../layout';
interface AssetsDialogProps {
onClose: () => void;
asset: IotaObjectData;
refetchAssets: () => void;
}

interface FormValues {
Expand All @@ -27,7 +28,7 @@ const INITIAL_VALUES: FormValues = {
to: '',
};

export function AssetDialog({ onClose, asset }: AssetsDialogProps): JSX.Element {
export function AssetDialog({ onClose, asset, refetchAssets }: AssetsDialogProps): JSX.Element {
const [view, setView] = useState<AssetsDialogView>(AssetsDialogView.Details);
const account = useCurrentAccount();
const [digest, setDigest] = useState<string>('');
Expand Down Expand Up @@ -55,6 +56,7 @@ export function AssetDialog({ onClose, asset }: AssetsDialogProps): JSX.Element
});

setDigest(tx.digest);
refetchAssets();
addNotification('Transfer transaction successful', NotificationType.Success);
setView(AssetsDialogView.TransactionDetails);
} catch {
Expand Down

0 comments on commit 7aaa4b8

Please sign in to comment.