2024-08-07 16:02:13 -05:00
|
|
|
import React, { useRef, useState, useEffect, use } from "react";
|
2024-02-11 16:26:33 -06:00
|
|
|
import { Button } from "primereact/button";
|
2024-08-06 14:50:32 -05:00
|
|
|
import { DataTable } from "primereact/datatable";
|
|
|
|
import { Menu } from "primereact/menu";
|
|
|
|
import { Column } from "primereact/column";
|
2024-02-11 16:26:33 -06:00
|
|
|
import { useImageProxy } from "@/hooks/useImageProxy";
|
2024-03-20 13:00:05 -05:00
|
|
|
import { useRouter } from "next/router";
|
2024-08-07 16:02:13 -05:00
|
|
|
import { useSession } from 'next-auth/react';
|
2024-08-06 14:50:32 -05:00
|
|
|
import UserContent from "@/components/profile/UserContent";
|
2024-02-11 16:26:33 -06:00
|
|
|
import Image from "next/image";
|
2024-08-06 14:50:32 -05:00
|
|
|
import BitcoinConnectButton from "@/components/profile/BitcoinConnect";
|
2024-02-11 16:26:33 -06:00
|
|
|
|
|
|
|
const Profile = () => {
|
2024-08-07 16:02:13 -05:00
|
|
|
const { data: session, status } = useSession();
|
|
|
|
const [user, setUser] = useState(null);
|
2024-08-06 14:50:32 -05:00
|
|
|
const { returnImageProxy } = useImageProxy();
|
|
|
|
const menu = useRef(null);
|
2024-02-11 16:26:33 -06:00
|
|
|
|
2024-08-07 16:02:13 -05:00
|
|
|
useEffect(() => {
|
|
|
|
if (session) {
|
|
|
|
setUser(session.user);
|
|
|
|
}
|
|
|
|
}, [session]);
|
2024-08-06 19:52:06 -05:00
|
|
|
|
2024-08-06 14:50:32 -05:00
|
|
|
const purchases = [];
|
2024-02-11 16:26:33 -06:00
|
|
|
|
2024-08-06 14:50:32 -05:00
|
|
|
const menuItems = [
|
|
|
|
{
|
|
|
|
label: "Edit",
|
|
|
|
icon: "pi pi-pencil",
|
|
|
|
command: () => {
|
|
|
|
// Add your edit functionality here
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Delete",
|
|
|
|
icon: "pi pi-trash",
|
|
|
|
command: () => {
|
|
|
|
// Add your delete functionality here
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
2024-03-20 13:00:05 -05:00
|
|
|
|
2024-08-06 14:50:32 -05:00
|
|
|
const header = (
|
|
|
|
<div className="flex flex-wrap align-items-center justify-content-between gap-2">
|
|
|
|
<span className="text-xl text-900 font-bold text-white">Purchases</span>
|
|
|
|
</div>
|
|
|
|
);
|
2024-03-16 14:56:58 -05:00
|
|
|
|
2024-08-06 14:50:32 -05:00
|
|
|
return (
|
|
|
|
user && (
|
|
|
|
<div className="w-[90vw] mx-auto max-tab:w-[100vw] max-mob:w-[100vw]">
|
|
|
|
<div className="w-[85vw] flex flex-col justify-center mx-auto max-tab:w-[100vw] max-mob:w-[100vw]">
|
|
|
|
<div className="relative flex w-full items-center justify-center">
|
|
|
|
<Image
|
|
|
|
alt="user's avatar"
|
|
|
|
src={returnImageProxy(user.avatar, user.pubkey)}
|
|
|
|
width={100}
|
|
|
|
height={100}
|
|
|
|
className="rounded-full my-4"
|
|
|
|
/>
|
|
|
|
<i
|
|
|
|
className="pi pi-ellipsis-h absolute right-24 text-2xl my-4 cursor-pointer hover:opacity-75"
|
|
|
|
onClick={(e) => menu.current.toggle(e)}
|
|
|
|
></i>
|
|
|
|
<Menu model={menuItems} popup ref={menu} />
|
|
|
|
</div>
|
2024-03-16 14:56:58 -05:00
|
|
|
|
2024-08-06 14:50:32 -05:00
|
|
|
<h1 className="text-center text-2xl my-2">
|
|
|
|
{user.username || "Anon"}
|
|
|
|
</h1>
|
|
|
|
<h2 className="text-center text-xl my-2 truncate max-tab:px-4 max-mob:px-4">
|
|
|
|
{user.pubkey}
|
|
|
|
</h2>
|
|
|
|
<div className="flex flex-col w-1/2 mx-auto my-4 justify-between items-center">
|
|
|
|
<h2>Connect Your Lightning Wallet</h2>
|
|
|
|
<BitcoinConnectButton />
|
|
|
|
</div>
|
|
|
|
<div className="flex flex-col w-1/2 mx-auto my-4 justify-between items-center">
|
|
|
|
<h2>Subscription</h2>
|
|
|
|
<p className="text-center">You currently have no active subscription</p>
|
|
|
|
<Button
|
|
|
|
label="Subscribe"
|
|
|
|
className="p-button-raised p-button-success w-auto my-2 text-[#f8f8ff]"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<DataTable
|
|
|
|
emptyMessage="No purchases"
|
|
|
|
value={purchases}
|
|
|
|
tableStyle={{ minWidth: "100%" }}
|
|
|
|
header={header}
|
|
|
|
>
|
|
|
|
<Column field="cost" header="Cost"></Column>
|
|
|
|
<Column field="name" header="Name"></Column>
|
|
|
|
<Column field="category" header="Category"></Column>
|
|
|
|
<Column field="date" header="Date"></Column>
|
|
|
|
</DataTable>
|
|
|
|
<UserContent />
|
|
|
|
</div>
|
2024-02-11 16:26:33 -06:00
|
|
|
)
|
2024-08-06 14:50:32 -05:00
|
|
|
);
|
|
|
|
};
|
2024-02-11 16:26:33 -06:00
|
|
|
|
2024-08-06 14:50:32 -05:00
|
|
|
export default Profile;
|