From 54d781ef91f9fb2332fca8234d81281f81b117ed Mon Sep 17 00:00:00 2001
From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com>
Date: Fri, 1 Sep 2023 17:10:06 +0530
Subject: [PATCH] fix: auth screens (#2054)
---
apps/space/components/issues/navbar/index.tsx | 39 +++++++++++++++++--
.../issues/peek-overview/issue-activity.tsx | 34 +++++++++++++---
apps/space/pages/index.tsx | 4 +-
apps/space/store/user.ts | 5 ++-
4 files changed, 69 insertions(+), 13 deletions(-)
diff --git a/apps/space/components/issues/navbar/index.tsx b/apps/space/components/issues/navbar/index.tsx
index 83d79f349..c9d0f52d1 100644
--- a/apps/space/components/issues/navbar/index.tsx
+++ b/apps/space/components/issues/navbar/index.tsx
@@ -1,12 +1,17 @@
import { useEffect } from "react";
+
+import Link from "next/link";
import Image from "next/image";
-import { observer } from "mobx-react-lite";
import { useRouter } from "next/router";
+
+// mobx
+import { observer } from "mobx-react-lite";
// components
import { NavbarSearch } from "./search";
import { NavbarIssueBoardView } from "./issue-board-view";
-import { NavbarIssueFilter } from "./issue-filter";
import { NavbarTheme } from "./theme";
+// ui
+import { PrimaryButton } from "components/ui";
// lib
import { useMobxStore } from "lib/mobx/store-provider";
// store
@@ -25,11 +30,13 @@ const renderEmoji = (emoji: string | { name: string; color: string }) => {
};
const IssueNavbar = observer(() => {
- const { project: projectStore }: RootStore = useMobxStore();
+ const { project: projectStore, user: userStore }: RootStore = useMobxStore();
// router
const router = useRouter();
const { workspace_slug, project_slug, board } = router.query;
+ const user = userStore?.currentUser;
+
useEffect(() => {
if (workspace_slug && project_slug) {
projectStore.fetchProjectSettings(workspace_slug.toString(), project_slug.toString());
@@ -77,6 +84,32 @@ const IssueNavbar = observer(() => {
+
+ {user ? (
+
+ {user.avatar && user.avatar !== "" ? (
+
+ {/* eslint-disable-next-line @next/next/no-img-element */}
+

+
+ ) : (
+
+ {(user.display_name ?? "A")[0]}
+
+ )}
+
{user.display_name}
+
+ ) : (
+
+ )}
);
});
diff --git a/apps/space/components/issues/peek-overview/issue-activity.tsx b/apps/space/components/issues/peek-overview/issue-activity.tsx
index 9f12b9f73..47e9e4d0f 100644
--- a/apps/space/components/issues/peek-overview/issue-activity.tsx
+++ b/apps/space/components/issues/peek-overview/issue-activity.tsx
@@ -1,10 +1,16 @@
-import React, { useEffect } from "react";
+import React from "react";
+
+import Link from "next/link";
import { useRouter } from "next/router";
+
+// mobx
import { observer } from "mobx-react-lite";
// lib
import { useMobxStore } from "lib/mobx/store-provider";
// components
import { CommentCard, AddComment } from "components/issues/peek-overview";
+// ui
+import { Icon, PrimaryButton } from "components/ui";
// types
import { IIssue } from "types/issue";
@@ -20,10 +26,10 @@ export const PeekOverviewIssueActivity: React.FC = observer((props) => {
const comments = issueDetailStore.details[issueDetailStore.peekId || ""]?.comments || [];
- console.log("issueDetailStore", issueDetailStore);
+ const user = userStore?.currentUser;
return (
-
+
Activity
{workspace_slug && (
@@ -32,9 +38,25 @@ export const PeekOverviewIssueActivity: React.FC
= observer((props) => {
))}
- {projectStore.deploySettings?.comments && (
-
-
+ {user ? (
+ <>
+ {projectStore.deploySettings?.comments && (
+
+ )}
+ >
+ ) : (
+
)}
diff --git a/apps/space/pages/index.tsx b/apps/space/pages/index.tsx
index 26949d76b..5501ea926 100644
--- a/apps/space/pages/index.tsx
+++ b/apps/space/pages/index.tsx
@@ -17,7 +17,7 @@ const HomePage = () => {
const { user: userStore } = useMobxStore();
const router = useRouter();
- const { next_path = "/" } = router.query;
+ const { next_path } = router.query;
const { setToastAlert } = useToast();
@@ -38,7 +38,7 @@ const HomePage = () => {
router.push(`/onboarding?next_path=${next_path}`);
return;
}
- router.push(next_path.toString());
+ router.push((next_path ?? "/").toString());
};
const handleGoogleSignIn = async ({ clientId, credential }: any) => {
diff --git a/apps/space/store/user.ts b/apps/space/store/user.ts
index 4ccc2d2bb..b1a87d133 100644
--- a/apps/space/store/user.ts
+++ b/apps/space/store/user.ts
@@ -28,8 +28,9 @@ class UserStore implements IUserStore {
}
setCurrentUser = (user: any) => {
- // TODO: destructure user object
- this.currentUser = user;
+ runInAction(() => {
+ this.currentUser = { ...user };
+ });
};
/**