Skip to content

Commit e4eb82f

Browse files
authored
Fix initial state of accounts showing empty (#286)
1 parent e0195e4 commit e4eb82f

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

renderer/components/SendMultisigLedgerAssetsFlow/Steps/GetUnsignedTransaction.tsx

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { defineMessages, useIntl } from "react-intl";
1313

1414
import octopus from "@/images/octopus.svg";
1515
import { WithExplanatorySidebar } from "@/layouts/WithExplanatorySidebar";
16-
import { trpcReact } from "@/providers/TRPCProvider";
16+
import { trpcReact, TRPCRouterOutputs } from "@/providers/TRPCProvider";
1717
import { Select } from "@/ui/Forms/Select/Select";
1818
import { TextareaInput } from "@/ui/Forms/TextareaInput/TextareaInput";
1919
import { PillButton } from "@/ui/PillButton/PillButton";
@@ -122,11 +122,33 @@ function InputUnsignedTransaction({
122122
onSubmit: (unsignedTransaction: string, selectedAccount: string) => void;
123123
}) {
124124
const accounts = trpcReact.getMultisigLedgerAccounts.useQuery();
125-
const accountsData = accounts.data;
126125

126+
if (accounts.isLoading) {
127+
return "Loading Accounts...";
128+
}
129+
130+
if (accounts.isError) {
131+
return `Error loading accounts ${accounts.error.message}`;
132+
}
133+
134+
return (
135+
<InputUnsignedTransactionWithAccounts
136+
onSubmit={onSubmit}
137+
accountsData={accounts.data}
138+
/>
139+
);
140+
}
141+
142+
function InputUnsignedTransactionWithAccounts({
143+
onSubmit,
144+
accountsData,
145+
}: {
146+
onSubmit: (unsignedTransaction: string, selectedAccount: string) => void;
147+
accountsData: TRPCRouterOutputs["getMultisigLedgerAccounts"];
148+
}) {
127149
const [unsignedTransaction, setUnsignedTransaction] = useState("");
128150
const [selectedAccount, setSelectedAccount] = useState<string | null>(
129-
accounts.data?.[0]?.name ?? null,
151+
accountsData[0]?.name ?? null,
130152
);
131153

132154
const accountOptions = useMemo(() => {

0 commit comments

Comments
 (0)