-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add success page to ai minter (#138)
* add success page to ai minter * add success page to ai minter * add success page to ai minter * add success page to ai minter * add success page to ai minter * add txn hash * ai minter * ai minter * ai minter * ai minter
- Loading branch information
1 parent
94dce59
commit a6f2f12
Showing
18 changed files
with
308 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,64 @@ | ||
"use client"; | ||
|
||
import { Inter } from "next/font/google"; | ||
import { AppProvider } from "@/components/Provider"; | ||
import { Metadata } from "next"; | ||
import { headers } from "next/headers"; | ||
import "./globals.css"; | ||
import { MintbaseWalletContextProvider } from "@mintbase-js/react"; | ||
import { MintbaseWalletSetup } from "@/config/setup"; | ||
import "@near-wallet-selector/modal-ui/styles.css"; | ||
import { ReplicateProvider } from "@/providers/replicate"; | ||
|
||
const inter = Inter({ subsets: ["latin"] }); | ||
const extractSignMeta = (url: string): string | null => { | ||
const signMetaIndex = url.indexOf("signMeta="); | ||
if (signMetaIndex === -1) { | ||
return null; // signMeta not found | ||
} | ||
|
||
const startIndex = signMetaIndex + "signMeta=".length; | ||
const endIndex = url.indexOf("&", startIndex); | ||
if (endIndex === -1) { | ||
return url.substring(startIndex); // signMeta is the last parameter in the URL | ||
} else { | ||
return url.substring(startIndex, endIndex); | ||
} | ||
}; | ||
|
||
export async function generateMetadata(): Promise<Metadata> { | ||
const headersList = headers(); | ||
const referer = headersList.get("referer"); | ||
|
||
let pageTitle = "Mintbase Minter Example"; | ||
let pageDescription = | ||
"Learn how to Mint NFTs on NEAR with Mintbase Minter Example"; | ||
|
||
// Check if signMeta exists in the URL | ||
const signMeta = referer ? extractSignMeta(referer) : ""; | ||
if (signMeta) { | ||
const signMetaData = JSON.parse(decodeURIComponent(signMeta)); | ||
|
||
pageTitle = `Success! You just minted: ${signMetaData?.args?.title}`; | ||
pageDescription = `Just Minted ${signMetaData?.args?.title} on Mintbase`; | ||
// Now you can further process the extracted signMeta value | ||
} | ||
|
||
return { | ||
metadataBase: new URL("https://ai-minter.mintbase.xyz"), | ||
title: pageTitle, | ||
openGraph: { | ||
title: pageTitle, | ||
description: pageDescription, | ||
images: ["./thumbnail.png"], | ||
}, | ||
twitter: { | ||
title: pageTitle, | ||
description: pageDescription, | ||
siteId: "1467726470533754880", | ||
creator: "Mintbase", | ||
card: "summary_large_image", | ||
images: "./thumbnail.png", | ||
}, | ||
}; | ||
} | ||
|
||
export default function RootLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
return ( | ||
<MintbaseWalletContextProvider {...MintbaseWalletSetup}> | ||
<ReplicateProvider> | ||
<html lang="en"> | ||
<body className={`${inter.className} dark`}> | ||
<div className="flex flex-1 flex-col min-h-screen text-gray-500 gradient w-full h-full flex justify-center items-center bold text-white"> | ||
{children} | ||
</div> | ||
</body> | ||
</html> | ||
</ReplicateProvider> | ||
</MintbaseWalletContextProvider> | ||
); | ||
return <AppProvider> {children} </AppProvider>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"use client" | ||
|
||
import { MintbaseWalletContextProvider } from "@mintbase-js/react"; | ||
import { MintbaseWalletSetup } from "@/config/setup"; | ||
import "@near-wallet-selector/modal-ui/styles.css"; | ||
import { ReplicateProvider } from "@/providers/replicate"; | ||
import { Inter } from "next/font/google"; | ||
|
||
const inter = Inter({ subsets: ["latin"] }); | ||
|
||
export const AppProvider = ({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) => { | ||
|
||
return ( | ||
<MintbaseWalletContextProvider {...MintbaseWalletSetup}> | ||
<ReplicateProvider> | ||
<html lang="en"> | ||
<body className={`${inter.className} dark`}> | ||
<div className="flex flex-1 flex-col min-h-screen text-gray-500 gradient w-full h-full flex justify-center items-center bold text-white"> | ||
{children} | ||
</div> | ||
</body> | ||
</html> | ||
</ReplicateProvider> | ||
</MintbaseWalletContextProvider> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import * as React from "react"; | ||
|
||
import { Button } from "@/components/ui/button"; | ||
import { | ||
Card, | ||
CardContent, | ||
CardDescription, | ||
CardFooter, | ||
CardHeader, | ||
CardTitle, | ||
} from "@/components/ui/card"; | ||
import Link from "next/link"; | ||
|
||
interface SuccessPageData { | ||
nftTitle: string; | ||
mediaUrl: string; | ||
metaPage: string; | ||
txnHashUrl: string; | ||
} | ||
|
||
export function SuccessPage({ data }: { data: SuccessPageData }): JSX.Element { | ||
const { nftTitle, mediaUrl, metaPage, txnHashUrl } = data; | ||
|
||
|
||
|
||
return ( | ||
<Card className="w-[350px]"> | ||
<CardHeader> | ||
<CardDescription> Success you just Minted! </CardDescription> | ||
<CardTitle>{nftTitle}</CardTitle> | ||
</CardHeader> | ||
<CardContent> | ||
<div className="flex w-full relative"> | ||
<img src={mediaUrl} width="100%" height="auto" alt={nftTitle} /> | ||
</div> | ||
</CardContent> | ||
<CardFooter className="flex justify-between"> | ||
<Link target="_blank" href={txnHashUrl} className="text-xs"> | ||
View Transaction | ||
</Link> | ||
<Link target="_blank" href={metaPage}> | ||
<Button> View Nft on Mintbase</Button> | ||
</Link> | ||
</CardFooter> | ||
</Card> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.