From 9d5216195784c8a892c5c54357fc2e73014b4fdf Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Sun, 12 Sep 2021 20:48:11 -0700 Subject: [PATCH] Start supporting Juteyuji --- src/App.tsx | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index efea1aa..d351e88 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -6,10 +6,10 @@ import {declineSaimiar} from './saimiar_morphology'; const backendUrl = 'https://kucinakobackend.ichigo.everydayimshuflin.com'; enum Conlang { - Saimiar = 'sai', - Elesu = 'ele', - Tukvaysi = 'tuk', - Juteyuji = 'jut', + Saimiar = 'saimiar', + Elesu = 'elesu', + Tukvaysi = 'tukvaysi', + Juteyuji = 'juteyuji', } const renderConlang = (conlang: Conlang): string => { @@ -45,6 +45,10 @@ const Entry = (props) => { return ; } + if (conlang === Conlang.Juteyuji) { + return ; + } + return
Conlang { conlang } not yet supported
; }; @@ -66,6 +70,20 @@ const SaiEntry = (props) => { ); }; +const JutEntry = (props) => { + const {entry} = props; + console.log(props); + + return ( +
+ { entry.jut } - { entry.eng } +
+ + { entry.syn_category === 'noun' ? entry.gender : null } + +
); +}; + function formatMorphology(entry) { const decl = declineSaimiar(entry); if (!decl) { @@ -87,7 +105,7 @@ const Results = (props) => { const content = () => { const {conlang} = props; const num = props.searchResults.length; - console.log(`Conlang is: ${conlang}`); + const renderedName = renderConlang(conlang); const searchType = (props.direction === 'toConlang') ? `English -> ${renderedName}` : `${renderedName} -> English`; const header = ( @@ -120,6 +138,7 @@ class App extends Component { this.searchEng = this.searchEng.bind(this); this.searchSaimiar = this.searchSaimiar.bind(this); + this.searchJuteyuji = this.searchJuteyuji.bind(this); this.searchConlang = this.searchConlang.bind(this); this.state = { @@ -135,6 +154,8 @@ class App extends Component { const {conlang} = this.state; if (conlang === Conlang.Saimiar) { this.searchSaimiar(searchTerm); + } else if (conlang == Conlang.Juteyuji) { + this.searchJuteyuji(searchTerm); } else { console.error(`Conlang ${conlang} not supported`); } @@ -151,9 +172,21 @@ class App extends Component { } } + searchJuteyuji(searchTerm: string) { + const request = `juteyuji?jut=like.*${searchTerm}*`; + if (searchTerm === '') { + this.setState({searchResults: null, searchTerm: null, direction: null}); + } else { + makeRequest(request, (json) => { + this.setState({searchResults: json, searchTerm, direction: 'toEnglish'}); + }); + } + } + searchEng(_evt) { const searchTerm = this.input.current.value; - const request = `saimiar?eng=like.*${searchTerm}*`; + const {conlang} = this.state; + const request = `${conlang}?eng=like.*${searchTerm}*`; if (searchTerm === '') { this.setState({searchResults: null, searchTerm: null}); } else { @@ -166,7 +199,7 @@ class App extends Component { handleLangChange(evt) { const conlang: Conlang = evt.target.value as Conlang; console.log('Conlang in handlelangchange', conlang); - this.setState({conlang}); + this.setState({conlang, searchResults: null}); } render() {