Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turborepo packages #14

Merged
merged 17 commits into from
Aug 8, 2024
15 changes: 11 additions & 4 deletions apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
"name": "website",
"version": "0.1.0",
"private": true,

"scripts": {
"dev": "next dev",
"start": "next start",
"build:app": "pnpm run build:nostr_sdk && next build",
"build": "next build",
"build:nostr_sdk": "cd ../.. && pnpm run build:nostr_sdk",
"lint": "next lint",
"lint:fix":"next lint --fix",
"prettier:fix":"pnpm prettier --write 'src/**/*.tsx'",
"prettier:fix:ts":"pnpm prettier --write 'src/**/*.ts'"
"prettier:fix:ts":"pnpm prettier --write 'src/**/*.ts'",
"check-types": "tsc --noEmit"
},
"dependencies": {
"@avnu/avnu-sdk": "^2.0.0",
Expand All @@ -21,9 +25,12 @@
"qs": "^6.12.3",
"starknet": "6.9.0",
"zod": "^3.23.8",
"afk_nostr_sdk":"workspace:*",
"@nostr-dev-kit/ndk": "^2.8.2"

"@tanstack/react-query": "^5.40.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"zustand": "^4.5.2",
"@nostr-dev-kit/ndk": "^2.8.2",
"afk_nostr_sdk":"workspace:*"
},
"devDependencies": {
"@types/node": "^20",
Expand Down
20 changes: 11 additions & 9 deletions apps/website/src/app/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import './index.css';
import type { Metadata } from 'next';

import type {Metadata} from 'next';

import Providers from './providers';

export const metadata: Metadata = {
title: 'afk community portal',
description: 'afk community portal',
};
import { AppProps } from 'next/app';
import {AppProps} from 'next/app';

function MyApp({ Component, pageProps }: AppProps) {
return (
<Providers>
<Component {...pageProps} />
</Providers>
);
function MyApp({Component, pageProps}: AppProps) {
return (
<Providers>
<Component {...pageProps} />
</Providers>
);
}

export default MyApp;
export default MyApp;
127 changes: 59 additions & 68 deletions apps/website/src/app/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,109 +1,100 @@
"use client";
'use client';

import { ContributeSection } from '../components/landing/ContributeSection';
import { Footer } from '../components/Footer';
import { Navbar } from '../components/Navbar';
import { useRootNotes } from 'afk_nostr_sdk/hooks/useRootNotes';
// import { NDKEvent } from 'afk_nostr_sdk';

import Providers from '../providers';
import NDK, { NDKEvent, NDKFilter, NDKKind } from '@nostr-dev-kit/ndk';
import { AFK_RELAYS } from 'afk_nostr_sdk/utils/relay';
import { useEffect } from 'react';
import { useNostrContext } from 'afk_nostr_sdk/context/NostrContext';
import { useSearch, useSearchNotes } from 'afk_nostr_sdk/hooks';
import { useState } from 'react';
import {NDKEvent, NDKFilter, NDKKind} from '@nostr-dev-kit/ndk';
import {useNostrContext, useSearchNotes} from 'afk_nostr_sdk';
import {useEffect} from 'react';
import {useState} from 'react';

import {Footer} from '../components/Footer';
import {Navbar} from '../components/Navbar';
export default function AppHomepage() {

const nostr = useNostrContext()

const [events, setEvents] = useState<NDKEvent[]>([])
const [isInitDone, setIsInitDone] = useState<boolean>(false)

const nostr = useNostrContext();
const [events, setEvents] = useState<NDKEvent[]>([]);
const [isInitDone, setIsInitDone] = useState<boolean>(false);
useEffect(() => {

if (!isInitDone) {
fetch()
setIsInitDone(true)
fetch();
setIsInitDone(true);
}

})
});
const fetch = async () => {
const filter: NDKFilter = {
kinds: [NDKKind.Text, NDKKind.ChannelMetadata, NDKKind.Metadata],

};
let events_package = await nostr?.ndk?.fetchEvents(filter)
const events_package = await nostr?.ndk?.fetchEvents(filter);
// console.log("events_package", events_package)
setEvents([
...events_package,
...eventsSearch?.data?.pages
])
}
// [...eventsSearch?.data?.pages]
]);
};

const eventsSearch = useSearchNotes({
kinds: [
NDKKind.Text,
NDKKind.Text,
// NDKKind.ChannelMetadata
]

],
});
// const events = useRootNotes();
console.log("events hooks", eventsSearch?.data?.pages)
console.log('events hooks', eventsSearch?.data?.pages);
return (
// <Providers>
<div className="min-h-screen w-full relative bg-black text-white">
<Navbar />


<button onClick={() => fetch()}>Reload</button>


<div className='md:grid-cols-2'>
{events?.length > 0 && events.map((e: NDKEvent, i) => {
// console.log("e", e)
return (
<div className='text-white'>
<p>{e?.id}</p>
<p>{e?.content}</p>
<p>{e?.created_at}</p>

<a href="#" className="block max-w-sm p-6 bg-white border border-gray-200 rounded-lg shadow hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:hover:bg-gray-700">

<h5 className="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">Noteworthy technology acquisitions 2021</h5>
<p className="font-normal text-gray-700 dark:text-gray-400">Here are the biggest enterprise technology acquisitions of 2021 so far, in reverse chronological order.</p>
</a>

</div>
)
})}
<div className="md:grid-cols-2">
{events?.length > 0 &&
events.map((e: NDKEvent, i) => {
return (
<div className="text-white" key={i}>
<p>{e?.id}</p>
<p>{e?.content}</p>
<p>{e?.created_at}</p>

<a
href="#"
className="block max-w-sm p-6 bg-white border border-gray-200 rounded-lg shadow hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:hover:bg-gray-700"
>
<h5 className="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">
Noteworthy technology acquisitions 2021
</h5>
<p className="font-normal text-gray-700 dark:text-gray-400">
Here are the biggest enterprise technology acquisitions of 2021 so far, in
reverse chronological order.
</p>
</a>
</div>
);
})}
</div>

<div className='md:grid-cols-2'>
<div className="md:grid-cols-2">
{eventsSearch?.data?.pages?.map((e: NDKEvent) => {
console.log("e", e)
console.log('e', e);
return (
<div key={e?.id} className='text-white'>
<div key={e?.id} className="text-white">
<p>{e?.id}</p>

<a href="#" className="block max-w-sm p-6 bg-white border border-gray-200 rounded-lg shadow hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:hover:bg-gray-700">

<h5 className="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">Noteworthy technology acquisitions 2021</h5>
<p className="font-normal text-gray-700 dark:text-gray-400">Here are the biggest enterprise technology acquisitions of 2021 so far, in reverse chronological order.</p>
<a
href="#"
className="block max-w-sm p-6 bg-white border border-gray-200 rounded-lg shadow hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:hover:bg-gray-700"
>
<h5 className="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">
Noteworthy technology acquisitions 2021
</h5>
<p className="font-normal text-gray-700 dark:text-gray-400">
Here are the biggest enterprise technology acquisitions of 2021 so far, in reverse
chronological order.
</p>
</a>

</div>
)
);
})}
</div>




<Footer />
</div>
// </Providers>

);
}
4 changes: 2 additions & 2 deletions apps/website/src/app/features/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {ContributeSection} from '../components/landing/ContributeSection';
import {DescriptionFeatures} from '../components/features/DescriptionFeatures';
import {Footer} from '../components/Footer';
import {ContributeSection} from '../components/landing/ContributeSection';
import {DescriptionFeatures} from '../components/landing/features/DescriptionFeatures';
import {Navbar} from '../components/Navbar';

export default function Features() {
Expand Down
6 changes: 3 additions & 3 deletions apps/website/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import './index.css';

import type { Metadata } from 'next';
import Providers from './providers';
import type {Metadata} from 'next';

import Providers from './providers';
export const metadata: Metadata = {
title: 'afk community portal',
description: 'afk community portal',
};

export default function RootLayout({ children }: { children: React.ReactNode }) {
export default function RootLayout({children}: {children: React.ReactNode}) {
return (
<html lang="en">
<Providers>
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {Footer} from './components/Footer';
import {About} from './components/landing/About';
import {ContributeSection} from './components/landing/ContributeSection';
import {DescriptionSection} from './components/landing/DescriptionSection';
import {DownloadSection} from './components/landing/DownloadSection';
import {Faq} from './components/landing/Faq';
import {Footer} from './components/Footer';
import {HeroSection} from './components/landing/HeroSection';
import {Navbar} from './components/Navbar';

Expand Down
14 changes: 5 additions & 9 deletions apps/website/src/app/providers.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
"use client";

import { NostrProvider } from 'afk_nostr_sdk/context/NostrContext';
import { TanstackProvider } from 'afk_nostr_sdk/context/TanstackProvider';

export default function Providers({ children }: { children: React.ReactNode }) {
'use client';
import {TanstackProvider} from 'afk_nostr_sdk';
import {NostrProvider} from 'afk_nostr_sdk';
export default function Providers({children}: {children: React.ReactNode}) {
return (
<NostrProvider>
<TanstackProvider>
{children}
</TanstackProvider>
<TanstackProvider>{children}</TanstackProvider>
</NostrProvider>
);
}
5 changes: 3 additions & 2 deletions apps/website/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dom.iterable",
"esnext"
],
"module": "ES6",
"module": "esnext",
"allowJs": true,
"skipLibCheck": true,
"strict": true,
Expand All @@ -27,7 +27,8 @@
"paths": {
"@/*": [
"./src/*"
]
],
"afk_nostr_sdk": ["../../packages/afk_nostr_sdk/src"]
},
"noEmit": true
},
Expand Down
1 change: 1 addition & 0 deletions apps/website/vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"installCommand": "pnpm install"

}

}

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"dev:website":"cd apps/website && pnpm run dev",
"build:mobile":"cd apps/mobile && pnpm run build",
"dev:mobile":"cd apps/mobile && pnpm run start",
"build:nostr_sdk":"cd packages/afk_nostr_sdk && pnpm run build",
"dev": "turbo run dev",
"web":"turbo run dev --filter=website",
"mobile":"turbo run start --filter=mobile",
Expand Down
2 changes: 2 additions & 0 deletions packages/afk_nostr_sdk/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ Cargo.lock
/node_modules

node_modules/

/dist
4 changes: 1 addition & 3 deletions packages/afk_nostr_sdk/context/NostrContext.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import React, {createContext, useContext, useEffect, useState} from 'react';
import NDK, {NDKPrivateKeySigner} from '@nostr-dev-kit/ndk';
import {createContext, useContext, useEffect, useState} from 'react';
import { useAuth } from '../store/auth';
import {AFK_RELAYS} from "../utils/relay"
export type NostrContextType = {
ndk: NDK;
};

export const NostrContext = createContext<NostrContextType | null>(null);

export const NostrProvider: React.FC<React.PropsWithChildren> = ({children}) => {
const privateKey = useAuth((state) => state.privateKey);

Expand Down
4 changes: 4 additions & 0 deletions packages/afk_nostr_sdk/hooks/useEditContacts.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import {NDKEvent, NDKKind} from '@nostr-dev-kit/ndk';
import {useMutation} from '@tanstack/react-query';
import {useNostrContext} from '../context/NostrContext';

<<<<<<<< HEAD:packages/afk_nostr_sdk/src/hooks/useEditContacts.ts
========
import {useNostrContext} from '../context/NostrContext';

>>>>>>>> main:packages/afk_nostr_sdk/hooks/useEditContacts.ts
import {useAuth} from '../store/auth';

export const useEditContacts = () => {
Expand Down
1 change: 0 additions & 1 deletion packages/afk_nostr_sdk/hooks/useEditProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {useMutation} from '@tanstack/react-query';
// import {useNostrContext} from '../../context/NostrContext';
// import {useAuth} from '../../store/auth';
// import {useNostrContext} from '../context/NostrContext';

import {useNostrContext} from '../context/NostrContext';

import {useAuth} from '../store/auth';
Expand Down
3 changes: 3 additions & 0 deletions packages/afk_nostr_sdk/hooks/useNote.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import {NDKKind} from '@nostr-dev-kit/ndk';
import {useQuery} from '@tanstack/react-query';

<<<<<<<< HEAD:packages/afk_nostr_sdk/src/hooks/useNote.ts
========
// import {useNostrContext} from '../../context/NostrContext';
>>>>>>>> main:packages/afk_nostr_sdk/hooks/useNote.ts
import {useNostrContext} from '../context/NostrContext';

import {useAuth} from '../store/auth';
Expand Down
4 changes: 4 additions & 0 deletions packages/afk_nostr_sdk/hooks/useProfile.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import {useQuery} from '@tanstack/react-query';
<<<<<<<< HEAD:packages/afk_nostr_sdk/src/hooks/useProfile.ts
import {useNostrContext} from '../context/NostrContext';
========

// import {useNostrContext} from '../../context/NostrContext';

import {useNostrContext} from '../context/NostrContext';

import {useAuth} from '../store/auth';
>>>>>>>> main:packages/afk_nostr_sdk/hooks/useProfile.ts
export type UseProfileOptions = {
publicKey?: string;
};
Expand Down
Loading
Loading