diff --git a/src/App.jsx b/src/App.jsx
index e3a043d..576f2b5 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -6,66 +6,66 @@ import {declineSaimiar} from './saimiar_morphology.ts';
const backendUrl = 'https://kucinakobackend.ichigo.everydayimshuflin.com';
function makeRequest(queryString, jsonHandler) {
- const effectiveUrl = `${backendUrl}/${queryString}`;
- fetch(`${effectiveUrl}`)
- .then((resp) => resp.json())
- .then((json) => {
- jsonHandler(json);
- });
+ const effectiveUrl = `${backendUrl}/${queryString}`;
+ fetch(`${effectiveUrl}`)
+ .then((resp) => resp.json())
+ .then((json) => {
+ jsonHandler(json);
+ });
}
function renderConlangName(name) {
- if (name === 'saimiar') {
- return 'Saimiar';
- }
+ if (name === 'saimiar') {
+ return 'Saimiar';
+ }
- if (name === 'elesu') {
- return 'Elésu';
- }
+ if (name === 'elesu') {
+ return 'Elésu';
+ }
- if (name === 'juteyuji') {
- return 'Juteyuji';
- }
+ if (name === 'juteyuji') {
+ return 'Juteyuji';
+ }
- if (name === 'tukvaysi') {
- return 'Tukvaysi';
- }
+ if (name === 'tukvaysi') {
+ return 'Tukvaysi';
+ }
}
const Entry = (props) => {
- const {conlang} = props;
- if (conlang === 'saimiar') {
- return ;
- }
+ const {conlang} = props;
+ if (conlang === 'saimiar') {
+ return ;
+ }
- return
Unknown entry type for { conlang }
;
+ return Unknown entry type for { conlang }
;
};
const SaiEntry = (props) => {
- const {entry} = props;
- const synCategory = entry.syn_category;
- const isNominal = synCategory === 'nominal';
- return (
-
- { entry.sai } - { entry.eng }
-
-
- { entry.syn_category }
- { entry.morph_type ? `\t\t${entry.morph_type}` : null }
-
- { isNominal ? formatMorphology(entry) : null }
-
-
- );
+ const {entry} = props;
+ const synCategory = entry.syn_category;
+ const isNominal = synCategory === 'nominal';
+ return (
+
+ { entry.sai } - { entry.eng }
+
+
+ { entry.syn_category }
+ { entry.morph_type ? `\t\t${entry.morph_type}` : null }
+
+ { isNominal ? formatMorphology(entry) : null }
+
+
+ );
};
function formatMorphology(entry) {
- const decl = declineSaimiar(entry);
- if (!decl) {
- return '';
- }
+ const decl = declineSaimiar(entry);
+ if (!decl) {
+ return '';
+ }
- return (
+ return (
Abs: {decl.abs}, Erg: {decl.erg},
Adp: {decl.adp},
All: {decl.all},
@@ -73,108 +73,108 @@ function formatMorphology(entry) {
Ell: {decl.ell},
Inst: {decl.inst},
Rel: {decl.rel}
- );
+ );
}
const Results = (props) => {
- const content = () => {
- const {conlang} = props;
- const num = props.searchResults.length;
- const renderedName = renderConlangName(conlang);
- const searchType = (props.direction === 'toConlang') ? `English -> ${renderedName}` : `${renderedName} -> English`;
- const header = (
-
+ const content = () => {
+ const {conlang} = props;
+ const num = props.searchResults.length;
+ const renderedName = renderConlangName(conlang);
+ const searchType = (props.direction === 'toConlang') ? `English -> ${renderedName}` : `${renderedName} -> English`;
+ const header = (
+
Searched for { props.searchTerm }, { searchType }, found { num } result(s)
-
);
- const entries = props.searchResults.map(
- (entry, _idx) =>
,
- );
- return [header].concat(entries);
- };
+
);
+ const entries = props.searchResults.map(
+ (entry, _idx) => ,
+ );
+ return [header].concat(entries);
+ };
- const results = props.searchResults;
- return (
-
- { results ? content() : 'No search' }
-
- );
+ const results = props.searchResults;
+ return (
+
+ { results ? content() : 'No search' }
+
+ );
};
class App extends Component {
- constructor(props) {
- super(props);
- this.input = React.createRef();
- this.handleLangChange = this.handleLangChange.bind(this);
+ constructor(props) {
+ super(props);
+ this.input = React.createRef();
+ this.handleLangChange = this.handleLangChange.bind(this);
- this.searchEng = this.searchEng.bind(this);
- this.searchSaimiar = this.searchSaimiar.bind(this);
+ this.searchEng = this.searchEng.bind(this);
+ this.searchSaimiar = this.searchSaimiar.bind(this);
- this.state = {
- searchResults: null,
- conlang: 'saimiar',
- direction: null,
- searchTerm: null,
- };
- }
+ this.state = {
+ searchResults: null,
+ conlang: 'saimiar',
+ direction: null,
+ searchTerm: null,
+ };
+ }
- searchSaimiar(_evt) {
- const searchTerm = this.input.current.value;
- const request = `saimiar?sai=like.*${searchTerm}*`;
- if (searchTerm === '') {
- this.setState({searchResults: null, searchTerm: null, direction: null});
- } else {
- makeRequest(request, (json) => {
- this.setState({searchResults: json, searchTerm, direction: 'toEnglish'});
- });
- }
- }
+ searchSaimiar(_evt) {
+ const searchTerm = this.input.current.value;
+ const request = `saimiar?sai=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}*`;
- if (searchTerm === '') {
- this.setState({searchResults: null, searchTerm: null});
- } else {
- makeRequest(request, (json) => {
- this.setState({searchResults: json, searchTerm, direction: 'toConlang'});
- });
- }
- }
+ searchEng(_evt) {
+ const searchTerm = this.input.current.value;
+ const request = `saimiar?eng=like.*${searchTerm}*`;
+ if (searchTerm === '') {
+ this.setState({searchResults: null, searchTerm: null});
+ } else {
+ makeRequest(request, (json) => {
+ this.setState({searchResults: json, searchTerm, direction: 'toConlang'});
+ });
+ }
+ }
- handleLangChange(evt) {
- const conlang = evt.target.value;
- this.setState({conlang});
- }
+ handleLangChange(evt) {
+ const conlang = evt.target.value;
+ this.setState({conlang});
+ }
- render() {
- return (
-
-
-
-
Kucinako
-
-
-
-
-
-
-
-
-
-
-
- );
- }
+ render() {
+ return (
+
+
+
+
Kucinako
+
+
+
+
+
+
+
+
+
+
+
+ );
+ }
}
export default App;