diff --git a/Kemkas.Web/Services/Shared/CharacterPersistenceService.cs b/Kemkas.Web/Services/Shared/CharacterPersistenceService.cs
index 72d9cfb..bc59eb2 100644
--- a/Kemkas.Web/Services/Shared/CharacterPersistenceService.cs
+++ b/Kemkas.Web/Services/Shared/CharacterPersistenceService.cs
@@ -113,28 +113,19 @@ public class CharacterPersistenceService(
})
.ToListAsync();
- var characters2ERaw = await dbContext.Karakterek2E.Include(k => k.Szintlepesek)
+ var characters2E = await dbContext.Karakterek2E.Include(k => k.Szintlepesek)
.Where(k => k.OwnerUserId == currentUser.Id)
- .Select(k => new
+ .Select(k => new CharacterListItemDto
{
- k.Id,
- k.Nev,
- k.Szint,
- k.Faj,
- Osztalyok = k.Szintlepesek.Select(x => x.Osztaly).ToList(),
+ Id = k.Id,
+ Name = k.Nev,
+ Szint = k.Szint,
+ Faj = k.Faj.Convert(),
+ Osztaly = k.Szintlepesek.OrderBy(x => x.KarakterSzint).Select(x => x.Osztaly).First().Convert(),
+ Edition = "2e"
})
.ToListAsync();
- var characters2E = characters2ERaw.Select(k => new CharacterListItemDto
- {
- Id = k.Id,
- Name = k.Nev,
- Szint = k.Szint,
- Faj = k.Faj.Convert(),
- Osztaly = string.Join('/', k.Osztalyok.Select(o => o.Convert())),
- Edition = "2e"
- });
-
characters.AddRange(characters2E);
return characters;
diff --git a/Kemkas.Web/frontend/src/App.tsx b/Kemkas.Web/frontend/src/App.tsx
index 6df6105..8ab30db 100644
--- a/Kemkas.Web/frontend/src/App.tsx
+++ b/Kemkas.Web/frontend/src/App.tsx
@@ -3,7 +3,7 @@ import './App.css';
import {Faro} from "@grafana/faro-web-sdk";
import {createBrowserRouter, redirect, RouterProvider} from "react-router-dom";
import CreateCharacter from "./first-edition/pages/CreateCharacter";
-import CharacterList from "./first-edition/pages/CharacterList";
+import CharacterList from "./shared/pages/CharacterList";
import ErrorBoundary from "./shared/ErrorBoundary";
import Header from "./shared/Header";
import Footer from "./shared/Footer";
@@ -42,7 +42,7 @@ function App(props: {faro?: Faro}) {
const router = createBrowserRouter([
{
path: "/",
- loader: () => fetchedUser.data == null ? redirect("/1e/karakter") : redirect("/karaktereim")
+ loader: () => fetchedUser.data == null ? redirect("/2e/karakter") : redirect("/karaktereim")
},
{
path: "/karaktereim",
diff --git a/Kemkas.Web/frontend/src/first-edition/components/CharacterListItem.tsx b/Kemkas.Web/frontend/src/first-edition/components/CharacterListItem.tsx
deleted file mode 100644
index 2af786a..0000000
--- a/Kemkas.Web/frontend/src/first-edition/components/CharacterListItem.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-import * as React from "react";
-import {Osztaly, OsztalyLabel} from "../domain-models/osztaly";
-import {Faj, FajLabel} from "../domain-models/faj";
-
-export interface CharacterListItemDto {
- id: string,
- name: string,
- szint: number,
- faj: Faj,
- osztaly: Osztaly,
- edition: "1e" | "2e"
-}
-
-function CharacterListItem(props: {
- character: CharacterListItemDto,
-}) {
- const {character:c} = props
- return <>
-
{c.name} |
- {c.szint}. szintű |
- {FajLabel(c.faj)} |
- {OsztalyLabel(c.osztaly)} |
- >
-}
-
-export default CharacterListItem;
\ No newline at end of file
diff --git a/Kemkas.Web/frontend/src/first-edition/pages/CharacterList.tsx b/Kemkas.Web/frontend/src/first-edition/pages/CharacterList.tsx
deleted file mode 100644
index 6f627e4..0000000
--- a/Kemkas.Web/frontend/src/first-edition/pages/CharacterList.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import * as React from "react";
-import {useLoaderData} from "react-router-dom";
-import CharacterListItem, {CharacterListItemDto} from "../components/CharacterListItem";
-
-function CharacterList(props: {}) {
- const characters = useLoaderData() as CharacterListItemDto[];
-
- return
-
-
Karakterek
-
-
-
-
-
- | Név |
- Szint |
- Faj |
- Osztály |
-
-
-
- {characters.map(c => (
-
-
-
- ))}
-
-
-
-}
-
-export default CharacterList;
diff --git a/Kemkas.Web/frontend/src/shared/components/CharacterListItem.tsx b/Kemkas.Web/frontend/src/shared/components/CharacterListItem.tsx
new file mode 100644
index 0000000..122b13f
--- /dev/null
+++ b/Kemkas.Web/frontend/src/shared/components/CharacterListItem.tsx
@@ -0,0 +1,19 @@
+import * as React from "react";
+import {CharacterListItemViewModel} from "../pages/CharacterList";
+
+
+
+function CharacterListItem(props: {
+ character: CharacterListItemViewModel,
+}) {
+ const {character:c} = props
+ return <>
+ {c.name} |
+ {c.szint}. szintű |
+ {c.faj} |
+ {c.osztaly} |
+ {c.edition} |
+ >
+}
+
+export default CharacterListItem;
\ No newline at end of file
diff --git a/Kemkas.Web/frontend/src/shared/pages/CharacterList.tsx b/Kemkas.Web/frontend/src/shared/pages/CharacterList.tsx
new file mode 100644
index 0000000..1c92306
--- /dev/null
+++ b/Kemkas.Web/frontend/src/shared/pages/CharacterList.tsx
@@ -0,0 +1,101 @@
+import * as React from "react";
+import {useLoaderData} from "react-router-dom";
+import CharacterListItem from "../components/CharacterListItem";
+import {Faj, FajLabel as FajLabel1E} from "../../first-edition/domain-models/faj";
+import {Faj2E, FajLabel as FajLabel2E} from "../../second-edition/domain-models/faj2E";
+import {Osztaly, OsztalyLabel as OsztalyLabel1E} from "../../first-edition/domain-models/osztaly";
+import {Osztaly2E, OsztalyLabel as OsztalyLabel2E} from "../../second-edition/domain-models/osztaly2E";
+
+export interface CharacterListItemViewModel {
+ id: string,
+ name: string,
+ szint: number,
+ faj: string,
+ osztaly: string,
+ edition: "1e" | "2e"
+}
+
+interface CharacterListItemDto1E {
+ id: string,
+ name: string,
+ szint: number,
+ faj: Faj,
+ osztaly: Osztaly,
+ edition: "1e"
+}
+
+interface CharacterListItemDto2E {
+ id: string,
+ name: string,
+ szint: number,
+ faj: Faj2E,
+ osztaly: Osztaly2E,
+ edition: "2e"
+}
+
+type CharacterListItemDto = CharacterListItemDto1E | CharacterListItemDto2E;
+
+function mapDtoToViewModel(dto: CharacterListItemDto): CharacterListItemViewModel {
+ if (dto.edition === "1e") {
+ return {
+ id: dto.id,
+ name: dto.name,
+ edition: dto.edition,
+ szint: dto.szint,
+ faj: FajLabel1E(dto.faj),
+ osztaly: OsztalyLabel1E(dto.osztaly),
+ }
+ }
+ else {
+ return {
+ id: dto.id,
+ name: dto.name,
+ edition: dto.edition,
+ szint: dto.szint,
+ faj: FajLabel2E(dto.faj),
+ osztaly: OsztalyLabel2E(dto.osztaly),
+ }
+ }
+}
+
+function CharacterList(props: {}) {
+ const characters = useLoaderData() as CharacterListItemDto[];
+
+ return
+
+
Karakterek
+
+
+
+
+
+ | Név |
+ Szint |
+ Faj |
+ Osztály |
+ Kiadás |
+
+
+
+ {characters.map(c => (
+
+
+
+ ))}
+
+
+
+}
+
+export default CharacterList;