diff --git a/src/components/FajSelector.tsx b/src/components/FajSelector.tsx
index 028f1c9..f1ba527 100644
--- a/src/components/FajSelector.tsx
+++ b/src/components/FajSelector.tsx
@@ -1,31 +1,44 @@
import React from "react";
-import {Faj, FajLabel} from "../domain-models/faj";
+import {Faj, FajDescription, FajLabel, FajSpecials} from "../domain-models/faj";
import {UseFormRegisterReturn} from "react-hook-form";
-function FajSelector(props: {register: () => UseFormRegisterReturn}) {
- const {register} = props
- return
-
-
-
+function FajSelector(props: { register: () => UseFormRegisterReturn, currentFaj: () => Faj }) {
+ const {register, currentFaj} = props
+ return <>
+
+
+
+
+
+
+
+
+ {FajDescription(currentFaj())}
+
+
+ {FajSpecials(currentFaj()).map(((special, i) => (- {special}
)))}
+
+
+
+ >
}
export default FajSelector
\ No newline at end of file
diff --git a/src/components/OsztalySelector.tsx b/src/components/OsztalySelector.tsx
new file mode 100644
index 0000000..bbce2ba
--- /dev/null
+++ b/src/components/OsztalySelector.tsx
@@ -0,0 +1,73 @@
+import React from "react";
+import {
+ Osztaly,
+ OsztalyDescription,
+ OsztalyLabel,
+ OsztalyProperties,
+ OsztalySpecialSkills
+} from "../domain-models/osztaly";
+import {Faj} from "../domain-models/faj";
+import {UseFormRegisterReturn} from "react-hook-form";
+
+function OsztalySelector(props: {currentFaj: () => Faj, currentOsztaly: () => Osztaly, register: () => UseFormRegisterReturn}) {
+ const {currentFaj, currentOsztaly, register} = props;
+
+ return <>
+
+
+
+
+
+
+
+
+ {OsztalyDescription(currentOsztaly())}
+
+
+ {OsztalyProperties(currentOsztaly()).map(((special, i) => (- {special}
)))}
+
+
+ {OsztalySpecialSkills(currentOsztaly()).map(skill => (
+
+ ))}
+
+ {OsztalySpecialSkills(currentOsztaly()).map(skill => (
+
+
+ {skill.Description}
+
+
+ ))}
+
+
+ >
+}
+
+export default OsztalySelector;
\ No newline at end of file
diff --git a/src/pages/CreateCharacter.tsx b/src/pages/CreateCharacter.tsx
index a6f9a66..7bd373e 100644
--- a/src/pages/CreateCharacter.tsx
+++ b/src/pages/CreateCharacter.tsx
@@ -1,16 +1,14 @@
import React from 'react';
import './CreateCharacter.css'
import {useForm} from "react-hook-form";
-import {Faj, FajDescription, FajLabel, FajSpecials} from "../domain-models/faj";
-import {
- Osztaly,
- OsztalyDescription,
- OsztalyLabel,
- OsztalyProperties,
- OsztalySpecialSkills
-} from "../domain-models/osztaly"
+import {Faj} from "../domain-models/faj";
+import {Osztaly} from "../domain-models/osztaly"
import FajSelector from "../components/FajSelector";
import Tulajdonsagok from "../components/Tulajdonsagok";
+import OsztalySelector from "../components/OsztalySelector";
+
+const FAJ_FIELD_NAME = 'faj'
+const OSZTALY_FIELD_NAME = 'osztaly'
function CreateCharacterPage() {
const {
@@ -22,9 +20,9 @@ function CreateCharacterPage() {
} = useForm()
const sendForm = (data: any) => console.log(data)
- const currentFaj = () => watch().faj || Faj.Ember
+ const currentFaj = () => watch(FAJ_FIELD_NAME, Faj.Ember)
- const currentOsztaly = () => watch().osztaly || Osztaly.Harcos
+ const currentOsztaly = () => watch(OSZTALY_FIELD_NAME, Osztaly.Harcos)
return (
@@ -42,78 +40,26 @@ function CreateCharacterPage() {
defaultValue='Névtelen Kalandozó' {...register('nev', {required: true})} />
{errors.nev && A karaktered nem mászkálhat névtelenül a világban!}
- register('faj', {required: true})} />
-
-
-
-
- {FajDescription(currentFaj())}
-
-
- {FajSpecials(currentFaj()).map(((special, i) => (- {special}
)))}
-
-
-
+ register(FAJ_FIELD_NAME, {required: true})}
+ currentFaj={currentFaj}
+ />
-
+
Tanult
-
-
-
-
-
-
-
-
- {OsztalyDescription(currentOsztaly())}
-
-
- {OsztalyProperties(currentOsztaly()).map(((special, i) => (- {special}
)))}
-
-
- {OsztalySpecialSkills(currentOsztaly()).map(skill => (
-
- ))}
-
- {OsztalySpecialSkills(currentOsztaly()).map(skill => (
-
-
- {skill.Description}
-
-
- ))}
-
-
+ register(OSZTALY_FIELD_NAME, {required: true})}
+ />