ci: split repo: make this repo frontend only again
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import * as React from "react";
|
||||
|
||||
function ErrorBoundary(props: {}) {
|
||||
|
||||
return <div>
|
||||
<div className="container-fluid p-5 bg-danger text-white text-center">
|
||||
<h1>Valami hiba történt :(</h1>
|
||||
</div>
|
||||
<div className="p-5 text-center">
|
||||
<p>Töltsd újra az oldalt, és ha az sem segít lépj kapcsolatba a fejlesztővel a <a href="mailto:developer@kemkas.hu">developer@kemkas.hu</a> email címen!</p>
|
||||
<p>Kérlek vedd figyelembe, hogy ez egy hobby projekt limitált erőforrásokkal.</p>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
export default ErrorBoundary;
|
||||
@@ -0,0 +1,15 @@
|
||||
import * as React from "react";
|
||||
|
||||
|
||||
function Footer() {
|
||||
return <footer>
|
||||
<div className="text-center p-4" style={{backgroundColor: "rgba(0, 0, 0, 0.05)"}}>
|
||||
A Kard és Mágiát Lux Gábor alkotta. A szerzői jogok őt illetik. Ez az oldal egy "rajongói
|
||||
hozzájárulás", célja a Kard és Mágia népszerűsítése. Ha többet akarsz tudni a Kard és Mágiáról
|
||||
látogass el a <a href="https://fomalhaut.lfg.hu/">hivatalos honlapjára</a>. A Kard és Mágia az Open
|
||||
Gaming Licence 1.0a alatt lett kiadva, melynek szövege <a href="ogl.html">itt található</a>
|
||||
</div>
|
||||
</footer>
|
||||
}
|
||||
|
||||
export default Footer;
|
||||
@@ -0,0 +1,51 @@
|
||||
import * as React from "react";
|
||||
import {useContext} from "react";
|
||||
import axios from "axios";
|
||||
import {Container, Nav, Navbar} from "react-bootstrap";
|
||||
import { UserContext } from "./contexts/UserContext";
|
||||
|
||||
async function logout() {
|
||||
await axios.post("/Identity/Account/Logout")
|
||||
document.location.reload()
|
||||
}
|
||||
|
||||
function Header(props: {}) {
|
||||
|
||||
const fetchedUser = useContext(UserContext);
|
||||
|
||||
return <header>
|
||||
<Navbar expand="sm" className="navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<Container className="ps-4 pe-4">
|
||||
<Navbar.Brand href="/">Kemkas</Navbar.Brand>
|
||||
{fetchedUser.data != null && <Nav.Link className="text-dark" href="/karaktereim">Karaktereim</Nav.Link>}
|
||||
<Navbar.Toggle aria-controls="basic-navbar-nav" />
|
||||
<Navbar.Collapse id="basic-navbar-nav" className="d-sm-inline-flex flex-sm-row-reverse">
|
||||
<Nav>
|
||||
{fetchedUser.state !== "finished" ? "Loading..." :
|
||||
fetchedUser.data == null
|
||||
? <>
|
||||
<li className="nav-item">
|
||||
<a className="nav-link text-dark" href="/Identity/Account/Register">Register</a>
|
||||
</li>
|
||||
<li className="nav-item">
|
||||
<a className="nav-link text-dark" href="/Identity/Account/Login">Login</a>
|
||||
</li>
|
||||
</>
|
||||
: <>
|
||||
<li className="nav-item">
|
||||
<a className="nav-link text-dark"
|
||||
href="/Identity/Account/Manage">Hello {fetchedUser.data}!</a>
|
||||
</li>
|
||||
<li className="nav-item">
|
||||
<button className="nav-link nav text-dark" onClick={logout}>Logout</button>
|
||||
</li>
|
||||
</>
|
||||
}
|
||||
</Nav>
|
||||
</Navbar.Collapse>
|
||||
</Container>
|
||||
</Navbar>
|
||||
</header>
|
||||
}
|
||||
|
||||
export default Header;
|
||||
@@ -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,3 @@
|
||||
export function SignedNumberToText(val?: number) : string {
|
||||
return (val === null || val === undefined) ? "" : (val === 0 ? " 0" : (val > 0 ? '+'+val : val.toString()))
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { Fetched } from "../models/Fetched";
|
||||
import React from "react";
|
||||
|
||||
export const userDefaults: Fetched<string | null> = {
|
||||
state: "not-started",
|
||||
data: null,
|
||||
}
|
||||
|
||||
export const UserContext = React.createContext(userDefaults)
|
||||
UserContext.displayName = "UserEmailContext";
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
export function dAny(sides: number) {
|
||||
return Math.floor(Math.random() * sides) + 1;
|
||||
}
|
||||
|
||||
export function d6() {
|
||||
return dAny(6)
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
export type LoadingState = "not-started" | "loading" | "finished"
|
||||
|
||||
export interface Fetched<T> {
|
||||
data: T;
|
||||
state: LoadingState;
|
||||
}
|
||||
@@ -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