feat: add working user page
This commit is contained in:
parent
7daac080f5
commit
206feb21b8
6 changed files with 155 additions and 28 deletions
44
frontend/src/lib/FieldCard.tsx
Normal file
44
frontend/src/lib/FieldCard.tsx
Normal file
|
@ -0,0 +1,44 @@
|
|||
import {
|
||||
HeartFill,
|
||||
HandThumbsUp,
|
||||
HandThumbsDown,
|
||||
People,
|
||||
EmojiLaughing,
|
||||
} from "react-bootstrap-icons";
|
||||
|
||||
import type { Field } from "./types";
|
||||
|
||||
export default function FieldCard({ field }: { field: Field }) {
|
||||
return (
|
||||
<div className=" bg-slate-100 dark:bg-slate-700 rounded-md shadow">
|
||||
<h1 className="text-2xl p-2 border-b border-zinc-200 dark:border-slate-800">{field.name}</h1>
|
||||
<div className="flex flex-col p-2">
|
||||
{field.favourite.map((entry) => (
|
||||
<p className="text-lg font-bold">
|
||||
<HeartFill className="inline" /> {entry}
|
||||
</p>
|
||||
))}
|
||||
{field.okay.length !== 0 && (
|
||||
<p>
|
||||
<HandThumbsUp className="inline" /> {field.okay.join(", ")}
|
||||
</p>
|
||||
)}
|
||||
{field.jokingly.length !== 0 && (
|
||||
<p>
|
||||
<EmojiLaughing className="inline" /> {field.jokingly.join(", ")}
|
||||
</p>
|
||||
)}
|
||||
{field.friends_only.length !== 0 && (
|
||||
<p>
|
||||
<People className="inline" /> {field.friends_only.join(", ")}
|
||||
</p>
|
||||
)}
|
||||
{field.avoid.length !== 0 && (
|
||||
<p className="text-slate-600 dark:text-slate-400">
|
||||
<HandThumbsDown className="inline" /> {field.avoid.join(", ")}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
14
frontend/src/lib/fetch.ts
Normal file
14
frontend/src/lib/fetch.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
import axios from "axios";
|
||||
import type { APIError } from "./types";
|
||||
|
||||
export default async function fetchAPI<T>(path: string) {
|
||||
const resp = await axios.get<T | APIError>(`/api/v1${path}`, {
|
||||
headers: {
|
||||
Authorization: localStorage.getItem("pronouns-token"),
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
if (resp.status !== 200) throw resp.data as APIError;
|
||||
|
||||
return resp.data as T;
|
||||
}
|
|
@ -1,11 +1,5 @@
|
|||
export interface MeUser {
|
||||
id: string;
|
||||
username: string;
|
||||
display_name: string | null;
|
||||
bio: string | null;
|
||||
avatar_source: string | null;
|
||||
avatar_url: string | null;
|
||||
links: string[] | null;
|
||||
discord: string | null;
|
||||
discord_username: string | null;
|
||||
}
|
||||
|
@ -15,9 +9,10 @@ export interface User {
|
|||
username: string;
|
||||
display_name: string | null;
|
||||
bio: string | null;
|
||||
avatar_source: string | null;
|
||||
avatar_url: string | null;
|
||||
links: string[] | null;
|
||||
members: PartialMember[];
|
||||
fields: Field[];
|
||||
}
|
||||
|
||||
export interface PartialMember {
|
||||
|
@ -26,6 +21,15 @@ export interface PartialMember {
|
|||
avatar_url: string | null;
|
||||
}
|
||||
|
||||
export interface Field {
|
||||
name: string;
|
||||
favourite: string[] | null;
|
||||
okay: string[] | null;
|
||||
jokingly: string[] | null;
|
||||
friends_only: string[] | null;
|
||||
avoid: string[] | null;
|
||||
}
|
||||
|
||||
export interface APIError {
|
||||
code: ErrorCode;
|
||||
message?: string;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue