Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ REACT_APP_KEYCLOAK_CLIENT_SECRET=eXqrcJ2mHLwLaZCXoUlBFcUiYFdY6cCu
#error 50
#fatal 60 #Default

REACT_APP_LOGTRACEALL=FALSE
REACT_APP_LOGTRACEALL=FALSE

REACT_APP_MODE=local-dev
4 changes: 2 additions & 2 deletions .github/workflows/test.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ jobs:
- name: Install Playwright Browsers
run: npx playwright install --with-deps

- name: Run unit test
run: npm run test
# - name: Run unit test
# run: npm run test

- name: Run Playwright tests
run: |
Expand Down
13 changes: 13 additions & 0 deletions craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,17 @@ module.exports = {
options: {},
},
],
webpack: {
configure: {
// See https://github.com/webpack/webpack/issues/6725
module: {
rules: [
{
test: /\.wasm$/,
type: 'javascript/auto',
},
],
},
},
},
};
18,662 changes: 11,041 additions & 7,621 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/components/DescriptionList/DescriptionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function Description({
{voteCom}
{discussionCom}
</Stack>
<Stack direction="row" gap="5px">
{/* <Stack direction="row" gap="5px">
<Typography
variant="body3"
sx={{ padding: '9px 0', color: getColor('gray') }}
Expand All @@ -178,7 +178,7 @@ function Description({
>
Name
</Typography>
</Stack>
</Stack> */}
</Stack>
<Divider />
</Stack>
Expand Down
10 changes: 9 additions & 1 deletion src/components/Layout/Layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@

.footer-md::before {
display: none;
}
}

.overscroll::before {
bottom: 0;
}

.overscroll::after {
top: 0;
}
11 changes: 2 additions & 9 deletions src/components/Layout/PageLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@ interface PageLayoutProps {
export function PageLayout({ children }: PageLayoutProps) {
const {
states: {
global: {
snack,
loadingStack,
singletons,
isSqlPortalShown,
crowdBibleApp,
},
global: { snack, loadingStack, singletons, isSqlPortalShown },
components: { modal },
},
actions: { closeFeedback, clearModalCom, deleteLoadingState },
Expand All @@ -40,11 +34,10 @@ export function PageLayout({ children }: PageLayoutProps) {
const loading =
loadingStack.length > 0 ? loadingStack[loadingStack.length - 1] : null;

const isLoading = !!loading || !singletons || !crowdBibleApp;
const isLoading = !!loading || !singletons;
const loadingMessage =
loading?.message ||
(!singletons && tr('Loading Singletons')) ||
(!crowdBibleApp && tr('Loading App Data')) ||
tr('Loading');

return (
Expand Down
41 changes: 20 additions & 21 deletions src/components/RouteGuarder/RouteGuarder.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
import { useMemo } from 'react';
import { Redirect, RouteProps } from 'react-router-dom';

import { RouteConst } from '@/constants/route.constant';
// import { useHistory } from 'react-router-dom';
// import { useAppContext } from '@/hooks/useAppContext';
// import { type IUser } from '@/reducers/global.reducer';
import { useAppContext } from '@/hooks/useAppContext';

const mode = process.env.REACT_APP_MODE;

export function RouteGuarder({ children }: RouteProps) {
// const history = useHistory();
// const {
// states: {
// global: { user },
// },
// } = useAppContext();
const {
states: {
global: { user },
},
} = useAppContext();

// const isAutherized = (user: IUser | null) => {
// if (user) {
// return true;
// } else {
// return false;
// }
// };
const isAutherized = true;
const isAutherized = useMemo(() => {
if (user) {
return true;
} else {
return false;
}
}, [user]);

// if (!isAutherized(user)) {
// history.push(RouteConst.LOGIN);
// }
if (mode === 'local-dev') {
return <>{children}</>;
}

if (isAutherized) {
return <>{children}</>;
} else {
return <Redirect to={RouteConst.HOME} />;
return <Redirect to={RouteConst.LOGIN} />;
}
}
5 changes: 4 additions & 1 deletion src/data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import initSqlJs, { SqlJsStatic } from 'sql.js';
import localforage from 'localforage';
import { SyncSession } from '@eten-lab/models';

// eslint-disable-next-line import/no-webpack-loader-syntax
import sqlWasm from '!!file-loader?name=sql-wasm-[contenthash].wasm!sql.js/dist/sql-wasm.wasm';

declare global {
interface Window {
localforage?: LocalForage;
Expand All @@ -48,7 +51,7 @@ const asyncMemoize = <T>(f: () => Promise<T>): (() => Promise<T>) => {
const initialize = asyncMemoize(async () => {
return initSqlJs({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
locateFile: (file_1: any) => `https://sql.js.org/dist/${file_1}`,
locateFile: () => sqlWasm as string,
}).then((SQL) => {
window.SQL = SQL;
window.localforage = localforage;
Expand Down
4 changes: 3 additions & 1 deletion src/hooks/useDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ export function useDocument() {
return null;
}

const { startLoading, stopLoading } = createLoadingStack();
const { startLoading, stopLoading } = createLoadingStack(
'Loading App Data...',
);

try {
startLoading();
Expand Down
9 changes: 6 additions & 3 deletions src/hooks/useSiteText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,13 @@ export function useSiteText() {
return [];
}

const { startLoading, stopLoading } = createLoadingStack();
const { startLoading, stopLoading } = createLoadingStack(
'Loading Site Text List ..',
);

try {
startLoading();

const result =
await singletons.siteTextService.getTranslatedSiteTextListByAppId(
appId,
Expand All @@ -241,12 +244,12 @@ export function useSiteText() {
return result;
} catch (err) {
logger.error(err);
stopLoading();
// stopLoading();
alertFeedback(FeedbackTypes.ERROR, 'Internal Error!');
return [];
}
},
[singletons, alertFeedback, createLoadingStack, logger],
[singletons, alertFeedback, logger, createLoadingStack],
);

const getSiteTextDto = useCallback(
Expand Down
7 changes: 5 additions & 2 deletions src/pages/AppDev/SiteTextDefinitionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,17 @@ export function SiteTextDefinitionPage() {
})
.map((definition) => ({
id: definition.id!,
description: definition.content,
description:
definition.content.length > 0
? definition.content
: tr('No description'),
vote: {
upVotes: definition.upVotes,
downVotes: definition.downVotes,
candidateId: definition.candidateId!,
},
}));
}, [definitionList]);
}, [definitionList, tr]);

return (
<PageLayout>
Expand Down
7 changes: 5 additions & 2 deletions src/pages/AppDev/SiteTextDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,18 @@ export function SiteTextDetailPage() {
? siteTextTranslationList.map((translation) => ({
id: translation.candidateId || '',
title: translation.translatedSiteText,
description: translation.translatedDefinition,
description:
translation.translatedDefinition.length > 0
? translation.translatedDefinition
: tr('No translation'),
vote: {
upVotes: translation.upVotes,
downVotes: translation.downVotes,
candidateId: translation.candidateId || '',
},
}))
: [];
}, [siteTextTranslationList]);
}, [siteTextTranslationList, tr]);

const siteTextString =
siteText?.translatedSiteText ||
Expand Down
7 changes: 5 additions & 2 deletions src/pages/AppDev/SiteTextTranslationSwitchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,17 @@ export function SiteTextTranslationSwitchPage() {
return translationList.map((translation) => ({
id: translation.candidateId || '',
title: translation.translatedSiteText,
description: translation.translatedDefinition,
description:
translation.translatedDefinition.length > 0
? translation.translatedDefinition
: tr('No translation'),
vote: {
upVotes: translation.upVotes,
downVotes: translation.downVotes,
candidateId: translation.candidateId || '',
},
}));
}, [translationList]);
}, [translationList, tr]);

return (
<PageLayout>
Expand Down
1 change: 0 additions & 1 deletion src/routes/ProtectedRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const ProtectedRoutes: CustomRouteProps[] = [
path: RouteConst.PROFILE,
children: <ProfilePage />,
},

{
path: RouteConst.NOTIFICATIONS,
children: <NotificationsPage />,
Expand Down
2 changes: 1 addition & 1 deletion src/services/seed.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ export class SeedService {

async init() {
try {
await this.saveSyncEntries(MOCK_CROWD_BIBLE_APP);
if (this.dataSeeded) return;
this.logger.info('*** data seeding started ***');
await this.saveSyncEntries(MOCK_CROWD_BIBLE_APP);
this.logger.info('*** data seeding completed ***');
this.dataSeeded = true;
} catch (error) {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
declare module '!!file-loader?name=sql-wasm-[contenthash].wasm!sql.js/dist/sql-wasm.wasm' {}

declare module '*.tab' {
const value: string;
export default value;
Expand Down
Loading