Skip to content

Commit

Permalink
refactor(wallet-dashboard): rename handler functions for consistency …
Browse files Browse the repository at this point in the history
…and clarity
  • Loading branch information
panteleymonchuk committed Nov 28, 2024
1 parent 7bd0c26 commit 61a13f8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
11 changes: 6 additions & 5 deletions apps/wallet-dashboard/app/(protected)/assets/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const ASSET_CATEGORIES: { label: string; value: AssetCategory }[] = [

export default function AssetsDashboardPage(): React.JSX.Element {
const [view, setView] = useState<AssetsDialogView | undefined>(AssetsDialogView.Details);
const [selectedCategory, setSelectedCategory] = useState<AssetCategory>(AssetCategory.Visual);
const [selectedAsset, setSelectedAsset] = useState<IotaObjectData | null>(null);
const [selectedCategory, setSelectedCategory] = useState<AssetCategory>(AssetCategory.Visual);
const account = useCurrentAccount();
const { data, isFetching, fetchNextPage, hasNextPage } = useGetOwnedObjects(
account?.address,
Expand All @@ -52,13 +52,14 @@ export default function AssetsDashboardPage(): React.JSX.Element {
}
}

function handleClickAsset(asset: IotaObjectData) {
function onClickAsset(asset: IotaObjectData) {
setSelectedAsset(asset);
setView(AssetsDialogView.Details);
}

function handleCloseDialog() {
function onCloseDialog() {
setSelectedAsset(null);
setView(undefined);
}

return (
Expand All @@ -79,7 +80,7 @@ export default function AssetsDashboardPage(): React.JSX.Element {
<AssetList
assets={assets}
selectedCategory={selectedCategory}
onClick={handleClickAsset}
onClick={onClickAsset}
hasNextPage={hasNextPage}
isFetchingNextPage={isFetching}
fetchNextPage={fetchNextPage}
Expand All @@ -89,7 +90,7 @@ export default function AssetsDashboardPage(): React.JSX.Element {
view={view}
setView={setView}
isOpen={!!selectedAsset}
handleClose={handleCloseDialog}
onClose={onCloseDialog}
asset={selectedAsset}
/>
)}
Expand Down
14 changes: 5 additions & 9 deletions apps/wallet-dashboard/components/Dialogs/Assets/AssetsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { useRouter } from 'next/navigation';

interface AssetsDialogProps {
isOpen: boolean;
handleClose: () => void;
onClose: () => void;
asset: IotaObjectData | null;
view: AssetsDialogView;
setView: (view: AssetsDialogView | undefined) => void;
Expand All @@ -32,7 +32,7 @@ const INITIAL_VALUES: FormValues = {

export function AssetsDialog({
isOpen,
handleClose,
onClose,
asset,
setView,
view,
Expand All @@ -44,7 +44,7 @@ export function AssetsDialog({
const { addNotification } = useNotifications();
const validationSchema = createNftSendValidationSchema(activeAddress, objectId);

function handleDetailsSend() {
function onDetailsSend() {
setView(AssetsDialogView.Send);
}

Expand Down Expand Up @@ -87,15 +87,11 @@ export function AssetsDialog({
}

return (
<Dialog open={isOpen} onOpenChange={() => handleClose()}>
<Dialog open={isOpen} onOpenChange={() => onClose()}>
<FormikProvider value={formik}>
<>
{view === AssetsDialogView.Details && asset && (
<DetailsView
asset={asset}
handleClose={handleClose}
handleSend={handleDetailsSend}
/>
<DetailsView asset={asset} onClose={onClose} onSend={onDetailsSend} />
)}
{view === AssetsDialogView.Send && asset && (
<SendView asset={asset} onClose={onSendClose} onBack={onSendBack} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import { useCurrentAccount } from '@iota/dapp-kit';

interface DetailsViewProps {
asset: IotaObjectData;
handleClose: () => void;
handleSend: () => void;
onClose: () => void;
onSend: () => void;
}

export function DetailsView({ handleClose, asset, handleSend }: DetailsViewProps) {
export function DetailsView({ onClose, asset, onSend }: DetailsViewProps) {
const account = useCurrentAccount();

const senderAddress = account?.address ?? '';
Expand Down Expand Up @@ -53,7 +53,7 @@ export function DetailsView({ handleClose, asset, handleSend }: DetailsViewProps

return (
<Layout>
<Header title="Asset" onClose={handleClose} titleCentered />
<Header title="Asset" onClose={onClose} titleCentered />
<LayoutBody>
<div className="flex w-full flex-col items-center justify-center gap-xs">
<div className="w-[172px]">
Expand Down Expand Up @@ -174,12 +174,7 @@ export function DetailsView({ handleClose, asset, handleSend }: DetailsViewProps
/>
</div>
) : (
<Button
disabled={!isTransferable}
onClick={handleSend}
text="Send"
fullWidth
/>
<Button disabled={!isTransferable} onClick={onSend} text="Send" fullWidth />
)}
</div>
</LayoutFooter>
Expand Down

0 comments on commit 61a13f8

Please sign in to comment.