Skip to content

Commit

Permalink
cleaned up the login page
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen-Gordon committed Apr 23, 2024
1 parent 2ee4319 commit 087f832
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 46 deletions.
58 changes: 36 additions & 22 deletions src/app/@auth/(.)settings/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,60 @@ import { useLogout } from '@privy-io/react-auth';
import { useRouter } from 'next/navigation';

import {motion }from 'framer-motion';
import { usePrivySmartAccount } from '@zerodev/privy';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/app/components/ui/card';

export default function Page() {

// const { logout } = usePrivySmartAccount()
const { user } = usePrivySmartAccount();


const router = useRouter();


const { logout } = useLogout({
onSuccess: () => {
console.log('User logged out');
router.push('/login');
localStorage.clear();
// Any logic you'd like to execute after a user successfully logs out
},
});

return (
<>
<motion.div

className='grid space-y-6 p-4'>
<motion.div className='grid space-y-6 p-4'>
<p className='text-xl'> {user?.google?.name}</p>
<p className='text-base'> {user?.wallet?.address}</p>

<SendNotification />
<Button
className='bg-red-500'
//variant={'destructive'}
onClick={() => {
logout();
}}
>
Log out
</Button>
<Button
variant={'destructive'}
onClick={() => {
localStorage.clear();
}}
>
Clear Local Storage
</Button>
<Card className='grid'>
<CardHeader>
<CardTitle>Account</CardTitle>
<CardDescription>
<p>Control your account settings </p>
</CardDescription>
</CardHeader>
<CardContent className=' space-y-6'>

<Button
className='bg-red-500'
onClick={() => {
localStorage.clear();
}}
>
Clear Local Storage
</Button>

<Button
className='bg-red-500'
onClick={() => {
logout();
}}
>
Log out
</Button>
</CardContent>
</Card>
</motion.div>
</>
);
Expand Down
54 changes: 30 additions & 24 deletions src/app/components/SendNotification/SendNotification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import useGetAddress from '@/app/hooks/useGetAddress';
import type { MouseEventHandler } from 'react';
import { useEffect, useState } from 'react';
import { Button } from '../ui/button';
import { usePrivySmartAccount } from '@zerodev/privy';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../ui/card';

const base64ToUint8Array = (base64: string) => {
const padding = '='.repeat((4 - (base64.length % 4)) % 4);
Expand All @@ -18,10 +21,14 @@ const base64ToUint8Array = (base64: string) => {
};

export default function SendNotification() {


const [isSubscribed, setIsSubscribed] = useState(false);
const [subscription, setSubscription] = useState<PushSubscription | null>(
null
);


const [text, setText] = useState('');
const [registration, setRegistration] =
useState<ServiceWorkerRegistration | null>(null);
Expand Down Expand Up @@ -160,30 +167,29 @@ export default function SendNotification() {

return (
<>
<div className='grid'>
<p>{text}</p>
<button
type='button'
onClick={subscribeButtonOnClick}
disabled={isSubscribed}
>
Subscribe
</button>
<button
type='button'
onClick={unsubscribeButtonOnClick}
disabled={!isSubscribed}
>
Unsubscribe
</button>
<button
type='button'
onClick={sendNotificationButtonOnClick}
disabled={!isSubscribed}
>
Send Notification
</button>
</div>
<Card className='grid'>
<CardHeader>
<CardTitle>Notification Center</CardTitle>
<CardDescription>
<p>Control your Push Notifications</p>
</CardDescription>
</CardHeader>
<CardContent className=' space-y-6'>
<Button onClick={subscribeButtonOnClick}>
Turn Notifications on
</Button>
<Button onClick={unsubscribeButtonOnClick}>
Turn Notifications off
</Button>

<Button
onClick={sendNotificationButtonOnClick}
disabled={!isSubscribed}
>
Send Test Notification
</Button>
</CardContent>
</Card>
</>
);
}

0 comments on commit 087f832

Please sign in to comment.