From c33b02f77e9bda0bd70a813f55284f139363d48f Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Fri, 28 Mar 2025 10:20:31 -0700 Subject: [PATCH] Add UI basics. --- .../quickbooks-desktop/quickbooks-desktop.ts | 8 +-- src/renderer/src/App.tsx | 41 +++++++----- src/renderer/src/components/Home/Home.tsx | 21 ------- .../NavigationHeader/Navigationheader.tsx | 9 +++ .../Settings/Settings.WatchedPaths.tsx | 13 ++-- .../components/Settings/Settings.Watcher.tsx | 2 - .../src/components/Settings/Settings.tsx | 17 ++--- .../src/components/SignInForm/SignInForm.tsx | 40 +++++------- src/util/translations/en-US/renderer.json | 10 ++- translations.babel | 62 +++++++++++++++++++ 10 files changed, 142 insertions(+), 81 deletions(-) diff --git a/src/main/quickbooks-desktop/quickbooks-desktop.ts b/src/main/quickbooks-desktop/quickbooks-desktop.ts index 6353254..effc464 100644 --- a/src/main/quickbooks-desktop/quickbooks-desktop.ts +++ b/src/main/quickbooks-desktop/quickbooks-desktop.ts @@ -17,11 +17,9 @@ export async function handleQuickBookRequest( res: Response, ): Promise { if (process.platform !== "win32") { - res - .status(500) - .json({ - error: "QuickBooks Desktop integration is only available on Windows", - }); + res.status(500).json({ + error: "QuickBooks Desktop integration is only available on Windows", + }); return; } diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index dcd4e7b..c21cf09 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -1,5 +1,5 @@ import "@ant-design/v5-patch-for-react-19"; -import { Layout } from "antd"; +import { Layout, Skeleton } from "antd"; import { User } from "firebase/auth"; import { useEffect, useState } from "react"; import { ErrorBoundary } from "react-error-boundary"; @@ -16,10 +16,15 @@ import { auth } from "./util/firebase"; import { NotificationProvider } from "./util/notificationContext"; const App: React.FC = () => { - const [user, setUser] = useState(null); + const [user, setUser] = useState(false); useEffect(() => { // Only set up the listener once when component mounts + if (auth.currentUser) { + setUser(auth.currentUser); + } else { + setUser(false); + } const unsubscribe = auth.onAuthStateChanged((user: User | null) => { setUser(user); //Send back to the main process so that it knows we are authenticated. @@ -41,19 +46,25 @@ const App: React.FC = () => { - - {!user ? ( - - ) : ( - <> - - - - } /> - - - )} - + + + {!user ? ( + + ) : ( + <> + + + + + + + } /> + + + + )} + + diff --git a/src/renderer/src/components/Home/Home.tsx b/src/renderer/src/components/Home/Home.tsx index 7575fba..f02fa22 100644 --- a/src/renderer/src/components/Home/Home.tsx +++ b/src/renderer/src/components/Home/Home.tsx @@ -1,28 +1,7 @@ -import { Button } from "antd"; -import ipcTypes from "../../../../util/ipcTypes.json"; - const Home: React.FC = () => { return (

Home

- -
); }; diff --git a/src/renderer/src/components/NavigationHeader/Navigationheader.tsx b/src/renderer/src/components/NavigationHeader/Navigationheader.tsx index 633320c..fb49990 100644 --- a/src/renderer/src/components/NavigationHeader/Navigationheader.tsx +++ b/src/renderer/src/components/NavigationHeader/Navigationheader.tsx @@ -1,7 +1,9 @@ import { selectWatcherStatus } from "@renderer/redux/app.slice"; import { useAppSelector } from "@renderer/redux/reduxHooks"; +import { auth } from "@renderer/util/firebase"; import { Badge, Layout, Menu } from "antd"; import { MenuItemType } from "antd/es/menu/interface"; +import { signOut } from "firebase/auth"; import { useTranslation } from "react-i18next"; import { NavLink } from "react-router"; @@ -10,6 +12,13 @@ const NavigationHeader: React.FC = () => { const isWatcherStarted = useAppSelector(selectWatcherStatus); const menuItems: MenuItemType[] = [ { label: {t("navigation.home")}, key: "home" }, + { + label: t("navigation.signout"), + key: "watchlist", + onClick: (): void => { + signOut(auth); + }, + }, // { // label: {t("navigation.settings")}, // key: "settings", diff --git a/src/renderer/src/components/Settings/Settings.WatchedPaths.tsx b/src/renderer/src/components/Settings/Settings.WatchedPaths.tsx index 45e126c..dfe0999 100644 --- a/src/renderer/src/components/Settings/Settings.WatchedPaths.tsx +++ b/src/renderer/src/components/Settings/Settings.WatchedPaths.tsx @@ -41,9 +41,10 @@ const SettingsWatchedPaths: React.FC = () => { } > - - {watchedPaths?.map((path, index) => ( - + ({ + key: index, + children: ( {path} - + {error && ( + + + + )} + + + ); }; diff --git a/src/util/translations/en-US/renderer.json b/src/util/translations/en-US/renderer.json index 0e2e4be..bcf0197 100644 --- a/src/util/translations/en-US/renderer.json +++ b/src/util/translations/en-US/renderer.json @@ -1,8 +1,16 @@ { "translation": { + "auth": { + "login": { + "error": "The username and password combination provided is not valid.", + "login": "Log In", + "resetpassword": "Reset Password" + } + }, "navigation": { "home": "Home", - "settings": "Settings" + "settings": "Settings", + "signout": "Sign Out" }, "settings": { "actions": { diff --git a/translations.babel b/translations.babel index a66532d..fa30ee9 100644 --- a/translations.babel +++ b/translations.babel @@ -45,6 +45,55 @@ translation + + auth + + + login + + + error + false + + + + + + en-US + false + + + + + login + false + + + + + + en-US + false + + + + + resetpassword + false + + + + + + en-US + false + + + + + + + navigation @@ -74,6 +123,19 @@ + + signout + false + + + + + + en-US + false + + +