Configure to a hub in AirDC++ and then select a default hub here.
import React, { ReactElement, useState } from "react"; import { Form, Field } from "react-final-form"; import { isEmpty, isNil, isUndefined } from "lodash"; import Select from "react-select"; import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"; import axios from "axios"; import { produce } from "immer"; import { AIRDCPP_SERVICE_BASE_URI } from "../../../constants/endpoints"; export const AirDCPPHubsForm = (): ReactElement => { const queryClient = useQueryClient(); const { data: settings, isLoading, isError, refetch, } = useQuery({ queryKey: ["settings"], queryFn: async () => await axios({ url: "http://localhost:3000/api/settings/getAllSettings", method: "GET", }), staleTime: Infinity, }); const { data: hubs } = useQuery({ queryKey: ["hubs"], queryFn: async () => await axios({ url: `${AIRDCPP_SERVICE_BASE_URI}/getHubs`, method: "POST", data: { host: settings?.data.directConnect?.client?.host, }, }), enabled: !isEmpty(settings?.data.directConnect?.client?.host), }); let hubList: any[] = []; if (!isNil(hubs)) { hubList = hubs?.data.map(({ hub_url, identity }) => ({ value: hub_url, label: identity.name, })); } const mutation = useMutation({ mutationFn: async (values) => await axios({ url: `http://localhost:3000/api/settings/saveSettings`, method: "POST", data: { settingsPayload: values, settingsObjectId: settings?.data._id, settingsKey: "directConnect", }, }), onSuccess: (data) => { queryClient.setQueryData(["settings"], (oldData: any) => produce(oldData, (draft: any) => { draft.data.directConnect.client = { ...draft.data.directConnect.client, ...data.data.directConnect.client, }; }), ); }, }); const validate = async (values) => { const errors = {}; // Add any validation logic here if needed return errors; }; const SelectAdapter = ({ input, ...rest }) => { return ; }; if (isLoading) { return