adding separate page for create a conversation

This commit is contained in:
Arjun Patel
2022-01-31 17:23:39 -08:00
parent f4eef9c3d0
commit 6a4b353024
7 changed files with 78 additions and 21 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ enum Routes {
later = "/s#later", later = "/s#later",
done = "/s#done", done = "/s#done",
drawer = "/s#drawer", drawer = "/s#drawer",
rooms = "/s#rooms", createConvo = "/s#createConversation",
} }
export default Routes; export default Routes;
@@ -5,6 +5,7 @@ export default class ConversationData {
// if user wants more data, click button to fetch further back // if user wants more data, click button to fetch further back
// see if this convo is a priority one // see if this convo is a priority one
// all users in the conversation: userId's perhaps, but the actual user we can get from the relevantUsersCache map // all users in the conversation: userId's perhaps, but the actual user we can get from the relevantUsersCache map
// want to create individual convo chunks...if I send three messages in a row, it should show my name and only one click to listen to all three in order
} }
// one map: all relevant users, a map we build based on where the user visits // one map: all relevant users, a map we build based on where the user visits
+12 -1
View File
@@ -4,13 +4,24 @@ import { Timestamp } from "firebase/firestore";
export default class Conversation { export default class Conversation {
id: string = uuid(); id: string = uuid();
type: ConversationType;
name: string; // engineering, general, arjun and jacob... name: string; // engineering, general, arjun and jacob...
createdDate: Timestamp = Timestamp.now(); createdDate: Timestamp = Timestamp.now();
createdByUserId: string; createdByUserId: string;
constructor(_name: string, _createdByUserId: string) { constructor(
_name: string,
_createdByUserId: string,
_type: ConversationType
) {
this.name = _name; this.name = _name;
this.createdByUserId = _createdByUserId; this.createdByUserId = _createdByUserId;
this.type = _type;
} }
} }
export enum ConversationType {
personal = "personal",
group = "group",
}
@@ -0,0 +1,7 @@
export default function CreateConversation() {
return (
<div className="mx-auto my-auto">
<input className="p-2 rounded border" />
</div>
);
}
+2 -2
View File
@@ -43,9 +43,9 @@ export default function Header() {
</Menu> </Menu>
); );
const inputRef = useRef<HTMLInputElement>(); const inputRef = useRef<HTMLInputElement | undefined>();
const selectSearch = () => { const selectSearch = () => {
inputRef.current.focus(); inputRef.current?.focus();
}; };
const keyMap: KeyMap = { const keyMap: KeyMap = {
+4 -1
View File
@@ -30,7 +30,10 @@ function Sidebar() {
return ( return (
<div className="flex flex-col justify-start items-baseline w-[20rem]"> <div className="flex flex-col justify-start items-baseline w-[20rem]">
{/* new button */} {/* new button */}
<button className="rounded-full flex flex-row items-center px-5 py-2 ml-8 shadow-lg bg-white space-x-2"> <button
onClick={() => handleRoute(Routes.createConvo)}
className="rounded-full flex flex-row items-center px-5 py-2 ml-8 shadow-lg bg-white space-x-2"
>
<FaPlus className="text-teal-600 text-lg" /> <FaPlus className="text-teal-600 text-lg" />
<span className="text-slate-500 font-semibold">New</span> <span className="text-slate-500 font-semibold">New</span>
</button> </button>
+51 -16
View File
@@ -1,6 +1,6 @@
import Routes from "@nirvana/common/helpers/routes"; import Routes from "@nirvana/common/helpers/routes";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import React, { useEffect } from "react"; import React, { ReactElement, useEffect } from "react";
import { useRecoilState } from "recoil"; import { useRecoilState } from "recoil";
import Conversations from "../../components/v2/Conversations"; import Conversations from "../../components/v2/Conversations";
import Done from "../../components/v2/Done"; import Done from "../../components/v2/Done";
@@ -14,6 +14,8 @@ import {
TransitionGroup, TransitionGroup,
SwitchTransition, SwitchTransition,
} from "react-transition-group"; } from "react-transition-group";
import CreateConversation from "../../components/v2/CreateConversation";
import { FaArrowLeft } from "react-icons/fa";
export default function Me() { export default function Me() {
// figure out what content to render from here // figure out what content to render from here
@@ -48,26 +50,59 @@ export default function Me() {
} }
} }
/** full page replacements: clean full page
* 1. search page:
* 2. view a conversation
* 3. create conversation
* 4. profile edit? nah not needed...just keep current separate page
*/
var fullCleanPageContent: ReactElement = <></>;
if (currRoute === Routes.createConvo) {
fullCleanPageContent = <CreateConversation />;
}
return ( return (
<div className="flex flex-col"> <div className="flex flex-col">
<Header /> <Header />
<div className="flex-1 flex flex-row items-stretch"> {fullCleanPageContent ? (
<Sidebar /> <div className="flex flex-col px-20">
<div className="flex flex-row">
<span className="flex flex-col items-center">
<button
className="rounded-lg p-2 border flex flex-row items-center space-x-2
text-slate-400 text-xs hover:bg-slate-50"
>
<FaArrowLeft />
<span>back</span>
</button>
<SwitchTransition> <span className="flex flex-row items-center text-xs text-slate-300">
<CSSTransition ESC
appear={true} </span>
key={Math.random()} </span>
timeout={400} </div>
classNames="slide" {fullCleanPageContent}
> </div>
<div className="flex-1 flex flex-col px-20 justify-start items-stretch container mx-auto"> ) : (
{getCurrentContent()} <div className="flex-1 flex flex-row items-stretch">
</div> <Sidebar />
</CSSTransition>
</SwitchTransition> <SwitchTransition>
</div> <CSSTransition
appear={true}
key={"main_tabs_content"}
timeout={400}
classNames="slide"
>
<div className="flex-1 flex flex-col px-20 justify-start items-stretch container mx-auto">
{getCurrentContent()}
</div>
</CSSTransition>
</SwitchTransition>
</div>
)}
</div> </div>
); );
} }