Skip to content

Commit

Permalink
chore(app): add console warning
Browse files Browse the repository at this point in the history
  • Loading branch information
FussuChalice authored Jan 13, 2025
1 parent a99a3c7 commit 66406f8
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export { default as useInternetChecker } from './useInternetChecker';
export { default as useUserAutoLogin } from './useUserAutoLogin';
export { default as useIntersectionObserver } from './useIntersectionObserver';
export { default as useCurrentUser } from './useCurrentUser';
export { default as useConsoleWarning } from './useConsoleWarning';
31 changes: 31 additions & 0 deletions src/hooks/useConsoleWarning.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { useEffect, useRef } from 'react';
import useAppTranslation from './useAppTranslation';

const useConsoleWarning = () => {
const { t } = useAppTranslation();

const warningShownRef = useRef(false);

useEffect(() => {
const consoleWarningTitleStyle = `
background: #DD8C2C;
color: #FFFFFF;
font-size: 48px;
font-weight: 700;
`;

const consoleWarningDescStyle = `
font-weight: 500;
font-size: 32px;
`;

if (!warningShownRef.current) {
console.log(`%c${t('tr_consoleWarningTitle')}`, consoleWarningTitleStyle);
console.log(`%c${t('tr_consoleWarningDesc')}`, consoleWarningDescStyle);

warningShownRef.current = true;
}
}, [t]);
};

export default useConsoleWarning;
3 changes: 3 additions & 0 deletions src/layouts/root_layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ import WhatsNew from '@features/whats_new';
import Typography from '@components/typography';
import NetlifyLight from '@assets/img/netlify_lightmode.png';
import NetlifyDark from '@assets/img/netlify_darkmode.png';
import useConsoleWarning from '@hooks/useConsoleWarning';

const RootLayout = ({ updatePwa }: { updatePwa: VoidFunction }) => {
const { isSupported } = useGlobal();

useConsoleWarning();

const {
isAppLoad,
isOpenAbout,
Expand Down
4 changes: 3 additions & 1 deletion src/locales/en/general.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,7 @@
"tr_manageUserProfileSettings": "Manage user account settings",
"tr_createUserProfile": "Create user account",
"tr_download": "Download",
"tr_import": "Import"
"tr_import": "Import",
"tr_consoleWarningTitle": "!WARNING!",
"tr_consoleWarningDesc": "This console is a powerful tool intended for developers. If you're not a developer, please avoid entering or pasting commands here – even if someone asks you to. This ensures your Organized app data always stay safe."
}
3 changes: 2 additions & 1 deletion src/pages/persons/all_persons/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { Box, Slide } from '@mui/material';
import { Button, PageTitle } from '@components/index';
import {
Expand All @@ -18,7 +19,7 @@ import PersonsSearch from '@features/persons/search';
const PersonsAll = () => {
const { t } = useAppTranslation();

const { desktopUp } = useBreakpoints();
const { desktopUp, tablet500Down } = useBreakpoints();

const { isPersonEditor } = useCurrentUser();

Expand Down

0 comments on commit 66406f8

Please sign in to comment.