Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(hooks): add console warning | task CU-86c19zx2q #3363

Merged
Show file tree
Hide file tree
Changes from 3 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
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."
}
4 changes: 3 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 Expand Up @@ -105,6 +106,7 @@ const PersonsAll = () => {
<PersonsSearch />
<Button
variant="secondary"
sx={tablet500Down && { width: '35%' }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FussuChalice: not sure if this is intended to be included in this PR, but anyway, this has no effect to the button currently, so it can be removed to avoid confusion later. Thanks.

onClick={() => setIsPanelOpen((prev) => !prev)}
endIcon={
isPanelOpen ? <IconPanelOpen /> : <IconPanelClose />
Expand Down
Loading