diff --git a/src/components/AddAttestation.tsx b/src/components/AddAttestation.tsx index 0d29084d..94068dd6 100644 --- a/src/components/AddAttestation.tsx +++ b/src/components/AddAttestation.tsx @@ -1,10 +1,11 @@ -import { useContext, useState } from 'react'; -import { createAttestation } from './request'; +import { Dispatch, SetStateAction, useContext, useState } from 'react'; +import { createAttestation, createTestAttestation } from './request'; import Loading from './Loading'; import StarterKitContext from '../context/starterKit'; import GithubLoginButton from '../modules/Eas/Github/componens/LoginButton'; -import { useSession } from 'next-auth/react'; +import WakatimeButton from '../modules/Eas/Wakatime/WakatimeButton'; import WorldCoin from '../pages/worldcoin'; +import { useSession } from 'next-auth/react'; function AddAttestation(props: any) { const { user } = useContext(StarterKitContext); @@ -48,6 +49,7 @@ function AddAttestation(props: any) { <> {loading && }

{message}

+ {props.type === 'wakatime' && } {props.type === 'github' && } {props.type === 'worldcoin' && } {props.type === 'github' && data && ( @@ -78,6 +80,20 @@ function AddAttestation(props: any) { )} + {props.type === 'wakatime' && data && ( + <> +
+
+ +
+ + )} ); } diff --git a/src/components/Form/ProfileForm.tsx b/src/components/Form/ProfileForm.tsx index 3483a8e0..84303773 100644 --- a/src/components/Form/ProfileForm.tsx +++ b/src/components/Form/ProfileForm.tsx @@ -16,6 +16,8 @@ import { useChainId } from '../../hooks/useChainId'; import { useConfig } from '../../hooks/useConfig'; import { QuestionMarkCircle } from 'heroicons-react'; import AddAttestation from '../AddAttestation'; +import { useSession } from 'next-auth/react'; +import { createAttestation, createTestAttestation } from '../request'; interface IFormValues { title?: string; @@ -42,10 +44,28 @@ function ProfileForm({ callback }: { callback?: () => void }) { const { data: signer } = useSigner({ chainId, }); + const { data } = useSession(); + + const [wakatimeHandle, setWakatimeHandle] = useState(null); const { isActiveDelegate } = useContext(StarterKitContext); const [activeLvlUpMenu, setActiveLvlUpMenu] = useState(0); const menuItems = [ - { label: 'Github', content: }, + { + label: 'Github', + content: , + }, + { + label: 'WakaTime', + content: , + }, + { + label: 'Upwork', + content: , + }, + { + label: 'Malt', + content: , + }, { label: 'WorldCoin', content: }, { label: 'LinkedIn', content: }, { label: 'Upwork', content: }, diff --git a/src/modules/Eas/Wakatime/WakatimeButton.tsx b/src/modules/Eas/Wakatime/WakatimeButton.tsx new file mode 100644 index 00000000..9a02d5a5 --- /dev/null +++ b/src/modules/Eas/Wakatime/WakatimeButton.tsx @@ -0,0 +1,21 @@ +import { useSession, signIn, signOut } from 'next-auth/react'; +import { useState } from 'react'; +import Toggle from '../../../components/Toggle'; + +export default function WakatimeButton() { + const { data: session } = useSession(); + // TODO: load initial state from chain + const [wakatimeHandle, setWakatimeHandle] = useState(null); + + return ( + <> +

Tell us your wakatime handle!

+ { + setWakatimeHandle(e.target.value); + }} + /> + + ); +} diff --git a/src/pages/api/eas/create-attestation.ts b/src/pages/api/eas/create-attestation.ts index 990781b2..7baf89c2 100644 --- a/src/pages/api/eas/create-attestation.ts +++ b/src/pages/api/eas/create-attestation.ts @@ -13,7 +13,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) console.log('accessToken', accessToken); console.log('userId', userId); - const langStats = getGithubLangStats(userId, accessToken); + const langStats = await getGithubLangStats(userId, accessToken); const githubdata = { languageStats: langStats, diff --git a/src/pages/api/eas/create-test-attestation.ts b/src/pages/api/eas/create-test-attestation.ts index 35735d2e..a8c9626e 100644 --- a/src/pages/api/eas/create-test-attestation.ts +++ b/src/pages/api/eas/create-test-attestation.ts @@ -79,8 +79,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) const attestation = await getAttestation(uid); console.log('attestation', attestation); - res.status(200).json({ recipient: recipient }); - res.status(200).json({ uid: uid }); + res.status(200).json({ recipient: recipient, uid: uid }); } catch (error) { console.error('errorDebug', error); res.status(500).json('certificate creation failed');