diff --git a/.env b/.env
new file mode 100644
index 0000000..f019d8e
--- /dev/null
+++ b/.env
@@ -0,0 +1 @@
+NEXT_PUBLIC_FAIROSHOST=https://fairos.fairdatasociety.org/v1/
diff --git a/components/ContentHeader/index.tsx b/components/ContentHeader/index.tsx
index 4ade8a4..073e2eb 100644
--- a/components/ContentHeader/index.tsx
+++ b/components/ContentHeader/index.tsx
@@ -3,17 +3,15 @@ import FolderIcon from 'assets/icons/folder.svg';
import HamburgerIcon from 'assets/icons/hamburger.svg';
import UnionIcon from 'assets/icons/union.svg';
import Dropdown from 'components/Dropdown';
+import usePods from 'hooks/usePods';
const ContentHeader = () => {
- const dropdownOptions = [
- { title: 'Pod 1', href: '/' },
- { title: 'Pod 2', href: '/' },
- ];
+ const { pods } = usePods();
return (
-
+
diff --git a/components/Dropdown/index.tsx b/components/Dropdown/index.tsx
index 5da2856..31aa241 100644
--- a/components/Dropdown/index.tsx
+++ b/components/Dropdown/index.tsx
@@ -4,7 +4,7 @@ import Button, { StyleTypes } from 'components/Button';
import ChevronDownIcon from 'assets/icons/chevron-down.svg';
import useOnClickOutside from 'use-onclickoutside';
-interface DropdownItem {
+export interface DropdownItem {
title: string;
href?: string;
}
diff --git a/components/Layout/index.tsx b/components/Layout/index.tsx
index 707517e..c84ecea 100644
--- a/components/Layout/index.tsx
+++ b/components/Layout/index.tsx
@@ -1,3 +1,4 @@
+/* eslint-disable react-hooks/exhaustive-deps */
import { ReactNode, useEffect } from 'react';
import Router from 'next/router';
import Topbar from 'components/Topbar';
@@ -18,7 +19,7 @@ const Layout = ({ children }: Props) => {
setSidebarVisible(false);
Router.push('/login');
}
- }, [isAuthenticated, setSidebarVisible]);
+ }, [isAuthenticated]);
return (
diff --git a/components/Sidebar/index.tsx b/components/Sidebar/index.tsx
index 25caa89..d2d17bf 100644
--- a/components/Sidebar/index.tsx
+++ b/components/Sidebar/index.tsx
@@ -1,9 +1,16 @@
+import Link from 'next/link';
+import { useRouter } from 'next/router';
import classes from './Sidebar.module.scss';
import AlertIcon from 'assets/icons/alert.svg';
-import BinIcon from 'assets/icons/bin.svg';
+// import BinIcon from 'assets/icons/bin.svg';
import ChevronIcon from 'assets/icons/chevron-right.svg';
+import usePods from 'hooks/usePods';
const Sidebar = () => {
+ const { pods } = usePods();
+ const router = useRouter();
+ const { slug = '/' } = router.query;
+
return (
+
+ {JSON.stringify(files)}
)
);
diff --git a/pages/login.tsx b/pages/login.tsx
index 3c0d4f6..69c6e29 100644
--- a/pages/login.tsx
+++ b/pages/login.tsx
@@ -1,3 +1,4 @@
+/* eslint-disable react-hooks/exhaustive-deps */
import type { NextPage } from 'next';
import Layout from 'components/Layout';
import Title from 'components/Title';
@@ -5,12 +6,18 @@ import TextInput from 'components/TextInput';
import Button from 'components/Button';
import useUser from 'hooks/useUser';
import Router from 'next/router';
-import { SyntheticEvent, useEffect } from 'react';
+import { SyntheticEvent, useEffect, useState } from 'react';
import useApp from 'hooks/useApp';
+import useFairOs from 'hooks/useFairOs';
+import usePods from 'hooks/usePods';
const Login: NextPage = () => {
+ const [username, setUsername] = useState('');
+ const [password, setPassword] = useState('');
const { setUser, isAuthenticated } = useUser();
const { setSidebarVisible } = useApp();
+ const { login, getPodsWithHref } = useFairOs();
+ const { setPods } = usePods();
useEffect(() => {
if (isAuthenticated) {
@@ -18,14 +25,34 @@ const Login: NextPage = () => {
}
}, [isAuthenticated]);
- const onSubmitHandler = (event: SyntheticEvent) => {
+ const onChangeUsernameHandler = (evt: SyntheticEvent) => {
+ setUsername((evt.target as HTMLInputElement).value);
+ };
+
+ const onChangePasswordHandler = (evt: SyntheticEvent) => {
+ setPassword((evt.target as HTMLInputElement).value);
+ };
+
+ const onSubmitHandler = async (event: SyntheticEvent) => {
event.preventDefault();
console.log('onSubmitHandler');
- setSidebarVisible(true);
- setUser({
- username: 'johndoe',
+
+ const { data } = await login({
+ username,
+ password,
});
- Router.push('/');
+
+ if (data.code === 200) {
+ setSidebarVisible(true);
+ setUser({
+ username,
+ password,
+ });
+
+ setPods(await getPodsWithHref());
+
+ Router.push('/');
+ }
};
return (
@@ -33,8 +60,17 @@ const Login: NextPage = () => {
Login page