diff --git a/src/components/profile/UserProfile.js b/src/components/profile/UserProfile.js
new file mode 100644
index 0000000..098a72c
--- /dev/null
+++ b/src/components/profile/UserProfile.js
@@ -0,0 +1,116 @@
+import React, { useRef, useState, useEffect } from "react";
+import { DataTable } from "primereact/datatable";
+import { Button } from "primereact/button";
+import { Menu } from "primereact/menu";
+import { Column } from "primereact/column";
+import { useImageProxy } from "@/hooks/useImageProxy";
+import { useSession } from 'next-auth/react';
+import { ProgressSpinner } from "primereact/progressspinner";
+import PurchasedListItem from "@/components/profile/PurchasedListItem";
+import { useNDKContext } from "@/context/NDKContext";
+import { formatDateTime } from "@/utils/time";
+import { findKind0Fields } from "@/utils/nostr";
+import Image from "next/image";
+import BitcoinConnectButton from "@/components/bitcoinConnect/BitcoinConnect";
+import UserContent from "@/components/profile/UserContent";
+import SubscribeModal from "@/components/profile/subscription/SubscribeModal";
+const UserProfile = () => {
+ const [user, setUser] = useState(null);
+ const { data: session } = useSession();
+ const { returnImageProxy } = useImageProxy();
+ const { ndk, addSigner } = useNDKContext();
+ const menu = useRef(null);
+
+ useEffect(() => {
+ if (session?.user) {
+ setUser(session.user);
+ }
+ }, [session]);
+
+ 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
+ },
+ },
+ ];
+
+ const header = (
+
+ Purchases
+
+ );
+
+ return (
+ user && (
+
+
+
+
+ menu.current.toggle(e)}
+ >
+
+
+
+
+ {user.username || "Anon"}
+
+
+ {user.pubkey}
+
+ {user && (
+
+ )}
+
+ {!session || !session?.user || !ndk ? (
+
+ ) : (
+
+
+ {
+ console.log("rowData", rowData);
+ return
+ }}
+ header="Name"
+ >
+ item.courseId) ? "course" : "resource"} header="Category">
+ formatDateTime(rowData?.createdAt)} header="Date">
+
+ )}
+
+ )
+ );
+};
+
+export default UserProfile;
diff --git a/src/components/profile/UserSettings.js b/src/components/profile/UserSettings.js
new file mode 100644
index 0000000..4587302
--- /dev/null
+++ b/src/components/profile/UserSettings.js
@@ -0,0 +1,108 @@
+import React, { useRef, useState, useEffect } from "react";
+import { Button } from "primereact/button";
+import { DataTable } from "primereact/datatable";
+import { Column } from "primereact/column";
+import { useImageProxy } from "@/hooks/useImageProxy";
+import { useSession } from 'next-auth/react';
+import { ProgressSpinner } from "primereact/progressspinner";
+import { useNDKContext } from "@/context/NDKContext";
+import Image from "next/image";
+import BitcoinConnectButton from "@/components/bitcoinConnect/BitcoinConnect";
+
+const UserSettings = () => {
+ const [user, setUser] = useState(null);
+ const { data: session } = useSession();
+ const { returnImageProxy } = useImageProxy();
+ const { ndk } = useNDKContext();
+
+ useEffect(() => {
+ if (session?.user) {
+ setUser(session.user);
+ }
+ }, [session]);
+
+ const relayUrls = [
+ "wss://nos.lol/",
+ "wss://relay.damus.io/",
+ "wss://relay.snort.social/",
+ "wss://relay.nostr.band/",
+ "wss://nostr.mutinywallet.com/",
+ "wss://relay.mutinywallet.com/",
+ "wss://relay.primal.net/"
+ ];
+
+ const relayStatusBody = (url) => {
+ // Placeholder for relay status, replace with actual logic later
+ const isConnected = Math.random() > 0.5;
+ return (
+
+ );
+ };
+
+ const relayActionsBody = () => {
+ return (
+
+
+
+
+ );
+ };
+
+ const header = (
+
+ Relays
+
+
+ );
+
+ return (
+ user && (
+
+
+
+
+
+
+
+ {user.username || "Anon"}
+
+
+ {user.pubkey}
+
+
+
Connect Your Lightning Wallet
+
+
+
+ {!session || !session?.user || !ndk ? (
+
+ ) : (
+
+ url} header="Relay URL">
+
+
+
+ )}
+
+ )
+ );
+};
+
+export default UserSettings;
diff --git a/src/components/profile/subscription/SubscribeModal.js b/src/components/profile/subscription/SubscribeModal.js
index 85b83cb..06d0da3 100644
--- a/src/components/profile/subscription/SubscribeModal.js
+++ b/src/components/profile/subscription/SubscribeModal.js
@@ -1,4 +1,4 @@
-import React, { useState } from 'react';
+import React, { useState, useRef, useEffect } from 'react';
import { Dialog } from 'primereact/dialog';
import { ProgressSpinner } from 'primereact/progressspinner';
import SubscriptionPaymentButtons from '@/components/bitcoinConnect/SubscriptionPaymentButton';
@@ -8,13 +8,33 @@ import { useRouter } from 'next/router';
import { useToast } from '@/hooks/useToast';
import { Card } from 'primereact/card';
import { Badge } from 'primereact/badge';
+import { Button } from "primereact/button";
+import { Menu } from "primereact/menu";
+import { Message } from "primereact/message";
-// todo encrypt nwc before saving in db
-const SubscribeModal = ({ visible, onHide }) => {
+const SubscribeModal = ({ user }) => {
const { data: session, update } = useSession();
const { showToast } = useToast();
const router = useRouter();
const [isProcessing, setIsProcessing] = useState(false);
+ const [visible, setVisible] = useState(false);
+ const [subscribed, setSubscribed] = useState(false);
+ const [subscribedUntil, setSubscribedUntil] = useState(null);
+ const [subscriptionExpiredAt, setSubscriptionExpiredAt] = useState(null);
+ const menu = useRef(null);
+
+ useEffect(() => {
+ if (user && user.role) {
+ setSubscribed(user.role.subscribed);
+ const subscribedAt = new Date(user.role.lastPaymentAt);
+ const subscribedUntil = new Date(subscribedAt.getTime() + 31 * 24 * 60 * 60 * 1000);
+ setSubscribedUntil(subscribedUntil);
+ if (user.role.subscriptionExpiredAt) {
+ const expiredAt = new Date(user.role.subscriptionExpiredAt)
+ setSubscriptionExpiredAt(expiredAt);
+ }
+ }
+ }, [user]);
const handleSubscriptionSuccess = async (response) => {
setIsProcessing(true);
@@ -58,55 +78,121 @@ const SubscribeModal = ({ visible, onHide }) => {
}
};
+ const menuItems = [
+ {
+ label: "Renew Subscription",
+ icon: "pi pi-bolt",
+ command: () => {
+ // Add your renew functionality here
+ },
+ },
+ {
+ label: "Schedule 1:1",
+ icon: "pi pi-calendar",
+ command: () => {
+ // Add your schedule functionality here
+ },
+ },
+ {
+ label: "Cancel Subscription",
+ icon: "pi pi-trash",
+ command: () => {
+ // Add your cancel functionality here
+ },
+ },
+ ];
+
+ const subscriptionCardTitle = (
+
+ Plebdevs Subscription
+ menu.current.toggle(e)}
+ >
+
+
+ );
+
return (
-