Added privy

This commit is contained in:
sewmina7@gmail.com 2024-06-13 01:08:41 +05:30
parent df0391104b
commit 9cf07a4875
4 changed files with 4685 additions and 45 deletions

0
app/auth.tsx Normal file
View File

View File

@ -1,8 +1,8 @@
"use client"; // This line marks the file as a client component "use client";
import React, { useState, useEffect } from "react"; import React, { useState, useEffect } from "react";
import { SunIcon, MoonIcon } from "@heroicons/react/solid"; import { SunIcon, MoonIcon } from "@heroicons/react/solid";
import Image from "next/image"; import { PrivyProvider, usePrivy } from "@privy-io/react-auth";
// Helper functions to generate pseudo data // Helper functions to generate pseudo data
const generateRandomName = () => { const generateRandomName = () => {
@ -34,7 +34,8 @@ const generateTableData = (rows) => {
const tableData = generateTableData(10); const tableData = generateTableData(10);
export default function Home() { function Home() {
const { login, user, ready, logout } = usePrivy();
const [darkMode, setDarkMode] = useState(true); const [darkMode, setDarkMode] = useState(true);
useEffect(() => { useEffect(() => {
@ -58,9 +59,15 @@ export default function Home() {
<button onClick={toggleDarkMode} className="bg-gray-700 hover:bg-gray-500 text-white font-bold py-2 px-4 rounded mr-2"> <button onClick={toggleDarkMode} className="bg-gray-700 hover:bg-gray-500 text-white font-bold py-2 px-4 rounded mr-2">
{darkMode ? <SunIcon className="h-5 w-5 text-white" /> : <MoonIcon className="h-5 w-5 text-white" />} {darkMode ? <SunIcon className="h-5 w-5 text-white" /> : <MoonIcon className="h-5 w-5 text-white" />}
</button> </button>
<button className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"> {ready && user ? (
Login <button onClick={logout} className="bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded">
Logout
</button> </button>
) : (
<button onClick={login} className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
Login
</button>
)}
</div> </div>
</header> </header>
<div className="flex-grow flex flex-col items-center justify-center w-full p-4"> <div className="flex-grow flex flex-col items-center justify-center w-full p-4">
@ -92,3 +99,11 @@ export default function Home() {
</main> </main>
); );
} }
export default function App() {
return (
<PrivyProvider appId={process.env.NEXT_PUBLIC_PRIVY_APP_ID || 'clxc7nmy906ifhis11rkovoto'}>
<Home />
</PrivyProvider>
);
}

4704
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -10,6 +10,7 @@
}, },
"dependencies": { "dependencies": {
"@heroicons/react": "^1.0.6", "@heroicons/react": "^1.0.6",
"@privy-io/react-auth": "^1.70.0",
"@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-icons": "^1.3.0",
"class-variance-authority": "^0.7.0", "class-variance-authority": "^0.7.0",
"clsx": "^2.1.1", "clsx": "^2.1.1",