Skip to content

Commit

Permalink
Front fixes - Logs error and server components (#741)
Browse files Browse the repository at this point in the history
Fixing this errors related to server components insider client
components


![image](https://github.com/user-attachments/assets/3e5ec71b-9cd1-42e7-970e-3e2807f165d6)


<!-- This is an auto-generated comment: release notes by OSS
Entelligence.AI -->
### Summary by Entelligence.AI

- Refactor: Enhanced the `IdentifyPlugin` component to handle loading
states and error components, improving user experience during data
retrieval.
- Style: Adjusted the styling attributes of certain components for
better visual consistency.
- Chore: Cleaned up redundant empty lines in the code for improved
readability and maintainability.
- Refactor: Updated the rendering location of the `Plugins` component in
the `Summary` component, optimizing the conditional rendering based on
the length of `memory.plugins_results`.
<!-- end of auto-generated comment: release notes by OSS Entelligence.AI
-->
  • Loading branch information
josancamon19 committed Sep 3, 2024
2 parents fb3dd89 + d35cae2 commit 4773dd8
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 16 deletions.
6 changes: 1 addition & 5 deletions frontend/src/components/memories/plugins/plugins.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { PluginsResult } from '@/src/types/memory.types';
import Markdown from 'markdown-to-jsx';
import { Suspense } from 'react';
import IndentifyPlugin from '../../plugins/indentify-plugin';
import IdentifyPluginLoader from '../../plugins/identify-plugin-loader';
import { ErrorBoundary } from 'next/dist/client/components/error-boundary';
import ErrorIdentifyPlugin from '../../plugins/error-identify-plugin';

Expand All @@ -19,9 +17,7 @@ export default function Plugins({ plugins }: PluginsProps) {
return (
<div key={index}>
<ErrorBoundary errorComponent={ErrorIdentifyPlugin}>
<Suspense fallback={<IdentifyPluginLoader />}>
<IndentifyPlugin pluginId={puglin.plugin_id} />
</Suspense>
<IndentifyPlugin pluginId={puglin.plugin_id} />
</ErrorBoundary>
<div className="bg-[#0f0f0f] px-4 md:px-12">
<Markdown className="prose prose-slate text-white md:prose-lg prose-p:m-0 prose-p:mt-3 prose-p:text-white last:prose-p:mt-8 last:prose-p:rounded-lg last:prose-p:bg-zinc-900 last:prose-p:p-2 last:prose-p:px-4 last:prose-p:text-zinc-200 prose-strong:text-white prose-ul:my-0 prose-ul:list-disc prose-li:text-zinc-300 md:last:prose-p:text-sm">
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/memories/summary/sumary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ export default function Summary({ memory }: SummaryProps) {
<p className="mt-4 text-gray-400">No overview available for this memory.</p>
)}
</div>
{memory.plugins_results.length > 0 && <Plugins plugins={memory.plugins_results} />}
{memory?.structured?.action_items?.length > 0 && (
<ActionItems items={memory.structured.action_items} />
)}
{memory?.structured?.events?.length > 0 && (
<MemoryEvents events={memory.structured.events} />
)}
{memory.plugins_results.length > 0 && <Plugins plugins={memory.plugins_results} />}
</div>
);
}
4 changes: 2 additions & 2 deletions frontend/src/components/plugins/identify-plugin-loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { OnePointCircle } from 'iconoir-react';

export default function IdentifyPluginLoader() {
return (
<div className="sticky top-[4rem] z-[50] flex items-center gap-2 border-b border-solid border-zinc-900 bg-[#0f0f0f] bg-opacity-90 px-4 py-3 shadow-sm backdrop-blur-sm md:px-12">
<div className="grid h-9 w-9 place-items-center rounded-full bg-zinc-800">
<div className="sticky h-[69px] md:h-[73px] top-[4rem] z-[50] flex items-center gap-2 border-b border-solid border-zinc-900 bg-[#0f0f0f] bg-opacity-90 px-4 py-3 shadow-sm backdrop-blur-sm md:px-12">
<div className="grid h-[36px] w-[36px] place-items-center rounded-full bg-zinc-800">
<OnePointCircle className="animate-spin text-xs" />
</div>
<div>
Expand Down
40 changes: 34 additions & 6 deletions frontend/src/components/plugins/indentify-plugin.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,57 @@
'use client';

import { getCommunityPlugin } from '@/src/actions/plugins/get-community-plugins';
import { CommunityPlugin } from '@/src/types/plugins/plugins.types';
import Image from 'next/image';
import { Fragment, useEffect, useState } from 'react';
import ErrorIdentifyPlugin from './error-identify-plugin';
import IdentifyPluginLoader from './identify-plugin-loader';

interface IndentifyPluginProps {
pluginId: string;
}

export default async function IndentifyPlugin({ pluginId }: IndentifyPluginProps) {
const pluginCommunity = await getCommunityPlugin(pluginId);
if (!pluginCommunity) throw new Error('Plugin not found');
export default function IndentifyPlugin({ pluginId }: IndentifyPluginProps) {
const [pluginCommunity, setPluginCommunity] = useState<CommunityPlugin | undefined>(
undefined,
);
const [loading, setLoading] = useState(true);

useEffect(() => {
getCommunityPlugin(pluginId)
.then((plugin) => {
setPluginCommunity(plugin);
})
.finally(() => setLoading(false));
}, []);

if (loading) {
return <IdentifyPluginLoader />;
}

if (!pluginCommunity) {
return <ErrorIdentifyPlugin />;
}


return (
<div className="sticky top-[4rem] z-[50] mb-3 flex items-center gap-2 border-b border-solid border-zinc-900 bg-[#0f0f0f] bg-opacity-90 px-4 py-3 shadow-sm backdrop-blur-sm md:px-12">
<Fragment>
<div className="sticky top-[4rem] z-[50] mb-3 flex items-center gap-2 border-b border-solid border-zinc-900 bg-[#0f0f0f] bg-opacity-90 px-4 py-3 shadow-sm backdrop-blur-sm md:px-12">
<Image
className="grid h-9 w-9 min-w-[36px] place-items-center rounded-full bg-zinc-700"
src={`https://raw.githubusercontent.com/BasedHardware/Friend/main/${pluginCommunity.image}`}
src={`https://raw.githubusercontent.com/BasedHardware/Friend/main/${pluginCommunity?.image}`}
alt={''}
width={50}
height={50}
/>
<div>
<h3 className="text-base font-semibold md:text-base">{pluginCommunity.name}</h3>
<h3 className="text-base font-semibold md:text-base">{pluginCommunity?.name}</h3>
<p className="line-clamp-1 text-sm text-gray-500 md:text-base">
{pluginCommunity.description}
</p>
</div>
</div>
</Fragment>

);
}
2 changes: 0 additions & 2 deletions frontend/src/components/shared/gleap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { FC, ReactNode, useEffect } from 'react';
import Gleap from 'gleap';
import envConfig from '@/src/constants/envConfig';



export const GleapInit: FC<{ children?: ReactNode }> = ({ children }) => {
useEffect(() => {
Gleap.initialize(envConfig.GLEAP_API_KEY ?? '');
Expand Down

0 comments on commit 4773dd8

Please sign in to comment.