From 13c288d4a7d0223f15bdfeeecbd21c6323b21827 Mon Sep 17 00:00:00 2001 From: ceddybi Date: Wed, 14 Feb 2024 01:07:21 -0500 Subject: [PATCH] ui --- src/app/layout.tsx | 4 ++-- src/app/navbar.tsx | 41 +++++++++++++++++++++++++++------------- src/index.ts | 1 + src/utils/state/index.ts | 16 ++++++++++------ 4 files changed, 41 insertions(+), 21 deletions(-) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index aa995f3..789e3d3 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -68,8 +68,8 @@ export const Layout = () => { return (
- -
+ +
diff --git a/src/app/navbar.tsx b/src/app/navbar.tsx index f50bf33..7957c9d 100644 --- a/src/app/navbar.tsx +++ b/src/app/navbar.tsx @@ -14,9 +14,14 @@ function classNames(...classes: string[]) { return classes.filter(Boolean).join(" "); } -export default function Navbar({ user }: { user: any }) { - const pathname = ""; - +export default function Navbar({ + user, + ...props +}: { + user: any; + pathname: string; +}) { + const pathname = props.pathname.replace("#", ""); const signOut = () => { // console.log("sign out"); }; @@ -56,15 +61,24 @@ export default function Navbar({ user }: { user: any }) {
*/}
+ {navigation.map((item) => ( @@ -73,18 +87,19 @@ export default function Navbar({ user }: { user: any }) { ))}
-
+ + {/*
Open user menu - {/* {`${user?.name */} + />
+
*/} - + {/*
{navigation.map((item) => (
- {/* {`${user.name} */} + />
@@ -204,7 +219,7 @@ export default function Navbar({ user }: { user: any }) {
)}
- + */} )} diff --git a/src/index.ts b/src/index.ts index e3e5f50..8ba8eab 100644 --- a/src/index.ts +++ b/src/index.ts @@ -307,6 +307,7 @@ ipcMain.handle('questions:read', async (event, question) => { ipcMain.handle('questions:getall', async (event) => { const questions = await getAllQuestion(); + // console.log("questions:getall", questions.length); return questions; }); diff --git a/src/utils/state/index.ts b/src/utils/state/index.ts index ba89966..ae350cc 100644 --- a/src/utils/state/index.ts +++ b/src/utils/state/index.ts @@ -156,23 +156,27 @@ export async function getAllQuestion(): Promise { const questionFile = path.join(questionDirPath, file); const questionDataString = fs.readFileSync(questionFile, { encoding: "utf-8" }); - const questionJson: QuestionAnswer = JSON.parse(questionDataString); - + let questionJson: QuestionAnswer; // TODO remove after update let chainResTextAsJson; try { + questionJson = JSON.parse(questionDataString); chainResTextAsJson = JSON.parse(questionJson.chainRes.text); - if (questionJson.chainRes) { + if (questionJson?.chainRes) { questionJson.chainRes.json = chainResTextAsJson; } - } catch (error) { } - - return questionJson; + return questionJson; + } catch (error) { + // console.log("error questions.map", { message: error?.message, questionDataString, questionJson }); + } finally { + return questionJson; + } }); return compact(questions); } catch (error) { + console.log("error getAllQuestion", error?.message); return null; } };