Skip to content

Commit

Permalink
feat: toast error when connecting before synced to chain
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodylow committed Feb 2, 2024
1 parent 8010d76 commit e00ffba
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/client/src/views/fedimints/AddMint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,21 @@ import {
import { ColorButton } from '../../components/buttons/colorButton/ColorButton';
import { gatewayApi } from '../../api/GatewayApi';
import { useGatewayDispatch } from '../../context/GatewayContext';
import { useNodeInfo } from '../../hooks/UseNodeInfo';

export const AddMint = () => {
const gatewayDispatch = useGatewayDispatch();
const [isAdding, setIsAdding] = useState<boolean>(false);
const [inviteCode, setInviteCode] = useState<string>('');
const { syncedToChain } = useNodeInfo();

const handleEnter = () => {
if (!syncedToChain) {
toast.error(
'Node not synced to chain yet, cannot connect to federation.'
);
return;
}
gatewayApi.connectFederation(inviteCode).then(() => {
gatewayApi
.fetchInfo()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { useGatewayDispatch } from '../../../../context/GatewayContext';
import { gatewayApi } from '../../../../api/GatewayApi';
import { GatewayInfo } from '../../../../api/types';
import { useGatewayEcashTotalSats } from '../../../../hooks/UseGatewayEcashTotal';
import { useNodeInfo } from '../../../../hooks/UseNodeInfo';

interface FedimintGatewayCardProps {
gatewayInfo: GatewayInfo;
Expand All @@ -30,8 +31,16 @@ export const FedimintGatewayCard = ({
const gatewayDispath = useGatewayDispatch();
const [inviteCode, setInviteCode] = useState('');
const totalFedimintEcash = useGatewayEcashTotalSats();
const { syncedToChain } = useNodeInfo();

const handleEnter = () => {
if (!syncedToChain) {
toast.error(
'Node not synced to chain yet, cannot connect to federation.'
);
return;
}

gatewayApi.connectFederation(inviteCode).then(() => {
gatewayApi
.fetchInfo()
Expand Down

0 comments on commit e00ffba

Please sign in to comment.