Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
7 changes: 5 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"default_popup": "index.html",
"default_title": "Kleo Network: Extension"
},
"side_panel": {
"default_path": "index.html"
},
"icons":{
"128" : "logo/128.png",
"64": "logo/64.png",
Expand All @@ -19,7 +22,8 @@
"permissions": [
"tabs",
"history",
"storage"
"storage",
"sidePanel"
],
"content_scripts": [
{
Expand All @@ -34,4 +38,3 @@
}
]
}

22 changes: 22 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,28 @@
font-style: normal;
}

html,
body {
margin: 0;
min-width: 400px;
background: #eaecf5;
font-family: 'inter', sans-serif;
}

body {
overflow: hidden;
}

button,
input {
font: inherit;
}

.container {
width: 400px;
min-height: 640px;
}

.color-empty {
fill: #ebedf0; /* Light gray, for empty tiles */
}
Expand Down
5 changes: 2 additions & 3 deletions src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import React from 'react';
import { render, screen } from '@testing-library/react';
import App from './App';

test('renders learn react link', () => {
test('renders the Kleo account screen', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
expect(screen.getByText(/create an account/i)).toBeInTheDocument();
});
106 changes: 3 additions & 103 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,108 +1,8 @@
import { ReactElement, useEffect, useState } from 'react';
import { Route, Routes, useNavigate } from 'react-router-dom';
import { UserData } from './common/interface';
import Navbar from './navbar/Navbar';
import useFetch from './common/hooks/useFetch';
import { HomeComponent } from './pages/home/HomeComponent';
import Processing from './pages/ProfileCards/Processing'
import { ReactElement } from 'react';
import SidePanel from './pages/sidepanel/SidePanel';

function App(): ReactElement {
const emptyStringArray: string[] = [];
const [slug, setSlug] = useState<string>('');
const [isUserLoading, setIsUserLoading] = useState(false);

/*
{
"about": "",
"badges": [],
"content_tags": [],
"first_time_user": true,
"identity_tags": [],
"kleo_points": 52,
"last_attested": 0,
"last_cards_marked": 0,
"milestones": {
"data_owned": 23000,
"followed_on_twitter": true,
"referred_count": 0,
"tweet_activity_graph": false
},
"name": "",
"pfp": "",
"pii_removed_count": 3,
"profile_metadata": {},
"referee": null,
"referrals": [],
"settings": {},
"slug": "0x9bdcAeb9443316BbA3998a600Cc30888846A1C45",
"stage": 1,
"total_data_quantity": 23000,
"verified": false
}
*/
const [user, setUser] = useState<UserData>({
badges: emptyStringArray,
content_tags: emptyStringArray,
first_time_user: false,
identity_tags: emptyStringArray,
kleo_points: 88,
data_quality: 87,
last_minted: Math.floor(Date.now() / 1000),
address: '',
verified: false,
total_data_quantity: 2, // this would be in MegaBytes, this is 34MB
});
const navigate = useNavigate();

useEffect(() => {
chrome.storage.local.get('user', (storageData) => {
if (storageData.user) {
setSlug(storageData.user.id);
}
});

}, []);

const GET_USER_DETAIL = 'user/get-user/{slug}';
const { fetchData: fetchUserData } = useFetch<UserData>();

function getUserDetails(slug: string) {
return GET_USER_DETAIL.replace('{slug}', slug);
}


useEffect(() => {
try {
setIsUserLoading(true);
fetchUserData(getUserDetails(slug), {
onSuccessfulFetch(data) {
setIsUserLoading(false);
if (data) {
setUser(data)
navigate('/home')
}
},
});
} catch (error) {
console.error('Error fetching data:', error);
}
}, [slug]);

return (
<div className="h-[500px] w-[400px] rounded-xl bg-gray-50">
<div className="flex flex-col font-inter self-stretch h-full rounded-xl">
<header className="flex flex-row self-stretch items-center">
<Navbar slug={user.address || ''} />
</header>
{isUserLoading && <div className="h-full w-full flex justify-center items-center"><div className="w-8 h-8 border-4 border-t-4 border-gray-200 border-t-purple-500 rounded-full animate-spin"></div></div>}
{!isUserLoading && user && (
<Routes>
<Route path="/home" element={<HomeComponent user={user} isUserLoading={isUserLoading} />} />
</Routes>
)}
</div>
</div>
);
return <SidePanel />;
}

export default App;
Loading