mirror of
https://github.com/usatiuk/y.git
synced 2025-10-29 02:37:49 +01:00
prettier users
This commit is contained in:
@@ -11,6 +11,7 @@ import { Login } from "./Login";
|
|||||||
import { Signup } from "./Signup";
|
import { Signup } from "./Signup";
|
||||||
import { Home } from "./Home";
|
import { Home } from "./Home";
|
||||||
import {
|
import {
|
||||||
|
homeAction,
|
||||||
loginAction,
|
loginAction,
|
||||||
profileSelfAction,
|
profileSelfAction,
|
||||||
signupAction,
|
signupAction,
|
||||||
@@ -42,9 +43,8 @@ const router = createBrowserRouter([
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/home",
|
path: "/home",
|
||||||
loader: async () => {
|
loader: homeLoader,
|
||||||
return await homeLoader();
|
action: homeAction,
|
||||||
},
|
|
||||||
element: <Home />,
|
element: <Home />,
|
||||||
children: [
|
children: [
|
||||||
{ path: "feed", element: <Feed />, loader: feedLoader },
|
{ path: "feed", element: <Feed />, loader: feedLoader },
|
||||||
|
|||||||
@@ -14,6 +14,16 @@
|
|||||||
#SidebarUserInfo {
|
#SidebarUserInfo {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
|
button {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
padding: 0;
|
||||||
|
text-decoration: none;
|
||||||
|
cursor: pointer;
|
||||||
|
color: inherit;
|
||||||
|
font-size: inherit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
import { NavLink, NavLinkProps, Outlet, useLoaderData } from "react-router-dom";
|
import {
|
||||||
|
Form,
|
||||||
|
NavLink,
|
||||||
|
NavLinkProps,
|
||||||
|
Outlet,
|
||||||
|
useLoaderData,
|
||||||
|
} from "react-router-dom";
|
||||||
import { homeLoader, LoaderToType } from "./loaders";
|
import { homeLoader, LoaderToType } from "./loaders";
|
||||||
import { isError } from "./api/dto";
|
import { isError } from "./api/dto";
|
||||||
|
|
||||||
@@ -26,6 +32,16 @@ export function Home() {
|
|||||||
<div id="SidebarUserInfo">
|
<div id="SidebarUserInfo">
|
||||||
<a> username: {loaderData.username}</a>
|
<a> username: {loaderData.username}</a>
|
||||||
<a>name: {loaderData.fullName}</a>
|
<a>name: {loaderData.fullName}</a>
|
||||||
|
{/*method post for everything to reload*/}
|
||||||
|
<Form method={"post"}>
|
||||||
|
<button
|
||||||
|
type={"submit"}
|
||||||
|
name={"intent"}
|
||||||
|
value={"logout"}
|
||||||
|
>
|
||||||
|
logout
|
||||||
|
</button>
|
||||||
|
</Form>
|
||||||
</div>
|
</div>
|
||||||
<div id="SidebarNav">
|
<div id="SidebarNav">
|
||||||
<NavLink to={"feed"} className={activePendingClassName}>
|
<NavLink to={"feed"} className={activePendingClassName}>
|
||||||
|
|||||||
@@ -2,14 +2,38 @@
|
|||||||
width: 15rem;
|
width: 15rem;
|
||||||
height: 5rem;
|
height: 5rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: row;
|
||||||
border: 1px solid #EFEFEF;
|
border: 1px solid #EFEFEF;
|
||||||
border-radius: 7px;
|
border-radius: 7px;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
.fullName{
|
flex: auto;
|
||||||
font-size: 1.3rem;
|
|
||||||
}
|
|
||||||
.username{
|
|
||||||
|
|
||||||
|
.profileInfo {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex-grow: 1;
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fullName{
|
||||||
|
font-size: 1.3rem;
|
||||||
|
}
|
||||||
|
.username{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.profileActions {
|
||||||
|
button {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
padding: 0;
|
||||||
|
text-decoration: none;
|
||||||
|
cursor: pointer;
|
||||||
|
color: inherit;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,36 +16,40 @@ export function ProfileCard({
|
|||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div className={"profileCard"}>
|
<div className={"profileCard"}>
|
||||||
<Link to={`/home/profile/${username}`} className={"fullName"}>
|
<div className={"profileInfo"}>
|
||||||
{fullName}
|
<Link to={`/home/profile/${username}`} className={"fullName"}>
|
||||||
</Link>
|
{fullName}
|
||||||
<Link to={`/home/profile/${username}`} className={"username"}>
|
</Link>
|
||||||
{username}
|
<Link to={`/home/profile/${username}`} className={"username"}>
|
||||||
</Link>
|
{username}
|
||||||
{actions &&
|
</Link>
|
||||||
(alreadyFollowing ? (
|
</div>
|
||||||
<Form method={"put"}>
|
<div className={"profileActions"}>
|
||||||
<input hidden={true} value={uuid} name={"uuid"} />
|
{actions &&
|
||||||
<button
|
(alreadyFollowing ? (
|
||||||
type={"submit"}
|
<Form method={"put"}>
|
||||||
name={"intent"}
|
<input hidden={true} value={uuid} name={"uuid"} />
|
||||||
value={"unfollow"}
|
<button
|
||||||
>
|
type={"submit"}
|
||||||
unfollow
|
name={"intent"}
|
||||||
</button>
|
value={"unfollow"}
|
||||||
</Form>
|
>
|
||||||
) : (
|
unfollow
|
||||||
<Form method={"put"}>
|
</button>
|
||||||
<input hidden={true} value={uuid} name={"uuid"} />
|
</Form>
|
||||||
<button
|
) : (
|
||||||
type={"submit"}
|
<Form method={"put"}>
|
||||||
name={"intent"}
|
<input hidden={true} value={uuid} name={"uuid"} />
|
||||||
value={"follow"}
|
<button
|
||||||
>
|
type={"submit"}
|
||||||
follow
|
name={"intent"}
|
||||||
</button>
|
value={"follow"}
|
||||||
</Form>
|
>
|
||||||
))}
|
follow
|
||||||
|
</button>
|
||||||
|
</Form>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
11
client/src/UserList.scss
Normal file
11
client/src/UserList.scss
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
.userList {
|
||||||
|
min-width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
padding: 2.5rem 2rem 0;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
|
||||||
|
.profileCard {
|
||||||
|
margin: 0.2rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,8 @@ import { isError } from "./api/dto";
|
|||||||
import { ProfileCard } from "./ProfileCard";
|
import { ProfileCard } from "./ProfileCard";
|
||||||
import { useHomeContext } from "./HomeContext";
|
import { useHomeContext } from "./HomeContext";
|
||||||
|
|
||||||
|
import "./UserList.scss";
|
||||||
|
|
||||||
export function UserList() {
|
export function UserList() {
|
||||||
const loaderData = useLoaderData() as LoaderToType<typeof userListLoader>;
|
const loaderData = useLoaderData() as LoaderToType<typeof userListLoader>;
|
||||||
const homeContext = useHomeContext();
|
const homeContext = useHomeContext();
|
||||||
@@ -17,7 +19,7 @@ export function UserList() {
|
|||||||
return <div>Error</div>;
|
return <div>Error</div>;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className={"userList"}>
|
||||||
{people.map((u) => {
|
{people.map((u) => {
|
||||||
return (
|
return (
|
||||||
<ProfileCard
|
<ProfileCard
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { addFollower, removeFollower, signup } from "./api/Person";
|
|||||||
import { ActionFunctionArgs, redirect } from "react-router-dom";
|
import { ActionFunctionArgs, redirect } from "react-router-dom";
|
||||||
import { login } from "./api/Token";
|
import { login } from "./api/Token";
|
||||||
import { isError } from "./api/dto";
|
import { isError } from "./api/dto";
|
||||||
import { setToken } from "./api/utils";
|
import { deleteToken, setToken } from "./api/utils";
|
||||||
import { createPost, deletePost } from "./api/Post";
|
import { createPost, deletePost } from "./api/Post";
|
||||||
|
|
||||||
export type ActionToType<T extends (...args: any) => any> =
|
export type ActionToType<T extends (...args: any) => any> =
|
||||||
@@ -62,10 +62,18 @@ export async function profileSelfAction({ request }: ActionFunctionArgs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function homeAction({ request }: ActionFunctionArgs) {
|
||||||
|
const formData = await request.formData();
|
||||||
|
const intent = formData.get("intent")!.toString();
|
||||||
|
if (intent == "logout") {
|
||||||
|
deleteToken();
|
||||||
|
return redirect("/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function userListAction({ request }: ActionFunctionArgs) {
|
export async function userListAction({ request }: ActionFunctionArgs) {
|
||||||
const formData = await request.formData();
|
const formData = await request.formData();
|
||||||
const intent = formData.get("intent")!.toString();
|
const intent = formData.get("intent")!.toString();
|
||||||
console.log(intent);
|
|
||||||
if (intent == "follow") {
|
if (intent == "follow") {
|
||||||
return await addFollower(formData.get("uuid")!.toString());
|
return await addFollower(formData.get("uuid")!.toString());
|
||||||
} else if (intent == "unfollow") {
|
} else if (intent == "unfollow") {
|
||||||
|
|||||||
Reference in New Issue
Block a user