Skip to content

Commit

Permalink
chore(ui): fix UI TS
Browse files Browse the repository at this point in the history
  • Loading branch information
ijemmao committed Sep 21, 2024
1 parent 809c30b commit b8628d8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
11 changes: 4 additions & 7 deletions src/controllers/utils/minimizeVerbsAndSuffixes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@ import { assign, pick } from 'lodash';
import Version from '../../shared/constants/Version';
import WordClassEnum from '../../shared/constants/WordClassEnum';
import { MinimizedWord } from './types';
import { OutgoingWord, OutgoingLegacyWord } from '../../types';
import { OutgoingWord } from '../../types';

const isVerb = (wordClass: WordClassEnum) =>
wordClass === WordClassEnum.ADV ||
wordClass === WordClassEnum.AV ||
wordClass === WordClassEnum.PV ||
wordClass === WordClassEnum.MV;

const minimizeVerbsAndSuffixes = (
words: Partial<OutgoingWord>[] | Partial<OutgoingLegacyWord>[],
version: Version,
) => {
const minimizeVerbsAndSuffixes = (words: Partial<OutgoingWord>[], version: Version) => {
const minimizedWords = words.reduce(
(finalVerbsAndSuffixes, word) => {
const minimizedWord = pick(assign(word), ['word', 'definitions']) as MinimizedWord;
minimizedWord.definitions =
version === Version.VERSION_2
? (minimizedWord.definitions || []).map((definition) =>
pick(assign(definition), ['wordClass']),
pick(assign(definition), ['wordClass'])
)
: minimizedWord.definitions;
if (minimizedWord.definitions.some(({ wordClass }) => isVerb(wordClass))) {
Expand All @@ -30,7 +27,7 @@ const minimizeVerbsAndSuffixes = (
}
return finalVerbsAndSuffixes;
},
{ verbs: [], suffixes: [] } as { verbs: MinimizedWord[], suffixes: MinimizedWord[] },
{ verbs: [], suffixes: [] } as { verbs: MinimizedWord[], suffixes: MinimizedWord[] }
);
return minimizedWords;
};
Expand Down
2 changes: 1 addition & 1 deletion src/pages/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Statistics from './components/Statistics';
import MentionedIn from './components/MentionedIn';
import GitHubStars from './components/GitHubStars';
import Features from './components/Features';
import { DatabaseStats, GitHubStats, Word } from '../types';
import { DatabaseStats, GitHubStats, OutgoingWord as Word } from '../types';

const App = ({
searchWord,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/components/Demo/Demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import omit from 'lodash/omit';
import queryString from 'query-string';
import JSONPretty from 'react-json-pretty';
import { API_ROUTE, DICTIONARY_APP_URL } from '../../../siteConstants';
import { Example, Word } from '../../../types';
import { OutgoingExample as Example, OutgoingWord as Word } from '../../../types';
import { WordDialect } from '../../../types/word';

const Demo = ({ searchWord, words }: { searchWord?: string, words: Word[] }) => {
Expand Down

0 comments on commit b8628d8

Please sign in to comment.