refactor(databases): show ip in external connection instead of hostname

This commit is contained in:
Mauricio Siu
2024-07-20 15:23:44 -06:00
parent 60d6d781be
commit f36de7b2f5
6 changed files with 14 additions and 8 deletions

View File

@@ -44,6 +44,7 @@ interface Props {
mongoId: string;
}
export const ShowExternalMongoCredentials = ({ mongoId }: Props) => {
const { data: ip } = api.settings.getIp.useQuery();
const { data, refetch } = api.mongo.one.useQuery({ mongoId });
const { mutateAsync, isLoading } = api.mongo.saveExternalPort.useMutation();
const [connectionUrl, setConnectionUrl] = useState("");
@@ -77,10 +78,9 @@ export const ShowExternalMongoCredentials = ({ mongoId }: Props) => {
useEffect(() => {
const buildConnectionUrl = () => {
const hostname = window.location.hostname;
const port = form.watch("externalPort") || data?.externalPort;
return `mongodb://${data?.databaseUser}:${data?.databasePassword}@${hostname}:${port}`;
return `mongodb://${data?.databaseUser}:${data?.databasePassword}@${ip}:${port}`;
};
setConnectionUrl(buildConnectionUrl());