{children}
diff --git a/src/pages/feed/following.tsx b/src/pages/feed/following.tsx
index 8f56d2b8..00766a4a 100644
--- a/src/pages/feed/following.tsx
+++ b/src/pages/feed/following.tsx
@@ -1,5 +1,5 @@
import BaseLayout from '@layouts/baseLayout';
-import UserLayout from '@layouts/userLayout';
+import NewsFeedLayout from '@layouts/newsfeedLayout';
import { Placeholder } from '@components/note/placeholder';
import { Thread } from '@components/thread';
@@ -52,7 +52,7 @@ Page.getLayout = function getLayout(
) {
return (
- {page}
+ {page}
);
};
diff --git a/src/pages/feed/global.tsx b/src/pages/feed/global.tsx
index 0c590cf0..c8ce0a63 100644
--- a/src/pages/feed/global.tsx
+++ b/src/pages/feed/global.tsx
@@ -1,5 +1,5 @@
import BaseLayout from '@layouts/baseLayout';
-import UserLayout from '@layouts/userLayout';
+import NewsFeedLayout from '@layouts/newsfeedLayout';
import { Placeholder } from '@components/note/placeholder';
import { Thread } from '@components/thread';
@@ -48,7 +48,7 @@ Page.getLayout = function getLayout(
) {
return (
- {page}
+ {page}
);
};
diff --git a/src/pages/profile/update.tsx b/src/pages/profile/update.tsx
new file mode 100644
index 00000000..4d220a38
--- /dev/null
+++ b/src/pages/profile/update.tsx
@@ -0,0 +1,244 @@
+/* eslint-disable @typescript-eslint/no-explicit-any */
+import BaseLayout from '@layouts/baseLayout';
+import UserLayout from '@layouts/userLayout';
+
+import { currentUser } from '@stores/currentUser';
+
+import { useStore } from '@nanostores/react';
+import { useRouter } from 'next/router';
+import { dateToUnix, useNostr } from 'nostr-react';
+import { getEventHash, signEvent } from 'nostr-tools';
+import { JSXElementConstructor, ReactElement, ReactFragment, ReactPortal, useState } from 'react';
+import { useForm } from 'react-hook-form';
+import Database from 'tauri-plugin-sql-api';
+
+type FormValues = {
+ display_name: string;
+ name: string;
+ username: string;
+ picture: string;
+ banner: string;
+ about: string;
+ website: string;
+};
+
+// TODO: update the design
+export default function Page() {
+ const router = useRouter();
+ const { publish } = useNostr();
+ const [loading, setLoading] = useState(false);
+
+ const $currentUser: any = useStore(currentUser);
+ const profile = JSON.parse($currentUser.metadata);
+
+ const {
+ register,
+ handleSubmit,
+ formState: { errors, isDirty, isValid },
+ } = useForm
();
+
+ const onSubmit = async (data: any) => {
+ setLoading(true);
+
+ // publish account to relays
+ const event: any = {
+ content: JSON.stringify(data),
+ created_at: dateToUnix(),
+ kind: 0,
+ pubkey: $currentUser.pubkey,
+ tags: [],
+ };
+ event.id = getEventHash(event);
+ event.sig = signEvent(event, $currentUser.privkey);
+ publish(event);
+
+ // save account to database
+ const db = await Database.load('sqlite:lume.db');
+ await db.execute(
+ `UPDATE accounts SET metadata = '${JSON.stringify(data)}' WHERE pubkey = "${
+ $currentUser.pubkey
+ }"`
+ );
+ await db.close();
+
+ // set currentUser in global state
+ currentUser.set({
+ metadata: JSON.stringify(data),
+ npub: $currentUser.npub,
+ privkey: $currentUser.privkey,
+ pubkey: $currentUser.pubkey,
+ });
+
+ // redirect to newsfeed
+ setTimeout(() => {
+ setLoading(false);
+ router.push('/feed/following');
+ }, 1500);
+ };
+
+ return (
+
+ );
+}
+
+Page.getLayout = function getLayout(
+ page:
+ | string
+ | number
+ | boolean
+ | ReactElement>
+ | ReactFragment
+ | ReactPortal
+) {
+ return (
+
+ {page}
+
+ );
+};