mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-30 14:21:04 +00:00
feat: navigate back if request fails for get user
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { UserProfile } from "@types";
|
import { UserProfile } from "@types";
|
||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
import { useParams } from "react-router-dom";
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
import { setHeaderTitle } from "@renderer/features";
|
import { setHeaderTitle } from "@renderer/features";
|
||||||
import { useAppDispatch } from "@renderer/hooks";
|
import { useAppDispatch } from "@renderer/hooks";
|
||||||
import { UserSkeleton } from "./user-skeleton";
|
import { UserSkeleton } from "./user-skeleton";
|
||||||
@@ -12,6 +12,7 @@ import * as styles from "./user.css";
|
|||||||
export const User = () => {
|
export const User = () => {
|
||||||
const { userId } = useParams();
|
const { userId } = useParams();
|
||||||
const [userProfile, setUserProfile] = useState<UserProfile>();
|
const [userProfile, setUserProfile] = useState<UserProfile>();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
@@ -20,6 +21,8 @@ export const User = () => {
|
|||||||
if (userProfile) {
|
if (userProfile) {
|
||||||
dispatch(setHeaderTitle(userProfile.displayName));
|
dispatch(setHeaderTitle(userProfile.displayName));
|
||||||
setUserProfile(userProfile);
|
setUserProfile(userProfile);
|
||||||
|
} else {
|
||||||
|
navigate(-1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [dispatch, userId]);
|
}, [dispatch, userId]);
|
||||||
|
|||||||
Reference in New Issue
Block a user