Compare commits

..

No commits in common. "146b8126a2d987717fd0c279ca9d377f8f13d497" and "9d5216195784c8a892c5c54357fc2e73014b4fdf" have entirely different histories.

2 changed files with 12 additions and 50 deletions

View File

@ -21,10 +21,6 @@ module.exports = {
],
rules: {
"arrow-parens": ["error", "always"],
"indent": ["error", 4],
"unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"no-redeclare": "off",
"@typescript-eslint/no-redeclare": ["error"]
"indent": ["error", 4]
},
};

View File

@ -12,11 +12,6 @@ enum Conlang {
Juteyuji = 'juteyuji',
}
enum SearchDirection {
ToConlang,
ToEnglish
}
const renderConlang = (conlang: Conlang): string => {
if (conlang === Conlang.Saimiar) {
return 'Saimiar';
@ -44,34 +39,20 @@ function makeRequest(queryString, jsonHandler) {
});
}
interface EntryProps {
conlang: Conlang;
entry: SaiEntryProps | JutEntryProps;
key: string;
}
const Entry = (props: EntryProps) => {
const Entry = (props) => {
const {conlang} = props;
if (conlang === Conlang.Saimiar) {
return <SaiEntry entry={ props.entry as SaiEntryProps } />;
return <SaiEntry entry={ props.entry } />;
}
if (conlang === Conlang.Juteyuji) {
return <JutEntry entry={ props.entry as JutEntryProps } />;
return <JutEntry entry={ props.entry } />;
}
return <div>Conlang { conlang } not yet supported</div>;
};
interface SaiEntryProps {
id: number;
sai: string;
eng: string;
syn_category: string;
morph_type: string;
}
const SaiEntry = (props: {entry: SaiEntryProps}) => {
const SaiEntry = (props) => {
const {entry} = props;
const synCategory = entry.syn_category;
const isNominal = synCategory === 'nominal';
@ -89,15 +70,7 @@ const SaiEntry = (props: {entry: SaiEntryProps}) => {
);
};
interface JutEntryProps {
id: number;
jut: string;
eng: string;
syn_category: string;
gender: string;
}
const JutEntry = (props: {entry: JutEntryProps}) => {
const JutEntry = (props) => {
const {entry} = props;
console.log(props);
@ -128,20 +101,13 @@ function formatMorphology(entry) {
</span>);
}
interface ResultsProps {
searchResults: any;
searchTerm: string;
conlang: Conlang;
direction: SearchDirection;
}
const Results = (props: ResultsProps) => {
const Results = (props) => {
const content = () => {
const {conlang} = props;
const num = props.searchResults.length;
const renderedName = renderConlang(conlang);
const searchType = (props.direction === SearchDirection.ToConlang) ? `English -> ${renderedName}` : `${renderedName} -> English`;
const searchType = (props.direction === 'toConlang') ? `English -> ${renderedName}` : `${renderedName} -> English`;
const header = (
<div className="searchResultHeader" key="header">
Searched for <b>{ props.searchTerm }</b>, { searchType }, found { num } result(s)
@ -188,7 +154,7 @@ class App extends Component {
const {conlang} = this.state;
if (conlang === Conlang.Saimiar) {
this.searchSaimiar(searchTerm);
} else if (conlang === Conlang.Juteyuji) {
} else if (conlang == Conlang.Juteyuji) {
this.searchJuteyuji(searchTerm);
} else {
console.error(`Conlang ${conlang} not supported`);
@ -201,7 +167,7 @@ class App extends Component {
this.setState({searchResults: null, searchTerm: null, direction: null});
} else {
makeRequest(request, (json) => {
this.setState({searchResults: json, searchTerm, direction: SearchDirection.ToEnglish});
this.setState({searchResults: json, searchTerm, direction: 'toEnglish'});
});
}
}
@ -212,7 +178,7 @@ class App extends Component {
this.setState({searchResults: null, searchTerm: null, direction: null});
} else {
makeRequest(request, (json) => {
this.setState({searchResults: json, searchTerm, direction: SearchDirection.ToEnglish});
this.setState({searchResults: json, searchTerm, direction: 'toEnglish'});
});
}
}
@ -225,7 +191,7 @@ class App extends Component {
this.setState({searchResults: null, searchTerm: null});
} else {
makeRequest(request, (json) => {
this.setState({searchResults: json, searchTerm, direction: SearchDirection.ToConlang});
this.setState({searchResults: json, searchTerm, direction: 'toConlang'});
});
}
}