Skip to content

Commit

Permalink
add loading
Browse files Browse the repository at this point in the history
  • Loading branch information
domechn committed Nov 18, 2023
1 parent 3a0909c commit 583adf9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/components/configuration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ const App = ({ onConfigurationSave }: { onConfigurationSave?: () => void }) => {
const [addOtherDialogOpen, setAddOtherDialogOpen] = useState(false);

const [saveCexConfigLoading, setSaveCexConfigLoading] = useState(false);
const [saveWalletConfigLoading, setSaveWalletConfigLoading] = useState(false);

const [addExchangeConfig, setAddExchangeConfig] = useState<
| {
Expand Down Expand Up @@ -834,6 +835,7 @@ const App = ({ onConfigurationSave }: { onConfigurationSave?: () => void }) => {
});
return;
}
setSaveWalletConfigLoading(true);
validateWalletAddress(addWalletConfig.type, addWalletConfig.address)
.then((valid) => {
if (!valid) {
Expand All @@ -856,7 +858,8 @@ const App = ({ onConfigurationSave }: { onConfigurationSave?: () => void }) => {
description: e.message ?? e,
variant: "destructive",
});
});
})
.finally(() => setSaveWalletConfigLoading(false));
}

function renderAddWalletForm() {
Expand Down Expand Up @@ -935,7 +938,14 @@ const App = ({ onConfigurationSave }: { onConfigurationSave?: () => void }) => {
</div>
</div>
<DialogFooter>
<Button type="submit" onClick={onAddWalletFormSubmit}>
<Button
type="submit"
onClick={onAddWalletFormSubmit}
disabled={saveWalletConfigLoading}
>
{saveWalletConfigLoading && (
<ReloadIcon className="mr-2 h-4 w-4 animate-spin" />
)}
Save changes
</Button>
</DialogFooter>
Expand Down

0 comments on commit 583adf9

Please sign in to comment.