We've made this tool completely free and cover all the costs 😇
diff --git a/wasp-ai/src/client/pages/ResultPage.jsx b/wasp-ai/src/client/pages/ResultPage.jsx
index 04ddb69cb..e72dc5efe 100644
--- a/wasp-ai/src/client/pages/ResultPage.jsx
+++ b/wasp-ai/src/client/pages/ResultPage.jsx
@@ -34,7 +34,8 @@ const jsConfetti = new JSConfetti();
export const ResultPage = () => {
const { appId } = useParams();
const [generationDone, setGenerationDone] = useState(false);
- const [isStarRepoOpen, setIsStarRepoOpen] = useState(false);
+ const [isRunning, setIsRunning] = useState(false);
+ const [isSuccessModalOpen, setIsSuccessModalOpen] = useState(false);
const {
data: appGenerationResult,
isError,
@@ -46,7 +47,7 @@ export const ResultPage = () => {
);
const [activeFilePath, setActiveFilePath] = useState(null);
const [currentStatus, setCurrentStatus] = useState({
- status: "idle",
+ status: "idle",
message: "Waiting",
});
const [currentFiles, setCurrentFiles] = useState({});
@@ -73,10 +74,16 @@ export const ResultPage = () => {
}, [appId]);
useEffect(() => {
- if (currentStatus.status === "success") {
- setIsStarRepoOpen(true);
+ const currentAppStatus = appGenerationResult?.project?.status;
+ if (currentAppStatus === "in-progress") {
+ setIsRunning(true)
+ } else if (currentAppStatus === "success" && isRunning) {
+ setIsSuccessModalOpen(true)
+ setIsRunning(false)
+ } else if (isRunning) {
+ setIsRunning(false)
}
- }, [currentStatus])
+ }, [appGenerationResult?.project?.status])
const logs = appGenerationResult?.project?.logs.map((log) => log.content);
@@ -217,7 +224,7 @@ export const ResultPage = () => {
currentStatus={currentStatus}
isStatusVisible={!!appGenerationResult?.project}
/>
-
+
{isError && (
@@ -406,59 +413,71 @@ function getCardinalNumber(number) {
}
}
-export function StarOurRepoModal({ isStarRepoOpen, setIsStarRepoOpen, appGenerationResult }) {
- const [tokens, setTokens] = useState(0)
- const { data: numTotalProjects } = useQuery(getNumProjects, {}, { enabled: isStarRepoOpen })
-
- const tokenNumberStr = appGenerationResult?.project?.logs?.filter(log => log.content.toLowerCase().includes("tokens usage") === true)[0]?.content.split(':')[1]?.trim()
+export function OnSuccessModal({ isOpen, setIsOpen, appGenerationResult }) {
+ const [numTokensSpent, setNumTokensSpent] = useState(0)
+ const { data: numTotalProjects } = useQuery(getNumProjects, {}, { enabled: isOpen })
useEffect(() => {
- if (!!tokenNumberStr) {
- const num = tokenNumberStr.slice(1, -1) * 1000
- setTokens(num)
+ const logText = appGenerationResult?.project?.logs?.find((log) => /tokens usage/i.test(log.content))?.content;
+ const tokenNumberStr = logText ? logText.split(":")[1]?.trim() : null;
+ if (tokenNumberStr) {
+ const num = Number(tokenNumberStr.replace(/[\s~k]/gi, '')) * 1000;
+ if (num.toString().match(/^[0-9]+$/)) {
+ setNumTokensSpent(num);
+ }
}
- }, [tokenNumberStr])
+ }, [appGenerationResult]);
useEffect(() => {
- if (isStarRepoOpen) {
+ if (isOpen) {
jsConfetti.addConfetti({
emojis: ['🐝'],
emojiSize: 120,
})
}
- }, [isStarRepoOpen])
+ }, [isOpen])
+
+ function FormattedText({ children }) {
+ return
{children};
+ }
+
return (
-
setIsStarRepoOpen(false)} title={Your App is Ready! 🎉}>
+ setIsOpen(false)} title={Your App is Ready! 🎉}>
We've made this tool completely free and cover all the costs 😇
-
- {/* Fun Stats */}
-
- Number of tokens your app used: |
-
- {" "}
- {tokens.toLocaleString(2) ?? "~22k"}{" "}
- |
-
-
- Cost to generate your app: |
-
- {" "}
- {tokens ? `$${((tokens / 1000) * 0.004).toFixed(2)}` : "~ $0.50"}{" "}
- |
-
- {numTotalProjects && (
-
- Total number of apps generated with Mage: |
-
- {" "}
- {numTotalProjects.toLocaleString()}{" "}
- |
-
- )}
-
+ {numTokensSpent && (
+
+
+
+ Number of tokens your app used: |
+
+ {" "}
+ {numTokensSpent.toLocaleString()}{" "}
+ |
+
+
+ Cost to generate your app: |
+
+ {" "}
+
+ {`$${((Number(numTokensSpent) / 1000) * 0.004).toFixed(2)}`}
+ {" "}
+ |
+
+ {numTotalProjects && (
+
+ Total number of apps generated with Mage: |
+
+ {" "}
+ {numTotalProjects.toLocaleString()}{" "}
+ |
+
+ )}
+
+
+ )}
But you can still show your support by starring us on GitHub:
@@ -478,15 +497,9 @@ export function StarOurRepoModal({ isStarRepoOpen, setIsStarRepoOpen, appGenerat
We'd very much appreciate it! 🧙
- )
+ );
}
-function FormattedText({ children }) {
- return (
- {children}
- )
-}
-
export default function RunTheAppModal({ disabled, onDownloadZip }) {
const [showModal, setShowModal] = useState(false);
return (
diff --git a/wasp-ai/src/server/auth.ts b/wasp-ai/src/server/auth.ts
index b54419310..ede5df730 100644
--- a/wasp-ai/src/server/auth.ts
+++ b/wasp-ai/src/server/auth.ts
@@ -13,19 +13,3 @@ export const getGoogleAuthConfig = () => {
scope: ["profile", "email"],
};
};
-
-
-export const getGitHubUserFields: GetUserFieldsFn = async (_context, args) => {
- // NOTE: if we don't want to access users' emails, we can use scope ["user:read"]
- // instead of ["user"] and access args.profile.username instead
- const email = args.profile.emails[0].value;
- return { email };
-};
-
-export function getGitHubAuthConfig() {
- return {
- clientID: process.env.GITHUB_CLIENT_ID, // look up from env or elsewhere
- clientSecret: process.env.GITHUB_CLIENT_SECRET, // look up from env or elsewhere
- scope: ["user"],
- };
-}
\ No newline at end of file
diff --git a/wasp-ai/src/server/operations.ts b/wasp-ai/src/server/operations.ts
index 7dcd91a43..f266697f6 100644
--- a/wasp-ai/src/server/operations.ts
+++ b/wasp-ai/src/server/operations.ts
@@ -225,9 +225,7 @@ export const getStats = (async (_args, context) => {
}) satisfies GetStats<{}>;
export const getNumProjects = (async (_args, context) => {
- const { Project } = context.entities;
- const numProjects = await Project.count();
- return numProjects;
+ return context.entities.Project.count();
}) satisfies GetNumProjects<{}>;
function getDownloadStats(projects: Project[]) {