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

disable connect wallet when mint cap is reached and custom html banner #84

Merged
merged 1 commit into from
Dec 23, 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
5 changes: 3 additions & 2 deletions src/comps/Deposit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const DepositFlowAmount = ({
useMintCaps();
const maxDepositAmount = currentCap / 1e8;
const minDepositAmount = perDepositMinimum / 1e8;
const isMintCapReached = currentCap <= 0;

const validationSchema = useMemo(
() =>
Expand Down Expand Up @@ -146,11 +147,11 @@ const DepositFlowAmount = ({
nameKey="amount"
type="number"
placeholder={
currentCap <= 0
isMintCapReached
? "Mint cap reached!"
: "BTC amount to transfer (e.g. 0.01)"
}
disabled={isLoading || currentCap <= 0}
disabled={isLoading || isMintCapReached}
handleSubmit={(value) => handleSubmit(value)}
validationSchema={validationSchema}
/>
Expand Down
15 changes: 11 additions & 4 deletions src/comps/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { useNotifications } from "@/hooks/use-notifications";
import { NotificationStatusType } from "./Notifications";
import SBTCBalance from "./ui/sbtc-balance";
import TOS from "./tos";
import useMintCaps from "@/hooks/use-mint-caps";

// converting to lower case to avoid case sensitive issue

Expand Down Expand Up @@ -50,6 +51,10 @@ const Header = ({ config }: { config: BridgeConfig }) => {
showConnectWalletAtom,
);

const { currentCap } = useMintCaps();

const isMintCapReached = currentCap <= 0;

const renderUserWalletInfo = () => {
return (
<>
Expand All @@ -69,9 +74,10 @@ const Header = ({ config }: { config: BridgeConfig }) => {
return (
<>
{config.BANNER_CONTENT && (
<div className="w-full bg-[#F26969] text-white text-center py-2">
{config.BANNER_CONTENT}
</div>
<div
className="w-full bg-[#F26969] text-white text-center py-2"
dangerouslySetInnerHTML={{ __html: config.BANNER_CONTENT }}
/>
)}
<header className="w-full py-6 flex items-center justify-center">
<div
Expand Down Expand Up @@ -102,7 +108,8 @@ const Header = ({ config }: { config: BridgeConfig }) => {
) : (
<button
onClick={() => setShowConnectWallet(true)}
className=" bg-orange px-4 py-2 rounded-md"
disabled={isMintCapReached}
className=" bg-orange px-4 py-2 rounded-md disabled:opacity-50 disabled:cursor-not-allowed"
>
<h3 className="font-Matter text-xs font-semibold tracking-wide">
CONNECT WALLET
Expand Down
3 changes: 2 additions & 1 deletion src/comps/core/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ export const FlowForm = ({
</PrimaryButton>
) : (
<button
disabled={disabled}
type="button"
onClick={() => setShowConnectWallet(true)}
className="bg-orange px-4 py-2 rounded-md font-Matter text-xs font-semibold tracking-wide"
className="bg-orange px-4 py-2 rounded-md font-Matter text-xs font-semibold tracking-wide disabled:opacity-50 disabled:cursor-not-allowed"
>
CONNECT WALLET
</button>
Expand Down
Loading