diff --git a/code/client/src/App.tsx b/code/client/src/App.tsx
index aed182f4..d786e65e 100644
--- a/code/client/src/App.tsx
+++ b/code/client/src/App.tsx
@@ -10,8 +10,9 @@ import { WorkspaceProvider } from '@ui/contexts/workspace/WorkspaceContext';
import Workspaces from '@ui/pages/workspaces/Workspaces';
import { CommunicationProvider } from '@ui/contexts/communication/CommunicationContext';
import Home from '@ui/pages/home/Home';
-import Login from '@ui/pages/login/Login';
import AuthProvider from '@ui/contexts/auth/AuthContext';
+import Profile from '@ui/pages/profile/Profile';
+import Landing from '@ui/pages/landing/Landing';
function App() {
return (
@@ -23,8 +24,9 @@ function App() {
+ } />
@@ -32,7 +34,7 @@ function App() {
>
}
/>
- } />
+ } />
{
return await http.get(`/users/${id}`);
}
@@ -16,6 +17,7 @@ function authService(http: HttpCommunication) {
async function deleteUser(id: string) {
await http.delete(`/users/${id}`);
+ Cookies.remove('token');
}
return {
diff --git a/code/client/src/services/workspace/workspaceService.ts b/code/client/src/services/workspace/workspaceService.ts
index 24fb9f72..3350fbd3 100644
--- a/code/client/src/services/workspace/workspaceService.ts
+++ b/code/client/src/services/workspace/workspaceService.ts
@@ -1,6 +1,7 @@
import { HttpCommunication } from '@services/communication/http/httpCommunication';
import { WorkspaceInputModel, WorkspaceMeta } from '@notespace/shared/src/workspace/types/workspace';
import { Workspace } from '@notespace/shared/src/workspace/types/workspace';
+import { UserData } from '@notespace/shared/src/users/types';
function workspaceService(http: HttpCommunication) {
async function getWorkspace(id: string): Promise {
@@ -23,12 +24,28 @@ function workspaceService(http: HttpCommunication) {
await http.put(`/workspaces/${id}`, newProps);
}
+ async function getWorkspaceMembers(id: string): Promise {
+ const workspace: WorkspaceMeta = await http.get(`/workspaces/${id}`);
+ return workspace.members;
+ }
+
+ async function addWorkspaceMember(id: string, email: string): Promise {
+ await http.post(`/workspaces/${id}/members`, { email });
+ }
+
+ async function removeWorkspaceMember(id: string, email: string): Promise {
+ await http.delete(`/workspaces/${id}/members`, { email });
+ }
+
return {
getWorkspace,
getWorkspaces,
createWorkspace,
deleteWorkspace,
updateWorkspace,
+ getWorkspaceMembers,
+ addWorkspaceMember,
+ removeWorkspaceMember,
};
}
diff --git a/code/client/src/ui/components/dialog/Dialog.tsx b/code/client/src/ui/components/dialog/Dialog.tsx
index 840684c1..7802b94b 100644
--- a/code/client/src/ui/components/dialog/Dialog.tsx
+++ b/code/client/src/ui/components/dialog/Dialog.tsx
@@ -21,10 +21,11 @@ interface DialogProps {
fields: Field[];
onSubmit: (values: { [key: string]: any }) => void;
submitText?: string;
+ extraContent?: React.ReactNode;
children: React.ReactNode;
}
-function Dialog({ title, fields, onSubmit, submitText, children }: DialogProps) {
+function Dialog({ title, fields, onSubmit, submitText, extraContent, children }: DialogProps) {
const [open, setOpen] = useState(false);
const [values, setValues] = useState<{ [key: string]: any }>(
fields.reduce((obj, item) => ({ ...obj, [item.name]: item.type === 'checkbox' ? false : '' }), {})
@@ -82,6 +83,7 @@ function Dialog({ title, fields, onSubmit, submitText, children }: DialogProps)
/>
)
)}
+ {extraContent}
diff --git a/code/client/src/ui/components/header/Header.scss b/code/client/src/ui/components/header/Header.scss
index bb5a4291..94103245 100644
--- a/code/client/src/ui/components/header/Header.scss
+++ b/code/client/src/ui/components/header/Header.scss
@@ -11,6 +11,10 @@
justify-content: space-between;
align-items: center;
+ a {
+ padding-left: 10vh;
+ }
+
div {
display: flex;
align-items: center;
diff --git a/code/client/src/ui/components/header/Header.tsx b/code/client/src/ui/components/header/Header.tsx
index d837db09..8bac00ee 100644
--- a/code/client/src/ui/components/header/Header.tsx
+++ b/code/client/src/ui/components/header/Header.tsx
@@ -6,16 +6,16 @@ function Header() {
const { currentUser, logout } = useAuth();
return (
);
diff --git a/code/client/src/ui/components/sidebar/Sidebar.tsx b/code/client/src/ui/components/sidebar/Sidebar.tsx
index bfa26a0b..15d089ce 100644
--- a/code/client/src/ui/components/sidebar/Sidebar.tsx
+++ b/code/client/src/ui/components/sidebar/Sidebar.tsx
@@ -29,7 +29,6 @@ function Sidebar() {
)}
- NoteSpace
-
diff --git a/code/client/src/ui/contexts/auth/AuthContext.tsx b/code/client/src/ui/contexts/auth/AuthContext.tsx
index 9d0a3863..ecf38f28 100644
--- a/code/client/src/ui/contexts/auth/AuthContext.tsx
+++ b/code/client/src/ui/contexts/auth/AuthContext.tsx
@@ -32,7 +32,7 @@ export function AuthProvider({ children }: AuthProviderProps) {
const loginWithProvider = async (provider: Provider) => {
try {
const { user } = await signInWithPopup(auth, provider);
- await registerUser(user.uid, { username: user.displayName!, email: user.email! });
+ await registerUser(user.uid, { name: user.displayName!, email: user.email! });
const token = await user.getIdToken();
Cookies.set('token', token, { expires: 1, secure: true, sameSite: 'Strict' });
} catch (e) {
@@ -56,6 +56,13 @@ export function AuthProvider({ children }: AuthProviderProps) {
});
}, []);
+ useEffect(() => {
+ console.log(currentUser);
+ if (!currentUser && window.location.pathname !== '/') {
+ window.location.href = '/';
+ }
+ }, [currentUser]);
+
return (
{
if (currentUser) {
- navigate('/');
+ navigate('/home');
}
}, [currentUser, navigate]);
return (
-
-
Login
+
+
Welcome to NoteSpace