-
+
+
+
+
+
+ Made with
+
+ ♥
+
+ on
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Powered by
+
+
+
+ / undefined
diff --git a/src/components/Header/Header.test.tsx b/src/components/Header/Header.test.tsx
index fdfef85..aeed01f 100644
--- a/src/components/Header/Header.test.tsx
+++ b/src/components/Header/Header.test.tsx
@@ -18,7 +18,7 @@ describe('
component with logged in state', () => {
test('should load the component in logged out state', () => {
const { container, queryByTestId, getByText } = render(
-
+
@@ -32,7 +32,7 @@ describe('
component with logged in state', () => {
test('should load the component in logged in state', () => {
const { container, getByTestId, queryByText } = render(
-
+
@@ -46,7 +46,7 @@ describe('
component with logged in state', () => {
test('should open login dialog', async () => {
const { getByText } = render(
-
+
@@ -61,7 +61,7 @@ describe('
component with logged in state', () => {
test('should logout the user', async () => {
const { getByText, getByTestId } = render(
-
+
@@ -79,7 +79,7 @@ describe('
component with logged in state', () => {
test("The question icon should open a new tab of verdaccio's website - installation doc", () => {
const { getByTestId } = render(
-
+
@@ -92,7 +92,7 @@ describe('
component with logged in state', () => {
test('should open the registrationInfo modal when clicking on the info icon', async () => {
const { getByTestId } = render(
-
+
@@ -109,7 +109,7 @@ describe('
component with logged in state', () => {
test('should close the registrationInfo modal when clicking on the button close', async () => {
const { getByTestId, getByText, queryByTestId } = render(
-
+
diff --git a/src/components/LoginDialog/LoginDialog.test.tsx b/src/components/LoginDialog/LoginDialog.test.tsx
index ab104ba..15c3830 100644
--- a/src/components/LoginDialog/LoginDialog.test.tsx
+++ b/src/components/LoginDialog/LoginDialog.test.tsx
@@ -8,7 +8,6 @@ import LoginDialog from './LoginDialog';
const appContextValue: AppContextProps = {
scope: '',
- packages: [],
setUser: jest.fn(),
};
diff --git a/src/pages/home/Home.tsx b/src/pages/home/Home.tsx
index 6f2c72b..6406e0e 100644
--- a/src/pages/home/Home.tsx
+++ b/src/pages/home/Home.tsx
@@ -1,17 +1,35 @@
-import React from 'react';
+import React, { useEffect, useState } from 'react';
import { PackageList } from '../../components/PackageList';
-import { PackageInterface } from '../../components/Package/Package';
+import API from '../../utils/api';
+import Loading from '../../components/Loading';
interface Props {
isUserLoggedIn: boolean;
- packages: PackageInterface[];
}
-const Home: React.FC
= ({ packages }) => (
-
-);
+const Home: React.FC = ({ isUserLoggedIn }) => {
+ const [packages, setPackages] = useState([]);
+ const [isLoading, setIsLoading] = useState(true);
+ const loadPackages = async () => {
+ try {
+ const packages = await API.request('packages', 'GET');
+ // FIXME add correct type for package
+ setPackages(packages as never[]);
+ } catch (error) {
+ // FIXME: add dialog
+ console.error({
+ title: 'Warning',
+ message: `Unable to load package list: ${error.message}`,
+ });
+ }
+ setIsLoading(false);
+ };
+ useEffect(() => {
+ loadPackages().then();
+ }, [isUserLoggedIn]);
+
+ return ;
+};
export default Home;