Skip to content

Commit

Permalink
fix: improve error messages when UPF/gnB lists are empty (#692)
Browse files Browse the repository at this point in the history
Signed-off-by: Dario Faccin <[email protected]>
  • Loading branch information
dariofaccin authored Dec 18, 2024
1 parent 12c2f1b commit 369bc90
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions components/NetworkSliceModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,35 +124,39 @@ const NetworkSliceModal = ({ networkSlice, toggleModal }: NetworkSliceModalProps
},
});

const { data: upfList = [], isLoading: isUpfLoading } = useQuery({
const { data: upfList = [], isLoading: isUpfLoading, isError: isUpfError } = useQuery({
queryKey: [queryKeys.upfList, auth.user?.authToken],
queryFn: () => getUpfList(auth.user ? auth.user.authToken : ""),
enabled: auth.user ? true : false,
});

useEffect(() => {
const checkUpfList = async () => {
if (!isUpfLoading && upfList.length === 0) {
setUpfApiError("Failed to retrieve the list of UPFs from the server.");
if (isUpfError) {
setUpfApiError("Failed to retrieve the list of UPFs from the server.")
} else if (!isUpfLoading && upfList.length === 0) {
setUpfApiError("No available UPF. Please add at least one UPF.");
}
};
checkUpfList();
}, [isUpfLoading, upfList]);
}, [isUpfLoading, isUpfError, upfList]);

const { data: gnbList = [], isLoading: isGnbLoading } = useQuery({
const { data: gnbList = [], isLoading: isGnbLoading, isError: isGnbError } = useQuery({
queryKey: [queryKeys.gnbList, auth.user?.authToken],
queryFn: () => getGnbList(auth.user ? auth.user.authToken : ""),
enabled: auth.user ? true : false,
});

useEffect(() => {
const checkGnbList = async () => {
if (!isGnbLoading && gnbList.length === 0) {
setGnbApiError("Failed to retrieve the list of GNBs from the server.");
if (isGnbError) {
setGnbApiError("Failed to retrieve the list of GNBs from the server.")
} else if (!isGnbLoading && gnbList.length === 0) {
setGnbApiError("No available GNB. Please add at least one GNB.");
}
};
checkGnbList();
}, [isGnbLoading, gnbList]);
}, [isGnbLoading, isGnbError, gnbList]);

const handleUpfChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
const upf = upfList.find(
Expand Down

0 comments on commit 369bc90

Please sign in to comment.