adding in stuff to make search work but still testing and stuff

This commit is contained in:
talksik
2022-03-18 12:37:39 -04:00
parent 726ab29b64
commit 1ff61bf91d
12 changed files with 225 additions and 64 deletions
@@ -0,0 +1,41 @@
import {
Add,
CardGiftcardRounded,
ContactsRounded,
LinkRounded,
PushPinRounded,
} from "@mui/icons-material";
export default function Conversations() {
return (
<>
{/* actions navbar */}
<div className="flex justify-end mx-10 mt-5 space-x-3">
<span className="hover:bg-slate-500 p-1 rounded-full cursor-pointer flex justify-center items-center">
<ContactsRounded className="text-slate-100" fontSize="small" />
</span>
<span className="hover:bg-slate-500 p-1 rounded-full cursor-pointer flex justify-center items-center">
<LinkRounded className="text-slate-100" fontSize="small" />
</span>
<span className="hover:bg-slate-500 p-1 rounded-full cursor-pointer flex justify-center items-center">
<CardGiftcardRounded className="text-pink-100" fontSize="small" />
</span>
<span className="hover:bg-slate-500 p-1 rounded-full cursor-pointer flex justify-center items-center">
<Add className="text-slate-100" fontSize="small" />
</span>
</div>
{/* pinned conversations */}
<div className="m-5 bg-slate-500 shadow-lg rounded">
<span className="flex flex-row justify-start p-4 items-center">
<PushPinRounded className="text-slate-100" />
<span className="tracking-wider text-slate-100 uppercase text-sm font-semibold">
Pinned
</span>
</span>
</div>
</>
);
}
@@ -0,0 +1,35 @@
import Logo, { LogoType } from "../../../components/Logo";
import { $searchQuery } from "../../../controller/recoil";
import { useGetUserDetails } from "../../../controller/index";
import { useRecoilState } from "recoil";
export default function Header() {
const { data: user } = useGetUserDetails();
const [searchQuery, setSearchQuery] = useRecoilState($searchQuery);
return (
<div className="flex flex-row items-center bg-slate-800 h-20">
<Logo type={LogoType.small} className="scale-[0.4]" />
<input
placeholder="type / to search"
className="placeholder:text-slate-400 bg-transparent outline-none text-slate-100"
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
/>
<button className="ml-auto hover:scale-110 bg-slate-600 text-teal-500 py-1 px-2 rounded-lg text-sm">
flow state
</button>
<span className="relative mx-5">
<img
src={user.picture}
className="rounded-lg h-8 hover:bg-slate-200 hover:cursor-pointer hover:scale-110"
alt="cannot find"
/>
<span className="absolute bottom-0 -right-1.5 rounded-full bg-emerald-600 h-3 w-3"></span>
</span>
</div>
);
}
+9 -55
View File
@@ -1,69 +1,23 @@
import {
Add,
CardGiftcardRounded,
ContactsRounded,
LinkRounded,
PushPinRounded,
} from "@mui/icons-material";
import Logo, { LogoType } from "../../components/Logo";
import { $searchQuery } from "../../controller/recoil";
import Conversations from "./conversations";
import Header from "./header";
import Search from "./search";
import { useEffect } from "react";
import { useGetUserDetails } from "../../controller/index";
import { useGetUserDetails } from "../../controller/";
import { useRecoilValue } from "recoil";
export default function Home() {
const { data: user } = useGetUserDetails();
const searchQuery = useRecoilValue($searchQuery);
return (
<div className="h-screen w-screen bg-slate-700">
{/* header */}
<div className="flex flex-row items-center bg-slate-800 h-20">
<Logo type={LogoType.small} className="scale-[0.4]" />
<input
placeholder="type / to search"
className="placeholder:text-slate-400 bg-transparent outline-none text-slate-100"
/>
<Header />
<button className="ml-auto hover:scale-110 bg-slate-600 text-teal-500 py-1 px-2 rounded-lg text-sm">
flow state
</button>
<span className="relative mx-5">
<img
src={user.picture}
className="rounded-lg h-8 hover:bg-slate-200 hover:cursor-pointer hover:scale-110"
alt="cannot find"
/>
<span className="absolute bottom-0 -right-1.5 rounded-full bg-emerald-600 h-3 w-3"></span>
</span>
</div>
{/* actions navbar */}
<div className="flex justify-end mx-10 mt-5 space-x-3">
<span className="hover:bg-slate-500 p-1 rounded-full cursor-pointer flex justify-center items-center">
<ContactsRounded className="text-slate-100" fontSize="small" />
</span>
<span className="hover:bg-slate-500 p-1 rounded-full cursor-pointer flex justify-center items-center">
<LinkRounded className="text-slate-100" fontSize="small" />
</span>
<span className="hover:bg-slate-500 p-1 rounded-full cursor-pointer flex justify-center items-center">
<CardGiftcardRounded className="text-pink-100" fontSize="small" />
</span>
<span className="hover:bg-slate-500 p-1 rounded-full cursor-pointer flex justify-center items-center">
<Add className="text-slate-100" fontSize="small" />
</span>
</div>
{/* pinned conversations */}
<div className="m-5 bg-slate-500 shadow-lg rounded">
<span className="flex flex-row justify-start p-4 items-center">
<PushPinRounded className="text-slate-100" />
<span className="tracking-wider text-slate-100 uppercase text-sm font-semibold">
Pinned
</span>
</span>
</div>
{searchQuery ? <Search /> : <Conversations />}
</div>
);
}
@@ -0,0 +1,24 @@
import { $searchQuery } from "../../../controller/recoil";
import { useEffect } from "react";
import { useSearch } from "../../../controller";
export default function Search() {
const { data: searchResultsResponse, isLoading, isError } = useSearch();
useEffect(() => {}, []);
if (!searchResultsResponse?.users) {
return (
<span className="text-white">
no results. please try someone's email or name.
</span>
);
}
return (
<div>
{searchResultsResponse.users?.map((user) => {
return <span>{user.name}</span>;
})}
</div>
);
}