Skip to content

Commit

Permalink
fixed # of generations left in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Nutlope committed Mar 10, 2023
1 parent 0749a84 commit 52e5270
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pages/api/remaining.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export default async function handler(
const hours = Math.floor(diff / 1000 / 60 / 60);
const minutes = Math.floor(diff / 1000 / 60) - hours * 60;

const remainingGenerations = 5 - Number(usedGenerations);
const remainingGenerations =
Number(usedGenerations) > 5 ? 0 : 5 - Number(usedGenerations);

return res.status(200).json({ remainingGenerations, hours, minutes });
}
4 changes: 2 additions & 2 deletions pages/dream.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const Home: NextPage = () => {
left today. Your generation
{Number(data.remainingGenerations) > 1 ? "s" : ""} will renew in{" "}
<span className="font-semibold text-gray-300">
{data.hours} hours and {data.minutes} minutes.
{data.hours + 5} hours and {data.minutes} minutes.
</span>
</p>
)}
Expand Down Expand Up @@ -308,7 +308,7 @@ const Home: NextPage = () => {
role="alert"
>
<div className="bg-red-500 text-white font-bold rounded-t px-4 py-2">
Please try again in 24 hours
Please try again later.
</div>
<div className="border border-t-0 border-red-400 rounded-b bg-red-100 px-4 py-3 text-red-700">
{error}
Expand Down

1 comment on commit 52e5270

@vercel
Copy link

@vercel vercel bot commented on 52e5270 Mar 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.