Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove unused mods #1306

Merged
merged 2 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions apps/web/src/components/Mod/Deployment.tsx

This file was deleted.

86 changes: 86 additions & 0 deletions apps/web/src/components/Mod/Signup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import {
LENS_PERMISSIONLESS_CREATOR_ABI,
TAPE_SIGNUP_PROXY_ABI
} from '@tape.xyz/abis'
import {
LENS_PERMISSIONLESS_CREATOR_ADDRESS,
POLYGON_CHAIN_ID,
TAPE_SIGNUP_PROXY_ADDRESS
} from '@tape.xyz/constants'
import { Button } from '@tape.xyz/ui'
import React, { useState } from 'react'
import toast from 'react-hot-toast'
import { formatUnits } from 'viem'
import { useBalance, useReadContract, useWriteContract } from 'wagmi'

const Signup = () => {
const [loading, setLoading] = useState(false)

const { data } = useReadContract({
abi: LENS_PERMISSIONLESS_CREATOR_ABI,
address: LENS_PERMISSIONLESS_CREATOR_ADDRESS,
args: [TAPE_SIGNUP_PROXY_ADDRESS],
functionName: 'getCreditBalance',
query: { refetchInterval: 2000 }
})
const credits = String(data)

const { data: totalCount } = useReadContract({
abi: TAPE_SIGNUP_PROXY_ABI,
address: TAPE_SIGNUP_PROXY_ADDRESS,
functionName: 'totalCount',
query: { refetchInterval: 2000 }
})
const totalSignupCount = String(totalCount)

const { data: contractBalance } = useBalance({
address: TAPE_SIGNUP_PROXY_ADDRESS,
chainId: POLYGON_CHAIN_ID,
query: {
refetchInterval: 2000
}
})
const balance =
contractBalance && parseFloat(formatUnits(contractBalance.value, 18))

const { writeContractAsync } = useWriteContract({
mutation: {
onSuccess: () => {
toast.success('Funds withdrawn')
setLoading(false)
},
onError: (error) => {
toast.error(error.message)
setLoading(false)
}
}
})

const withdraw = async () => {
setLoading(true)
try {
await writeContractAsync({
abi: TAPE_SIGNUP_PROXY_ABI,
address: TAPE_SIGNUP_PROXY_ADDRESS,
functionName: 'withdrawFunds'
})
} catch {}
}

return (
<div className="space-y-2 p-5">
<ul>
<li>Credits: {credits}</li>
<li>Total Signups: {totalSignupCount}</li>
<li>Total Balance: {balance}</li>
</ul>
<div className="flex">
<Button disabled={loading} loading={loading} onClick={() => withdraw()}>
Withdraw funds
</Button>
</div>
</div>
)
}

export default Signup
39 changes: 35 additions & 4 deletions apps/web/src/components/Mod/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import MetaTags from '@components/Common/MetaTags'
import useProfileStore from '@lib/store/idb/profile'
import { ADMIN_IDS } from '@tape.xyz/constants'
import React from 'react'
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@tape.xyz/ui'
import React, { useState } from 'react'
import Custom404 from 'src/pages/404'

import Deployment from './Deployment'
import Recents from './Recents'
import Signup from './Signup'

const Mod = () => {
const { activeProfile } = useProfileStore()
const [activeTab, setActiveTab] = useState('videos')

if (!ADMIN_IDS.includes(activeProfile?.id)) {
return <Custom404 />
Expand All @@ -17,8 +19,37 @@ const Mod = () => {
return (
<>
<MetaTags title="Stats" />
<Deployment />
<Recents />
<div className="container mx-auto">
<Tabs defaultValue={activeTab}>
<TabsList>
<TabsTrigger
className="rounded-t-lg border-black px-4 py-1.5 text-sm font-medium data-[state=active]:border-b data-[state=active]:bg-gray-100 dark:border-white data-[state=active]:dark:bg-gray-800"
onClick={() => {
setActiveTab('videos')
}}
value="videos"
>
Videos
</TabsTrigger>
<TabsTrigger
className="rounded-t-lg border-black px-4 py-1.5 text-sm font-medium data-[state=active]:border-b data-[state=active]:bg-gray-100 dark:border-white data-[state=active]:dark:bg-gray-800"
onClick={() => {
setActiveTab('signup')
}}
value="signup"
>
Signup
</TabsTrigger>
</TabsList>

<TabsContent value="videos">
<Recents />
</TabsContent>
<TabsContent value="signup">
<Signup />
</TabsContent>
</Tabs>
</div>
</>
)
}
Expand Down
1 change: 1 addition & 0 deletions packages/abis/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './src/LensHubProxy'
export * from './src/LensPermissionlessCreator'
export * from './src/TapeSignupProxy'
Loading