Skip to content

Commit

Permalink
Replace some useChainIds
Browse files Browse the repository at this point in the history
  • Loading branch information
aeolianeth committed Dec 8, 2024
1 parent db8901a commit 30bc3d4
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 32 deletions.
11 changes: 0 additions & 11 deletions src/packages/v4/hooks/useV4ProjectRoute.ts

This file was deleted.

25 changes: 15 additions & 10 deletions src/packages/v4/views/V4ProjectDashboard/V4ProjectHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ import useMobile from 'hooks/useMobile'
import Link from 'next/link'
import { ProjectHeaderPopupMenu } from 'packages/v4/components/ProjectDashboard/components/ProjectHeaderPopupMenu'
import V4ProjectHandleLink from 'packages/v4/components/V4ProjectHandleLink'
import { useCurrentRouteChainId } from 'packages/v4/hooks/useCurrentRouteChainId'
import { useV4WalletHasPermission } from 'packages/v4/hooks/useV4WalletHasPermission'
import { V4OperatorPermission } from 'packages/v4/models/v4Permissions'
import { settingsPagePath, v4ProjectRoute } from 'packages/v4/utils/routes'
import { twMerge } from 'tailwind-merge'
import { useChainId } from 'wagmi'
import { useV4ProjectHeader } from './hooks/useV4ProjectHeader'
import { ProjectHeaderStats } from './ProjectHeaderStats'

export type SocialLink = 'twitter' | 'discord' | 'telegram' | 'website'

export const V4ProjectHeader = ({ className }: { className?: string }) => {
const socialLinks = useSocialLinks()
const chainId = useChainId()
const chainId = useCurrentRouteChainId()

const {
title,
Expand Down Expand Up @@ -103,13 +103,14 @@ export const V4ProjectHeader = ({ className }: { className?: string }) => {
</div>
<div className="flex flex-col justify-between gap-8 md:flex-row md:gap-12">
<div className="flex min-w-0 flex-col gap-3">
{subtitle &&
(subtitle.type === 'tagline' ? (
<TruncatedText
className="text-grey-700 dark:text-slate-50 md:text-lg"
text={subtitle.text}
/>
) : null)
{
subtitle &&
(subtitle.type === 'tagline' ? (
<TruncatedText
className="text-grey-700 dark:text-slate-50 md:text-lg"
text={subtitle.text}
/>
) : null)
// <Subtitle subtitle={subtitle.text} />
}
<div className="text-grey-500 dark:text-slate-200">
Expand All @@ -129,7 +130,11 @@ export const V4ProjectHeader = ({ className }: { className?: string }) => {
{gnosisSafe && projectId && (
<GnosisSafeBadge
safe={gnosisSafe}
href={`${v4ProjectRoute({ projectId, chainId })}/safe`}
href={

Check failure on line 133 in src/packages/v4/views/V4ProjectDashboard/V4ProjectHeader.tsx

View workflow job for this annotation

GitHub Actions / Compile Typescript

Type 'string | undefined' is not assignable to type 'string'.

Check failure on line 133 in src/packages/v4/views/V4ProjectDashboard/V4ProjectHeader.tsx

View workflow job for this annotation

GitHub Actions / Compile Typescript

Type 'string | undefined' is not assignable to type 'string'.
chainId
? `${v4ProjectRoute({ projectId, chainId })}/safe`
: undefined
}
/>
)}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ import { SettingOutlined } from '@ant-design/icons'
import { Button, Tooltip } from 'antd'
import { AddTokenToMetamaskButton } from 'components/buttons/AddTokenToMetamaskButton'
import { ISSUE_ERC20_EXPLANATION } from 'components/strings'
import { useJBContractContext } from 'juice-sdk-react'
import { useJBChainId, useJBContractContext } from 'juice-sdk-react'
import { V4TokenHoldersModal } from 'packages/v4/components/modals/V4TokenHoldersModal/V4TokenHoldersModal'
import { useProjectHasErc20Token } from 'packages/v4/hooks/useProjectHasErc20Token'
import { v4ProjectRoute } from 'packages/v4/utils/routes'
import { useCallback, useState } from 'react'
import { reloadWindow } from 'utils/windowUtils'
import { useChainId } from 'wagmi'
import { useV4BalanceMenuItemsUserFlags } from './hooks/useV4BalanceMenuItemsUserFlags'
import { useV4TokensPanel } from './hooks/useV4TokensPanel'
import { useV4YourBalanceMenuItems } from './hooks/useV4YourBalanceMenuItems'
Expand Down Expand Up @@ -181,7 +180,7 @@ export const V4TokensPanel = () => {
}

const ProjectTokenCard = () => {
const chainId = useChainId()
const chainId = useJBChainId()
const { projectId: projectIdBig } = useJBContractContext()
const projectId = Number(projectIdBig)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { Cog6ToothIcon, XMarkIcon } from '@heroicons/react/24/solid'
import { Trans } from '@lingui/macro'
import { useJBContractContext } from 'juice-sdk-react'
import Link from 'next/link'
import { useCurrentRouteChainId } from 'packages/v4/hooks/useCurrentRouteChainId'
import { v4ProjectRoute } from 'packages/v4/utils/routes'
import { useChainId } from 'wagmi'

export const ProjectSettingsLayout: React.FC<React.PropsWithChildren> = ({
children,
}) => {
const { projectId } = useJBContractContext()
const chainId = useChainId()
const chainId = useCurrentRouteChainId()

return (
<>
<header className="sticky top-0 right-0 z-10 mb-8 border-b border-solid border-b-grey-100 bg-white dark:border-b-slate-500 dark:bg-slate-900">
Expand All @@ -21,7 +21,11 @@ export const ProjectSettingsLayout: React.FC<React.PropsWithChildren> = ({
</h1>

<Link
href={v4ProjectRoute({ projectId: Number(projectId), chainId })}
href={
chainId
? v4ProjectRoute({ projectId: Number(projectId), chainId })
: undefined
}
className="text-secondary"
>
<XMarkIcon className="h-6 w-6" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { useJBContractContext } from 'juice-sdk-react'
import { useCurrentRouteChainId } from 'packages/v4/hooks/useCurrentRouteChainId'
import { settingsPagePath } from 'packages/v4/utils/routes'
import { useChainId } from 'wagmi'
import { SettingsPageKey } from '../ProjectSettingsDashboard'

export function useSettingsPagePath(key?: SettingsPageKey) {
const { projectId } = useJBContractContext()
const chainId = useChainId()
const chainId = useCurrentRouteChainId()
if (!chainId) {
return undefined
}

return settingsPagePath({ projectId: Number(projectId), chainId }, key, )
return settingsPagePath({ projectId: Number(projectId), chainId }, key)
}

0 comments on commit 30bc3d4

Please sign in to comment.