mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-13 03:32:13 +00:00
feat: show buttons to open checkout
This commit is contained in:
parent
8a24fd8ef9
commit
a72eb768e7
7 changed files with 54 additions and 8 deletions
|
@ -160,7 +160,8 @@
|
||||||
"wine_prefix_description": "The Wine prefix used to run this game",
|
"wine_prefix_description": "The Wine prefix used to run this game",
|
||||||
"no_download_option_info": "No information available",
|
"no_download_option_info": "No information available",
|
||||||
"backup_deletion_failed": "Failed to delete backup",
|
"backup_deletion_failed": "Failed to delete backup",
|
||||||
"max_number_of_artifacts_reached": "Maximum number of backups reached for this game"
|
"max_number_of_artifacts_reached": "Maximum number of backups reached for this game",
|
||||||
|
"achievements_not_sync": "Your achievements are not synchronized"
|
||||||
},
|
},
|
||||||
"activation": {
|
"activation": {
|
||||||
"title": "Activate Hydra",
|
"title": "Activate Hydra",
|
||||||
|
|
|
@ -156,7 +156,8 @@
|
||||||
"wine_prefix_description": "O prefixo Wine que foi utilizado para instalar o jogo",
|
"wine_prefix_description": "O prefixo Wine que foi utilizado para instalar o jogo",
|
||||||
"no_download_option_info": "Sem informações disponíveis",
|
"no_download_option_info": "Sem informações disponíveis",
|
||||||
"backup_deletion_failed": "Falha ao apagar backup",
|
"backup_deletion_failed": "Falha ao apagar backup",
|
||||||
"max_number_of_artifacts_reached": "Número máximo de backups atingido para este jogo"
|
"max_number_of_artifacts_reached": "Número máximo de backups atingido para este jogo",
|
||||||
|
"achievements_not_sync": "Suas conquistas não estão sincronizadas"
|
||||||
},
|
},
|
||||||
"activation": {
|
"activation": {
|
||||||
"title": "Ativação",
|
"title": "Ativação",
|
||||||
|
|
|
@ -53,6 +53,7 @@ export const gameDetailsContext = createContext<GameDetailsContext>({
|
||||||
setShowGameOptionsModal: () => {},
|
setShowGameOptionsModal: () => {},
|
||||||
setShowRepacksModal: () => {},
|
setShowRepacksModal: () => {},
|
||||||
setHasNSFWContentBlocked: () => {},
|
setHasNSFWContentBlocked: () => {},
|
||||||
|
handleClickOpenCheckout: () => {},
|
||||||
});
|
});
|
||||||
|
|
||||||
const { Provider } = gameDetailsContext;
|
const { Provider } = gameDetailsContext;
|
||||||
|
@ -110,6 +111,11 @@ export function GameDetailsContextProvider({
|
||||||
(state) => state.userPreferences.value
|
(state) => state.userPreferences.value
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleClickOpenCheckout = () => {
|
||||||
|
// TODO: show modal before redirecting to checkout page
|
||||||
|
window.electron.openCheckout();
|
||||||
|
};
|
||||||
|
|
||||||
const updateGame = useCallback(async () => {
|
const updateGame = useCallback(async () => {
|
||||||
return window.electron
|
return window.electron
|
||||||
.getGameByObjectId(objectId!)
|
.getGameByObjectId(objectId!)
|
||||||
|
@ -282,6 +288,7 @@ export function GameDetailsContextProvider({
|
||||||
updateGame,
|
updateGame,
|
||||||
setShowRepacksModal,
|
setShowRepacksModal,
|
||||||
setShowGameOptionsModal,
|
setShowGameOptionsModal,
|
||||||
|
handleClickOpenCheckout,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|
|
@ -29,4 +29,5 @@ export interface GameDetailsContext {
|
||||||
setShowRepacksModal: React.Dispatch<React.SetStateAction<boolean>>;
|
setShowRepacksModal: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
setShowGameOptionsModal: React.Dispatch<React.SetStateAction<boolean>>;
|
setShowGameOptionsModal: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
setHasNSFWContentBlocked: React.Dispatch<React.SetStateAction<boolean>>;
|
setHasNSFWContentBlocked: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
|
handleClickOpenCheckout: () => void;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ export function GameDetailsContent() {
|
||||||
gameColor,
|
gameColor,
|
||||||
setGameColor,
|
setGameColor,
|
||||||
hasNSFWContentBlocked,
|
hasNSFWContentBlocked,
|
||||||
|
handleClickOpenCheckout,
|
||||||
} = useContext(gameDetailsContext);
|
} = useContext(gameDetailsContext);
|
||||||
|
|
||||||
const { userDetails, hasActiveSubscription } = useUserDetails();
|
const { userDetails, hasActiveSubscription } = useUserDetails();
|
||||||
|
@ -104,7 +105,7 @@ export function GameDetailsContent() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasActiveSubscription) {
|
if (!hasActiveSubscription) {
|
||||||
window.electron.openCheckout();
|
handleClickOpenCheckout();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,3 +154,16 @@ export const listItemImage = recipe({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const subscriptionRequiredButton = style({
|
||||||
|
textDecoration: "none",
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "center",
|
||||||
|
width: "100%",
|
||||||
|
gap: `${SPACING_UNIT / 2}px`,
|
||||||
|
color: vars.color.warning,
|
||||||
|
cursor: "pointer",
|
||||||
|
":hover": {
|
||||||
|
textDecoration: "underline",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
|
@ -10,12 +10,17 @@ import { Button, Link } from "@renderer/components";
|
||||||
import * as styles from "./sidebar.css";
|
import * as styles from "./sidebar.css";
|
||||||
import { gameDetailsContext } from "@renderer/context";
|
import { gameDetailsContext } from "@renderer/context";
|
||||||
import { useDate, useFormat, useUserDetails } from "@renderer/hooks";
|
import { useDate, useFormat, useUserDetails } from "@renderer/hooks";
|
||||||
import { DownloadIcon, LockIcon, PeopleIcon } from "@primer/octicons-react";
|
import {
|
||||||
|
CloudOfflineIcon,
|
||||||
|
DownloadIcon,
|
||||||
|
LockIcon,
|
||||||
|
PeopleIcon,
|
||||||
|
} from "@primer/octicons-react";
|
||||||
import { HowLongToBeatSection } from "./how-long-to-beat-section";
|
import { HowLongToBeatSection } from "./how-long-to-beat-section";
|
||||||
import { howLongToBeatEntriesTable } from "@renderer/dexie";
|
import { howLongToBeatEntriesTable } from "@renderer/dexie";
|
||||||
import { SidebarSection } from "../sidebar-section/sidebar-section";
|
import { SidebarSection } from "../sidebar-section/sidebar-section";
|
||||||
import { buildGameAchievementPath } from "@renderer/helpers";
|
import { buildGameAchievementPath } from "@renderer/helpers";
|
||||||
import { SPACING_UNIT } from "@renderer/theme.css";
|
import { SPACING_UNIT, vars } from "@renderer/theme.css";
|
||||||
|
|
||||||
const fakeAchievements: UserAchievement[] = [
|
const fakeAchievements: UserAchievement[] = [
|
||||||
{
|
{
|
||||||
|
@ -57,13 +62,20 @@ export function Sidebar() {
|
||||||
data: HowLongToBeatCategory[] | null;
|
data: HowLongToBeatCategory[] | null;
|
||||||
}>({ isLoading: true, data: null });
|
}>({ isLoading: true, data: null });
|
||||||
|
|
||||||
const { userDetails } = useUserDetails();
|
const { userDetails, hasActiveSubscription } = useUserDetails();
|
||||||
|
|
||||||
const [activeRequirement, setActiveRequirement] =
|
const [activeRequirement, setActiveRequirement] =
|
||||||
useState<keyof SteamAppDetails["pc_requirements"]>("minimum");
|
useState<keyof SteamAppDetails["pc_requirements"]>("minimum");
|
||||||
|
|
||||||
const { gameTitle, shopDetails, objectId, shop, stats, achievements } =
|
const {
|
||||||
useContext(gameDetailsContext);
|
gameTitle,
|
||||||
|
shopDetails,
|
||||||
|
objectId,
|
||||||
|
shop,
|
||||||
|
stats,
|
||||||
|
achievements,
|
||||||
|
handleClickOpenCheckout,
|
||||||
|
} = useContext(gameDetailsContext);
|
||||||
|
|
||||||
const { t } = useTranslation("game_details");
|
const { t } = useTranslation("game_details");
|
||||||
const { formatDateTime } = useDate();
|
const { formatDateTime } = useDate();
|
||||||
|
@ -162,6 +174,16 @@ export function Sidebar() {
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<ul className={styles.list}>
|
<ul className={styles.list}>
|
||||||
|
{!hasActiveSubscription && (
|
||||||
|
<button
|
||||||
|
className={styles.subscriptionRequiredButton}
|
||||||
|
onClick={handleClickOpenCheckout}
|
||||||
|
>
|
||||||
|
<CloudOfflineIcon size={16} />
|
||||||
|
<span>{t("achievements_not_sync")}</span>
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
|
||||||
{achievements.slice(0, 4).map((achievement, index) => (
|
{achievements.slice(0, 4).map((achievement, index) => (
|
||||||
<li key={index}>
|
<li key={index}>
|
||||||
<Link
|
<Link
|
||||||
|
|
Loading…
Reference in a new issue