diff --git a/src/features/Donations/components/DonateCard/DonateCard.stories.tsx b/src/features/Donations/components/DonateCard/DonateCard.stories.tsx new file mode 100644 index 0000000..9d21db7 --- /dev/null +++ b/src/features/Donations/components/DonateCard/DonateCard.stories.tsx @@ -0,0 +1,13 @@ +import { ComponentStory, ComponentMeta } from '@storybook/react'; +import DonateCard from './DonateCard'; + + +export default { + title: 'Donations/Componets/Donate Card', + component: DonateCard, +} as ComponentMeta; + +const Template: ComponentStory = (args) =>
; + +export const Default = Template.bind({}); + diff --git a/src/features/Donations/components/DonateCard/DonateCard.tsx b/src/features/Donations/components/DonateCard/DonateCard.tsx new file mode 100644 index 0000000..7136729 --- /dev/null +++ b/src/features/Donations/components/DonateCard/DonateCard.tsx @@ -0,0 +1,103 @@ +import React, { FormEvent, useState } from 'react'; +import { PaymentStatus, useVote } from 'src/utils/hooks'; +import Confetti from "react-confetti"; +import { useWindowSize } from '@react-hookz/web'; +import { Vote_Item_Type } from 'src/graphql'; + +const defaultOptions = [ + { text: '500', value: 500 }, + { text: '1,000', value: 1000 }, + { text: '5,000', value: 5000 }, + { text: '25,000', value: 25000 }, +] + + + +export default function DonateCard() { + const { width, height } = useWindowSize() + + + const [selectedOption, setSelectedOption] = useState(-1); + const [donationAmount, setDonationAmount] = useState(); + + const { vote, paymentStatus } = useVote({ + itemId: 123, + itemType: Vote_Item_Type.Project + }) + + const onChangeInput = (event: React.ChangeEvent) => { + setSelectedOption(-1); + setDonationAmount(Number(event.target.value)); + }; + + const onSelectOption = (idx: number) => { + setSelectedOption(idx); + setDonationAmount(defaultOptions[idx].value); + } + + const requestPayment = (e: FormEvent) => { + e.preventDefault(); + if (donationAmount) + vote(donationAmount, { + onSuccess: () => { + setTimeout(() => { + setDonationAmount(undefined); + setSelectedOption(-1); + }, 4000); + }, + onError: () => { + setTimeout(() => { + setDonationAmount(undefined); + setSelectedOption(-1); + }, 4000); + } + }); + } + + return ( +
+

Donate to BOLT🔩FUN

+
+
+ +

+ Sats +

+
+
+ {defaultOptions.map((option, idx) => + + )} +
+ {paymentStatus === PaymentStatus.FETCHING_PAYMENT_DETAILS &&

Please wait while we the fetch payment details.

} + {paymentStatus === PaymentStatus.NOT_PAID &&

You did not confirm the payment. Please try again.

} + {paymentStatus === PaymentStatus.PAID &&

The invoice was paid! Please wait while we confirm it.

} + {paymentStatus === PaymentStatus.AWAITING_PAYMENT &&

Waiting for your payment...

} + {paymentStatus === PaymentStatus.PAYMENT_CONFIRMED &&

Thanks for your vote

} + +
+ {paymentStatus === PaymentStatus.PAYMENT_CONFIRMED && } +
+ ) +} diff --git a/src/features/Donations/index.tsx b/src/features/Donations/index.tsx index 27fcad3..1b71f83 100644 --- a/src/features/Donations/index.tsx +++ b/src/features/Donations/index.tsx @@ -1 +1 @@ -export * from './pages/DonationsPage' \ No newline at end of file +export * from './pages/DonatePage/DonatePage' \ No newline at end of file diff --git a/src/features/Donations/pages/DonatePage/DonatePage.stories.tsx b/src/features/Donations/pages/DonatePage/DonatePage.stories.tsx new file mode 100644 index 0000000..bb7b0ea --- /dev/null +++ b/src/features/Donations/pages/DonatePage/DonatePage.stories.tsx @@ -0,0 +1,20 @@ +import { ComponentStory, ComponentMeta } from '@storybook/react'; + +import DonatePage from './DonatePage'; + +export default { + title: 'Donations/Donate Page/Page', + component: DonatePage, + argTypes: { + backgroundColor: { control: 'color' }, + }, +} as ComponentMeta; + + +const Template: ComponentStory = (args) => + +export const Default = Template.bind({}); +Default.args = { +} + + diff --git a/src/features/Donations/pages/DonationsPage.tsx b/src/features/Donations/pages/DonatePage/DonatePage.tsx similarity index 73% rename from src/features/Donations/pages/DonationsPage.tsx rename to src/features/Donations/pages/DonatePage/DonatePage.tsx index 2f82e8e..814e836 100644 --- a/src/features/Donations/pages/DonationsPage.tsx +++ b/src/features/Donations/pages/DonatePage/DonatePage.tsx @@ -1,6 +1,6 @@ -export default function HackathonsPage() { +export default function DonatePage() { return (
+ Donations} + value='$2.6k' + /> + Tournaments} + value='1' + /> + Prizes} + value='2.5k' + /> + Applications} + value='36' + /> +
+ ) +} diff --git a/src/features/Donations/pages/DonatePage/DonationStats/StatCard.stories.tsx b/src/features/Donations/pages/DonatePage/DonationStats/StatCard.stories.tsx new file mode 100644 index 0000000..e05f3d6 --- /dev/null +++ b/src/features/Donations/pages/DonatePage/DonationStats/StatCard.stories.tsx @@ -0,0 +1,20 @@ +import { ComponentStory, ComponentMeta } from '@storybook/react'; +import { FiGrid } from 'react-icons/fi' +import DonationStats from './DonationStats'; + +export default { + title: 'Donations/Donate Page/DonationStats', + component: DonationStats, + argTypes: { + backgroundColor: { control: 'color' }, + }, +} as ComponentMeta; + + +const Template: ComponentStory = (args) =>
+ +export const Default = Template.bind({}); +Default.args = { +} + + diff --git a/src/features/Donations/pages/DonatePage/Header/Header.stories.tsx b/src/features/Donations/pages/DonatePage/Header/Header.stories.tsx new file mode 100644 index 0000000..067943f --- /dev/null +++ b/src/features/Donations/pages/DonatePage/Header/Header.stories.tsx @@ -0,0 +1,20 @@ +import { ComponentStory, ComponentMeta } from '@storybook/react'; + +import Header from './Header'; + +export default { + title: 'Donations/Donate Page/Header', + component: Header, + argTypes: { + backgroundColor: { control: 'color' }, + }, +} as ComponentMeta; + + +const Template: ComponentStory = (args) =>
+ +export const Default = Template.bind({}); +Default.args = { +} + + diff --git a/src/features/Donations/pages/DonatePage/Header/Header.tsx b/src/features/Donations/pages/DonatePage/Header/Header.tsx new file mode 100644 index 0000000..94fabd7 --- /dev/null +++ b/src/features/Donations/pages/DonatePage/Header/Header.tsx @@ -0,0 +1,26 @@ +import DonateCard from 'src/features/Donations/components/DonateCard/DonateCard' +import DonationStats from '../DonationStats/DonationStats' +import styles from './styles.module.scss' + +export default function Header() { + return ( +
+
+
+

+ Donate +

+

+ Help fund BOLT🔩FUN, as well as other Makers working on lightning apps through tournaments and prize pools +

+
+
+ +
+
+
+ +
+
+ ) +} diff --git a/src/features/Donations/pages/DonatePage/Header/styles.module.scss b/src/features/Donations/pages/DonatePage/Header/styles.module.scss new file mode 100644 index 0000000..50c3d97 --- /dev/null +++ b/src/features/Donations/pages/DonatePage/Header/styles.module.scss @@ -0,0 +1,17 @@ +@import "/src/styles/mixins"; + +.header { + padding: 56px 24px; + background: #ffecf9; + background: linear-gradient(40deg, white -5%, #ffb7d963 74%, #e3faff61 100%); + + & > div { + max-width: calc(min(100%, 910px)); + margin-left: auto; + margin-right: auto; + } + + @include gt-md { + padding: 156px 0; + } +} diff --git a/src/features/Donations/pages/DonatePage/StatCard/StatCard.stories.tsx b/src/features/Donations/pages/DonatePage/StatCard/StatCard.stories.tsx new file mode 100644 index 0000000..289b1e7 --- /dev/null +++ b/src/features/Donations/pages/DonatePage/StatCard/StatCard.stories.tsx @@ -0,0 +1,23 @@ +import { ComponentStory, ComponentMeta } from '@storybook/react'; +import { FiGrid } from 'react-icons/fi' +import StatCard from './StatCard'; + +export default { + title: 'Donations/Donate Page/StatCard', + component: StatCard, + argTypes: { + backgroundColor: { control: 'color' }, + }, +} as ComponentMeta; + + +const Template: ComponentStory = (args) =>
+ +export const Default = Template.bind({}); +Default.args = { + color: "#3B82F6", + label: <> Applications, + value: '36' +} + + diff --git a/src/features/Donations/pages/DonatePage/StatCard/StatCard.tsx b/src/features/Donations/pages/DonatePage/StatCard/StatCard.tsx new file mode 100644 index 0000000..74d900c --- /dev/null +++ b/src/features/Donations/pages/DonatePage/StatCard/StatCard.tsx @@ -0,0 +1,24 @@ +import { ReactNode } from 'react' + +interface Props { + label: ReactNode, + value: ReactNode, + color: string +} + +export default function StatCard(props: Props) { + return ( +
+

+ {props.label} +

+

+ {props.value} +

+
+ ) +} diff --git a/src/features/Donations/pages/donate.graphql b/src/features/Donations/pages/DonatePage/donate.graphql similarity index 100% rename from src/features/Donations/pages/donate.graphql rename to src/features/Donations/pages/DonatePage/donate.graphql