Skip to content

Commit

Permalink
ui
Browse files Browse the repository at this point in the history
  • Loading branch information
ceddybi committed Feb 14, 2024
1 parent dc9de7c commit 13c288d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export const Layout = () => {

return (
<div className="h-full bg-gray-50 w-full">
<Navbar user={null} />
<div className="p-3" style={{ paddingTop: "80px" }}>
<Navbar pathname={hash} user={null} />
<div className="p-3 overflow-scroll" style={{ paddingTop: "80px" }}>
<Component state={state} />
</div>
</div>
Expand Down
41 changes: 28 additions & 13 deletions src/app/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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");
};
Expand Down Expand Up @@ -56,15 +61,24 @@ export default function Navbar({ user }: { user: any }) {
</svg>
</div> */}
<div className="-my-px ml-6 flex space-x-8">
<img
src={"static://assets/icon.png"}
style={{
height: "45px",
display: "flex",
justifyContent: "center",
alignSelf: "center",
}}
/>
{navigation.map((item) => (
<a
key={item.name}
href={`#${item.href}`}
className={classNames(
pathname === item.href
? "border-slate-500 text-gray-900"
? "border-blue-500 text-blue-600"
: "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300",
"inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium"
"inline-flex items-center px-1 pt-1 border-b-2 text-xl font-medium"
)}
aria-current={pathname === item.href ? "page" : undefined}
>
Expand All @@ -73,18 +87,19 @@ export default function Navbar({ user }: { user: any }) {
))}
</div>
</div>
<div className="hidden sm:ml-6 sm:flex sm:items-center">

{/* <div className="hidden sm:ml-6 sm:flex sm:items-center">
<Menu as="div" className="relative ml-3">
<div>
<Menu.Button className="flex rounded-full bg-white text-sm focus:outline-none focus:ring-2 focus:ring-slate-500 focus:ring-offset-2">
<span className="sr-only">Open user menu</span>
{/* <Image
<Image
className="h-8 w-8 rounded-full"
src={user?.image || 'https://avatar.vercel.sh/leerob'}
height={32}
width={32}
alt={`${user?.name || 'placeholder'} avatar`}
/> */}
/>
</Menu.Button>
</div>
<Transition
Expand Down Expand Up @@ -139,11 +154,11 @@ export default function Navbar({ user }: { user: any }) {
<Bars3Icon className="block h-6 w-6" aria-hidden="true" />
)}
</Disclosure.Button>
</div>
</div> */}
</div>
</div>

<Disclosure.Panel className="sm:hidden">
{/* <Disclosure.Panel className="sm:hidden">
<div className="space-y-1 pt-2 pb-3">
{navigation.map((item) => (
<Disclosure.Button
Expand All @@ -167,13 +182,13 @@ export default function Navbar({ user }: { user: any }) {
<>
<div className="flex items-center px-4">
<div className="flex-shrink-0">
{/* <Image
<Image
className="h-8 w-8 rounded-full"
src={user.image}
height={32}
width={32}
alt={`${user.name} avatar`}
/> */}
/>
</div>
<div className="ml-3">
<div className="text-base font-medium text-gray-800">
Expand Down Expand Up @@ -204,7 +219,7 @@ export default function Navbar({ user }: { user: any }) {
</div>
)}
</div>
</Disclosure.Panel>
</Disclosure.Panel> */}
</>
)}
</Disclosure>
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

Expand Down
16 changes: 10 additions & 6 deletions src/utils/state/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,23 +156,27 @@ export async function getAllQuestion(): Promise<QuestionAnswer[]> {
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;
}
};
Expand Down

0 comments on commit 13c288d

Please sign in to comment.