From 62dd4fdbf99d037cb2ca1e79b3ad07a69150db7c Mon Sep 17 00:00:00 2001 From: Joshen Lim Date: Wed, 1 Feb 2023 14:11:04 +0800 Subject: [PATCH] Update --- .../NetworkRestrictions/AddRestrictionModal.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx b/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx index 1187bcc8a3b..c3039d22494 100644 --- a/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx +++ b/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx @@ -1,4 +1,4 @@ -import { FC } from 'react' +import { FC, useState } from 'react' import { Address4 } from 'ip-address' import { Button, Form, IconHelpCircle, Input, Modal } from 'ui' import * as Tooltip from '@radix-ui/react-tooltip' @@ -104,7 +104,10 @@ const AddRestrictionModal: FC = ({ const isValidCIDR = isValidBlockSize && !isPrivate && addressRange !== undefined + const [isFetchingAddress, setIsFetchingAddress] = useState(false) + const getClientIpAddress = async () => { + setIsFetchingAddress(true) const res = await fetch('http://www.geoplugin.net/json.gp', { method: 'GET' }) const { geoplugin_request } = await res.json() @@ -118,6 +121,7 @@ const AddRestrictionModal: FC = ({ message: 'Failed to retrieve client IP address, please enter address manually', }) } + setIsFetchingAddress(false) } return ( @@ -142,7 +146,7 @@ const AddRestrictionModal: FC = ({ className="" /> -
+
@@ -179,12 +183,14 @@ const AddRestrictionModal: FC = ({ />
-

getClientIpAddress()} > Use my IP address -

+