Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 1 | /** |
| 2 | * How the site speaks of a workspace's trial credit. Pure, so it can be | |
| 3 | * tested. | |
| 4 | */ | |
| 5 | ||
| 6 | import type { Trial } from "@g1t/contracts"; | |
| 7 | ||
| 8 | /** "November 1", in UTC, when new trials start again. */ | |
| 9 | export function resumesOn(at: string): string { | |
| 10 | return new Date(at).toLocaleDateString("en-US", { month: "long", day: "numeric", timeZone: "UTC" }); | |
| 11 | } | |
| 12 | ||
| 13 | /** Why the trial cannot pay for anything now, in a sentence, or null when it can. */ | |
| 14 | export function trialClosed(trial: Trial | null | undefined, workspace: string): string | null { | |
| 15 | if (!trial || trial.open) return null; | |
| 16 | if (trial.reason === "used") return `${workspace} has used its trial credit on g1t.`; | |
| 17 | if (trial.reason === "pool") | |
| 18 | return trial.waitsUntil | |
| 19 | ? `This month's free trials are all given out; new ones start on ${resumesOn(trial.waitsUntil)}.` | |
| 20 | : "This month's free trials are all given out; new ones start next month."; | |
| 21 | if (trial.reason === "ended") return "The free allowance on g1t's models has ended."; | |
| 22 | return null; | |
| 23 | } |