mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: navigate back if request fails for get user
This commit is contained in:
parent
1ceabb00be
commit
c27182c618
1 changed files with 4 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
|||
import { UserProfile } from "@types";
|
||||
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 { useAppDispatch } from "@renderer/hooks";
|
||||
import { UserSkeleton } from "./user-skeleton";
|
||||
|
@ -12,6 +12,7 @@ import * as styles from "./user.css";
|
|||
export const User = () => {
|
||||
const { userId } = useParams();
|
||||
const [userProfile, setUserProfile] = useState<UserProfile>();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
|
@ -20,6 +21,8 @@ export const User = () => {
|
|||
if (userProfile) {
|
||||
dispatch(setHeaderTitle(userProfile.displayName));
|
||||
setUserProfile(userProfile);
|
||||
} else {
|
||||
navigate(-1);
|
||||
}
|
||||
});
|
||||
}, [dispatch, userId]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue