mirror of
https://github.com/morbalint/kemkas.git
synced 2026-07-17 19:03:46 +00:00
release 2e
This commit is contained in:
@@ -113,28 +113,19 @@ public class CharacterPersistenceService(
|
|||||||
})
|
})
|
||||||
.ToListAsync();
|
.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)
|
.Where(k => k.OwnerUserId == currentUser.Id)
|
||||||
.Select(k => new
|
.Select(k => new CharacterListItemDto
|
||||||
{
|
{
|
||||||
k.Id,
|
Id = k.Id,
|
||||||
k.Nev,
|
Name = k.Nev,
|
||||||
k.Szint,
|
Szint = k.Szint,
|
||||||
k.Faj,
|
Faj = k.Faj.Convert(),
|
||||||
Osztalyok = k.Szintlepesek.Select(x => x.Osztaly).ToList(),
|
Osztaly = k.Szintlepesek.OrderBy(x => x.KarakterSzint).Select(x => x.Osztaly).First().Convert(),
|
||||||
|
Edition = "2e"
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.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);
|
characters.AddRange(characters2E);
|
||||||
|
|
||||||
return characters;
|
return characters;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import './App.css';
|
|||||||
import {Faro} from "@grafana/faro-web-sdk";
|
import {Faro} from "@grafana/faro-web-sdk";
|
||||||
import {createBrowserRouter, redirect, RouterProvider} from "react-router-dom";
|
import {createBrowserRouter, redirect, RouterProvider} from "react-router-dom";
|
||||||
import CreateCharacter from "./first-edition/pages/CreateCharacter";
|
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 ErrorBoundary from "./shared/ErrorBoundary";
|
||||||
import Header from "./shared/Header";
|
import Header from "./shared/Header";
|
||||||
import Footer from "./shared/Footer";
|
import Footer from "./shared/Footer";
|
||||||
@@ -42,7 +42,7 @@ function App(props: {faro?: Faro}) {
|
|||||||
const router = createBrowserRouter([
|
const router = createBrowserRouter([
|
||||||
{
|
{
|
||||||
path: "/",
|
path: "/",
|
||||||
loader: () => fetchedUser.data == null ? redirect("/1e/karakter") : redirect("/karaktereim")
|
loader: () => fetchedUser.data == null ? redirect("/2e/karakter") : redirect("/karaktereim")
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/karaktereim",
|
path: "/karaktereim",
|
||||||
|
|||||||
@@ -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 <>
|
|
||||||
<td><a href={`/${c.edition}/karakter/${c.id}`}>{c.name}</a></td>
|
|
||||||
<td>{c.szint}. szintű</td>
|
|
||||||
<td>{FajLabel(c.faj)}</td>
|
|
||||||
<td>{OsztalyLabel(c.osztaly)}</td>
|
|
||||||
</>
|
|
||||||
}
|
|
||||||
|
|
||||||
export default CharacterListItem;
|
|
||||||
@@ -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 <div className="container">
|
|
||||||
<div className="container-fluid p-5 bg-black text-white text-center">
|
|
||||||
<h1>Karakterek</h1>
|
|
||||||
</div>
|
|
||||||
<div className="d-grid gap-2 m-5">
|
|
||||||
<a className="btn btn-dark btn-lg" href="/" type="button">Új karakter létrehozása</a>
|
|
||||||
</div>
|
|
||||||
<table className="table mt-3">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">Név</th>
|
|
||||||
<th scope="col">Szint</th>
|
|
||||||
<th scope="col">Faj</th>
|
|
||||||
<th scope="col">Osztály</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{characters.map(c => (
|
|
||||||
<tr key={c.id}>
|
|
||||||
<CharacterListItem character={c}/>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
export default CharacterList;
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import * as React from "react";
|
||||||
|
import {CharacterListItemViewModel} from "../pages/CharacterList";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function CharacterListItem(props: {
|
||||||
|
character: CharacterListItemViewModel,
|
||||||
|
}) {
|
||||||
|
const {character:c} = props
|
||||||
|
return <>
|
||||||
|
<td><a href={`/${c.edition}/karakter/${c.id}`}>{c.name}</a></td>
|
||||||
|
<td>{c.szint}. szintű</td>
|
||||||
|
<td>{c.faj}</td>
|
||||||
|
<td>{c.osztaly}</td>
|
||||||
|
<td>{c.edition}</td>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CharacterListItem;
|
||||||
@@ -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 <div className="container">
|
||||||
|
<div className="container-fluid p-5 bg-black text-white text-center">
|
||||||
|
<h1>Karakterek</h1>
|
||||||
|
</div>
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-6">
|
||||||
|
<div className="d-grid gap-1 m-3 m-lg-5">
|
||||||
|
<a className="btn btn-dark btn-lg" href="/2e/karakter/" type="button">Új 2e karakter létrehozása</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-6">
|
||||||
|
<div className="d-grid gap-1 m-3 m-lg-5">
|
||||||
|
<a className="btn btn-dark btn-lg" href="/1e/karakter/" type="button">Új 1e karakter létrehozása</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<table className="table mt-3">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">Név</th>
|
||||||
|
<th scope="col">Szint</th>
|
||||||
|
<th scope="col">Faj</th>
|
||||||
|
<th scope="col">Osztály</th>
|
||||||
|
<th scope="col">Kiadás</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{characters.map(c => (
|
||||||
|
<tr key={c.id}>
|
||||||
|
<CharacterListItem character={mapDtoToViewModel(c)}/>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CharacterList;
|
||||||
Reference in New Issue
Block a user