mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-01-23 21:44:55 +03:00
feat: update with user endpoint changes
This commit is contained in:
parent
6b2549ed13
commit
d05150a078
@ -15,16 +15,16 @@ export const downloadSourceSchema = z.object({
|
|||||||
|
|
||||||
const gamesArray = z.array(
|
const gamesArray = z.array(
|
||||||
z.object({
|
z.object({
|
||||||
id: z.number(),
|
id: z.string().length(8),
|
||||||
objectId: z.string().max(255),
|
objectId: z.string().max(255),
|
||||||
playTimeInMilliseconds: z.number().int(),
|
playTimeInSeconds: z.number().int(),
|
||||||
shop: z.enum(["steam", "epic"]),
|
shop: z.enum(["steam", "epic"]),
|
||||||
lastTimePlayed: z.coerce.date().nullable(),
|
lastTimePlayed: z.coerce.date().nullable(),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
export const userProfileSchema = z.object({
|
export const userProfileSchema = z.object({
|
||||||
username: z.string(),
|
displayName: z.string(),
|
||||||
libraryGames: gamesArray,
|
libraryGames: gamesArray,
|
||||||
recentGames: gamesArray,
|
recentGames: gamesArray,
|
||||||
});
|
});
|
||||||
|
@ -12,7 +12,7 @@ const getUserProfile = async (
|
|||||||
username: string
|
username: string
|
||||||
): Promise<UserProfile | null> => {
|
): Promise<UserProfile | null> => {
|
||||||
try {
|
try {
|
||||||
const response = await HydraApi.get(`/profile/${username}`);
|
const response = await HydraApi.get(`/user/${username}`);
|
||||||
const profile = userProfileSchema.parse(response.data);
|
const profile = userProfileSchema.parse(response.data);
|
||||||
|
|
||||||
const recentGames = await Promise.all(
|
const recentGames = await Promise.all(
|
||||||
|
@ -144,7 +144,7 @@ export function Sidebar() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleClickProfile = () => {
|
const handleClickProfile = () => {
|
||||||
navigate("/profile/zamitto");
|
navigate("/profile/pmbk5ezJ");
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -12,13 +12,13 @@ export const ProfileContent = ({ userProfile }: ProfileContentProps) => {
|
|||||||
<>
|
<>
|
||||||
<section className={styles.profileContentBox}>
|
<section className={styles.profileContentBox}>
|
||||||
<img
|
<img
|
||||||
alt={userProfile.username + " profile image"}
|
alt={userProfile.displayName + " profile image"}
|
||||||
className={styles.profileAvatar}
|
className={styles.profileAvatar}
|
||||||
src="https://cdn.losbroxas.org/3918aa27-9b96-4fdf-b066-4c545d6667ab.png"
|
src="https://cdn.losbroxas.org/3918aa27-9b96-4fdf-b066-4c545d6667ab.png"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className={styles.profileInformation}>
|
<div className={styles.profileInformation}>
|
||||||
<h3 style={{ fontWeight: "bold" }}>{userProfile.username}</h3>
|
<h2 style={{ fontWeight: "bold" }}>{userProfile.displayName}</h2>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@ -51,14 +51,18 @@ export const ProfileContent = ({ userProfile }: ProfileContentProps) => {
|
|||||||
>
|
>
|
||||||
{userProfile.recentGames.map((game) => {
|
{userProfile.recentGames.map((game) => {
|
||||||
return (
|
return (
|
||||||
<div key={game.objectID}>
|
<div key={game.objectID} className={styles.feedItem}>
|
||||||
<img
|
<img
|
||||||
|
className={styles.gameIcon}
|
||||||
src={game.iconUrl}
|
src={game.iconUrl}
|
||||||
width={50}
|
width={50}
|
||||||
height={50}
|
height={50}
|
||||||
alt={"Icon for " + game.title}
|
alt={"Icon for " + game.title}
|
||||||
/>
|
/>
|
||||||
<p>{game.title}</p>
|
<div className={styles.gameInformation}>
|
||||||
|
<p>{game.title}</p>
|
||||||
|
<p>há 3 horas</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@ -92,14 +96,18 @@ export const ProfileContent = ({ userProfile }: ProfileContentProps) => {
|
|||||||
>
|
>
|
||||||
{userProfile.libraryGames.map((game) => {
|
{userProfile.libraryGames.map((game) => {
|
||||||
return (
|
return (
|
||||||
<div key={game.objectID}>
|
<div key={game.objectID} className={styles.gameListItem}>
|
||||||
<img
|
<img
|
||||||
|
className={styles.gameIcon}
|
||||||
src={game.iconUrl}
|
src={game.iconUrl}
|
||||||
width={50}
|
width={50}
|
||||||
height={50}
|
height={50}
|
||||||
alt={"Icon for " + game.title}
|
alt={"Icon for " + game.title}
|
||||||
/>
|
/>
|
||||||
<p>{game.title}</p>
|
<div className={styles.gameInformation}>
|
||||||
|
<p>{game.title}</p>
|
||||||
|
<p>Jogou por 10 horas</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
@ -36,10 +36,6 @@ export const profileInformation = style({
|
|||||||
alignItems: "flex-start",
|
alignItems: "flex-start",
|
||||||
});
|
});
|
||||||
|
|
||||||
export const profileHeaderSkeleton = style({
|
|
||||||
height: "200px",
|
|
||||||
});
|
|
||||||
|
|
||||||
export const profileContent = style({
|
export const profileContent = style({
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
@ -70,3 +66,37 @@ export const contentSidebar = style({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const gameIcon = style({
|
||||||
|
width: "48px",
|
||||||
|
height: "48px",
|
||||||
|
borderRadius: "50%",
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
position: "relative",
|
||||||
|
});
|
||||||
|
|
||||||
|
export const feedItem = style({
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "row",
|
||||||
|
gap: `${SPACING_UNIT}px`,
|
||||||
|
width: "100%",
|
||||||
|
});
|
||||||
|
|
||||||
|
export const gameListItem = style({
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "row",
|
||||||
|
gap: `${SPACING_UNIT}px`,
|
||||||
|
width: "100%",
|
||||||
|
});
|
||||||
|
|
||||||
|
export const gameInformation = style({
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
alignItems: "flex-start",
|
||||||
|
});
|
||||||
|
|
||||||
|
export const profileHeaderSkeleton = style({
|
||||||
|
height: "200px",
|
||||||
|
});
|
||||||
|
@ -18,7 +18,7 @@ export const Profile = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
window.electron.getUserProfile(username!).then((userProfile) => {
|
window.electron.getUserProfile(username!).then((userProfile) => {
|
||||||
if (userProfile) {
|
if (userProfile) {
|
||||||
dispatch(setHeaderTitle(userProfile.username));
|
dispatch(setHeaderTitle(userProfile.displayName));
|
||||||
setUserProfile(userProfile);
|
setUserProfile(userProfile);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -243,7 +243,7 @@ export interface RealDebridUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface UserProfile {
|
export interface UserProfile {
|
||||||
username: string;
|
displayName: string;
|
||||||
libraryGames: ProfileGame[];
|
libraryGames: ProfileGame[];
|
||||||
recentGames: ProfileGame[];
|
recentGames: ProfileGame[];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user