a little cleanup

This commit is contained in:
Stepan Usatiuk
2023-12-29 18:22:43 +01:00
parent 5a70e2555d
commit bf8a2a3123
42 changed files with 538 additions and 409 deletions

View File

@@ -38,6 +38,17 @@
cursor: pointer;
color: inherit;
font-size: 0.8rem;
font-family: inherit;
}
span {
background: none;
border: none;
padding: 0;
text-decoration: none;
color: inherit;
font-size: 0.8rem;
font-family: inherit;
}
}
}

View File

@@ -9,6 +9,7 @@ export function ProfileCard({
actions,
alreadyFollowing,
isAdmin,
isFollower,
}: {
username: string;
fullName: string;
@@ -16,6 +17,7 @@ export function ProfileCard({
actions: boolean;
alreadyFollowing: boolean;
isAdmin: boolean;
isFollower: boolean;
}) {
const homeContext = useHomeContext();
@@ -85,6 +87,7 @@ export function ProfileCard({
</button>
</Form>
))}
{isFollower && <span>follows you</span>}
</div>
</div>
);

View File

@@ -14,8 +14,8 @@ export function UserList() {
return <div>Error</div>;
}
const { people, following } = loaderData;
if (isError(following) || isError(people)) {
const { people, following, followers } = loaderData;
if (isError(following) || isError(people) || isError(followers)) {
return <div>Error</div>;
}
return (
@@ -32,6 +32,7 @@ export function UserList() {
alreadyFollowing={following.some(
(f) => f.uuid == u.uuid,
)}
isFollower={followers.some((f) => f.uuid == u.uuid)}
/>
);
})}

View File

@@ -56,6 +56,10 @@ export async function getFollowing(): Promise<TPersonToArrResp> {
return fetchJSONAuth("/person/following", "GET", PersonToArrResp);
}
export async function getFollowers(): Promise<TPersonToArrResp> {
return fetchJSONAuth("/person/followers", "GET", PersonToArrResp);
}
export async function getPersonByUsername(
username: string,
): Promise<TPersonToResp> {

View File

@@ -31,7 +31,7 @@ export async function getPostsByAuthorUuid(
author: string,
): Promise<TPostToArrResp> {
return fetchJSONAuth(
`/post/by-author-uuid?author=${author}`,
`/post/by-author-uuid/${author}`,
"GET",
PostToArrResp,
);
@@ -45,7 +45,7 @@ export async function getPostsByAuthorUsername(
author: string,
): Promise<TPostToArrResp> {
return fetchJSONAuth(
`/post/by-author-username?author=${author}`,
`/post/by-author-username/${author}`,
"GET",
PostToArrResp,
);

View File

@@ -1,5 +1,6 @@
import {
getAllPerson,
getFollowers,
getFollowing,
getPersonByUsername,
getSelf,
@@ -36,7 +37,11 @@ export async function homeLoader() {
}
export async function userListLoader() {
return { people: await getAllPerson(), following: await getFollowing() };
return {
people: await getAllPerson(),
following: await getFollowing(),
followers: await getFollowers(),
};
}
export async function profileLoader({