Skip to content

Commit

Permalink
Merge branch 'new-features' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
serefyarar committed Jun 25, 2024
2 parents bce4c13 + f26898f commit c39891c
Show file tree
Hide file tree
Showing 20 changed files with 445 additions and 103 deletions.
7 changes: 0 additions & 7 deletions web-app/src/app/[...id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@ const Discovery = () => {

return (
<DiscoveryLayout>
{/* {JSON.stringify(view)}
<br />
{JSON.stringify(index.data)}
<br />
{JSON.stringify(did.data)}
<br />
{JSON.stringify(conversation.data?.sources[0])} */}
{view.discoveryType === DiscoveryType.DID && <UserConversationSection />}
{view.discoveryType === DiscoveryType.INDEX && (
<IndexConversationSection />
Expand Down
3 changes: 2 additions & 1 deletion web-app/src/components/layout/base/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ const Navbar = ({

const handleLogoClick = () => {
setLeftTabKey(IndexListTabKey.ALL);
if (status === AuthStatus.CONNECTED) {
const isGuest = localStorage.getItem("isGuest");
if (status === AuthStatus.CONNECTED || isGuest) {
router.push(`/${session?.did.parent}`);
} else {
router.push(`/`);
Expand Down
7 changes: 3 additions & 4 deletions web-app/src/components/layout/site/AppHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { useRouter } from "next/navigation";
import { useCallback, useState } from "react";

const AppHeader = () => {
const { connect, disconnect, status, setStatus } = useAuth();
const { connect, disconnect, session, status, setStatus } = useAuth();
const router = useRouter();
const { isLanding } = useRouteParams();
const [modalVisible, setModalVisible] = useState(false);
Expand Down Expand Up @@ -46,14 +46,14 @@ const AppHeader = () => {
if (window !== undefined) {
const allowed = localStorage.getItem("allowed");

console.log("allowed", allowed);
if (!allowed) {
setModalVisible(true);
return;
}
}

await connect();
// router.push(`/${session?.did.parent}`);
} catch (err) {
console.log(err);
}
Expand All @@ -77,14 +77,13 @@ const AppHeader = () => {
);
}

if (status !== AuthStatus.CONNECTED) {
if (localStorage.getItem("isGuest") || status !== AuthStatus.CONNECTED) {
return (
<>
{modalVisible && (
<WaitBetaModal
visible={modalVisible}
onClose={() => setModalVisible(false)}
onCreate={() => {}}
/>
)}
<Navbar logoSize="mini" className="site-navbar">
Expand Down
24 changes: 24 additions & 0 deletions web-app/src/components/layout/site/DiscoveryLayout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import ConfirmTransaction from "@/components/site/modal/Common/ConfirmTransaction";
import CreateModal from "@/components/site/modal/CreateModal";
import EditProfileModal from "@/components/site/modal/EditProfileModal";
import GuestModal from "@/components/site/modal/GuestModal";
import { useApp } from "@/context/AppContext";
import { useAuth } from "@/context/AuthContext";
import cc from "classcat";
import AppLeft from "components/sections/AppLeft";
import AppRight from "components/sections/AppRight";
Expand All @@ -28,8 +30,22 @@ const DiscoveryLayout = ({ children }: DiscoveryLayoutProps) => {
createModalVisible,
setCreateModalVisible,
handleCreate,
handleGuest,
guestTryingChat,
setGuestTryingChat,
} = useApp();

const { connect } = useAuth();

const tryConnect = async () => {
await connect();
setGuestTryingChat(false);
};
const tryGuest = async () => {
await handleGuest();
setGuestTryingChat(false);
};

const closeSidebars = () => {
setLeftSidebarOpen(false);
setRightSidebarOpen(false);
Expand Down Expand Up @@ -78,6 +94,14 @@ const DiscoveryLayout = ({ children }: DiscoveryLayoutProps) => {
visible={transactionApprovalWaiting}
/>
)}
{guestTryingChat && (
<GuestModal
visible={guestTryingChat}
tryGuest={tryGuest}
connect={tryConnect}
onClose={() => setGuestTryingChat(false)}
/>
)}
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const IndexConversationHeader: FC = () => {

const handleIndexToggle = useCallback(
async (toggleType: "own" | "star") => {
console.log("88", session, api);
if (!api) return;

const value =
Expand Down
15 changes: 13 additions & 2 deletions web-app/src/components/site/indexes/AskIndexes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ export interface MessageWithIndex extends Message {

const AskIndexes: FC<AskIndexesProps> = ({ sources }) => {
const { session } = useAuth();
const { leftSectionIndexes, leftTabKey } = useApp();
const {
leftSectionIndexes,
leftTabKey,
setGuestTryingChat,
guestTryingChat,
} = useApp();
const { isIndex, id } = useRouteParams();
const { ready: apiReady, api } = useApi();
const router = useRouter();
Expand Down Expand Up @@ -91,6 +96,12 @@ const AskIndexes: FC<AskIndexesProps> = ({ sources }) => {
const handleSendMessage = useCallback(
async (messageStr: string) => {
if (!apiReady || !api) return;

if (!session) {
setGuestTryingChat(true);
return;
}

try {
isLocalUpdate.current = false;
const newMessage: Message = {
Expand Down Expand Up @@ -129,7 +140,7 @@ const AskIndexes: FC<AskIndexesProps> = ({ sources }) => {
console.error("Error sending message", error);
}
},
[api, viewedConversation, id, dispatch, router, apiReady],
[api, viewedConversation, id, dispatch, router, apiReady, session],
);

useEffect(() => {
Expand Down
5 changes: 3 additions & 2 deletions web-app/src/components/site/indexes/NoLinks/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import Header from "components/base/Header";
import Col from "components/layout/base/Grid/Col";
import Row from "components/layout/base/Grid/Row";
import { useApp } from "@/context/AppContext";
import React from "react";
import { useAppSelector } from "@/store/store";
import { selectIndex } from "@/store/slices/indexSlice";

export interface NoLinksProps {
search?: string;
Expand All @@ -15,7 +16,7 @@ const NoLinks: React.FC<NoLinksProps> = ({
isOwner = false,
tabKey,
}) => {
const { viewedIndex } = useApp();
const { data: viewedIndex } = useAppSelector(selectIndex);
return (
<>
<Row rowSpacing={5} fullWidth>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import Button from "components/base/Button";
import { ModalProps } from "components/base/Modal";
import { memo } from "react";

export interface AskConnectModalContentProps
extends Omit<ModalProps, "header" | "footer" | "body"> {
tryGuest: () => void;
connect: () => void;
}

const AskConnectModalContent = ({
tryGuest,
connect,
...modalProps
}: AskConnectModalContentProps) => {
const handleClose = () => {
modalProps.onClose?.();
};

const allowed = localStorage.getItem("allowed");

return (
<div
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
flexDirection: "column",
}}
>
<p
style={{
margin: "0",
padding: "0",
}}
>
Index is currently in a testing phase with a limited number of users. If
you're interested in joining, apply for the beta—we'd love to hear from
you!
</p>
<div
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
padding: "0 0 2.4rem 0",
}}
>
<video
autoPlay
loop
muted
playsInline
className={"p-0"}
style={{
width: "60%",
margin: "auto",
}}
>
<source src="/video/sequence.mp4" type="video/mp4" />
</video>
</div>
<div
style={{
display: "flex",
justifyContent: "space-between",
alignItems: "center",
flexDirection: "row",
gap: "1rem",
width: "100%",
}}
>
<div>
<Button
size="lg"
className="mt-7 pl-8 pr-8"
theme="clear"
onClick={tryGuest}
>
Chat as guest
</Button>
</div>
<div>
{allowed ? (
<Button
onClick={connect}
theme="primary"
size="lg"
className="mt-7 pl-8 pr-8"
>
Connect
</Button>
) : (
<Button
onClick={() => {
window.open("https://sjxy3b643r8.typeform.com/to/phuRF52O");
}}
theme="primary"
size="lg"
className="mt-7 pl-8 pr-8"
>
Apply for beta
</Button>
)}
</div>
</div>
</div>
);
};

export default memo(AskConnectModalContent);
104 changes: 104 additions & 0 deletions web-app/src/components/site/modal/GuestModal/WaitBetaModalContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import Button from "components/base/Button";
import Header from "components/base/Header";
import Modal, { ModalProps } from "components/base/Modal";
import Col from "components/layout/base/Grid/Col";
import { memo } from "react";

export interface WaitBetaModalContentProps
extends Omit<ModalProps, "header" | "footer" | "body"> {
onCloseHandler?: () => void;
}

const WaitBetaModalContent = ({
onCloseHandler,
...modalProps
}: WaitBetaModalContentProps) => {
const handleClose = () => {
if (onCloseHandler) {
onCloseHandler();
return;
}
modalProps.onClose?.();
};

return (
<div>
<div
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
flexDirection: "column",
}}
>
<p
style={{
margin: "0",
padding: "0",
}}
>
Index is currently in a testing phase with a limited number of users.
If you're interested in joining, apply for the beta—we'd love to hear
from you!
</p>
<div
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
padding: "0 0 2.4rem 0",
}}
>
<video
autoPlay
loop
muted
playsInline
className={"p-0"}
style={{
width: "60%",
margin: "auto",
}}
>
<source src="/video/sequence.mp4" type="video/mp4" />
</video>
</div>
</div>
<div
style={{
display: "flex",
justifyContent: "space-between",
alignItems: "center",
flexDirection: "row",
gap: "1rem",
width: "100%",
}}
>
<div>
<Button
size="lg"
className="mt-7 pl-8 pr-8"
theme="clear"
onClick={handleClose}
>
Cancel
</Button>
</div>
<div>
<Button
onClick={() => {
window.open("https://sjxy3b643r8.typeform.com/to/phuRF52O");
}}
theme="primary"
size="lg"
className="mt-7 pl-8 pr-8"
>
Apply for beta
</Button>
</div>
</div>
</div>
);
};

export default memo(WaitBetaModalContent);
Loading

0 comments on commit c39891c

Please sign in to comment.