diff --git a/src/dictionaries/seed.js b/src/dictionaries/seed.js deleted file mode 100644 index f260d883..00000000 --- a/src/dictionaries/seed.js +++ /dev/null @@ -1,100 +0,0 @@ -import map from 'lodash/map'; -import flatten from 'lodash/flatten'; -import keys from 'lodash/keys'; -import omit from 'lodash/omit'; -import { createWord } from '../controllers/words'; -import dictionary from './ig-en/ig-en.json'; -import Dialects from '../shared/constants/Dialect'; -import WordClass from '../shared/constants/WordClass'; -import { createDbConnection, handleCloseConnection } from '../services/database'; - -const WRITE_DB_DELAY = 15000; - -const populate = async (connection) => { - /* This route will populate a local MongoDB database */ - if (process.env.NODE_ENV !== 'production') { - console.blue('🌱 Seeding database...'); - connection.dropDatabase(); - const wordPromises = flatten( - map(keys(dictionary), (key) => { - const value = dictionary[key]; - return map(value, (term) => { - const word = omit({ ...term }, ['stems']); - const cleanedKey = key.replace(/\./g, ''); - word.word = key; - word.definitions = [ - { - wordClass: word.wordClass || WordClass.NNC.value, - definitions: word.definitions, - }, - ]; - word.dialects = [ - { - dialects: [Dialects.NSA.value], - variations: [], - pronunciation: '', - word: `${cleanedKey}-dialect`, - }, - ]; - return createWord(word, connection); - }); - }) - ); - /* Waits for all the MongoDB document save promises to resolve */ - const savedWords = await Promise.all(wordPromises) - .then(async () => { - /* Wait 15 seconds to allow the data to be written to database */ - await new Promise((resolve) => - setTimeout(() => { - console.green('✅ Seeding successful'); - if (process.env.NODE_ENV === 'production') { - resolve(); - process.exit(0); - } else { - resolve(); - } - }, WRITE_DB_DELAY) - ); - }) - .catch((err) => { - console.red('🔴 Seeding failed', err); - }); - return savedWords; - } - return Promise.resolve(); -}; - -const seed = () => { - const connection = createDbConnection(); - connection.on('error', console.error.bind(console, 'connection error:')); - return new Promise((resolve) => - connection.once('connected', async () => { - console.green('🗄 Database is connected'); - await populate(connection); - await handleCloseConnection(connection); - return resolve(); - }) - ); -}; - -const sendResponseAndEndServer = (res) => { - res.redirect('/'); - return setTimeout(() => { - console.log('💡 Restarting the server'); - return process.exit(0); - }, 2000); -}; - -export const seedDatabase = async (_, res, next) => { - try { - await seed(); - /* Ends the docker container to restart. Necessary for - * Text Indexes to be created for testing purposes */ - if (process.env.CONTAINER_HOST === 'mongodb') { - return sendResponseAndEndServer(res); - } - return res.redirect('/'); - } catch (err) { - return next(new Error('An error occurred during seeding')); - } -}; diff --git a/src/middleware/authorization.js b/src/middleware/authorization.js deleted file mode 100644 index 81595d0f..00000000 --- a/src/middleware/authorization.js +++ /dev/null @@ -1,29 +0,0 @@ -import { isDevelopment } from '../config'; -import { handleRequest, findDeveloper } from '../controllers/utils/findDeveloper'; - -const FALLBACK_API_KEY = 'fallback_api_key'; - -export default async (req, res, next) => { - try { - let { apiToken: apiKey } = handleRequest(req); - - if (!apiKey && isDevelopment) { - apiKey = FALLBACK_API_KEY; - } - - // Check if API key belongs to the requested developer - const developer = await findDeveloper(apiKey); - - if (developer.length < 1) { - throw new Error('Invalid API Key. Check your API Key and try again', { cause: 403 }); - } - req.developer = developer; - return next(); - } catch (err) { - let status = 400; - if ('cause' in err) { - status = err.cause; - } - return res.status(status).send({ error: err.message }); - } -}; diff --git a/src/pages/about.js b/src/pages/about.js deleted file mode 100644 index d6ed31d6..00000000 --- a/src/pages/about.js +++ /dev/null @@ -1,117 +0,0 @@ -import React, { useEffect, useState } from 'react'; -import i18n from 'i18next'; -import { useTranslation } from 'react-i18next'; -import Navbar from './components/Navbar'; -import Footer from './components/Footer'; -import { DICTIONARY_APP_URL } from '../siteConstants'; - -const About = () => { - const { t } = useTranslation('about'); - const [language, setLanguage] = useState(i18n.language); - useEffect(() => { - /* Logic for rendering Nsịbịdị */ - // if (i18n?.language === 'ig') { - // document.body.classList.add('akagu'); - // document.body.style.fontFamily = 'Akagu'; - // } - setLanguage(i18n?.language); - }, [i18n?.language]); // eslint-disable-line react-hooks/exhaustive-deps - - return ( -
- -
-
-

{t('About')}

-

- {t( - 'The Igbo API is a multidialectal, audio-supported, open-to-contribute, Igbo-English dictionary API. ' + - 'This project focuses on enabling developers, organizations, and teams to create technology ' + - 'that relies on the Igbo language.' - )} -

-

- {t( - 'Our main goal is to make an easy-to-access, robust, lexical Igbo language resource ' + - 'to help solve a variety of complex problems within the worlds of education to Machine Learning.' - )} -

- {language === 'en' ? ( -

- {'The Igbo API hosts and serves all word and example sentence data that is shown on '} - - Nkọwa okwu - - , our official online Igbo-English dictionary app. -

- ) : ( -

- )} - {language === 'en' ? ( -

- {`The initial words and examples that populated this API came - from Kay Williamson's Igbo Dictionary entitled `} - - {'Dictionary of Ònìchà Igbo. '} - -

- ) : ( -

- )} - {language === 'en' ? ( -

- {'This is an '} - - open-source project - - {' created by '} - - Ijemma Onwuzulike - - . -

- ) : ( -

- )} -

-
-
-

{t('Contact')}

-

- {t('Email')} - {': '} - - kedu@nkowaokwu.com - -

-
-
- ); -}; - -export default About; diff --git a/src/pages/components/Sidebar/SidebarItem.tsx b/src/pages/components/Sidebar/SidebarItem.tsx index 2bb86b23..ca74bf7a 100644 --- a/src/pages/components/Sidebar/SidebarItem.tsx +++ b/src/pages/components/Sidebar/SidebarItem.tsx @@ -1,19 +1,36 @@ import React from 'react'; -import { Box, Flex } from '@chakra-ui/react'; +import { Box, Flex, FlexProps } from '@chakra-ui/react'; interface IconType { size?: string | number | boolean; } -interface SidebarItemProps { +interface SidebarItemProps extends FlexProps { icon: React.ReactElement; href: string; children: React.ReactNode; activeBgColor?: string; activeTextColor?: string; + _active?: { + bg: string; + }; + _hover?: { + bg?: string; + color?: string; + }; + mb?: number; } -const SidebarItem = ({ icon, href, children, activeBgColor, activeTextColor }: SidebarItemProps) => ( +const SidebarItem = ({ + icon, + href, + children, + activeBgColor, + activeTextColor, + _active, + _hover, + mb, +}: SidebarItemProps) => ( {icon} {children} diff --git a/src/pages/components/Statistics/Statistics.js b/src/pages/components/Statistics/Statistics.js deleted file mode 100644 index ebb43af5..00000000 --- a/src/pages/components/Statistics/Statistics.js +++ /dev/null @@ -1,102 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { Tooltip } from '@chakra-ui/react'; -import { useTranslation } from 'react-i18next'; -import Stat from './Stat'; - -const Statistics = ({ - totalWords, - totalExamples, - totalAudioPronunciations, - totalIgboDefinitions, - totalProverbs, - totalBibleVerses, - totalNsibidiWords, - totalDevelopers, - contributors, - stars, -}) => { - const { t } = useTranslation(); - const totalSlackMembers = 230; - return ( -
-
- - - - - - - - -
-
- {contributors ? ( - -
- {contributors - .slice(0, 18) - .filter(({ login }) => login !== 'semantic-release-bot') - .map((contributor) => ( - -
- - github avatar - -
-
- ))} -
-
- ) : null} - - -
-
- ); -}; - -Statistics.propTypes = { - totalWords: PropTypes.number, - totalExamples: PropTypes.number, - totalAudioPronunciations: PropTypes.number, - totalIgboDefinitions: PropTypes.number, - totalProverbs: PropTypes.number, - totalBibleVerses: PropTypes.number, - totalNsibidiWords: PropTypes.number, - totalDevelopers: PropTypes.number, - contributors: PropTypes.arrayOf(PropTypes.shape({})), - stars: PropTypes.number, -}; - -Statistics.defaultProps = { - totalWords: 0, - totalExamples: 0, - totalAudioPronunciations: 0, - totalIgboDefinitions: 0, - totalProverbs: 0, - totalBibleVerses: 0, - totalNsibidiWords: 0, - totalDevelopers: 0, - contributors: [], - stars: 0, -}; - -export default Statistics; diff --git a/src/pages/components/UserInformation/UserInfo.js b/src/pages/components/UserInformation/UserInfo.js deleted file mode 100644 index 04a80908..00000000 --- a/src/pages/components/UserInformation/UserInfo.js +++ /dev/null @@ -1,13 +0,0 @@ -import { Heading } from '@chakra-ui/react'; -import React from 'react'; - -const UserInfo = () => ( -
- User Information -

Name: David Ndubuisi

-

Email: davydocsurg@gmail.com

-

Total Daily Usage: 54

-
-); - -export default UserInfo; diff --git a/src/pages/components/UserInformation/index.js b/src/pages/components/UserInformation/index.js deleted file mode 100644 index 472091c5..00000000 --- a/src/pages/components/UserInformation/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import UserInfo from './UserInfo'; - -export default UserInfo; diff --git a/src/pages/login.js b/src/pages/login.js deleted file mode 100644 index f7628fa7..00000000 --- a/src/pages/login.js +++ /dev/null @@ -1,6 +0,0 @@ -import React from 'react'; -import { Box } from '@chakra-ui/react'; - -const Login = () => Login; - -export default Login;