diff --git a/.eslintrc.json b/.eslintrc.json index 68ce17347..510585286 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -7,7 +7,6 @@ "plugin:import/errors", "plugin:import/warnings", "plugin:jsx-a11y/recommended", - "plugin:react-hooks/recommended", "airbnb", "next" ], diff --git a/app/favicon.ico b/app/favicon.ico deleted file mode 100755 index f443de1d8..000000000 Binary files a/app/favicon.ico and /dev/null differ diff --git a/app/head.js b/app/head.js deleted file mode 100755 index 4094cccc9..000000000 --- a/app/head.js +++ /dev/null @@ -1,13 +0,0 @@ -// import i18n from '../src/translations/i18n'; -import '../styles/nprogress.css'; - -export default function Head() { - return ( - <> - - - - Scribe Scripture editor - - ); -} diff --git a/app/home/layout.jsx b/app/home/layout.jsx deleted file mode 100755 index b2072ec06..000000000 --- a/app/home/layout.jsx +++ /dev/null @@ -1,22 +0,0 @@ -'use client'; - -import PropTypes from 'prop-types'; -import SubMenuBar from '@/layouts/editor/SubMenuBar'; -import MenuBar from '@/layouts/editor/WebMenuBar'; - -export default function EditorLayout(props) { - const { children } = props; - - return ( - <> - - - -
{children}
- - ); -} - -EditorLayout.propTypes = { - children: PropTypes.any, -}; diff --git a/app/home/page.jsx b/app/home/page.jsx deleted file mode 100755 index 0187a3615..000000000 --- a/app/home/page.jsx +++ /dev/null @@ -1,12 +0,0 @@ -'use client'; - -import SectionContainer from '@/layouts/editor/WebSectionContainer'; -import ProtectedRoute from '@/components/Protected'; - -export default function page() { - return ( - - - - ); -} diff --git a/app/layout.js b/app/layout.js deleted file mode 100755 index addf47cf9..000000000 --- a/app/layout.js +++ /dev/null @@ -1,16 +0,0 @@ -import { Providers } from './providers'; -import '../styles/nprogress.css'; -import '../styles/globals.css'; -// import { initializeParse } from '@parse/react-ssr'; -import 'usfm-editor/dist/style.css'; -import '../styles/style-override.lazy.css'; - -export default function RootLayout({ children }) { - return ( - - - {children} - - - ); -} diff --git a/app/loading.js b/app/loading.js deleted file mode 100755 index c9d5ef850..000000000 --- a/app/loading.js +++ /dev/null @@ -1,7 +0,0 @@ -import LoadingScreen from '@/components/Loading/LoadingScreen'; - -const Loading = () => ( - -); - -export default Loading; diff --git a/app/login/page.jsx b/app/login/page.jsx deleted file mode 100755 index 40a3f7e7f..000000000 --- a/app/login/page.jsx +++ /dev/null @@ -1,5 +0,0 @@ -import WebLogin from '@/components/Login/WebLogin'; - -const login = () => ; - -export default login; diff --git a/app/newproject/page.js b/app/newproject/page.js deleted file mode 100755 index aea0cfe49..000000000 --- a/app/newproject/page.js +++ /dev/null @@ -1,10 +0,0 @@ -import ProtectedRoute from '@/components/Protected'; -import NewWebProject from '@/components/Projects/NewWebProject'; - -const newproject = () => ( - - - -); - -export default newproject; diff --git a/app/page.js b/app/page.js deleted file mode 100755 index 3ac175a66..000000000 --- a/app/page.js +++ /dev/null @@ -1,7 +0,0 @@ -import WebHome from '../renderer/src/WebHome'; - -const index = () => ( - -); - -export default index; diff --git a/app/profile/page.js b/app/profile/page.js deleted file mode 100755 index bb48f9fb9..000000000 --- a/app/profile/page.js +++ /dev/null @@ -1,12 +0,0 @@ -import React from 'react'; -// import Profile from '@/modules/projects/Profile'; -import ProtectedRoute from '@/components/Protected'; - -const ProfilePage = () => ( - - Profile page - {/* */} - -); - -export default ProfilePage; diff --git a/app/projects/page.jsx b/app/projects/page.jsx deleted file mode 100755 index 3f93376ee..000000000 --- a/app/projects/page.jsx +++ /dev/null @@ -1,12 +0,0 @@ -'use client'; - -import ProjectList from '@/components/Projects/ProjectList'; -import ProtectedRoute from '@/components/Protected'; - -const projects = () => ( - - - -); - -export default projects; diff --git a/app/providers.js b/app/providers.js deleted file mode 100755 index 943797c73..000000000 --- a/app/providers.js +++ /dev/null @@ -1,26 +0,0 @@ -'use client'; - -import ScribexContextProvider from '@/components/context/ScribexContext'; -import SyncContextProvider from '@/components/context/SyncContext'; -import ProjectContextProvider from '../renderer/src/components/context/ProjectContext'; -import ReferenceContextProvider from '../renderer/src/components/context/ReferenceContext'; -import AuthenticationContextProvider from '../renderer/src/components/Login/AuthenticationContextProvider'; -import AutographaContextProvider from '../renderer/src/components/context/AutographaContext'; - -export function Providers({ children }) { - return ( - - - - - - - {children} - - - - - - - ); -} diff --git a/app/resource/page.jsx b/app/resource/page.jsx deleted file mode 100755 index 9498e94e4..000000000 --- a/app/resource/page.jsx +++ /dev/null @@ -1,12 +0,0 @@ -import React from 'react'; -// import SectionPlaceholder1 from '../../renderer/src/layouts/editor/SectionPlaceholder1'; -// import SectionPlaceholder2 from '../../renderer/src/layouts/editor/SectionPlaceholder2'; - -const Page = () => ( -
- {/* - */} -
-); - -export default Page; diff --git a/app/signup/page.jsx b/app/signup/page.jsx deleted file mode 100755 index 441ea4b7b..000000000 --- a/app/signup/page.jsx +++ /dev/null @@ -1,8 +0,0 @@ -/* eslint-disable no-tabs */ -import SignupPage from '@/components/Signup/WebSignup'; - -function Page() { - return ; -} - -export default Page; diff --git a/app/sync/page.js b/app/sync/page.js deleted file mode 100755 index db8ccf987..000000000 --- a/app/sync/page.js +++ /dev/null @@ -1,11 +0,0 @@ -import ProtectedRoute from '@/components/Protected'; -// import Sync from '@/modules/projects/Sync'; - -const sync = () => ( - - Sync page - {/* */} - -); - -export default sync; diff --git a/e2e-tests/base.test.ts b/e2e-tests/base.test.ts index 9d122cea9..b99f1fa4b 100755 --- a/e2e-tests/base.test.ts +++ b/e2e-tests/base.test.ts @@ -132,7 +132,7 @@ test("Click the view users button and delete the playwright user from the active await archiveDiv.nth(i).click() } await window.locator('//*[@id="active-tab"]').click() - await window.locator(`//*[@dataId="${userName.toLowerCase()}"]`).click() + await window.locator(`//*[@data-id="${userName.toLowerCase()}"]`).click() break } } diff --git a/package.json b/package.json index a44616af2..0823cfe9a 100644 --- a/package.json +++ b/package.json @@ -142,8 +142,6 @@ "@heroicons/react": "^2.0.14", "@ionic/react": "^7.0.0", "@ionic/react-router": "^7.0.0", - "@material-ui/core": "^4.12.4", - "@material-ui/icons": "^4.11.3", "@material-ui/lab": "4.0.0-alpha.57", "@mui/lab": "^5.0.0-alpha.104", "@mui/material": "^5.15.15", @@ -153,7 +151,6 @@ "@radix-ui/react-dialog": "^1.0.3", "@radix-ui/react-dropdown-menu": "^2.0.4", "@react-pdf/renderer": "^3.4.0", - "@supabase/supabase-js": "^2.26.0", "@tailwindcss/forms": "^0.5.2", "@tailwindcss/typography": "^0.5.9", "@types/jest": "^29.5.5", diff --git a/renderer/pages/_document.js b/renderer/pages/_document.js index aab233c03..6380f12ba 100644 --- a/renderer/pages/_document.js +++ b/renderer/pages/_document.js @@ -12,7 +12,7 @@ export default class MyDocument extends Document { return ( - +
diff --git a/renderer/pages/signup.js b/renderer/pages/signup.js deleted file mode 100644 index 1e0477cbf..000000000 --- a/renderer/pages/signup.js +++ /dev/null @@ -1,11 +0,0 @@ -import Signup from '../src/components/Signup/Signup'; -import Meta from '../src/Meta'; - -const signup = () => ( -
- - -
-); - -export default signup; diff --git a/renderer/src/Meta.js b/renderer/src/Meta.js index ddf5f80d4..61b90cc81 100644 --- a/renderer/src/Meta.js +++ b/renderer/src/Meta.js @@ -7,7 +7,7 @@ const Meta = () => ( {/* */} - + {i18n.t('app-name')} ); diff --git a/renderer/src/WebHome.js b/renderer/src/WebHome.js deleted file mode 100644 index 2b769078f..000000000 --- a/renderer/src/WebHome.js +++ /dev/null @@ -1,33 +0,0 @@ -'use client'; - -import { useState, useEffect } from 'react'; -import { useRouter } from 'next/navigation'; -import { getorPutAppLangage } from './core/projects/handleProfile'; -import i18n from './translations/i18n'; -import { getSupabaseSession } from '../../supabase'; -import WebLogin from './components/Login/WebLogin'; - -const WebHome = () => { - const [session, setSession] = useState(); - const router = useRouter(); - - useEffect(() => { - const checkSession = async () => { - const data = await getSupabaseSession(); - if (data.session.user) { - setSession(data.session); - const appLangCode = await getorPutAppLangage('get', data.session.user.email); - if (i18n.language !== appLangCode) { - i18n.changeLanguage(appLangCode); - } - router.push('/projects'); - } - }; - - checkSession(); - }, [router, session]); - - return ( - ); -}; -export default WebHome; diff --git a/renderer/src/components/AudioRecorder/components/EditorPage.js b/renderer/src/components/AudioRecorder/components/EditorPage.js index 4862d9ded..5f1c68aac 100644 --- a/renderer/src/components/AudioRecorder/components/EditorPage.js +++ b/renderer/src/components/AudioRecorder/components/EditorPage.js @@ -222,7 +222,7 @@ const EditorPage = ({ }; export default EditorPage; EditorPage.propTypes = { - content: PropTypes.object, + content: PropTypes.oneOfType([PropTypes.array, PropTypes.object]), onChangeVerse: PropTypes.any, verse: PropTypes.string, location: PropTypes.string, diff --git a/renderer/src/components/AudioRecorder/components/WaveForm.js b/renderer/src/components/AudioRecorder/components/WaveForm.js index 5847bf25e..60700cd4a 100644 --- a/renderer/src/components/AudioRecorder/components/WaveForm.js +++ b/renderer/src/components/AudioRecorder/components/WaveForm.js @@ -10,7 +10,7 @@ import MicrophonePlugin from 'wavesurfer.js/dist/plugin/wavesurfer.microphone.js // eslint-disable-next-line prefer-const let microphone = MicrophonePlugin.create(); -const AudioWaveForm = (props) => { +const AudioWaveForm = ((props, ref) => { const { height, waveColor, @@ -38,6 +38,7 @@ const AudioWaveForm = (props) => { // eslint-disable-next-line prefer-const // let microphone = useRef(null); const [playing, setPlaying] = useState(false); + const combinedRef = ref || waveformRef; const formWaveSurferOptions = (ref) => ({ container: ref || '#waveform', waveColor, @@ -59,7 +60,7 @@ const AudioWaveForm = (props) => { }); const createForm = async (currentUrl) => { - const options = formWaveSurferOptions(waveformRef.current); + const options = formWaveSurferOptions(combinedRef.current); wavesurfer.current = WaveSurfer.create(options); // Below url is for testing/development purpose // const currentUrl = 'https://www.mfiles.co.uk/mp3-downloads/brahms-st-anthony-chorale-theme-two-pianos.mp3'; @@ -85,7 +86,7 @@ const AudioWaveForm = (props) => { }; const createRecForm = async () => { - const options = formWaveSurferOptions(waveformRef.current); + const options = formWaveSurferOptions(combinedRef.current); wavesurfer.current = WaveSurfer.create(options); wavesurfer.current?.microphone.on('deviceReady', (stream) => { // eslint-disable-next-line no-console @@ -208,7 +209,7 @@ const AudioWaveForm = (props) => { && ( <>
-
+
{show && ( @@ -234,7 +235,7 @@ const AudioWaveForm = (props) => { )}
); -}; +}); export default forwardRef(AudioWaveForm); AudioWaveForm.propTypes = { height: PropTypes.number, diff --git a/renderer/src/components/AutoCompleteSearch/AutoComplete.test.js b/renderer/src/components/AutoCompleteSearch/AutoComplete.test.js deleted file mode 100644 index 5d8f92aa9..000000000 --- a/renderer/src/components/AutoCompleteSearch/AutoComplete.test.js +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react'; -import { render, fireEvent } from '@testing-library/react'; -import { act } from 'react-dom/test-utils'; -import '@testing-library/jest-dom/extend-expect'; -import { AutoCompleteSearch } from './AutoCompleteSearch'; - -jest.useFakeTimers(); -const version = [ - { id: 1, value: 'IRV' }, - { id: 2, value: 'NLT' }, - { id: 3, value: 'UDB' }, - { id: 4, value: 'ULB' }, - { id: 5, value: 'UJNT' }, - ]; - -test('AutoCompleteSearch renders without error', () => { - render(); -}); diff --git a/renderer/src/components/AutoCompleteSearch/AutoCompleteSearch.js b/renderer/src/components/AutoCompleteSearch/AutoCompleteSearch.js deleted file mode 100644 index 3210c7a16..000000000 --- a/renderer/src/components/AutoCompleteSearch/AutoCompleteSearch.js +++ /dev/null @@ -1,38 +0,0 @@ -import * as React from 'react'; -import PropTypes from 'prop-types'; -import { TextField } from '@material-ui/core'; -import Autocomplete from '@material-ui/lab/Autocomplete'; - -export const AutoCompleteSearch = ({ - listarray, customPlaceholder, selectedValue, setSelectedValue, -}) => ( - option} - inputValue={selectedValue} - onInputChange={(region) => { - setSelectedValue(region); - }} - renderInput={(params) => ( - - )} - ListboxProps={{ 'data-testid': 'list-box' }} - /> -); -AutoCompleteSearch.propTypes = { - // list of array props that needs to be searched - listarray: PropTypes.instanceOf(Array), - // selected state value prop - selectedValue: PropTypes.string, - // setting state value prop - setSelectedValue: PropTypes.func, - // placeholder to display - customPlaceholder: PropTypes.string, -}; -AutoCompleteSearch.defaultProps = { - listarray: PropTypes.instanceOf(Array), -}; diff --git a/renderer/src/components/EditorPage/AudioEditor/MainPlayer.js b/renderer/src/components/EditorPage/AudioEditor/MainPlayer.js index 88e5f115c..d47981fa4 100644 --- a/renderer/src/components/EditorPage/AudioEditor/MainPlayer.js +++ b/renderer/src/components/EditorPage/AudioEditor/MainPlayer.js @@ -105,7 +105,7 @@ const MainPlayer = () => { const path = require('path'); let i = 1; // Checking whether the take has any audio - if (fs.existsSync(path.join(audioCurrentChapter.filePath, audioCurrentChapter.chapterNum, `${chapter}_${verse}_${value}.mp3`))) { + if (audioCurrentChapter?.filePath && fs.existsSync(path.join(audioCurrentChapter?.filePath, audioCurrentChapter?.chapterNum, `${chapter}_${verse}_${value}.mp3`))) { while (i < 4) { // Looking for the existed default file so that we can easily rename both the files if (fs.existsSync(path.join(audioCurrentChapter.filePath, audioCurrentChapter.chapterNum, `${chapter}_${verse}_${i}_default.mp3`))) { diff --git a/renderer/src/components/EditorPage/JuxtAlignEditor/hooks/saveToFile.js b/renderer/src/components/EditorPage/JuxtAlignEditor/hooks/saveToFile.js index 5b226c677..6827c1e1a 100644 --- a/renderer/src/components/EditorPage/JuxtAlignEditor/hooks/saveToFile.js +++ b/renderer/src/components/EditorPage/JuxtAlignEditor/hooks/saveToFile.js @@ -1,10 +1,7 @@ import localforage from 'localforage'; -// import { readRefMeta } from '../../../core/reference/readRefMeta'; -import { isElectron } from '@/core/handleElectron'; import writeToFile from '@/core/editor/writeToFile'; import { readRefBurrito } from '@/core/reference/readRefBurrito'; import packageInfo from '../../../../../../package.json'; -import { newPath } from '../../../../../../supabase'; import * as logger from '../../../../logger'; // function to save to file. @@ -13,11 +10,11 @@ export const saveToFile = async (juxtaData, bookCode) => { try { const upperCaseBookCode = bookCode.toUpperCase(); const userProfile = await localforage.getItem('userProfile'); - const userName = isElectron() ? userProfile?.username : userProfile?.user?.email; + const userName = userProfile?.username; const projectName = await localforage.getItem('currentProject'); const path = require('path'); const newpath = localStorage.getItem('userPath'); - const metaPath = isElectron() ? path.join(newpath, packageInfo.name, 'users', userName, 'projects', projectName, 'metadata.json') : `${newPath}/${userName}/projects/${projectName}/metadata.json`; + const metaPath = path.join(newpath, packageInfo.name, 'users', userName, 'projects', projectName, 'metadata.json'); const metaData = JSON.parse(await readRefBurrito({ metaPath })); Object.entries(metaData.ingredients).forEach(async ([key, _ingredients]) => { if (_ingredients.scope) { diff --git a/renderer/src/components/EditorPage/JuxtaTextEditor/hooks/saveToFile.js b/renderer/src/components/EditorPage/JuxtaTextEditor/hooks/saveToFile.js index 5b226c677..6827c1e1a 100644 --- a/renderer/src/components/EditorPage/JuxtaTextEditor/hooks/saveToFile.js +++ b/renderer/src/components/EditorPage/JuxtaTextEditor/hooks/saveToFile.js @@ -1,10 +1,7 @@ import localforage from 'localforage'; -// import { readRefMeta } from '../../../core/reference/readRefMeta'; -import { isElectron } from '@/core/handleElectron'; import writeToFile from '@/core/editor/writeToFile'; import { readRefBurrito } from '@/core/reference/readRefBurrito'; import packageInfo from '../../../../../../package.json'; -import { newPath } from '../../../../../../supabase'; import * as logger from '../../../../logger'; // function to save to file. @@ -13,11 +10,11 @@ export const saveToFile = async (juxtaData, bookCode) => { try { const upperCaseBookCode = bookCode.toUpperCase(); const userProfile = await localforage.getItem('userProfile'); - const userName = isElectron() ? userProfile?.username : userProfile?.user?.email; + const userName = userProfile?.username; const projectName = await localforage.getItem('currentProject'); const path = require('path'); const newpath = localStorage.getItem('userPath'); - const metaPath = isElectron() ? path.join(newpath, packageInfo.name, 'users', userName, 'projects', projectName, 'metadata.json') : `${newPath}/${userName}/projects/${projectName}/metadata.json`; + const metaPath = path.join(newpath, packageInfo.name, 'users', userName, 'projects', projectName, 'metadata.json'); const metaData = JSON.parse(await readRefBurrito({ metaPath })); Object.entries(metaData.ingredients).forEach(async ([key, _ingredients]) => { if (_ingredients.scope) { diff --git a/renderer/src/components/EditorPage/JuxtalinearEditor/components/Layout/Layout.tsx b/renderer/src/components/EditorPage/JuxtalinearEditor/components/Layout/Layout.tsx index a7acec0fa..40fcdb48d 100644 --- a/renderer/src/components/EditorPage/JuxtalinearEditor/components/Layout/Layout.tsx +++ b/renderer/src/components/EditorPage/JuxtalinearEditor/components/Layout/Layout.tsx @@ -1,9 +1,9 @@ import React from 'react'; import { AppHeader } from '../AppHeader'; -import { Box } from '@material-ui/core'; +import { Box } from '@mui/material'; // Updated import for MUI v5 interface LayoutProps { - children?: React.ReactNode + children?: React.ReactNode; } export const Layout = ({ children }: LayoutProps) => { @@ -14,5 +14,5 @@ export const Layout = ({ children }: LayoutProps) => { {children}
- ) -} + ); +}; diff --git a/renderer/src/components/EditorPage/Navigation/CustomNavigation.js b/renderer/src/components/EditorPage/Navigation/CustomNavigation.js index c8099801d..e6b464881 100644 --- a/renderer/src/components/EditorPage/Navigation/CustomNavigation.js +++ b/renderer/src/components/EditorPage/Navigation/CustomNavigation.js @@ -242,7 +242,7 @@ export default function CustomNavigation({ CustomNavigation.propTypes = { showVerse: PropTypes.bool, initialBook: PropTypes.string, - initialChapter: PropTypes.string, + initialChapter: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), initialVerse: PropTypes.string, setNavigation: PropTypes.func, }; diff --git a/renderer/src/components/EditorPage/Navigation/reference/SelectVerse.js b/renderer/src/components/EditorPage/Navigation/reference/SelectVerse.js index 85e206319..6eae360bf 100644 --- a/renderer/src/components/EditorPage/Navigation/reference/SelectVerse.js +++ b/renderer/src/components/EditorPage/Navigation/reference/SelectVerse.js @@ -170,7 +170,7 @@ export default function SelectVerse({ SelectVerse.propTypes = { children: PropTypes.any, bookName: PropTypes.string, - chapter: PropTypes.string, + chapter: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), verse: PropTypes.string, chapterList: PropTypes.array, verseList: PropTypes.array, diff --git a/renderer/src/components/EditorPage/ObsEditor/ObsImage.jsx b/renderer/src/components/EditorPage/ObsEditor/ObsImage.jsx index 87924ba70..c50928ca9 100644 --- a/renderer/src/components/EditorPage/ObsEditor/ObsImage.jsx +++ b/renderer/src/components/EditorPage/ObsEditor/ObsImage.jsx @@ -1,15 +1,12 @@ -import { isElectron } from '@/core/handleElectron'; import { environment } from '../../../../environment'; import packageInfo from '../../../../../package.json'; -import { newPath } from '../../../../../supabase'; function ObsImage({ story, online }) { const path = require('path'); const newpath = localStorage.getItem('userPath'); const imageName = story.img.split('/'); const fileName = imageName[imageName.length - 1]; - const obsImagePath = isElectron() ? path.join('file://', newpath, packageInfo.name, 'common', environment.OBS_IMAGE_DIR, fileName) - : path.join(newPath, packageInfo.name, 'common', environment.OBS_IMAGE_DIR, fileName); + const obsImagePath = path.join('file://', newpath, packageInfo.name, 'common', environment.OBS_IMAGE_DIR, fileName); return online ? ( ) : (offline); diff --git a/renderer/src/components/EditorPage/ObsEditor/core.js b/renderer/src/components/EditorPage/ObsEditor/core.js index b132b4e80..a7641de82 100644 --- a/renderer/src/components/EditorPage/ObsEditor/core.js +++ b/renderer/src/components/EditorPage/ObsEditor/core.js @@ -1,5 +1,4 @@ import packageInfo from '../../../../../package.json'; -import { newPath, sbStorageDownload } from '../../../../../supabase'; const loadData = (fs, file, projectName, username) => { const newpath = localStorage.getItem('userPath'); @@ -59,17 +58,6 @@ export async function readBlobAsync(blob) { } } -const loadWebData = async (file, projectName, username) => { - const filePath = `${newPath}/${username}/resources/${projectName}/content/${file}.md`; - const { data } = await sbStorageDownload(filePath); - const parsedData = readBlobAsync(data); - - if (parsedData) { - return parsedData; - } - return 'No Content'; -}; - const core = (fs, num, projectName, username) => { const stories = []; // eslint-disable-next-line prefer-const @@ -150,85 +138,4 @@ const core = (fs, num, projectName, username) => { return stories; }; -const webCore = async (num, projectName, username) => { - const stories = []; - // eslint-disable-next-line prefer-const - let id = 1; let footer = false; - const data = await loadWebData(num.toString().padStart(2, 0), projectName, username); - const allLines = data.split(/\r\n|\n/); - // Reading line by line - allLines.forEach((line) => { - // To avoid the values after footer, we have added id=0 - if (line && id !== 0) { - if (line.match(/^(\s)*#/gm)) { - // Fetching the header content - const hash = line.match(/# (.*)/); - stories.push({ - id, title: hash[1], - }); - id += 1; - } else if (line.match(/^(\s)*_/gm) || footer === true) { - // Fetching the footer - const objIndex = stories.findIndex(((obj) => obj.id === id)); - if (objIndex !== -1 && Object.prototype.hasOwnProperty.call(stories[objIndex], 'img')) { - stories[objIndex].text = ''; - id += 1; - } - if (line.match(/_(.*)_/g) && footer === false) { - // single line footer - const underscore = line.match(/_(.*)_/); - stories.push({ - id, end: underscore[1], - }); - // Logically footer is the last line of the story - id = 0; - } else { - // To get multi-line footer (footer=true) - footer = true; - if (line.match(/^(\s)*_/gm)) { - // starting of footer - const underscore = line.match(/^(\s)*_(.*)/); - stories.push({ - id, - end: underscore[2], - }); - } else if (line.match(/_$/gm)) { - // end of footer - const underscore = line.match(/(.*)_$/); - stories[id - 1].end = `${stories[id - 1].end}\n${underscore[1]}`; - // Logically footer is the last line of the story - id = 0; - } else { - // middle lines of footer if available - stories[id - 1].end = `${stories[id - 1].end}\n${line}`; - } - } - } else if (line.match(/^(\s)*!/gm)) { - // Fetching the IMG url - const objIndex = stories.findIndex(((obj) => obj.id === id)); - if (objIndex !== -1 && Object.prototype.hasOwnProperty.call(stories[objIndex], 'img')) { - stories[objIndex].text = ''; - id += 1; - } - const imgUrl = line.match(/\((.*)\)/); - stories.push({ - id, img: imgUrl[1], - }); - } else { - // Reading the content line by line - const objIndex = stories.findIndex(((obj) => obj.id === id)); - if (objIndex !== -1) { - // Reading first line after img - stories[objIndex].text = line; - id += 1; - } else { - // Reading other lines and appending with previous line data - stories[id - 2].text = `${stories[id - 2]?.text}\n${line}`; - } - } - } - }); - return stories; -}; - -export { core, webCore }; +export { core }; diff --git a/renderer/src/components/EditorPage/ObsEditor/utils/getDetails.js b/renderer/src/components/EditorPage/ObsEditor/utils/getDetails.js index 3b5f354ff..f173b2648 100644 --- a/renderer/src/components/EditorPage/ObsEditor/utils/getDetails.js +++ b/renderer/src/components/EditorPage/ObsEditor/utils/getDetails.js @@ -1,7 +1,6 @@ import * as localforage from 'localforage'; import { isElectron } from '@/core/handleElectron'; import packageInfo from '../../../../../../package.json'; -import { newPath } from '../../../../../../supabase'; import * as logger from '../../../../logger'; export async function getDetails() { @@ -12,12 +11,8 @@ export async function getDetails() { const path = require('path'); const username = isElectron() ? userProfile?.username : userProfile?.user?.email; - const projectsDir = isElectron() - ? path.join(newpath, packageInfo.name, 'users', username, 'projects', currentProject) - : `${newPath}/${username}/projects/${currentProject}`; - const metaPath = isElectron() - ? path.join(newpath, packageInfo.name, 'users', username, 'projects', currentProject, 'metadata.json') - : `${newPath}/${username}/projects/${currentProject}/metadata.json`; + const projectsDir = path.join(newpath, packageInfo.name, 'users', username, 'projects', currentProject); + const metaPath = path.join(newpath, packageInfo.name, 'users', username, 'projects', currentProject, 'metadata.json'); return { projectName: currentProject, username, projectsDir, metaPath, path, diff --git a/renderer/src/components/EditorPage/Reference/ReferenceCard.js b/renderer/src/components/EditorPage/Reference/ReferenceCard.js index 130892e37..a2f5b5246 100644 --- a/renderer/src/components/EditorPage/Reference/ReferenceCard.js +++ b/renderer/src/components/EditorPage/Reference/ReferenceCard.js @@ -73,7 +73,7 @@ export default ReferenceCard; ReferenceCard.propTypes = { items: PropTypes.array, filters: PropTypes.array, - markdown: PropTypes.object, + markdown: PropTypes.oneOfType([PropTypes.object, PropTypes.string]), languageId: PropTypes.string.isRequired, selectedQuote: PropTypes.string, setQuote: PropTypes.func, diff --git a/renderer/src/components/EditorPage/Reference/TabSelector.js b/renderer/src/components/EditorPage/Reference/TabSelector.js index 181edcdce..c6ea0a0d7 100644 --- a/renderer/src/components/EditorPage/Reference/TabSelector.js +++ b/renderer/src/components/EditorPage/Reference/TabSelector.js @@ -34,7 +34,7 @@ function TabSelector({ currentTab, setCurrentTab, tabData }) { export default TabSelector; TabSelector.propTypes = { - currentTab: PropTypes.object, + currentTab: PropTypes.oneOfType([PropTypes.number, PropTypes.object]), setCurrentTab: PropTypes.func, tabData: PropTypes.shape({ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), diff --git a/renderer/src/components/EditorPage/Reference/TranslationHelps.js b/renderer/src/components/EditorPage/Reference/TranslationHelps.js index ffb9c8042..b60ec61c1 100644 --- a/renderer/src/components/EditorPage/Reference/TranslationHelps.js +++ b/renderer/src/components/EditorPage/Reference/TranslationHelps.js @@ -337,9 +337,9 @@ TranslationHelps.propTypes = { languageId: PropTypes.string, refName: PropTypes.string, bookId: PropTypes.string, - chapter: PropTypes.string, + chapter: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), verse: PropTypes.string, owner: PropTypes.string, story: PropTypes.string, - offlineResource: PropTypes.bool || PropTypes.object, + offlineResource: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]), }; diff --git a/renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js b/renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js index ce3939d84..99359ff7f 100644 --- a/renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js +++ b/renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js @@ -101,6 +101,56 @@ export default function TranslationHelpsCard({ // switch resources switch (resourceId) { case 'tn': + if (fs.existsSync(path.join(folder, projectName))) { + // eslint-disable-next-line array-callback-return + const currentFile = offlineResource?.data?.value?.projects.filter((item) => { + if (item?.identifier.toLowerCase() === projectId.toLowerCase()) { + return item; + } + }); + + if (currentFile?.length > 0) { + const filecontent = await fs.readFileSync(path.join(folder, projectName, currentFile[0].path), 'utf8'); + // convert tsv to json + const headerArr = filecontent.split('\n')[0].split('\t'); + let noteName; + let indexOfNote; + if (headerArr.indexOf('Note') > 0) { + indexOfNote = headerArr.indexOf('Note'); + noteName = headerArr[indexOfNote]; + } else if (headerArr.indexOf('OccurrenceNote')) { + indexOfNote = headerArr.indexOf('OccurrenceNote'); + noteName = headerArr[indexOfNote]; + } + + let bvcType = true; + if (headerArr.includes('Reference') && headerArr.every((value) => !['Book', 'Verse', 'Chapter'].includes(value))) { + bvcType = false; + } + + const json = filecontent.split('\n') + .map((file) => { + if (bvcType) { + const [Book, Chapter, Verse, ID, SupportReference, OrigQuote, Occurrence, GLQuote, OccurrenceNote] = file.split('\t'); + return { + Book, Chapter, Verse, ID, SupportReference, OrigQuote, Occurrence, GLQuote, OccurrenceNote, + }; + } + const Book = projectId; + const [ref, ID] = file.split('\t'); + const Chapter = ref.split(':')[0]; + const Verse = ref.split(':')[1]; + return { + Book, Chapter, Verse, ID, [noteName]: file.split('\t')[indexOfNote], + }; + }).filter((data) => data.Chapter === currentChapterVerse.chapter && data.Verse === currentChapterVerse.verse); + setOfflineItemsDisable(false); + setOfflineItems(json); + } else { + setOfflineMarkdown({ error: true, data: 'No Content Available' }); + } + } + break; case 'x-bcvnotes': // console.log("yep", folder, 'and projectName ==', projectName); if (fs.existsSync(path.join(folder, projectName))) { diff --git a/renderer/src/components/EditorPage/Reference/TranslationhelpsNav.js b/renderer/src/components/EditorPage/Reference/TranslationhelpsNav.js index 1be25031d..2719e3801 100644 --- a/renderer/src/components/EditorPage/Reference/TranslationhelpsNav.js +++ b/renderer/src/components/EditorPage/Reference/TranslationhelpsNav.js @@ -1,9 +1,8 @@ /* eslint-disable react/jsx-no-useless-fragment */ import React from 'react'; import PropTypes from 'prop-types'; +import { ChevronLeft, ChevronRight } from '@mui/icons-material'; import styled from 'styled-components'; -import ChevronLeftIcon from '@material-ui/icons/ChevronLeft'; -import ChevronRightIcon from '@material-ui/icons/ChevronRight'; const FlexDiv = styled.div` display: flex; @@ -16,10 +15,7 @@ const FlexSpacedDiv = styled.div` `; const TranslationhelpsNav = ({ - items, - classes, - itemIndex, - setItemIndex, + items, classes, itemIndex, setItemIndex, }) => { const onPrevItem = () => { const newIndex = itemIndex - 1; @@ -43,14 +39,14 @@ const TranslationhelpsNav = ({ <> {items && ( - {`${itemIndex + 1} of ${items.length}`} - @@ -60,11 +56,11 @@ const TranslationhelpsNav = ({ ); }; -export default TranslationhelpsNav; - TranslationhelpsNav.propTypes = { items: PropTypes.array, - classes: PropTypes.bool, + classes: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]), itemIndex: PropTypes.number, setItemIndex: PropTypes.func, }; + +export default TranslationhelpsNav; diff --git a/renderer/src/components/EditorPage/TextEditor/index.jsx b/renderer/src/components/EditorPage/TextEditor/index.jsx index 47574e05f..dd1a680a3 100644 --- a/renderer/src/components/EditorPage/TextEditor/index.jsx +++ b/renderer/src/components/EditorPage/TextEditor/index.jsx @@ -56,6 +56,7 @@ export default function TextEditor() { const { usj, error } = cachedData; if (!loading) { if (error) { + // eslint-disable-next-line no-console console.error('Error parsing USFM:', error); setParseError(true); showSnackbar( diff --git a/renderer/src/components/Login/CustomLogin.js b/renderer/src/components/Login/CustomLogin.js deleted file mode 100644 index 4df75a32a..000000000 --- a/renderer/src/components/Login/CustomLogin.js +++ /dev/null @@ -1,111 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { TextField, Typography } from '@material-ui/core'; -import Autocomplete from '@material-ui/lab/Autocomplete'; -import PersonOutlineIcon from '@material-ui/icons/PersonOutline'; -import 'tailwindcss/tailwind.css'; - -const CustomLogin = ({ - ui, error, login, userlist, validation, buttonname, -}) => { - const [values, setValue] = React.useState({}); - const handleChange = (prop) => (event) => { - setValue({ ...values, [prop]: event.target.value }); - }; - const handleSubmit = (e) => { - e.preventDefault(); - login(values); - setValue({}); - }; - return ( - -
handleSubmit(e)}> - {validation?.msg} - {ui?.autocomplete?.count?.map((v) => ( -
-
- -
- - option.username || ''} - onChange={handleChange(values)} - getOptionSelected={(option, value) => option.username === value.username} - onInputChange={(event, newInputValue) => { - setValue({ ...values, username: newInputValue }); - }} - renderInput={(params) => ( - - )} - /> -
- ))} - {ui?.textfield?.count?.map((c) => ( -
-
-
- {c.label} - * -
- -
- {validation?.[c.name]} -
- ))} -
- {ui?.viewForgot && ( - - Forgot Password? - - )} -
- -
- - ); -}; -export default CustomLogin; -CustomLogin.propTypes = { - /** State which triggers login. */ - ui: PropTypes.object, - error: PropTypes.object, - login: PropTypes.func, - userlist: PropTypes.array, - validation: PropTypes.object, - buttonname: PropTypes.string, -}; diff --git a/renderer/src/components/Login/LeftLogin.js b/renderer/src/components/Login/LeftLogin.js index b866f0061..d916d3743 100644 --- a/renderer/src/components/Login/LeftLogin.js +++ b/renderer/src/components/Login/LeftLogin.js @@ -4,7 +4,7 @@ import React, { } from 'react'; import * as localForage from 'localforage'; import { TrashIcon } from '@heroicons/react/24/outline'; -import { Restore } from '@material-ui/icons'; +import { Restore } from '@mui/icons-material'; import LogoIcon from '@/icons/logo.svg'; import { createUser, handleLogin, writeToFile } from '../../core/Login/handleLogin'; import { isElectron } from '../../core/handleElectron'; @@ -304,7 +304,7 @@ const LeftLogin = () => { role="button" tabIndex={0} aria-label="submit" - dataId={user.username} + data-id={user.username} onClick={() => { handleSubmit({ username: user.username }); }} className="w-full p-4 py-3 text-sm rounded-lg cursor-pointer bg-[#F9F9F9] hover:bg-primary hover:text-white border border-[#E3E3E3] font-semibold" > diff --git a/renderer/src/components/Login/Signin.js b/renderer/src/components/Login/Signin.js deleted file mode 100644 index 78a665f2b..000000000 --- a/renderer/src/components/Login/Signin.js +++ /dev/null @@ -1,86 +0,0 @@ -import React, { useState } from 'react'; -import Link from 'next/link'; -import { useRouter } from 'next/navigation'; -import * as localforage from 'localforage'; -import { supabaseSignIn } from '../../../../supabase'; - -const SignIn = () => { - const [email, setEmail] = useState(''); - const [password, setPassword] = useState(''); - const [error, setError] = useState(''); - const [loading, setLoading] = useState(false); - const router = useRouter(); - - const handleSubmit = async (e) => { - e.preventDefault(); - setLoading(true); - const { data, error: signInError } = await supabaseSignIn({ - email, - password, - }); - if (data.session) { - await localforage.setItem('userProfile', data); - router.push('/projects'); - setLoading(false); - } else { - setError(signInError); - setLoading(false); - } - }; - - return ( -
-
-

Sign In

- {error &&

{error.toString()}

} -
-
- - setEmail(e.target.value)} - /> -
-
- - setPassword(e.target.value)} - /> -
- -
- - Don't have an account? - {' '} - - Sign Up - - - -
-
- ); -}; - -export default SignIn; diff --git a/renderer/src/components/Login/WebLogin.js b/renderer/src/components/Login/WebLogin.js deleted file mode 100644 index 630e7375a..000000000 --- a/renderer/src/components/Login/WebLogin.js +++ /dev/null @@ -1,15 +0,0 @@ -'use client'; - -import SignIn from './Signin'; -import RightLogin from './RightLogin'; - -export default function WebLogin() { - return ( -
-
- -
- -
- ); -} diff --git a/renderer/src/components/Login/tests/CustomLogin.test.js b/renderer/src/components/Login/tests/CustomLogin.test.js deleted file mode 100644 index 358612b75..000000000 --- a/renderer/src/components/Login/tests/CustomLogin.test.js +++ /dev/null @@ -1,30 +0,0 @@ -import React from 'react'; -import { render } from '@testing-library/react'; -import CustomLogin from '../CustomLogin' -const online = { - textfield: { - count: [ - { label: 'Username', type: 'text', name: 'identifier' }, - ], - }, - viewForgot: true, -}; -const offline = { - autocomplete: { count: [{ label: 'Username' }] }, - viewForgot: false, -}; -describe('Login component tests', () => { - test('Should render CustomLogin component without error', () => { - render(); - }); - test('Should have text box', async () => { - const { getByTestId } = render(); - const textbox = getByTestId('text-box'); - expect(textbox.type).toEqual('text'); - }); - test('Should have login button', async () => { - const { getByTestId } = render(); - const button = getByTestId('login-button'); - expect(button.type).toEqual('submit'); - }); -}); diff --git a/renderer/src/components/Profile/UserProfile.js b/renderer/src/components/Profile/UserProfile.js index 5addac51d..d792eb1be 100644 --- a/renderer/src/components/Profile/UserProfile.js +++ b/renderer/src/components/Profile/UserProfile.js @@ -10,26 +10,13 @@ import { import { classNames } from '@/util/classNames'; import { AuthenticationContext } from '@/components/Login/AuthenticationContextProvider'; import { useGetUserName } from '@/components/hooks/useGetUserName'; -import { useRouter } from 'next/navigation'; import { isElectron } from '@/core/handleElectron'; -import * as localforage from 'localforage'; -import { supabaseSignout } from '../../../../supabase'; const UserProfile = () => { const { action: { logout } } = useContext(AuthenticationContext); const { t } = useTranslation(); const profile = [t('label-your-profile')]; const userPic = true; - const router = useRouter(); - - const signOut = async () => { - // if(!process.env.NEXT_PUBLIC_IS_ELECTRON){ - const { error } = await supabaseSignout(); - localforage.removeItem('userProfile'); - // eslint-disable-next-line no-console - error ? console.log({ error }) : router.push('/login'); - }; - // } // get username from custom hook const { username } = useGetUserName(); @@ -121,7 +108,7 @@ const UserProfile = () => { href="/" id="signout" aria-label="signout" - onClick={() => (isElectron() ? logout() : signOut())} + onClick={() => (logout())} role="button" tabIndex={0} className={classNames( diff --git a/renderer/src/components/ProgressCircle/ProgressCircle.js b/renderer/src/components/ProgressCircle/ProgressCircle.js index c79201a0b..ea476c0b9 100644 --- a/renderer/src/components/ProgressCircle/ProgressCircle.js +++ b/renderer/src/components/ProgressCircle/ProgressCircle.js @@ -2,8 +2,8 @@ import * as React from 'react'; import PropTypes from 'prop-types'; import { Box, CircularProgress, Typography, -} from '@material-ui/core'; -import { createTheme, ThemeProvider } from '@material-ui/core/styles'; +} from '@mui/material'; +import { createTheme, ThemeProvider } from '@mui/material/styles'; const progressCircletheme = createTheme({ // older versions diff --git a/renderer/src/components/Projects/EnhancedTableHead.js b/renderer/src/components/Projects/EnhancedTableHead.js index 0153a64ed..71bac9fb8 100644 --- a/renderer/src/components/Projects/EnhancedTableHead.js +++ b/renderer/src/components/Projects/EnhancedTableHead.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import { TableSortLabel, TableCell, -} from '@material-ui/core'; +} from '@mui/material'; import { StarIcon, } from '@heroicons/react/24/outline'; diff --git a/renderer/src/components/Projects/NewWebProject.js b/renderer/src/components/Projects/NewWebProject.js deleted file mode 100644 index 7ecdf573a..000000000 --- a/renderer/src/components/Projects/NewWebProject.js +++ /dev/null @@ -1,496 +0,0 @@ -'use client'; - -import { useEffect, useContext, useState } from 'react'; -import PropTypes from 'prop-types'; -import { useRouter } from 'next/navigation'; -import { useTranslation } from 'react-i18next'; -import { ChevronDownIcon } from '@heroicons/react/24/solid'; -import ProjectsLayout from '@/layouts/projects/Layout'; -import AdvancedSettingsDropdown from '@/components/ProjectsPage/CreateProject/AdvancedSettingsDropdown'; -import { ProjectContext } from '@/components/context/ProjectContext'; -import { AutographaContext } from '@/components/context/AutographaContext'; -import TargetLanguagePopover from '@/components/ProjectsPage/CreateProject/TargetLanguagePopover'; -import PopoverProjectType from '@/layouts/editor/PopoverProjectType'; -import { SnackBar } from '@/components/SnackBar'; -import useValidator from '@/components/hooks/useValidator'; -import ConfirmationModal from '@/layouts/editor/ConfirmationModal'; -import CustomMultiComboBox from '@/components/Resources/ResourceUtils/CustomMultiComboBox'; -import { InformationCircleIcon } from '@heroicons/react/24/outline'; -import moment from 'moment'; -import { v5 as uuidv5 } from 'uuid'; -import { environment } from '../../../environment'; -import LayoutIcon from '@/icons/basil/Outline/Interface/Layout.svg'; -import BullhornIcon from '@/icons/basil/Outline/Communication/Bullhorn.svg'; -import ImageIcon from '@/icons/basil/Outline/Files/Image.svg'; -import { classNames } from '../../util/classNames'; -import * as logger from '../../logger'; -import ImportPopUp from './ImportPopUp'; -import burrito from '../../lib/BurritoTemplate.json'; -// eslint-disable-next-line no-unused-vars -const solutions = [ - { - name: 'Translation', - href: '##', - icon: LayoutIcon, - }, - { - name: 'Audio', - href: '##', - icon: BullhornIcon, - }, - // { - // name: 'MT', - // href: '##', - // icon: ProcessorIcon, - // }, - { - name: 'OBS', - href: '##', - icon: ImageIcon, - }, -]; - -function TargetLanguageTag(props) { - const { children } = props; - return ( -
{children}
- ); -} - -function BibleHeaderTagDropDown(headerDropDown, handleDropDown, call) { - return ( - call === 'new' - ? ( - - - - ) - : ( - - ) - - ); -} -export default function NewWebProject({ call, project, closeEdit }) { - const { - states: { - newProjectFields, - languages, - language, - }, - actions: { - setLanguage, - createSupabaseProject, - setNewProjectFields, - }, - } = useContext(ProjectContext); - - const { - states: { - loading, - }, - action: { - setLoading, - }, - } = useContext(AutographaContext); - const { t } = useTranslation(); - const { action: { validateField, isLengthValidated, isTextValidated } } = useValidator(); - const router = useRouter(); - const [snackBar, setOpenSnackBar] = useState(false); - const [snackText, setSnackText] = useState(''); - const [notify, setNotify] = useState(); - const [metadata, setMetadata] = useState(); - const [openModal, setOpenModal] = useState(false); - const [projectLangData, setProjectLangData] = useState({}); - const [error, setError] = useState({ - projectName: {}, - abbr: {}, - description: {}, - }); - - const [headerDropDown, setHeaderDropDown] = useState(solutions[0].name); - const handleDropDown = (currentSelection) => { - setHeaderDropDown(currentSelection); - }; - - function getAbbreviation(text) { - if (typeof text !== 'string' || !text) { - return ''; - } - const abbr = []; - const splitText = text.trim().split(' '); - splitText.forEach((t) => { - abbr.push(t.charAt(0)); - }); - return abbr.join('').toUpperCase(); - } - - const handleProjectName = (e) => { - const abbreviation = getAbbreviation(e.target.value); - setNewProjectFields({ ...newProjectFields, projectName: e.target.value, abbreviation }); - }; - - const setEditLanguage = async (value) => { - // check the language already in the list or set a new one which create on save project - if (value.ang) { - const editLang = languages.filter((l) => l.ang?.toLowerCase() === value.ang?.toLowerCase()); - if (editLang.length > 0) { - setLanguage(editLang[0]); - } else { - const key = value.ang + +moment().format(); - const id = uuidv5(key, environment.uuidToken); - setLanguage( - { - id, - ang: value.ang, - ld: value?.ld || 'LTR', - lc: value?.lc, - custom: true, - }, - ); - } - } - }; - - const createWebProject = async (update) => { - setLoading(true); - if (newProjectFields.projectName && newProjectFields.abbreviation) { - const value = await createSupabaseProject(call, metadata, update, headerDropDown); - - const status = value[0]; - logger.debug('NewProject.js', status.value); - setLoading(false); - setNotify(status.type); - setSnackText(status.value); - setOpenSnackBar(true); - if (status.type === 'success') { - if (call === 'edit') { - closeEdit(); - } else { - router.push('/projects'); - } - } - } - }; - const validate = async () => { - setLoading(true); - let create = true; - if (newProjectFields.projectName && newProjectFields.abbreviation) { - logger.debug('NewProject.js', 'Validating all the fields.'); - const checkName = await validateField([isLengthValidated(newProjectFields.projectName, { minLen: 5, maxLen: 40 }), isTextValidated(newProjectFields.projectName, 'nonSpecChar')]); - if (checkName[0].isValid === false || checkName[1].isValid === false) { - logger.warn('NewProject.js', 'Validation failed for Project Name.'); - create = false; - } - const checkAbbr = await validateField([isLengthValidated(newProjectFields.abbreviation, { minLen: 1, maxLen: 10 }), isTextValidated(newProjectFields.abbreviation, 'nonSpecChar')]); - if (checkAbbr[0].isValid === false || checkAbbr[1].isValid === false) { - logger.warn('NewProject.js', 'Validation failed for Abbreviation.'); - create = false; - } - // eslint-disable-next-line max-len - const checkDesc = await validateField([isLengthValidated(newProjectFields.description, { minLen: 0, maxLen: 400 })]); - if (checkDesc[0].isValid === false) { - logger.warn('NewProject.js', 'Validation failed for Description.'); - create = false; - } - setError({ - ...error, projectName: checkName, abbr: checkAbbr, description: checkDesc, - }); - } else { - create = false; - logger.warn('NewProject.js', 'Validation Failed - Fill all the required fields.'); - setNotify('warning'); - setSnackText(t('dynamic-msg-fill-all-fields')); - setOpenSnackBar(true); - } - if (create === true) { - // Checking whether the burrito is of latest version - if (call === 'edit' && burrito?.meta?.version !== metadata?.meta?.version) { - setOpenModal(true); - setLoading(false); - } else { - logger.warn('NewProject.js', 'Calling createTheProject function'); - createWebProject(false); - } - } else { - setLoading(false); - } - }; - - const updateBurritoVersion = () => { - setOpenModal(false); - logger.warn('NewProject.js', 'Calling createTheProject function with burrito update'); - createWebProject(true); - }; - const [openPopUp, setOpenPopUp] = useState(false); - const [replaceWarning, setReplaceWarning] = useState(false); - - function openImportPopUp() { - setOpenPopUp(true); - } - - function closeImportPopUp() { - setOpenPopUp(false); - if (call === 'edit') { - setReplaceWarning(true); - } - } - const loadData = async (project) => { - logger.debug('NewProject.js', 'In loadData for loading current project details in Edit page'); - setNewProjectFields({ - projectName: project.identification.name.en, - abbreviation: project.identification.abbreviation.en, - description: project.project[project.type.flavorType.flavor.name].description, - }); - setProjectLangData({ - ang: project.languages[0].name.en, - ld: project.project[project.type.flavorType.flavor.name].scriptDirection, - lc: project.languages[0]?.tag ? project.languages[0].tag : project.languages[0].name.en.substring(0, 3), - }); - setMetadata(project); - // set dropdown to the project type - switch (project.type.flavorType.flavor.name) { - case 'textTranslation': - setHeaderDropDown('Translation'); - break; - - case 'textStories': - setHeaderDropDown('OBS'); - break; - - case 'audioTranslation': - setHeaderDropDown('Audio'); - break; - - default: - break; - } - }; - - useEffect(() => { - setEditLanguage(projectLangData); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [languages.length, projectLangData]); - - useEffect(() => { - if (call === 'edit') { - loadData(project); - } else if (call === 'new') { - // set englsh as default lang - const defaulLang = languages.filter((lang) => lang.lc === 'en'); - setLanguage(defaulLang[0]); - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [call]); - - return ( - - {loading === true - ? ( -
- - - - -
- ) - : ( -
-
- -
-

- {t('label-project-name')} - * -

- { - handleProjectName(e); - }} - disabled={call !== 'new'} - className={classNames(call !== 'new' ? 'bg-gray-200' : '', 'w-52 lg:w-80 block rounded shadow-sm sm:text-sm focus:border-primary border-gray-300')} - /> - {error.projectName[0]?.message || error.projectName[1]?.message} -

{t('label-description')}

-