diff --git a/fe/app/_components/burn-dialog.tsx b/fe/app/_components/burn-dialog.tsx index 670eab3..43924d0 100644 --- a/fe/app/_components/burn-dialog.tsx +++ b/fe/app/_components/burn-dialog.tsx @@ -3,6 +3,7 @@ import { LoaderIcon } from "lucide-react"; import Image from "next/image"; import type { ComponentProps, FC, PropsWithChildren } from "react"; +import { useAccount } from "wagmi"; import { Button } from "@/components/ui/button"; import { Dialog, @@ -22,6 +23,8 @@ type Props = ComponentProps & { export const BurnDialog: FC> = (props) => { const { tokenId: tokenIdToBurn, tokenBalance, ...rest } = props; + const { address } = useAccount(); + const { burnCall, isPending, isConfirming } = useBurn({ tokenIdToBurn, }); @@ -31,7 +34,7 @@ export const BurnDialog: FC> = (props) => { diff --git a/fe/app/_components/mint-button.tsx b/fe/app/_components/mint-button.tsx index 181017e..ef8ae10 100644 --- a/fe/app/_components/mint-button.tsx +++ b/fe/app/_components/mint-button.tsx @@ -1,71 +1,63 @@ "use client"; import { LoaderIcon } from "lucide-react"; -import { type FC, useCallback } from "react"; +import { ComponentProps, type FC, useCallback } from "react"; +import { useAccount } from "wagmi"; import { useCoolDown } from "@/app/_hooks/use-cool-down"; import { useTokens } from "@/app/_hooks/use-tokens"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import { useMint } from "../_hooks/use-mint"; -import { CountDown } from "./count-down"; +import { Countdown } from "./count-down"; -type Props = React.ComponentProps<"button"> & { - tokenId: number; - isBaseToken: boolean; -}; +type Props = ComponentProps & { tokenId: number; isBaseToken: boolean } export const MintButton: FC = (props) => { - const { tokenId, isBaseToken, ...rest } = props; - - const { mintCall, error, isPending, isConfirming, isConfirmed } = useMint({ - tokenId, - }); - - const { isCoolDown, setIsCoolDown, forgeabilityByTokenId } = useTokens(); - - const coolDownDelay = useCoolDown({ - isBaseToken, - isMintError: error, - isMintConfirmed: isConfirmed, - }); - + const { + tokenId, + isBaseToken, + ...rest +} = props + + const { address } = useAccount(); + const { mintCall, error, isPending, isConfirming, isConfirmed } = useMint({ tokenId }); + const { isCoolDown, setIsCoolDown, forgeabilityByTokenId, coolDownEndTime } = useTokens(); + + useCoolDown({ isBaseToken, isMintError: error, isMintConfirmed: isConfirmed }); + const isForgeable = !!forgeabilityByTokenId[tokenId]; - - const onMint = useCallback(() => { - if (isBaseToken) { - setIsCoolDown(true); - } - mintCall(); - }, [isBaseToken, setIsCoolDown, mintCall]); - - const isDisabled = - isPending || - isConfirming || - (isBaseToken && isCoolDown) || - (!isBaseToken && !isForgeable); - - return ( - - ); + const isDisabled = !address || isPending || isConfirming || (isBaseToken && isCoolDown) || (!isBaseToken && !isForgeable); + + const onMint = useCallback(() => { + if (isBaseToken) setIsCoolDown(true); + mintCall(); + }, [isBaseToken, setIsCoolDown, mintCall]); + + if (isBaseToken && isCoolDown && coolDownEndTime) { + return ( + + ); + } + + return ( + + ); }; diff --git a/fe/app/_components/token-card.tsx b/fe/app/_components/token-card.tsx index 7fa8785..4400cc0 100644 --- a/fe/app/_components/token-card.tsx +++ b/fe/app/_components/token-card.tsx @@ -49,10 +49,13 @@ export const TokenCard: FC = (props) => { [isBaseToken, hoveredForgeTokenId, requiredToForgeTokenIds], ); + const firstCardId = id === 0 ? { id: "cards" } : {}; + return ( = (props) => { const { tokenId: tokenIdToBurn, tokenBalance } = props; + const { address } = useAccount(); + const { tradeCall, isPending, isConfirming } = useTrade({ tokenIdToBurn, }); @@ -29,7 +32,11 @@ export const TradeDialog: FC = (props) => { return ( - - + - Burn -
-
-
- Token Image -
+ Burn to trade +
+
+ Token Image
= (props) => {
( - Token To Mint - - + @@ -112,7 +107,7 @@ export const TradeForm: FC = (props) => { )} /> - + - Go Home + Go Home
diff --git a/fe/app/globals.css b/fe/app/globals.css index 6ca2137..5fd0b9a 100644 --- a/fe/app/globals.css +++ b/fe/app/globals.css @@ -164,7 +164,7 @@ @layer base { * { - @apply border-border outline-ring/50; + @apply scroll-smooth border-border outline-ring/50; } body { @apply bg-background text-foreground; diff --git a/fe/app/layout.tsx b/fe/app/layout.tsx index 68da8fa..6f14372 100644 --- a/fe/app/layout.tsx +++ b/fe/app/layout.tsx @@ -34,7 +34,7 @@ export default async function RootLayout({ ); return ( - + diff --git a/fe/app/page.tsx b/fe/app/page.tsx index 0d82398..41bceb9 100644 --- a/fe/app/page.tsx +++ b/fe/app/page.tsx @@ -11,7 +11,7 @@ export default function Home() { -
+
    diff --git a/fe/components/ui/dialog.tsx b/fe/components/ui/dialog.tsx index d9ccec9..41f4ae4 100644 --- a/fe/components/ui/dialog.tsx +++ b/fe/components/ui/dialog.tsx @@ -1,143 +1,143 @@ -"use client" +"use client"; -import * as React from "react" -import * as DialogPrimitive from "@radix-ui/react-dialog" -import { XIcon } from "lucide-react" +import * as DialogPrimitive from "@radix-ui/react-dialog"; +import { XIcon } from "lucide-react"; +import type * as React from "react"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; function Dialog({ - ...props + ...props }: React.ComponentProps) { - return + return ; } function DialogTrigger({ - ...props + ...props }: React.ComponentProps) { - return + return ; } function DialogPortal({ - ...props + ...props }: React.ComponentProps) { - return + return ; } function DialogClose({ - ...props + ...props }: React.ComponentProps) { - return + return ; } function DialogOverlay({ - className, - ...props + className, + ...props }: React.ComponentProps) { - return ( - - ) + return ( + + ); } function DialogContent({ - className, - children, - showCloseButton = true, - ...props + className, + children, + showCloseButton = true, + ...props }: React.ComponentProps & { - showCloseButton?: boolean + showCloseButton?: boolean; }) { - return ( - - - - {children} - {showCloseButton && ( - - - Close - - )} - - - ) + return ( + + + + {children} + {showCloseButton && ( + + + Close + + )} + + + ); } function DialogHeader({ className, ...props }: React.ComponentProps<"div">) { - return ( -
    - ) + return ( +
    + ); } function DialogFooter({ className, ...props }: React.ComponentProps<"div">) { - return ( -
    - ) + return ( +
    + ); } function DialogTitle({ - className, - ...props + className, + ...props }: React.ComponentProps) { - return ( - - ) + return ( + + ); } function DialogDescription({ - className, - ...props + className, + ...props }: React.ComponentProps) { - return ( - - ) + return ( + + ); } export { - Dialog, - DialogClose, - DialogContent, - DialogDescription, - DialogFooter, - DialogHeader, - DialogOverlay, - DialogPortal, - DialogTitle, - DialogTrigger, -} + Dialog, + DialogClose, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogOverlay, + DialogPortal, + DialogTitle, + DialogTrigger, +}; diff --git a/fe/components/ui/dropdown-menu.tsx b/fe/components/ui/dropdown-menu.tsx index bbe6fb0..129ec40 100644 --- a/fe/components/ui/dropdown-menu.tsx +++ b/fe/components/ui/dropdown-menu.tsx @@ -1,257 +1,257 @@ -"use client" +"use client"; -import * as React from "react" -import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu" -import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react" +import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"; +import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react"; +import type * as React from "react"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; function DropdownMenu({ - ...props + ...props }: React.ComponentProps) { - return + return ; } function DropdownMenuPortal({ - ...props + ...props }: React.ComponentProps) { - return ( - - ) + return ( + + ); } function DropdownMenuTrigger({ - ...props + ...props }: React.ComponentProps) { - return ( - - ) + return ( + + ); } function DropdownMenuContent({ - className, - sideOffset = 4, - ...props + className, + sideOffset = 4, + ...props }: React.ComponentProps) { - return ( - - - - ) + return ( + + + + ); } function DropdownMenuGroup({ - ...props + ...props }: React.ComponentProps) { - return ( - - ) + return ( + + ); } function DropdownMenuItem({ - className, - inset, - variant = "default", - ...props + className, + inset, + variant = "default", + ...props }: React.ComponentProps & { - inset?: boolean - variant?: "default" | "destructive" + inset?: boolean; + variant?: "default" | "destructive"; }) { - return ( - - ) + return ( + + ); } function DropdownMenuCheckboxItem({ - className, - children, - checked, - ...props + className, + children, + checked, + ...props }: React.ComponentProps) { - return ( - - - - - - - {children} - - ) + return ( + + + + + + + {children} + + ); } function DropdownMenuRadioGroup({ - ...props + ...props }: React.ComponentProps) { - return ( - - ) + return ( + + ); } function DropdownMenuRadioItem({ - className, - children, - ...props + className, + children, + ...props }: React.ComponentProps) { - return ( - - - - - - - {children} - - ) + return ( + + + + + + + {children} + + ); } function DropdownMenuLabel({ - className, - inset, - ...props + className, + inset, + ...props }: React.ComponentProps & { - inset?: boolean + inset?: boolean; }) { - return ( - - ) + return ( + + ); } function DropdownMenuSeparator({ - className, - ...props + className, + ...props }: React.ComponentProps) { - return ( - - ) + return ( + + ); } function DropdownMenuShortcut({ - className, - ...props + className, + ...props }: React.ComponentProps<"span">) { - return ( - - ) + return ( + + ); } function DropdownMenuSub({ - ...props + ...props }: React.ComponentProps) { - return + return ; } function DropdownMenuSubTrigger({ - className, - inset, - children, - ...props + className, + inset, + children, + ...props }: React.ComponentProps & { - inset?: boolean + inset?: boolean; }) { - return ( - - {children} - - - ) + return ( + + {children} + + + ); } function DropdownMenuSubContent({ - className, - ...props + className, + ...props }: React.ComponentProps) { - return ( - - ) + return ( + + ); } export { - DropdownMenu, - DropdownMenuPortal, - DropdownMenuTrigger, - DropdownMenuContent, - DropdownMenuGroup, - DropdownMenuLabel, - DropdownMenuItem, - DropdownMenuCheckboxItem, - DropdownMenuRadioGroup, - DropdownMenuRadioItem, - DropdownMenuSeparator, - DropdownMenuShortcut, - DropdownMenuSub, - DropdownMenuSubTrigger, - DropdownMenuSubContent, -} + DropdownMenu, + DropdownMenuPortal, + DropdownMenuTrigger, + DropdownMenuContent, + DropdownMenuGroup, + DropdownMenuLabel, + DropdownMenuItem, + DropdownMenuCheckboxItem, + DropdownMenuRadioGroup, + DropdownMenuRadioItem, + DropdownMenuSeparator, + DropdownMenuShortcut, + DropdownMenuSub, + DropdownMenuSubTrigger, + DropdownMenuSubContent, +}; diff --git a/fe/components/ui/form.tsx b/fe/components/ui/form.tsx index 524b986..22c13ee 100644 --- a/fe/components/ui/form.tsx +++ b/fe/components/ui/form.tsx @@ -1,167 +1,167 @@ -"use client" +"use client"; -import * as React from "react" -import * as LabelPrimitive from "@radix-ui/react-label" -import { Slot } from "@radix-ui/react-slot" +import type * as LabelPrimitive from "@radix-ui/react-label"; +import { Slot } from "@radix-ui/react-slot"; +import * as React from "react"; import { - Controller, - FormProvider, - useFormContext, - useFormState, - type ControllerProps, - type FieldPath, - type FieldValues, -} from "react-hook-form" - -import { cn } from "@/lib/utils" -import { Label } from "@/components/ui/label" - -const Form = FormProvider + Controller, + type ControllerProps, + type FieldPath, + type FieldValues, + FormProvider, + useFormContext, + useFormState, +} from "react-hook-form"; +import { Label } from "@/components/ui/label"; +import { cn } from "@/lib/utils"; + +const Form = FormProvider; type FormFieldContextValue< - TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath, + TFieldValues extends FieldValues = FieldValues, + TName extends FieldPath = FieldPath, > = { - name: TName -} + name: TName; +}; const FormFieldContext = React.createContext( - {} as FormFieldContextValue -) + {} as FormFieldContextValue, +); const FormField = < - TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath, + TFieldValues extends FieldValues = FieldValues, + TName extends FieldPath = FieldPath, >({ - ...props + ...props }: ControllerProps) => { - return ( - - - - ) -} + return ( + + + + ); +}; const useFormField = () => { - const fieldContext = React.useContext(FormFieldContext) - const itemContext = React.useContext(FormItemContext) - const { getFieldState } = useFormContext() - const formState = useFormState({ name: fieldContext.name }) - const fieldState = getFieldState(fieldContext.name, formState) - - if (!fieldContext) { - throw new Error("useFormField should be used within ") - } - - const { id } = itemContext - - return { - id, - name: fieldContext.name, - formItemId: `${id}-form-item`, - formDescriptionId: `${id}-form-item-description`, - formMessageId: `${id}-form-item-message`, - ...fieldState, - } -} + const fieldContext = React.useContext(FormFieldContext); + const itemContext = React.useContext(FormItemContext); + const { getFieldState } = useFormContext(); + const formState = useFormState({ name: fieldContext.name }); + const fieldState = getFieldState(fieldContext.name, formState); + + if (!fieldContext) { + throw new Error("useFormField should be used within "); + } + + const { id } = itemContext; + + return { + id, + name: fieldContext.name, + formItemId: `${id}-form-item`, + formDescriptionId: `${id}-form-item-description`, + formMessageId: `${id}-form-item-message`, + ...fieldState, + }; +}; type FormItemContextValue = { - id: string -} + id: string; +}; const FormItemContext = React.createContext( - {} as FormItemContextValue -) + {} as FormItemContextValue, +); function FormItem({ className, ...props }: React.ComponentProps<"div">) { - const id = React.useId() - - return ( - -
    - - ) + const id = React.useId(); + + return ( + +
    + + ); } function FormLabel({ - className, - ...props + className, + ...props }: React.ComponentProps) { - const { error, formItemId } = useFormField() - - return ( -