diff --git a/src/features/settings/components/data-settings.tsx b/src/features/settings/components/data-settings.tsx index 82138e8..d619ce9 100644 --- a/src/features/settings/components/data-settings.tsx +++ b/src/features/settings/components/data-settings.tsx @@ -1,4 +1,13 @@ import { Button } from "@/shared/components/ui/button" +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, +} from "@/shared/components/ui/dialog" +import { ListItem } from "@/shared/components/ui/list-item" import { t } from "@/shared/i18n" import { useRef, useState } from "react" import { useDataManagement } from "../hooks/use-data-management" @@ -7,6 +16,7 @@ export function DataSettings() { const { exportData, importData, clearAll } = useDataManagement() const fileRef = useRef(null) const [status, setStatus] = useState(null) + const [confirmOpen, setConfirmOpen] = useState(false) const handleImport = async (e: React.ChangeEvent) => { const file = e.target.files?.[0] @@ -20,35 +30,72 @@ export function DataSettings() { } const handleClear = async () => { - if (!window.confirm(t("settings.data.clearConfirm"))) return + setConfirmOpen(false) await clearAll() setStatus("All data cleared") } return ( -
- - -
- +
+ + {t("settings.data.export")} + + } + /> + fileRef.current?.click()}> + {t("settings.data.import")} + + } /> -
- + - {status &&

{status}

} -
+
+ setConfirmOpen(true)} + > + {t("settings.data.clear")} + + } + /> +
+ + {status && ( +
+

{status}

+
+ )} + + + + + {t("settings.data.clear")} + {t("settings.data.clearConfirm")} + + + + + + + + ) } diff --git a/src/features/settings/components/gog-settings.tsx b/src/features/settings/components/gog-settings.tsx index 9eaa005..aec492d 100644 --- a/src/features/settings/components/gog-settings.tsx +++ b/src/features/settings/components/gog-settings.tsx @@ -1,9 +1,10 @@ import { Button } from "@/shared/components/ui/button" import { Input } from "@/shared/components/ui/input" +import { ListItem } from "@/shared/components/ui/list-item" import { useConfig, useSaveConfig } from "@/shared/db/hooks" import { t } from "@/shared/i18n" +import { useSyncStore } from "@/shared/stores/sync-store" import { useState } from "react" -import { useGogSync } from "../hooks/use-gog-sync" const GOG_AUTH_URL = "https://auth.gog.com/auth?client_id=46899977096215655&redirect_uri=https%3A%2F%2Fembed.gog.com%2Fon_login_success%3Forigin%3Dclient&response_type=code&layout=client2" @@ -12,13 +13,15 @@ export function GogSettings() { const gogConfig = useConfig<{ accessToken: string; refreshToken: string; userId: string }>("gog") const saveConfig = useSaveConfig() const lastSync = useConfig("gog_last_sync") - const { connect, syncGames, syncing, error, lastCount } = useGogSync() + const { syncing, error, lastCount } = useSyncStore((s) => s.gog) + const connectGog = useSyncStore((s) => s.connectGog) + const syncGogGames = useSyncStore((s) => s.syncGogGames) const [code, setCode] = useState("") const isConnected = Boolean(gogConfig?.accessToken) const handleConnect = async () => { - const tokens = await connect(code) + const tokens = await connectGog(code) if (tokens) { setCode("") } @@ -26,7 +29,7 @@ export function GogSettings() { const handleSync = () => { if (gogConfig) { - syncGames(gogConfig.accessToken, gogConfig.refreshToken) + syncGogGames(gogConfig.accessToken, gogConfig.refreshToken) } } @@ -35,63 +38,79 @@ export function GogSettings() { } return ( -
+ <> {!isConnected ? ( <> -
-

1. Open the GOG login page below

-

2. Log in with your GOG account

-

3. Copy the authorization code from the URL

-

4. Paste the code below

+
+
    +
  1. Open the GOG login page below
  2. +
  3. Log in with your GOG account
  4. +
  5. Copy the authorization code from the URL
  6. +
  7. Paste the code below
  8. +
+ + Open GOG Login → +
- - Open GOG Login → - -
-