mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 08:43:48 +03:00
feat: redoing page
This commit is contained in:
parent
ea5b07a1ec
commit
2700f27d03
@ -51,7 +51,7 @@ const getAchievementLocalUser = async (shop: string, objectId: string) => {
|
|||||||
...achievementData,
|
...achievementData,
|
||||||
unlocked: false,
|
unlocked: false,
|
||||||
unlockTime: null,
|
unlockTime: null,
|
||||||
icon: icongray,
|
icongray: icongray,
|
||||||
} as UserAchievement;
|
} as UserAchievement;
|
||||||
})
|
})
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
|
@ -42,7 +42,9 @@ export const getGameAchievementData = async (
|
|||||||
where: { objectId, shop },
|
where: { objectId, shop },
|
||||||
})
|
})
|
||||||
.then((gameAchievements) => {
|
.then((gameAchievements) => {
|
||||||
return JSON.parse(gameAchievements?.achievements || "[]");
|
return JSON.parse(
|
||||||
|
gameAchievements?.achievements || "[]"
|
||||||
|
) as AchievementData[];
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -5,7 +5,7 @@ import { useContext, useEffect, useMemo, useRef, useState } from "react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import * as styles from "./achievements.css";
|
import * as styles from "./achievements.css";
|
||||||
import { formatDownloadProgress } from "@renderer/helpers";
|
import { formatDownloadProgress } from "@renderer/helpers";
|
||||||
import { PersonIcon, TrophyIcon } from "@primer/octicons-react";
|
import { LockIcon, PersonIcon, TrophyIcon } from "@primer/octicons-react";
|
||||||
import { SPACING_UNIT, vars } from "@renderer/theme.css";
|
import { SPACING_UNIT, vars } from "@renderer/theme.css";
|
||||||
import { gameDetailsContext } from "@renderer/context";
|
import { gameDetailsContext } from "@renderer/context";
|
||||||
import { UserAchievement } from "@types";
|
import { UserAchievement } from "@types";
|
||||||
@ -26,8 +26,8 @@ interface AchievementsContentProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface AchievementListProps {
|
interface AchievementListProps {
|
||||||
achievements: UserAchievement[];
|
user: UserInfo;
|
||||||
otherUserAchievements?: UserAchievement[];
|
otherUser: UserInfo | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AchievementPanelProps {
|
interface AchievementPanelProps {
|
||||||
@ -39,18 +39,6 @@ function AchievementPanel({ user, otherUser }: AchievementPanelProps) {
|
|||||||
const { t } = useTranslation("achievement");
|
const { t } = useTranslation("achievement");
|
||||||
const { userDetails } = useUserDetails();
|
const { userDetails } = useUserDetails();
|
||||||
|
|
||||||
const getProfileImage = (imageUrl: string | null | undefined) => {
|
|
||||||
return (
|
|
||||||
<div className={styles.profileAvatar}>
|
|
||||||
{imageUrl ? (
|
|
||||||
<img className={styles.profileAvatar} src={imageUrl} alt={"teste"} />
|
|
||||||
) : (
|
|
||||||
<PersonIcon size={24} />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const userTotalAchievementCount = user.achievements.length;
|
const userTotalAchievementCount = user.achievements.length;
|
||||||
const userUnlockedAchievementCount = user.achievements.filter(
|
const userUnlockedAchievementCount = user.achievements.filter(
|
||||||
(achievement) => achievement.unlocked
|
(achievement) => achievement.unlocked
|
||||||
@ -63,11 +51,9 @@ function AchievementPanel({ user, otherUser }: AchievementPanelProps) {
|
|||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
width: "100%",
|
width: "100%",
|
||||||
padding: `0 ${SPACING_UNIT * 2}px`,
|
|
||||||
gap: `${SPACING_UNIT * 2}px`,
|
gap: `${SPACING_UNIT * 2}px`,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{getProfileImage(user.profileImageUrl)}
|
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
@ -125,7 +111,7 @@ function AchievementPanel({ user, otherUser }: AchievementPanelProps) {
|
|||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
display: "grid",
|
display: "grid",
|
||||||
gridTemplateColumns: "3fr 1fr 1fr",
|
gridTemplateColumns: "2fr 1fr 1fr",
|
||||||
gap: `${SPACING_UNIT * 2}px`,
|
gap: `${SPACING_UNIT * 2}px`,
|
||||||
padding: `${SPACING_UNIT}px`,
|
padding: `${SPACING_UNIT}px`,
|
||||||
}}
|
}}
|
||||||
@ -221,19 +207,31 @@ function AchievementPanel({ user, otherUser }: AchievementPanelProps) {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>{getProfileImage(otherUser.profileImageUrl)}</div>
|
|
||||||
<div>{getProfileImage(user.profileImageUrl)}</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function AchievementList({
|
function AchievementList({ user, otherUser }: AchievementListProps) {
|
||||||
achievements,
|
const achievements = user.achievements;
|
||||||
otherUserAchievements,
|
const otherUserAchievements = otherUser?.achievements;
|
||||||
}: AchievementListProps) {
|
|
||||||
const { t } = useTranslation("achievement");
|
const { t } = useTranslation("achievement");
|
||||||
const { formatDateTime } = useDate();
|
const { formatDateTime } = useDate();
|
||||||
|
|
||||||
|
const { userDetails } = useUserDetails();
|
||||||
|
|
||||||
|
const getProfileImage = (imageUrl: string | null | undefined) => {
|
||||||
|
return (
|
||||||
|
<div className={styles.profileAvatar}>
|
||||||
|
{imageUrl ? (
|
||||||
|
<img className={styles.profileAvatar} src={imageUrl} alt={"teste"} />
|
||||||
|
) : (
|
||||||
|
<PersonIcon size={24} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
if (!otherUserAchievements || otherUserAchievements.length === 0) {
|
if (!otherUserAchievements || otherUserAchievements.length === 0) {
|
||||||
return (
|
return (
|
||||||
<ul className={styles.list}>
|
<ul className={styles.list}>
|
||||||
@ -273,7 +271,7 @@ function AchievementList({
|
|||||||
<li
|
<li
|
||||||
key={index}
|
key={index}
|
||||||
className={styles.listItem}
|
className={styles.listItem}
|
||||||
style={{ display: "grid", gridTemplateColumns: "3fr 1fr 1fr" }}
|
style={{ display: "grid", gridTemplateColumns: "2fr 1fr 1fr" }}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
@ -285,7 +283,7 @@ function AchievementList({
|
|||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
className={styles.listItemImage({
|
className={styles.listItemImage({
|
||||||
unlocked: otherUserAchievement.unlocked,
|
unlocked: true,
|
||||||
})}
|
})}
|
||||||
src={otherUserAchievement.icon}
|
src={otherUserAchievement.icon}
|
||||||
alt={otherUserAchievement.displayName}
|
alt={otherUserAchievement.displayName}
|
||||||
@ -300,22 +298,30 @@ function AchievementList({
|
|||||||
<div>
|
<div>
|
||||||
{otherUserAchievement.unlockTime ? (
|
{otherUserAchievement.unlockTime ? (
|
||||||
<div style={{ whiteSpace: "nowrap" }}>
|
<div style={{ whiteSpace: "nowrap" }}>
|
||||||
|
{getProfileImage(otherUser.profileImageUrl)}
|
||||||
<small>{t("unlocked_at")}</small>
|
<small>{t("unlocked_at")}</small>
|
||||||
<p>{formatDateTime(otherUserAchievement.unlockTime)}</p>
|
<p>{formatDateTime(otherUserAchievement.unlockTime)}</p>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
"Não desbloqueada"
|
<div>
|
||||||
|
<LockIcon />
|
||||||
|
<p>Não desbloqueada</p>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
{achievements[index].unlockTime ? (
|
{userDetails?.subscription && achievements[index].unlockTime ? (
|
||||||
<div style={{ whiteSpace: "nowrap" }}>
|
<div style={{ whiteSpace: "nowrap" }}>
|
||||||
|
{getProfileImage(user.profileImageUrl)}
|
||||||
<small>{t("unlocked_at")}</small>
|
<small>{t("unlocked_at")}</small>
|
||||||
<p>{formatDateTime(achievements[index].unlockTime)}</p>
|
<p>{formatDateTime(achievements[index].unlockTime)}</p>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
"Não desbloqueada"
|
<div>
|
||||||
|
<LockIcon />
|
||||||
|
<p>Não desbloqueada</p>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
@ -434,7 +440,7 @@ export function AchievementsContent({ otherUser }: AchievementsContentProps) {
|
|||||||
user={{
|
user={{
|
||||||
...userDetails,
|
...userDetails,
|
||||||
userId: userDetails.id,
|
userId: userDetails.id,
|
||||||
achievements: achievements!,
|
achievements: sortedAchievements,
|
||||||
}}
|
}}
|
||||||
otherUser={otherUser}
|
otherUser={otherUser}
|
||||||
/>
|
/>
|
||||||
@ -448,8 +454,12 @@ export function AchievementsContent({ otherUser }: AchievementsContentProps) {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<AchievementList
|
<AchievementList
|
||||||
achievements={sortedAchievements}
|
user={{
|
||||||
otherUserAchievements={otherUser?.achievements}
|
...userDetails,
|
||||||
|
userId: userDetails.id,
|
||||||
|
achievements: sortedAchievements,
|
||||||
|
}}
|
||||||
|
otherUser={otherUser}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
@ -72,8 +72,8 @@ export const container = style({
|
|||||||
export const panel = recipe({
|
export const panel = recipe({
|
||||||
base: {
|
base: {
|
||||||
width: "100%",
|
width: "100%",
|
||||||
height: "180px",
|
height: "150px",
|
||||||
minHeight: "180px",
|
minHeight: "150px",
|
||||||
padding: `${SPACING_UNIT * 2}px`,
|
padding: `${SPACING_UNIT * 2}px`,
|
||||||
backgroundColor: vars.color.darkBackground,
|
backgroundColor: vars.color.darkBackground,
|
||||||
transition: "all ease 0.2s",
|
transition: "all ease 0.2s",
|
||||||
@ -184,8 +184,8 @@ export const listItemSkeleton = style({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const profileAvatar = style({
|
export const profileAvatar = style({
|
||||||
height: "65px",
|
height: "32px",
|
||||||
width: "65px",
|
width: "32px",
|
||||||
borderRadius: "4px",
|
borderRadius: "4px",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
|
Loading…
Reference in New Issue
Block a user