diff --git a/web/components/layout/footer.tsx b/web/components/layout/footer.tsx index 4b7cec7..7b7805e 100644 --- a/web/components/layout/footer.tsx +++ b/web/components/layout/footer.tsx @@ -79,6 +79,7 @@ export const Footer: React.FC<{ children?: React.ReactNode }> = () => { }, []); const isMainnet = useAtomValue(isMainnetState); const faucetPath = useAccountPath('/faucet'); + const registerPath = useAccountPath('/register'); return ( = () => { )} - { - window.open('https://btc.us', '_blank'); - }} - href="https://btc.us" - target="_blank" - color="$onSurface-text-subdued" - > - Mint BNS names + {}} href={registerPath} color="$onSurface-text-subdued"> + Register BNS names {!isMainnet && ( diff --git a/web/components/p/register/index.tsx b/web/components/p/register/index.tsx index 6f8f60a..8525c9c 100644 --- a/web/components/p/register/index.tsx +++ b/web/components/p/register/index.tsx @@ -4,7 +4,7 @@ import { Box, Stack } from '@nelson-ui/react'; import { Input } from '@components/ui/input'; import { currentUserAddressNameStringsState, availableNamespacesState } from '@store/names'; import { useAtomValue, useSetAtom } from 'jotai'; -import { BnsNameRow } from '@components/bns-name-row'; +import { RegisterNameRow } from '@components/p/register/register-name-row'; import { Toaster } from 'sonner'; import { useDeepMemo } from '@common/hooks/use-deep-memo'; import { nameInputAtom, registerTxIdAtom, registrationNameState } from '@store/register'; @@ -35,7 +35,7 @@ export const Register: React.FC<{ children?: React.ReactNode }> = () => { if (nameIsValid === false) return null; if (emptyInput) return null; return availableNamespaces.map(namespace => ( - + )); }, [availableNamespaces, emptyInput, nameIsValid, transformedName]); diff --git a/web/components/bns-name-row.tsx b/web/components/p/register/register-name-row.tsx similarity index 73% rename from web/components/bns-name-row.tsx rename to web/components/p/register/register-name-row.tsx index 5ca89a8..903e84a 100644 --- a/web/components/bns-name-row.tsx +++ b/web/components/p/register/register-name-row.tsx @@ -4,7 +4,7 @@ import { Box } from '@nelson-ui/react'; import { Check, AlertCircle } from 'lucide-react'; import { Spinner } from '@components/spinner'; import { useDebounce } from 'usehooks-ts'; -import { Text } from './text'; +import { Text } from '../../text'; import { useAtomValue } from 'jotai'; import { Button } from '@components/ui/button'; import { ustxToStx } from '@common/utils'; @@ -17,6 +17,16 @@ import { useDeepMemo } from '@common/hooks/use-deep-memo'; import { TableCell, TableRow } from '@components/ui/table'; import { cva } from 'class-variance-authority'; import { cn } from '@common/ui-utils'; +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from '@components/ui/dialog'; +import { useConnect } from '@common/hooks/use-connect'; const nameVariants = cva('', { variants: { @@ -28,7 +38,7 @@ const nameVariants = cva('', { }, }); -export const BnsNameRow: React.FC<{ +export const RegisterNameRow: React.FC<{ namespace: string; }> = ({ namespace }) => { const name = useAtomValue(nameInputAtom.debouncedValueAtom); @@ -39,6 +49,7 @@ export const BnsNameRow: React.FC<{ return computeNamePrice(name, namespace); }, [namespace, name]); const { nameRegister } = useNameRegister(name, namespace, price); + const { isSignedIn, openAuthRequest } = useConnect(); // const tx = useAtomValue(registerTxAtom); // TODO: use this to display some status of the tx @@ -64,6 +75,39 @@ export const BnsNameRow: React.FC<{ return 'unavailable'; }, [isLoading, isAvailable]); + const action = useMemo(() => { + if (isSignedIn) { + return ( + + ); + } + return ( + + + + + + + Sign in to register + To register a name, connect your Stacks wallet + + + + + + + ); + }, [isSignedIn, nameRegister, openAuthRequest]); + return ( @@ -90,9 +134,7 @@ export const BnsNameRow: React.FC<{ {isLoading ? ( ) : isAvailable ? ( - + action ) : ( {' '} diff --git a/web/pages/accounts/[address]/register.tsx b/web/pages/accounts/[address]/register.tsx index 1402d5d..bd2612e 100644 --- a/web/pages/accounts/[address]/register.tsx +++ b/web/pages/accounts/[address]/register.tsx @@ -19,6 +19,5 @@ const RegisterPage: NextPage & { authRequired?: boolean } = () => { ); }; -RegisterPage.authRequired = true; export default RegisterPage; diff --git a/web/pages/register.tsx b/web/pages/register.tsx index 1402d5d..bd2612e 100644 --- a/web/pages/register.tsx +++ b/web/pages/register.tsx @@ -19,6 +19,5 @@ const RegisterPage: NextPage & { authRequired?: boolean } = () => { ); }; -RegisterPage.authRequired = true; export default RegisterPage;