Reimplemented outdated code, added encryption keys for each room, added support for profile images, added friend requests via url/qr-code
This commit is contained in:
1 parent
508f17315e
commit
32e4bf8b32
58 files changed
+3270
-362
No files matched your search
@@ -0,0 +1,54 @@
|
||||
"use client";
|
||||
|
||||
import { useTransition } from "react";
|
||||
import { acceptRequestAction } from "./actions";
|
||||
|
||||
export interface FriendRequest {
|
||||
id: string;
|
||||
sender_id: string;
|
||||
sender_name: string;
|
||||
}
|
||||
|
||||
export function RequestsList({ requests }: { requests: FriendRequest[] }) {
|
||||
if (requests.length === 0) return null;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h2 className="text-sm font-semibold text-neutral-900">
|
||||
Incoming Requests
|
||||
<span className="ml-2 inline-flex size-5 items-center justify-center rounded-full bg-neutral-900 text-xs text-white">
|
||||
{requests.length}
|
||||
</span>
|
||||
</h2>
|
||||
<ul className="mt-3 divide-y divide-neutral-100 rounded-xl border border-neutral-200 bg-white">
|
||||
{requests.map((req) => (
|
||||
<RequestItem key={req.id} req={req} />
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function RequestItem({ req }: { req: FriendRequest }) {
|
||||
const [pending, startTransition] = useTransition();
|
||||
|
||||
return (
|
||||
<li className="flex items-center justify-between px-4 py-3">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex size-8 items-center justify-center rounded-full bg-neutral-100 text-xs font-medium text-neutral-600">
|
||||
{req.sender_name.charAt(0).toUpperCase()}
|
||||
</div>
|
||||
<span className="text-sm font-medium text-neutral-900">
|
||||
{req.sender_name}
|
||||
</span>
|
||||
</div>
|
||||
<button
|
||||
disabled={pending}
|
||||
onClick={() => startTransition(() => acceptRequestAction(req.sender_id))}
|
||||
className="rounded-lg bg-neutral-900 px-3 py-1.5 text-xs font-medium text-white transition hover:bg-neutral-800 disabled:cursor-not-allowed disabled:bg-neutral-400"
|
||||
>
|
||||
{pending ? "Accepting..." : "Accept"}
|
||||
</button>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user