diff --git a/work-verify/src/app/buy/components/missing-params.tsx b/work-verify/src/app/buy/components/missing-params.tsx new file mode 100644 index 0000000..c861391 --- /dev/null +++ b/work-verify/src/app/buy/components/missing-params.tsx @@ -0,0 +1,87 @@ +"use client"; + +import { useState } from 'react'; +import { useRouter } from 'next/navigation'; + +// Hardcoded values for WORK token +const WORK_TOKEN = { + mint: "F7Hwf8ib5DVCoiuyGr618Y3gon429Rnd1r5F9R5upump", + decimals: 6, + amount: 200000000000, + symbol: "WORK" +}; + +export default function MissingParams() { + const router = useRouter(); + const [isLoading, setIsLoading] = useState(false); + + const handleBuyWork = () => { + setIsLoading(true); + // Construct URL with hardcoded parameters + const queryParams = new URLSearchParams({ + tokenMint: WORK_TOKEN.mint, + requiredRawAmount: WORK_TOKEN.amount.toString(), + tokenSymbol: WORK_TOKEN.symbol, + tokenDecimals: WORK_TOKEN.decimals.toString(), + guildName: "GibWork" + }); + + router.push(`/buy?${queryParams.toString()}`); + }; + + return ( +
+
+
+
+ + + +
+
+ +

Missing Parameters

+ +

+ The buy page requires specific parameters to function correctly. These parameters are typically provided through a proper buy link. +

+ +
+

How to get a valid link:

+
    +
  1. Use the Discord bot command to generate a buy link
  2. +
  3. Click on the link provided by the bot
  4. +
  5. Do not modify the URL parameters
  6. +
+
+ +
+
+

or

+
+
+ +
+

Buy WORK tokens directly:

+

+ You can proceed with buying WORK tokens with the default settings. +

+ + +
+
+
+ ); +} diff --git a/work-verify/src/app/buy/page.tsx b/work-verify/src/app/buy/page.tsx index f6537f9..4589993 100644 --- a/work-verify/src/app/buy/page.tsx +++ b/work-verify/src/app/buy/page.tsx @@ -9,6 +9,7 @@ import { toast, ToastContainer } from "react-toastify"; import "react-toastify/dist/ReactToastify.css"; import { QuoteResponse, SwapResponse } from "@/utils/types"; import { SOL_MINT, JUPITER_QUOTE_API, JUPITER_SWAP_API } from "@/utils/config"; +import MissingParams from "./components/missing-params"; export default function SwapPage() { const { publicKey, sendTransaction } = useWallet(); @@ -39,21 +40,9 @@ export default function SwapPage() { const decimalsStr = searchParams.get("tokenDecimals"); const gName = searchParams.get("guildName"); - let errorMsg = null; - - if (!mint) { - errorMsg = - "Required token information (tokenMint) is missing in the URL."; - } - if (!rawAmountStr) { - errorMsg = errorMsg - ? errorMsg + " Required amount (requiredRawAmount) is also missing." - : "Required amount information (requiredRawAmount) is missing in the URL."; - } - - if (errorMsg) { - setParamsError(errorMsg); - toast.error(errorMsg); + // Check if required parameters are missing + if (!mint || !rawAmountStr) { + setParamsError("Missing required parameters"); setParamsLoaded(true); return; } @@ -352,11 +341,7 @@ export default function SwapPage() { } if (paramsError) { - return ( -
- {paramsError} Please go back to Discord and try the link again. -
- ); + return ; } return (