Compare commits
2 Commits
use-vite
...
react-fixes
| Author | SHA1 | Date | |
|---|---|---|---|
| e8914d4bcb | |||
| 7c682373a5 |
+22
-22
@@ -11,10 +11,10 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup Node.js 18.x
|
||||
- name: Setup Node.js 24.x
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18.x
|
||||
node-version: 24.x
|
||||
- name: Cache NPM packages
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
@@ -27,11 +27,10 @@ jobs:
|
||||
- name: Yarn Install
|
||||
run: |
|
||||
cd ./frontend
|
||||
yarn install --frozen-lockfiles
|
||||
yarn install --frozen-lockfile
|
||||
- name: Yarn Test
|
||||
run: |
|
||||
cd ./frontend
|
||||
./compile-less.sh
|
||||
yarn run test
|
||||
|
||||
docker-fe-build:
|
||||
@@ -58,21 +57,22 @@ jobs:
|
||||
tags: |
|
||||
ghcr.io/${{ github.repository_owner }}/kemkas-frontend:${{ env.GITHUB_SHA_SHORT }}
|
||||
|
||||
deploy-to-beta:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- docker-fe-build
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ github.repository_owner }}/kemkas-deployment
|
||||
ref: refs/heads/main
|
||||
ssh-key: ${{ secrets.DEPLOYMENT_REPO_DEPLOY_KEY }}
|
||||
- uses: mikefarah/yq@v4
|
||||
with:
|
||||
cmd: yq -i '.spec.template.spec.containers[0].image = "${{ needs.docker-fe-build.outputs.image_tag }}"' ./kemkas-beta/kemkas-fe-deployment.yaml
|
||||
- run: |
|
||||
git config --add user.email "beta-fe-deployment-bot@kemkas.hu"
|
||||
git config --add user.name "Deployment Bot Beta FE"
|
||||
git commit -a -m "deploy ${{ needs.docker-fe-build.outputs.image_tag }}"
|
||||
git push
|
||||
# No longer used, and token expired.
|
||||
# deploy-to-beta:
|
||||
# runs-on: ubuntu-latest
|
||||
# needs:
|
||||
# - docker-fe-build
|
||||
# steps:
|
||||
# - uses: actions/checkout@v4
|
||||
# with:
|
||||
# repository: ${{ github.repository_owner }}/kemkas-deployment
|
||||
# ref: refs/heads/main
|
||||
# ssh-key: ${{ secrets.DEPLOYMENT_REPO_DEPLOY_KEY }}
|
||||
# - uses: mikefarah/yq@v4
|
||||
# with:
|
||||
# cmd: yq -i '.spec.template.spec.containers[0].image = "${{ needs.docker-fe-build.outputs.image_tag }}"' ./kemkas-beta/kemkas-fe-deployment.yaml
|
||||
# - run: |
|
||||
# git config --add user.email "beta-fe-deployment-bot@kemkas.hu"
|
||||
# git config --add user.name "Deployment Bot Beta FE"
|
||||
# git commit -a -m "deploy ${{ needs.docker-fe-build.outputs.image_tag }}"
|
||||
# git push
|
||||
|
||||
+2
-1
@@ -30,4 +30,5 @@ yarn-error.log*
|
||||
/local
|
||||
|
||||
obj/
|
||||
bin/
|
||||
bin/
|
||||
dist/
|
||||
+2
-2
@@ -1,2 +1,2 @@
|
||||
nodejs 20.15.1
|
||||
yarn 1.22.22
|
||||
nodejs 24.14.1
|
||||
yarn 1.22.22
|
||||
|
||||
+18
-2
@@ -1,11 +1,19 @@
|
||||
services:
|
||||
db:
|
||||
image: postgres:16.1-alpine3.19
|
||||
image: postgres:16.13-alpine3.23
|
||||
ports:
|
||||
- "5432:5432"
|
||||
environment:
|
||||
POSTGRES_USER: "kemkas"
|
||||
POSTGRES_PASSWORD: "kemkas-dev42"
|
||||
volumes:
|
||||
- db-data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U kemkas -d postgres"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 20
|
||||
start_period: 5s
|
||||
|
||||
backend:
|
||||
image: ghcr.io/morbalint/kemkas-backend:b8565f8e
|
||||
@@ -15,6 +23,9 @@ services:
|
||||
ConnectionStrings__DefaultConnection: "Server=db;User Id=kemkas;Password=kemkas-dev42"
|
||||
Email__DomainName: "mail.kemkas.hu"
|
||||
Email__ApiKey: ""
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
|
||||
proxy:
|
||||
image: nginx:latest
|
||||
@@ -23,4 +34,9 @@ services:
|
||||
volumes:
|
||||
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
- $HOME/.aspnet/https/kemkas.pem:/etc/nginx/kemkas.pem
|
||||
- $HOME/.aspnet/https/kemkas.key:/etc/nginx/kemkas.key
|
||||
- $HOME/.aspnet/https/kemkas.key:/etc/nginx/kemkas.key
|
||||
depends_on:
|
||||
- backend
|
||||
|
||||
volumes:
|
||||
db-data:
|
||||
@@ -1,3 +1,3 @@
|
||||
PORT=44478
|
||||
HTTPS=true
|
||||
HTTPS=false
|
||||
|
||||
|
||||
+4
-5
@@ -1,17 +1,16 @@
|
||||
FROM node:20.15.1-bookworm as builder
|
||||
FROM node:24.14.1-trixie AS builder
|
||||
|
||||
WORKDIR "/src"
|
||||
|
||||
COPY ["package.json", "yarn.lock", "./"]
|
||||
|
||||
RUN yarn install --frozen-lockfile
|
||||
RUN yarn install
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN ./compile-less.sh
|
||||
RUN yarn build
|
||||
|
||||
FROM nginx:latest as proxy
|
||||
FROM nginx:1.29.7-alpine3.23 AS proxy
|
||||
|
||||
COPY --from=builder "/src/build" "/usr/share/nginx/html"
|
||||
COPY --from=builder "/src/dist" "/usr/share/nginx/html"
|
||||
COPY ./nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
+12
-41
@@ -1,46 +1,17 @@
|
||||
# Getting Started with Create React App
|
||||
# Frontend (Vite)
|
||||
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||
This frontend now uses Vite + React + TypeScript.
|
||||
|
||||
## Available Scripts
|
||||
## Scripts
|
||||
|
||||
In the project directory, you can run:
|
||||
- `yarn dev` or `yarn start`: Start the Vite dev server.
|
||||
- `yarn build`: Build production assets to `dist/`.
|
||||
- `yarn preview`: Serve the production build locally.
|
||||
- `yarn test`: Run tests once with Vitest.
|
||||
- `yarn test:watch`: Run tests in watch mode.
|
||||
|
||||
### `yarn start`
|
||||
## Notes
|
||||
|
||||
Runs the app in the development mode.\
|
||||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
||||
|
||||
The page will reload if you make edits.\
|
||||
You will also see any lint errors in the console.
|
||||
|
||||
### `yarn test`
|
||||
|
||||
Launches the test runner in the interactive watch mode.\
|
||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
||||
|
||||
### `yarn run build`
|
||||
|
||||
Builds the app for production to the `build` folder.\
|
||||
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||
|
||||
The build is minified and the filenames include the hashes.\
|
||||
Your app is ready to be deployed!
|
||||
|
||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
||||
|
||||
### `yarn run eject`
|
||||
|
||||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
|
||||
|
||||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
||||
|
||||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
|
||||
|
||||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
|
||||
|
||||
## Learn More
|
||||
|
||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
||||
|
||||
To learn React, check out the [React documentation](https://reactjs.org/).
|
||||
- Static files are served from `public/`.
|
||||
- The app entry HTML is `index.html` at the project root.
|
||||
- LESS files are compiled by Vite automatically, no separate compile step is needed.
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
#!/bin/bash
|
||||
echo "Compiling all LESS files to CSS"
|
||||
|
||||
function compile_less() {
|
||||
FROM=$1
|
||||
TO=${FROM/.*/.css}
|
||||
SOURCE_MAP=${FROM/.*/.css.map}
|
||||
echo "$FROM --> $TO & $SOURCE_MAP"
|
||||
node_modules/less/bin/lessc "$FROM" "$TO" --source-map="$SOURCE_MAP"
|
||||
}
|
||||
|
||||
export -f compile_less
|
||||
find src -type f -name '*.less' -exec bash -c 'compile_less $1' shell {} \;
|
||||
@@ -0,0 +1,21 @@
|
||||
<!doctype html>
|
||||
<html lang="hu">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta name="description" content="Kém Karakter alkotási segédlet" />
|
||||
<link rel="apple-touch-icon" href="/logo192.png" />
|
||||
<link rel="manifest" href="/manifest.json" />
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link href="https://fonts.googleapis.com/css2?family=Merienda&display=swap" rel="stylesheet" />
|
||||
<title>Kém Karakter App</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/index.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
+14
-25
@@ -2,6 +2,9 @@
|
||||
"name": "kemkas",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": ">=24"
|
||||
},
|
||||
"dependencies": {
|
||||
"@grafana/faro-web-sdk": "^1.4.2",
|
||||
"@pdf-lib/fontkit": "^1.1.1",
|
||||
@@ -9,25 +12,19 @@
|
||||
"@testing-library/jest-dom": "^6.4.2",
|
||||
"@testing-library/react": "^15.0.7",
|
||||
"@testing-library/user-event": "^14.5.1",
|
||||
"@types/jest": "^29.5.6",
|
||||
"@types/node": "^20.14.10",
|
||||
"@types/node": "^24.0.0",
|
||||
"@types/react": "^18.3.2",
|
||||
"@types/react-dom": "^18.2.22",
|
||||
"axios": "^1.7.4",
|
||||
"bootstrap": "^5.3.2",
|
||||
"downloadjs": "^1.4.7",
|
||||
"http-proxy-middleware": "^2.0.6",
|
||||
"jquery": "^3.6.0",
|
||||
"merge": "^2.1.1",
|
||||
"oidc-client": "^1.11.5",
|
||||
"pdf-lib": "^1.17.1",
|
||||
"react": "^18.3.1",
|
||||
"react-bootstrap": "^2.10.2",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-redux": "^9.1.2",
|
||||
"react-router-dom": "^6.17.0",
|
||||
"react-scripts": "5.0.1",
|
||||
"rimraf": "^5.0.5",
|
||||
"typescript": "^5.2.2",
|
||||
"workbox-background-sync": "^7.1.0",
|
||||
"workbox-broadcast-update": "^7.1.0",
|
||||
@@ -43,23 +40,20 @@
|
||||
"workbox-streams": "^7.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
|
||||
"@vitejs/plugin-react": "^4.3.4",
|
||||
"@types/downloadjs": "^1.4.4",
|
||||
"cross-env": "^7.0.3",
|
||||
"jsdom": "^25.0.1",
|
||||
"less": "^4.2.0",
|
||||
"less-loader": "^11.1.3"
|
||||
"vite": "^5.4.10",
|
||||
"vitest": "^2.1.3"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "rimraf ./build && react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "cross-env CI=true react-scripts test --env=jsdom",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
"react-app/jest"
|
||||
]
|
||||
"dev": "vite",
|
||||
"start": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest"
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
@@ -72,10 +66,5 @@
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"jest": {
|
||||
"moduleNameMapper": {
|
||||
"^axios$": "axios/dist/node/axios.cjs"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="hu">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Kém Karakter alkotási segédlet"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Merienda&display=swap" rel="stylesheet">
|
||||
<title>Kém Karakter App</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,7 +1,18 @@
|
||||
import React from 'react';
|
||||
import { render } from '@testing-library/react';
|
||||
import { vi } from 'vitest';
|
||||
import App from './App';
|
||||
|
||||
vi.mock('react-router-dom', async () => {
|
||||
const actual = await vi.importActual<typeof import('react-router-dom')>('react-router-dom');
|
||||
|
||||
return {
|
||||
...actual,
|
||||
createBrowserRouter: vi.fn(() => ({})),
|
||||
RouterProvider: () => <div data-testid="router-provider" />,
|
||||
};
|
||||
});
|
||||
|
||||
test('renders App', () => {
|
||||
render(<App faro={undefined}/>);
|
||||
});
|
||||
|
||||
+88
-62
@@ -1,7 +1,7 @@
|
||||
import * as React from "react";
|
||||
import "./App.css";
|
||||
import {Faro} from "@grafana/faro-web-sdk";
|
||||
import {createBrowserRouter, redirect, RouterProvider} from "react-router-dom";
|
||||
import {createBrowserRouter, Outlet, redirect, RouterProvider} from "react-router-dom";
|
||||
import CreateCharacter from "./first-edition/pages/CreateCharacter";
|
||||
import CharacterList from "./shared/pages/CharacterList";
|
||||
import ErrorBoundary from "./shared/ErrorBoundary";
|
||||
@@ -14,11 +14,28 @@ import { useSelector, useDispatch } from 'react-redux'
|
||||
import {load, setUser, unsetUser, userSelector} from './shared/domain-models/userSlice'
|
||||
import {setCharacter} from "./second-edition/domain-models/characterSlice";
|
||||
|
||||
function RootLayout() {
|
||||
return (
|
||||
<>
|
||||
<Header />
|
||||
<div className='container'>
|
||||
<Outlet />
|
||||
</div>
|
||||
<Footer />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
function Router(props: {faro?: Faro}) {
|
||||
const dispatch = useDispatch.withTypes<AppDispatch>()()
|
||||
const fetchedUser = useSelector.withTypes<RootState>()(userSelector)
|
||||
|
||||
if (fetchedUser.state === "not-started") {
|
||||
React.useEffect(() => {
|
||||
if (fetchedUser.state !== "not-started") {
|
||||
return;
|
||||
}
|
||||
|
||||
let isCancelled = false;
|
||||
dispatch(load())
|
||||
fetch(`${window.location.origin}/api/User/me`)
|
||||
.then(response => {
|
||||
@@ -28,88 +45,97 @@ function Router(props: {faro?: Faro}) {
|
||||
console.log(response)
|
||||
})
|
||||
.then(userNameResponse => {
|
||||
if (isCancelled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (userNameResponse && userNameResponse.length > 0) {
|
||||
dispatch(setUser(userNameResponse))
|
||||
} else {
|
||||
dispatch(unsetUser())
|
||||
}
|
||||
|
||||
})
|
||||
.catch(() => {
|
||||
if (isCancelled) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(unsetUser())
|
||||
})
|
||||
}
|
||||
|
||||
return () => {
|
||||
isCancelled = true;
|
||||
}
|
||||
}, [dispatch, fetchedUser.state])
|
||||
|
||||
|
||||
const router = createBrowserRouter([
|
||||
const router = React.useMemo(() => createBrowserRouter([
|
||||
{
|
||||
path: "/",
|
||||
loader: () => fetchedUser.email == null ? redirect("/2e/karakter") : redirect("/karaktereim")
|
||||
element: <RootLayout />,
|
||||
children: [
|
||||
{
|
||||
index: true,
|
||||
loader: () => fetchedUser.email == null ? redirect("/2e/karakter") : redirect("/karaktereim")
|
||||
},
|
||||
{
|
||||
path: "karaktereim",
|
||||
element: <CharacterList />,
|
||||
loader: () => fetch(`${window.location.origin}/api/Character`),
|
||||
ErrorBoundary: ErrorBoundary,
|
||||
},
|
||||
{
|
||||
path: "1e",
|
||||
loader: () => redirect("/1e/karakter")
|
||||
},
|
||||
{
|
||||
path: "1e/karakter",
|
||||
element: <CreateCharacter faro={props.faro} />,
|
||||
ErrorBoundary: ErrorBoundary,
|
||||
},
|
||||
{
|
||||
path: "1e/karakter/:id",
|
||||
element: <CreateCharacter faro={props.faro}/>,
|
||||
loader: args => fetch(`${window.location.origin}/api/Character1E/${args.params.id}`),
|
||||
ErrorBoundary: ErrorBoundary,
|
||||
},
|
||||
{
|
||||
path: "2e",
|
||||
loader: () => redirect("/2e/karakter")
|
||||
},
|
||||
{
|
||||
path: "2e/karakter",
|
||||
element: <CreateCharacter2E faro={props.faro}/>,
|
||||
ErrorBoundary: ErrorBoundary,
|
||||
},
|
||||
{
|
||||
path: "2e/karakter/:id",
|
||||
element: <CreateCharacter2E faro={props.faro}/>,
|
||||
loader: async args => {
|
||||
const response = await fetch(`${window.location.origin}/api/Character2E/${args.params.id}`)
|
||||
if (response.ok) {
|
||||
const loaded2Echaracter = await response.json()
|
||||
dispatch(setCharacter(loaded2Echaracter))
|
||||
return loaded2Echaracter;
|
||||
}
|
||||
return {
|
||||
isPublic: false,
|
||||
error: response.statusText,
|
||||
};
|
||||
},
|
||||
ErrorBoundary: ErrorBoundary,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/karaktereim",
|
||||
element: <CharacterList />,
|
||||
loader: () => fetch(`${window.location.origin}/api/Character`),
|
||||
ErrorBoundary: ErrorBoundary,
|
||||
},
|
||||
{
|
||||
path: "/1e",
|
||||
loader: () => redirect("/1e/karakter")
|
||||
},
|
||||
{
|
||||
path: "/1e/karakter",
|
||||
element: <CreateCharacter faro={props.faro} />,
|
||||
ErrorBoundary: ErrorBoundary,
|
||||
},
|
||||
{
|
||||
path: "/1e/karakter/:id",
|
||||
element: <CreateCharacter faro={props.faro}/>,
|
||||
loader: args => fetch(`${window.location.origin}/api/Character1E/${args.params.id}`),
|
||||
ErrorBoundary: ErrorBoundary,
|
||||
},
|
||||
{
|
||||
path: "/2e",
|
||||
loader: () => redirect("/2e/karakter")
|
||||
},
|
||||
{
|
||||
path: "/2e/karakter",
|
||||
element: <CreateCharacter2E faro={props.faro}/>,
|
||||
ErrorBoundary: ErrorBoundary,
|
||||
},
|
||||
{
|
||||
path: "/2e/karakter/:id",
|
||||
element: <CreateCharacter2E faro={props.faro}/>,
|
||||
loader: async args => {
|
||||
const response = await fetch(`${window.location.origin}/api/Character2E/${args.params.id}`)
|
||||
if (response.ok) {
|
||||
const loaded2Echaracter = await response.json()
|
||||
dispatch(setCharacter(loaded2Echaracter))
|
||||
return loaded2Echaracter;
|
||||
}
|
||||
return {
|
||||
isPublic: false,
|
||||
error: response.statusText,
|
||||
};
|
||||
},
|
||||
ErrorBoundary: ErrorBoundary,
|
||||
},
|
||||
]);
|
||||
]), [dispatch, fetchedUser.email, props.faro]);
|
||||
|
||||
return (
|
||||
<div className='container'>
|
||||
<RouterProvider router={router}/>
|
||||
</div>
|
||||
)
|
||||
return <RouterProvider router={router}/>
|
||||
}
|
||||
|
||||
function App(props: { faro?: Faro }) {
|
||||
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<Header/>
|
||||
<Router faro={props.faro} />
|
||||
<Footer />
|
||||
</Provider>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, {useState} from 'react';
|
||||
import './CreateCharacter.css'
|
||||
import React, {useCallback, useEffect, useMemo, useState} from 'react';
|
||||
import './CreateCharacter.less'
|
||||
import {Faj, TulajdonsagokFajjal} from "../domain-models/faj";
|
||||
import {Osztaly, SetFelszerelesForChangedOsztaly} from "../domain-models/osztaly"
|
||||
import FajSelector from "../components/FajSelector";
|
||||
@@ -56,15 +56,43 @@ function CreateCharacterPage(props: {
|
||||
|
||||
let [karakter, changeKarakter] = useState(initialKarakterInputs)
|
||||
|
||||
const tulajdonsagokFajjal = TulajdonsagokFajjal(karakter.tulajdonsagok, karakter.faj)
|
||||
const tulajdonsagokFajjal = useMemo(() => TulajdonsagokFajjal(karakter.tulajdonsagok, karakter.faj), [karakter.tulajdonsagok, karakter.faj])
|
||||
|
||||
const changeKepzettseg = (k: KepzettsegId[]) => changeKarakter({...karakter, kepzettsegek: k})
|
||||
const changeTolvajKepzettseg = (tk?: KepzettsegId[]) => changeKarakter({...karakter, tolvajKepzettsegek: tk})
|
||||
SetDefaultTolvajKepzettsegek(karakter, changeTolvajKepzettseg)
|
||||
SetDefaultKepzettsegek({...karakter, tulajdonsagok: tulajdonsagokFajjal}, changeKepzettseg)
|
||||
const availableKepzettsegList = AvailableKezpettsegList(karakter.osztaly)
|
||||
const setFelszereles = (f: KarakterFelszereles) => changeKarakter({...karakter, felszereles: f})
|
||||
SetFelszerelesForChangedOsztaly(karakter.osztaly, karakter.felszereles, setFelszereles)
|
||||
const changeKepzettseg = useCallback((k: KepzettsegId[]) => {
|
||||
changeKarakter(prev => ({...prev, kepzettsegek: k}))
|
||||
}, [])
|
||||
const changeTolvajKepzettseg = useCallback((tk?: KepzettsegId[]) => {
|
||||
changeKarakter(prev => ({...prev, tolvajKepzettsegek: tk}))
|
||||
}, [])
|
||||
const availableKepzettsegList = useMemo(() => AvailableKezpettsegList(karakter.osztaly), [karakter.osztaly])
|
||||
const setFelszereles = useCallback((f: KarakterFelszereles) => {
|
||||
changeKarakter(prev => ({...prev, felszereles: f}))
|
||||
}, [])
|
||||
|
||||
const tolvajDefaultsInput = useMemo(() => ({
|
||||
osztaly: karakter.osztaly,
|
||||
tolvajKepzettsegek: karakter.tolvajKepzettsegek,
|
||||
}), [karakter.osztaly, karakter.tolvajKepzettsegek])
|
||||
|
||||
const kepzettsegDefaultsInput = useMemo(() => ({
|
||||
osztaly: karakter.osztaly,
|
||||
faj: karakter.faj,
|
||||
tulajdonsagok: tulajdonsagokFajjal,
|
||||
kepzettsegek: karakter.kepzettsegek,
|
||||
tolvajKepzettsegek: karakter.tolvajKepzettsegek,
|
||||
}), [karakter.osztaly, karakter.faj, tulajdonsagokFajjal, karakter.kepzettsegek, karakter.tolvajKepzettsegek])
|
||||
|
||||
useEffect(() => {
|
||||
SetDefaultTolvajKepzettsegek(tolvajDefaultsInput, changeTolvajKepzettseg)
|
||||
}, [tolvajDefaultsInput, changeTolvajKepzettseg])
|
||||
|
||||
useEffect(() => {
|
||||
SetDefaultKepzettsegek(kepzettsegDefaultsInput, changeKepzettseg)
|
||||
}, [kepzettsegDefaultsInput, changeKepzettseg])
|
||||
|
||||
useEffect(() => {
|
||||
SetFelszerelesForChangedOsztaly(karakter.osztaly, karakter.felszereles, setFelszereles)
|
||||
}, [karakter.osztaly, karakter.felszereles, setFelszereles])
|
||||
|
||||
const levelUp = () => LevelUp(karakter, changeKarakter)
|
||||
const levelDown = () => LevelDown(karakter, changeKarakter)
|
||||
|
||||
Vendored
+2
-1
@@ -1 +1,2 @@
|
||||
/// <reference types="react-scripts" />
|
||||
/// <reference types="vite/client" />
|
||||
/// <reference types="vitest/globals" />
|
||||
|
||||
@@ -1,24 +1,28 @@
|
||||
import * as React from "react";
|
||||
import axios from "axios";
|
||||
import {Container, Nav, Navbar} from "react-bootstrap";
|
||||
import {userSelector} from "./domain-models/userSlice";
|
||||
import {RootState} from "../store";
|
||||
import {useSelector} from "react-redux";
|
||||
|
||||
async function logout() {
|
||||
await axios.post("/Identity/Account/Logout")
|
||||
document.location.reload()
|
||||
}
|
||||
import {unsetUser, userSelector} from "./domain-models/userSlice";
|
||||
import {AppDispatch, RootState} from "../store";
|
||||
import {useDispatch, useSelector} from "react-redux";
|
||||
import {Link, useNavigate} from "react-router-dom";
|
||||
|
||||
function Header() {
|
||||
|
||||
const dispatch = useDispatch.withTypes<AppDispatch>()();
|
||||
const navigate = useNavigate();
|
||||
const fetchedUser = useSelector.withTypes<RootState>()(userSelector);
|
||||
|
||||
const logout = async () => {
|
||||
await axios.post("/Identity/Account/Logout")
|
||||
dispatch(unsetUser())
|
||||
navigate("/")
|
||||
}
|
||||
|
||||
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.email != null && <Nav.Link className="text-dark" href="/karaktereim">Karaktereim</Nav.Link>}
|
||||
<Navbar.Brand as={Link} to="/">Kemkas</Navbar.Brand>
|
||||
{fetchedUser.email != null && <Nav.Link as={Link} className="text-dark" to="/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>
|
||||
@@ -38,7 +42,7 @@ function Header() {
|
||||
href="/Identity/Account/Manage">Hello {fetchedUser.email}!</a>
|
||||
</li>
|
||||
<li className="nav-item">
|
||||
<button className="nav-link nav text-dark" onClick={logout}>Logout</button>
|
||||
<button type="button" className="nav-link nav text-dark" onClick={logout}>Logout</button>
|
||||
</li>
|
||||
</>
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as React from "react";
|
||||
import {useLoaderData} from "react-router-dom";
|
||||
import {Link, 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";
|
||||
@@ -68,12 +68,12 @@ function CharacterList(props: {}) {
|
||||
<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>
|
||||
<Link className="btn btn-dark btn-lg" to="/2e/karakter">Új 2e karakter létrehozása</Link>
|
||||
</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>
|
||||
<Link className="btn btn-dark btn-lg" to="/1e/karakter">Új 1e karakter létrehozása</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"target": "es2020",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
@@ -14,14 +14,14 @@
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
"downlevelIteration": true
|
||||
"jsx": "react-jsx"
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
"src",
|
||||
"vite.config.ts"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { defineConfig, loadEnv } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
|
||||
export default defineConfig(({ mode }) => {
|
||||
const env = loadEnv(mode, process.cwd(), '');
|
||||
const port = Number(env.PORT || 5173);
|
||||
const https = env.HTTPS === 'true';
|
||||
|
||||
return {
|
||||
plugins: [react()],
|
||||
server: {
|
||||
port,
|
||||
https,
|
||||
strictPort: true,
|
||||
allowedHosts: ['localhost', 'host.docker.internal', 'frontend'],
|
||||
},
|
||||
test: {
|
||||
globals: true,
|
||||
environment: 'jsdom',
|
||||
setupFiles: './vitest.setup.ts',
|
||||
},
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
import '@testing-library/jest-dom/vitest';
|
||||
+905
-9223
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -47,7 +47,7 @@ http {
|
||||
#access_log /var/log/nginx/host.access.log main;
|
||||
|
||||
location / {
|
||||
proxy_pass https://frontend;
|
||||
proxy_pass http://frontend;
|
||||
}
|
||||
|
||||
# redirect server error pages to the static page /50x.html
|
||||
|
||||
Reference in New Issue
Block a user