Skip to content

Commit ad60d23

Browse files
committed
Add donate button
1 parent edc879f commit ad60d23

File tree

4 files changed

+96
-1
lines changed

4 files changed

+96
-1
lines changed

src/components/AppNavBar.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { NavBar, Button, Menu, Avatar } from '@/ui'
22
import { signIn, signOut, useSession } from 'next-auth/client'
3-
import { Logo } from '@/components'
3+
import { Logo, DonateModal } from '@/components'
44
import Link from 'next/link'
55
import { useRouter } from 'next/router'
66
import { User } from 'src/pages/members'
77
import { Toggle } from '@/ui'
88
import { Gear, RocketLaunch, SignOut, UserCircle } from 'phosphor-react'
9+
import { useState } from 'react'
910

1011
const navbarItems = [
1112
{
@@ -23,6 +24,7 @@ const navbarItems = [
2324
export default function AppNavBar() {
2425
const [session, loading] = useSession()
2526
const router = useRouter()
27+
const [isDonateModalOpen, setIsDonateModalOpen] = useState(false)
2628

2729
return (
2830
<NavBar
@@ -43,6 +45,19 @@ export default function AppNavBar() {
4345
}
4446
rightDesktopItems={
4547
<>
48+
<Button
49+
variant="solid"
50+
variantColor="brand"
51+
onClick={() => setIsDonateModalOpen(true)}
52+
>
53+
Donate
54+
</Button>
55+
56+
<DonateModal
57+
isOpen={isDonateModalOpen}
58+
setIsOpen={setIsDonateModalOpen}
59+
/>
60+
4661
{loading && <p>loading....</p>}
4762
{!loading &&
4863
(session ? (

src/components/modal/Donate.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { useEffect } from 'react'
2+
3+
export default function Donate() {
4+
useEffect(() => {
5+
const script = document.createElement('script')
6+
const form = document.getElementById('donateForm')
7+
script.setAttribute(
8+
'src',
9+
'https://cdn.razorpay.com/static/widget/subscription-button.js'
10+
)
11+
script.setAttribute('data-subscription_button_id', 'pl_GdSwtlH5wuoiJS')
12+
script.setAttribute('data-button_theme', 'brand-color')
13+
form.appendChild(script)
14+
}, [])
15+
16+
return (
17+
<>
18+
<form id="donateForm"> </form>
19+
</>
20+
)
21+
}

src/components/modal/DonateModal.tsx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { Transition } from '@headlessui/react'
2+
import Donate from './Donate'
3+
4+
export default function DonateModal({
5+
isOpen,
6+
setIsOpen,
7+
}: {
8+
isOpen: boolean
9+
setIsOpen: (open: boolean) => void
10+
}) {
11+
if (!isOpen) {
12+
return <></>
13+
}
14+
return (
15+
<div className="fixed z-10 inset-0 overflow-y-auto">
16+
<div className="flex items-end justify-center min-h-screen text-center sm:block">
17+
<Transition
18+
show={isOpen}
19+
enter="ease-out duration-300"
20+
enterFrom="opacity-0"
21+
enterTo="opacity-100"
22+
leave="ease-in duration-200"
23+
leaveFrom="opacity-100"
24+
leaveTo="opacity-0"
25+
className="fixed inset-0 transition-opacity"
26+
aria-hidden="true"
27+
>
28+
<div
29+
className="absolute inset-0 bg-gray-500 opacity-75"
30+
onClick={() => setIsOpen(false)}
31+
></div>
32+
</Transition>
33+
34+
<span
35+
className="hidden sm:inline-block sm:align-middle sm:h-screen"
36+
aria-hidden="true"
37+
>
38+
&#8203;
39+
</span>
40+
<Transition
41+
show={isOpen}
42+
enter="ease-out duration-300"
43+
enterFrom="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
44+
enterTo="opacity-100 translate-y-0 sm:scale-100"
45+
leave="ease-in duration-200"
46+
leaveFrom="opacity-100 translate-y-0 sm:scale-100"
47+
leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
48+
className="inline-block align-bottom rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:align-middle sm:max-w-sm sm:w-full"
49+
role="dialog"
50+
aria-modal="true"
51+
aria-labelledby="modal-headline"
52+
>
53+
<Donate />
54+
</Transition>
55+
</div>
56+
</div>
57+
)
58+
}

src/components/modal/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export { default as Modal } from './Modal'
22
export { default as FollowModal } from './FollowModal'
33
export { default as LikeModal } from './LikeModal'
4+
export { default as DonateModal } from './DonateModal'

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy