-
-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e578472
commit 8823ae0
Showing
32 changed files
with
1,284 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/packages/v1/components/V1Project/V1ProjectToolsDrawer/V1ProjectToolsDrawer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
...ckages/v2v3/components/V2V3Project/ProjectDashboard/components/ProjectHeaderPopupMenu.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
import { WrenchScrewdriverIcon } from '@heroicons/react/24/outline' | ||
import { Trans } from '@lingui/macro' | ||
import { SocialLinkButton } from 'components/Project/ProjectHeader/SocialLinkButton' | ||
import { useSocialLinks } from 'components/Project/ProjectHeader/hooks/useSocialLinks' | ||
import { BookmarkButtonIcon } from 'components/buttons/BookmarkButton/BookmarkButtonIcon' | ||
import { useBookmarkButton } from 'components/buttons/BookmarkButton/hooks/useBookmarkButton' | ||
import { SubscribeButtonIcon } from 'components/buttons/SubscribeButton/SubscribeButtonIcon' | ||
import { useSubscribeButton } from 'components/buttons/SubscribeButton/hooks/useSubscribeButton' | ||
import { PopupMenu } from 'components/ui/PopupMenu' | ||
import { PV_V2 } from 'constants/pv' | ||
import useMobile from 'hooks/useMobile' | ||
import { useMemo, useState } from 'react' | ||
import { twJoin } from 'tailwind-merge' | ||
import { V2V3ProjectToolsDrawer } from '../../V2V3ProjectToolsDrawer' | ||
|
||
type SocialLink = 'twitter' | 'discord' | 'telegram' | 'website' | ||
|
||
export function ProjectHeaderPopupMenu({ | ||
className, | ||
projectId, | ||
}: { | ||
className?: string | ||
projectId: number | ||
}) { | ||
const socialLinks = useSocialLinks() | ||
const isMobile = useMobile() | ||
const [toolsIsOpen, setToolsIsOpen] = useState<boolean>() | ||
|
||
const { isBookmarked, onBookmarkButtonClicked } = useBookmarkButton({ | ||
projectId, | ||
pv: PV_V2, | ||
}) | ||
const { isSubscribed, onSubscribeButtonClicked } = useSubscribeButton({ | ||
projectId, | ||
}) | ||
|
||
const socialItems = useMemo( | ||
() => Object.entries(socialLinks).filter(([, href]) => !!href), | ||
[socialLinks], | ||
) as [string, string][] | ||
|
||
return ( | ||
<> | ||
<PopupMenu | ||
className={twJoin('z-20', className)} | ||
menuButtonIconClassName="h-8 w-8" | ||
items={[ | ||
...(isMobile | ||
? socialItems.map(([type, href]) => ({ | ||
id: type, | ||
label: ( | ||
<SocialLinkButton type={type as SocialLink} href={href} /> | ||
), | ||
href, | ||
})) | ||
: []), | ||
{ | ||
id: 'subscribe', | ||
label: ( | ||
<> | ||
<SubscribeButtonIcon | ||
isSubscribed={isSubscribed} | ||
className="h-5 w-5" | ||
/> | ||
|
||
<span className="whitespace-nowrap text-sm font-medium"> | ||
<Trans>Get notifications</Trans> | ||
</span> | ||
</> | ||
), | ||
onClick: onSubscribeButtonClicked, | ||
}, | ||
{ | ||
id: 'bookmark', | ||
label: ( | ||
<> | ||
<BookmarkButtonIcon | ||
isBookmarked={isBookmarked} | ||
className="h-5 w-5" | ||
/> | ||
<span className="whitespace-nowrap text-sm font-medium"> | ||
<Trans>Save project</Trans> | ||
</span> | ||
</> | ||
), | ||
onClick(ev) { | ||
ev.preventDefault() | ||
ev.stopPropagation() | ||
|
||
onBookmarkButtonClicked() | ||
}, | ||
}, | ||
{ | ||
id: 'tools', | ||
label: ( | ||
<> | ||
<WrenchScrewdriverIcon className="h-5 w-5" /> | ||
|
||
<span className="whitespace-nowrap text-sm font-medium"> | ||
<Trans>Tools</Trans> | ||
</span> | ||
</> | ||
), | ||
onClick: ev => { | ||
ev.preventDefault() | ||
ev.stopPropagation() | ||
|
||
setToolsIsOpen(true) | ||
}, | ||
}, | ||
]} | ||
/> | ||
|
||
<V2V3ProjectToolsDrawer | ||
open={toolsIsOpen} | ||
onClose={() => setToolsIsOpen(false)} | ||
/> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s/v2v3/components/V2V3Project/V2V3ProjectSettings/pages/TransferOwnershipSettingsPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
src/packages/v2v3/components/V2V3Project/V2V3ProjectToolsDrawer/V2V3ProjectToolsDrawer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
...4/components/ProjectDashboard/components/V4ProjectToolsDrawer/AddToProjectBalanceForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { Trans } from '@lingui/macro' | ||
import { waitForTransactionReceipt } from '@wagmi/core' | ||
import { Form } from 'antd' | ||
import InputAccessoryButton from 'components/buttons/InputAccessoryButton' | ||
import TransactorButton from 'components/buttons/TransactorButton' | ||
import FormattedNumberInput from 'components/inputs/FormattedNumberInput' | ||
import { TxHistoryContext } from 'contexts/Transaction/TxHistoryContext' | ||
import { useWallet } from 'hooks/Wallet' | ||
import { NATIVE_TOKEN } from 'juice-sdk-core' | ||
import { useJBContractContext, useWriteJbMultiTerminalAddToBalanceOf } from 'juice-sdk-react' | ||
import { wagmiConfig } from 'packages/v4/wagmiConfig' | ||
import { useContext, useState } from 'react' | ||
import { parseWad } from 'utils/format/formatNumber' | ||
import { emitErrorNotification } from 'utils/notifications' | ||
import { reloadWindow } from 'utils/windowUtils' | ||
|
||
export function AddToProjectBalanceForm() { | ||
const { contracts, projectId } = useJBContractContext() | ||
const { addTransaction } = useContext(TxHistoryContext) | ||
|
||
const [loadingAddToBalance, setLoadingAddToBalance] = useState<boolean>() | ||
|
||
const { userAddress } = useWallet() | ||
|
||
const [addToBalanceForm] = Form.useForm<{ amount: string }>() | ||
|
||
const { writeContractAsync: writeAddToBalance } = | ||
useWriteJbMultiTerminalAddToBalanceOf() | ||
|
||
|
||
async function addToBalance() { | ||
const amount = parseWad(addToBalanceForm.getFieldValue('amount')).toBigInt() | ||
if ( | ||
!amount || | ||
!contracts.primaryNativeTerminal.data || | ||
!projectId | ||
) | ||
return | ||
|
||
setLoadingAddToBalance(true) | ||
|
||
const args = [ | ||
projectId, | ||
NATIVE_TOKEN, | ||
amount, | ||
false, // shouldReturnHeldFees | ||
'', // memo | ||
'0x', // metadata | ||
] as const | ||
|
||
try { | ||
const hash = await writeAddToBalance({ | ||
address: contracts.primaryNativeTerminal.data, | ||
args, | ||
}) | ||
|
||
addTransaction?.('Send payouts', { hash }) | ||
await waitForTransactionReceipt(wagmiConfig, { | ||
hash, | ||
}) | ||
|
||
reloadWindow() | ||
|
||
setLoadingAddToBalance(false) | ||
} catch (e) { | ||
setLoadingAddToBalance(false) | ||
|
||
emitErrorNotification((e as unknown as Error).message) | ||
} | ||
} | ||
|
||
return ( | ||
<Form form={addToBalanceForm} layout="vertical"> | ||
<h3 className="text-primary"> | ||
<Trans>Transfer ETH to this project</Trans> | ||
</h3> | ||
<p> | ||
<Trans> | ||
Transfer ETH from your wallet to this project without minting tokens. | ||
</Trans> | ||
</p> | ||
|
||
<Form.Item name="amount" label={<Trans>Transfer amount</Trans>}> | ||
<FormattedNumberInput | ||
placeholder="0" | ||
accessory={<InputAccessoryButton content="ETH" />} | ||
/> | ||
</Form.Item> | ||
<TransactorButton | ||
onClick={() => addToBalance()} | ||
loading={loadingAddToBalance} | ||
size="small" | ||
type="primary" | ||
text={<Trans>Transfer ETH to project</Trans>} | ||
disabled={!userAddress} | ||
connectWalletText={<Trans>Connect wallet to transfer ETH</Trans>} | ||
/> | ||
</Form> | ||
) | ||
} |
Oops, something went wrong.