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

Replace WalletConnect with Google and GitHub authentication #36

Merged
merged 21 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
95a6d3c
Replace WalletConnect with Google and GitHub authentication
0xaaiden Dec 18, 2024
dcaf32b
Update authentication to use NextAuth.js
0xaaiden Dec 18, 2024
5a8e956
replace wallet connect
0xaaiden Dec 19, 2024
3005e2a
Merged Prsima Schemas into one. Cleaned up dependencies.
ahmedkall Dec 22, 2024
e55493d
Refactor dashboard components and session management
ahmedkall Dec 22, 2024
2dd39a0
added sign out button
ahmedkall Dec 22, 2024
9255d90
- Added GitHub authentication support using NextAuth.js.
ahmedkall Dec 22, 2024
fa01669
Enhance Sign-In Page with Floating Labels and New Icons
ahmedkall Dec 22, 2024
f035f43
Refactor Sign-In and Verify Request Pages; Update UI and State Manage…
ahmedkall Dec 23, 2024
cd6ca80
Update SiteHeader to display "Dashboard" in absence of user name
ahmedkall Dec 23, 2024
5524247
Refactor user session management to utilize NextAuth.js
ahmedkall Dec 23, 2024
38eb921
- Started Migration from AWS API Gateway to APIGEE
ahmedkall Dec 28, 2024
0904ae3
Refactor Dashboard and Pricing Components
ahmedkall Dec 28, 2024
1683e09
Enhance API Key Management in Dashboard
ahmedkall Dec 28, 2024
64d8315
Fixed bug with Dialog Hierarchy
ahmedkall Dec 29, 2024
fe5e072
Refactor API Keys Management
ahmedkall Dec 29, 2024
b4bb3e9
Add SubscriptionLoading component and update loading states in Subscr…
ahmedkall Dec 29, 2024
b04fce2
Get Rid of Price Retrieval from Lemonsqueezy
ahmedkall Dec 30, 2024
2665371
Remove unnecessary event prevention in DashboardGenerateAPIkeysDialog
ahmedkall Dec 31, 2024
5586618
Adjusted background opacity of the Card component for better visibility
ahmedkall Dec 31, 2024
8b5b3c4
fix build issue
BounebRayan Jan 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 0 additions & 55 deletions .env.example

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ next-env.d.ts
.zip
.gz
.pack.gz

apigee_key.json
10 changes: 5 additions & 5 deletions app/(dashboard)/dashboard/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { siteConfig } from "@/config/site"
import { getUser } from "@/lib/app/user-profile"
import { getSession } from "@/lib/session"

import { WalletConnect } from "@/components/blockchain/wallet-connect"
import { LoggedUser } from "@/components/layout/logged-user"
import { SidebarNav } from "@/components/layout/sidebar-nav"
import { SiteHeader } from "@/components/layout/site-header"
Expand All @@ -23,12 +22,16 @@ export default async function DashboardLayout({
}: DashboardLayoutProps) {
const session = await getSession()

if (!session || !session.user) {
if (!session?.user) {
redirect("/")
}

const user = await getUser(session.user.id)

if (!user) {
redirect("/")
}

return (
<div className="relative flex min-h-screen flex-col">
<SiteHeader />
Expand Down Expand Up @@ -69,9 +72,6 @@ export default async function DashboardLayout({
</aside>
<main className="flex w-full flex-col overflow-hidden">{children}</main>
</div>
<div className="fixed bottom-6 right-6">
<WalletConnect />
</div>
</div>
)
}
117 changes: 91 additions & 26 deletions app/(dashboard)/dashboard/page.tsx
Original file line number Diff line number Diff line change
@@ -1,52 +1,117 @@
import { Suspense } from "react"
import Link from "next/link"
import { redirect } from "next/navigation"
import { User } from "next-auth"

import { getCurrentSubscription } from "@/lib/app/actions"
import { getApiKeys } from "@/lib/app/api-key"
import { getUser } from "@/lib/app/user-profile"
import { getSession } from "@/lib/session"

import { DashboardGenerateAPIkeysDialog } from "@/components/app/dashboard-generate-apikeys-dialog"
import { DashboardTableAPIKeys } from "@/components/app/dashboard-table-apikeys"
import { Button } from "@/components/ui/button"
import { Card, CardContent } from "@/components/ui/card"
import { PageHeader } from "@/components/ui/page-header"

import { IsSignedIn } from "@/integrations/siwe/components/is-signed-in"
import { IsSignedOut } from "@/integrations/siwe/components/is-signed-out"
// Always revalidate the page to get the latest user data in case of an update
export const revalidate = 0

const planToApiKeyLimit: Record<number, number> = {
0: 0, // Free
1: 3, // Basic Monthly
2: 3, // Basic Bi-Annually
3: 3, // Basic Annually
4: 5, // Pro Monthly
5: 5, // Pro Bi-Annually
6: 5, // Pro Annually
7: 25, // Enterprise
}

async function APIKeysTable({
user,
apiKeyLimit,
}: {
user: User
apiKeyLimit: number
}) {
const apiKeys = await getApiKeys(user.id) // This will be fresh on each render

return (
<DashboardTableAPIKeys
apiKeys={apiKeys}
user={user}
apiKeyLimit={apiKeyLimit}
/>
)
}

export default async function PageDashboardApiKeys() {
const session = await getSession()

if (!session || !session.user) {
if (!session?.user) {
redirect("/")
}

const apiKeys = await getApiKeys(session.user.id)
// Get user from database
const user = await getUser(session.user.id)
const subscription = await getCurrentSubscription(user.id)
const isFreeTier = subscription.planId === 0
const apiKeyLimit = planToApiKeyLimit[subscription.planId]

if (!user) {
redirect("/")
}

if (!user.email) {
redirect("/dashboard/profile")
}

// Get API keys for the user
const apiKeys = await getApiKeys(user.id)

return (
<section className="w-full py-2 sm:p-10">
<div>
<PageHeader title="API Keys" description="Manage your API keys." />
<IsSignedOut>
<div className="flex items-center justify-between gap-x-5 text-center">
<span className="text-sm">
Authenticate to access your api keys.
</span>
{isFreeTier ? (
<div className="rounded-lg border border-neutral-200 bg-white p-6 shadow-sm transition-shadow hover:shadow-md dark:border-neutral-800 dark:bg-neutral-900">
<div className="flex flex-col gap-4">
<h3 className="text-lg font-semibold text-neutral-900 dark:text-neutral-100">
Unlock WalletLabels API Access
</h3>
<p className="text-sm text-neutral-600 dark:text-neutral-400">
You’re currently on a free plan. To utilize the WalletLabels API
and access advanced features, you’ll need to subscribe to one of
our plans. Choose the plan that fits your needs and start
leveraging powerful tools to analyze and categorize blockchain
wallets.
</p>
<Link href="/dashboard/subscription">
<Button className="w-full rounded-lg bg-secondary-foreground px-6 py-2 text-center font-semibold text-background transition-colors sm:w-auto">
Explore Plans
</Button>
</Link>
</div>
</div>
) : (
<>
<div>
<PageHeader title="API Keys" description="Manage your API keys." />
</div>
</IsSignedOut>
</div>
<hr className="my-5 opacity-50" />
<IsSignedIn>
<Card className="w-full p-6">
<CardContent>
<DashboardGenerateAPIkeysDialog
user={user}
apiKeysCount={apiKeys.length}
/>
</CardContent>

<DashboardTableAPIKeys apiKeys={apiKeys} />
</Card>
</IsSignedIn>
<hr className="my-5 opacity-50" />
<Card className="w-full p-6">
<CardContent>
<DashboardGenerateAPIkeysDialog
user={user}
apiKeysCount={apiKeys.length}
apiKeyLimit={apiKeyLimit}
/>
<Suspense fallback={<div>Loading...</div>}>
<APIKeysTable user={user} apiKeyLimit={apiKeyLimit} />
</Suspense>
</CardContent>
</Card>
</>
)}
</section>
)
}
26 changes: 10 additions & 16 deletions app/(dashboard)/dashboard/profile/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,31 @@ import { AppAccountForm } from "@/components/app/app-account-form"
import { Card } from "@/components/ui/card"
import { PageHeader } from "@/components/ui/page-header"

import { ButtonSIWELogin } from "@/integrations/siwe/components/button-siwe-login"
import { IsSignedIn } from "@/integrations/siwe/components/is-signed-in"
import { IsSignedOut } from "@/integrations/siwe/components/is-signed-out"

export default async function PageDashboardAccount() {
const session = await getSession()

if (!session || !session.user) {
if (!session?.user) {
redirect("/")
}

const user = await getUser(session.user.id)

if (!user) {
redirect("/")
}

return (
<section className="w-full py-4 sm:p-10">
<PageHeader
title="Account"
description="Manage your account information"
/>
<div className="h-4" />
<IsSignedIn>
<Card className="w-full p-6">
<h3 className="text-2xl font-semibold">Profile</h3>
<hr className="my-3 dark:opacity-30" />

<AppAccountForm user={user} />
</Card>
</IsSignedIn>
<IsSignedOut>
<ButtonSIWELogin />
</IsSignedOut>
<Card className="w-full p-6">
<h3 className="text-2xl font-semibold">Profile</h3>
<hr className="my-3 dark:opacity-30" />
<AppAccountForm user={user} />
</Card>
</section>
)
}
41 changes: 18 additions & 23 deletions app/(dashboard)/dashboard/submit/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react"
import { redirect } from "next/navigation"

import { getUser } from "@/lib/app/user-profile"
Expand All @@ -8,38 +7,34 @@ import { DashboardSubmitLabel } from "@/components/app/dashboard-submit-label"
import { Card, CardContent, CardHeader } from "@/components/ui/card"
import { PageHeader } from "@/components/ui/page-header"

import { ButtonSIWELogin } from "@/integrations/siwe/components/button-siwe-login"
import { IsSignedIn } from "@/integrations/siwe/components/is-signed-in"
import { IsSignedOut } from "@/integrations/siwe/components/is-signed-out"

export default async function SubmitPage() {
const session = await getSession()

if (!session || !session.user) {
if (!session?.user) {
redirect("/")
}

const user = await getUser(session.user.id)
// Get user from database using email
const user = await getUser(session.user.id!)

if (!user) {
redirect("/")
}

return (
<section className="w-full py-4">
<div className="h-4" />
<IsSignedIn>
<Card className="w-full">
<CardHeader>
<PageHeader
title="Submit"
description="Contribute new labels and get rewarded!"
/>
</CardHeader>
<CardContent>
<DashboardSubmitLabel userId={user.id} />
</CardContent>
</Card>
</IsSignedIn>
<IsSignedOut>
<ButtonSIWELogin />
</IsSignedOut>
<Card className="w-full">
<CardHeader>
<PageHeader
title="Submit"
description="Contribute new labels and get rewarded!"
/>
</CardHeader>
<CardContent>
<DashboardSubmitLabel userId={user.email} />
</CardContent>
</Card>
</section>
)
}
23 changes: 18 additions & 5 deletions app/(general)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
"use client"

import { ReactNode } from "react"
import { signIn, useSession } from "next-auth/react"

import { NetworkStatus } from "@/components/blockchain/network-status"
import { WalletConnect } from "@/components/blockchain/wallet-connect"
// import { NetworkStatus } from "@/components/blockchain/network-status"
import { Footer } from "@/components/layout/footer"
import { SiteHeader } from "@/components/layout/site-header"
import { FramerWrapper } from "@/components/providers/framer-wrapper"
import { Opensource } from "@/components/shared/opensource"

interface RootLayoutProps {
children: ReactNode
children: React.ReactNode
}

export default function RootLayout({ children }: RootLayoutProps) {
const { data: session } = useSession()

return (
<FramerWrapper>
<div className="relative flex min-h-screen flex-col">
Expand All @@ -20,9 +24,18 @@ export default function RootLayout({ children }: RootLayoutProps) {
<Opensource />
<Footer />
</div>
<NetworkStatus />
{/* <NetworkStatus /> */}
<div className="fixed bottom-6 right-6 z-50 block sm:hidden">
<WalletConnect />
{!session ? (
<button
onClick={() => signIn()}
className="rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground"
>
Sign in
</button>
) : (
<p>Welcome, {session.user.name}</p>
)}
</div>
</FramerWrapper>
)
Expand Down
Loading