Skip to content

Commit a7b010b

Browse files
committed
use generated code. this was very tiring.
1 parent e5fd3b1 commit a7b010b

14 files changed

Lines changed: 1082 additions & 577 deletions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"tauridev": "tauri dev",
1414
"build": "vite build",
1515
"lint": "prettier --write . && eslint .",
16-
"postinstall": "rimraf ./src/api && openapi-generator-cli generate -g typescript-fetch -i https://gamevault.alfagun74.de/api/docs-yaml -o ./src/api --global-property models,supportingFiles"
16+
"postinstall": "rimraf ./src/api && openapi-generator-cli generate -g typescript-fetch -i https://gamevault.alfagun74.de/api/docs-yaml -o ./src/api --global-property models,supportingFiles -p enumPropertyNaming=snake_case -p modelPropertyNaming=snake_case"
1717
},
1818
"dependencies": {
1919
"@headlessui/react": "^2.2.8",

src/components/GameCard.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ import { useNavigate } from "react-router";
1919
export function GameCard({ game }: { game: GamevaultGame }) {
2020
const coverId = getGameCoverMediaId(game);
2121
const { serverUrl } = useAuth();
22-
const { startDownload } = useDownloads() as any;
22+
const { startDownload } = useDownloads();
2323

24-
const filename = (() => {
25-
return `${game.title}.zip`;
24+
const filename = (() => {
25+
return `${game.title}.zip`;
2626
})();
2727

28-
const rawSize = (game as any).size;
28+
const rawSize = game.size;
2929

3030
const formatBytes = useCallback((bytes?: number) => {
3131
if (bytes === undefined || bytes === null || isNaN(bytes)) return null;
@@ -86,7 +86,7 @@ export function GameCard({ game }: { game: GamevaultGame }) {
8686
<div className="relative aspect-[3/4] w-full bg-bg-muted flex items-center justify-center overflow-hidden">
8787
{coverId ? (
8888
<Media
89-
media={{ id: coverId } as any}
89+
media={{ id: coverId }}
9090
size={300}
9191
className="h-full w-full object-contain rounded-none"
9292
square

src/components/Media.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { useAuth } from "@/context/AuthContext";
2-
import { Media as MediaType } from "@/types/api";
32
import React, { useEffect, useRef, useState } from "react";
3+
import { Media as MediaType } from "../api";
44

55
interface Props {
6-
media?: MediaType | null;
6+
media?: MediaType;
77
size?: number;
88
width?: number;
99
height?: number;
@@ -25,7 +25,7 @@ export function Media({
2525
fallback,
2626
onClick = () => {},
2727
}: Props) {
28-
const imageId = media?.ID ?? (media as any)?.id;
28+
const imageId = media?.id;
2929
const { authFetch, serverUrl } = useAuth();
3030
const [blobUrl, setBlobUrl] = useState<string | null>(null);
3131
const [error, setError] = useState<string | null>(null);

src/components/Sidebar.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,20 @@ import {
3434
Sidebar as TailwindSidebar,
3535
} from "@tw/sidebar";
3636
import { useEffect, useState } from "react";
37-
import { PermissionRole, normalizePermissionRole } from "@/types/api";
3837
import { useNavigate } from "react-router";
38+
import { GamevaultUserRoleEnum } from "../api";
3939
import { useNews } from "../hooks/useNews";
4040
import ThemeSwitch from "./ThemeSwitch";
41-
import { NewsDialog } from "./news/NewsDialog";
4241
import { UserEditorModal } from "./admin/UserEditorModal";
42+
import { NewsDialog } from "./news/NewsDialog";
4343

4444
export function Sidebar() {
4545
const { user, logout } = useAuth();
4646
const navigate = useNavigate();
4747
const [showNews, setShowNews] = useState(false);
4848
const [showEditProfile, setShowEditProfile] = useState(false);
49-
const username = user?.username || (user as any)?.Username || "Unknown";
50-
const email = user?.email || (user as any)?.EMail || "";
49+
const username = user?.username || "Unknown User";
50+
const email = user?.email || "";
5151
const avatar = user?.avatar;
5252
const { hasNewNews } = useNews();
5353
const [badgeVisible, setBadgeVisible] = useState(hasNewNews);
@@ -67,8 +67,8 @@ export function Sidebar() {
6767
setBadgeVisible(false);
6868
};
6969

70-
const roleVal = normalizePermissionRole((user as any)?.role);
71-
const isAdmin = roleVal === PermissionRole.ADMIN;
70+
const roleVal = user.role;
71+
const isAdmin = roleVal === GamevaultUserRoleEnum.NUMBER_3;
7272

7373
return (
7474
<>
@@ -204,7 +204,7 @@ export function Sidebar() {
204204
{showEditProfile && user && (
205205
<UserEditorModal
206206
self
207-
user={user as any}
207+
user={user}
208208
onClose={() => setShowEditProfile(false)}
209209
/>
210210
)}

0 commit comments

Comments
 (0)