| 22 | 22 | | spendRange, |
| 23 | 23 | | } from "../lib/billing"; |
| 24 | 24 | | import { money, wholeDollars } from "../lib/money"; |
| 25 | + | import { type Failed, isFailed } from "../lib/partial"; |
| 26 | + | import { Unavailable } from "./boundary"; |
| 25 | 27 | | import { ErrorText, SubmitButton } from "./ui"; |
| 26 | 28 | | import { Badge } from "./ui/badge"; |
| 27 | 29 | | import { RadioGroup, RadioGroupItem } from "./ui/radio-group"; |
| ⋯ |
| 359 | 361 | | ); |
| 360 | 362 | | } |
| 361 | 363 | | |
| 362 | | − | export function RaiseCard({ requests, owner, error }: { requests: LimitRequest[]; owner: boolean; error?: string }) { |
| 364 | + | export function RaiseCard({ requests, owner, error }: { requests: LimitRequest[] | Failed; owner: boolean; error?: string }) { |
| 365 | + | const about = |
| 366 | + | "Ask for a higher limit than you can set yourself. A person at g1t reads it and answers within one business day, in the app and by email. Nothing about price is negotiated."; |
| 367 | + | // Without the requests there is no telling whether one is open: no form, |
| 368 | + | // so a second one is never sent while the first waits. |
| 369 | + | if (isFailed(requests)) { |
| 370 | + | return ( |
| 371 | + | <Card id="raise" title="Raise my limit" about={about}> |
| 372 | + | <div className="mt-3"> |
| 373 | + | <Unavailable what={requests.what} compact /> |
| 374 | + | </div> |
| 375 | + | </Card> |
| 376 | + | ); |
| 377 | + | } |
| 363 | 378 | | const mine = requests.filter((request) => request.kind === "limit"); |
| 364 | 379 | | const waiting = mine.some((request) => request.status === "open"); |
| 365 | 380 | | return ( |
| 366 | | − | <Card |
| 367 | | − | id="raise" |
| 368 | | − | title="Raise my limit" |
| 369 | | − | about="Ask for a higher limit than you can set yourself. A person at g1t reads it and answers within one business day, in the app and by email. Nothing about price is negotiated." |
| 370 | | − | > |
| 381 | + | <Card id="raise" title="Raise my limit" about={about}> |
| 371 | 382 | | {owner && !waiting && ( |
| 372 | 383 | | <Form method="post" className="mt-4 space-y-3"> |
| 373 | 384 | | <input type="hidden" name="intent" value="request" /> |
| ⋯ |
| 512 | 523 | | |
| 513 | 524 | | // --- Overage ----------------------------------------------------------------------- |
| 514 | 525 | | |
| 515 | | − | export function OverageCard({ requests, owner, error }: { requests: LimitRequest[]; owner: boolean; error?: string }) { |
| 526 | + | export function OverageCard({ requests, owner, error }: { requests: LimitRequest[] | Failed; owner: boolean; error?: string }) { |
| 527 | + | const title = "Spent more than you meant to? Tell us."; |
| 528 | + | const about = |
| 529 | + | "A loop that ran all night, a workflow on every push: say what happened. g1t can credit usage you did not mean, once in 12 months; larger credits, or a second one within 12 months, are reviewed by a person."; |
| 530 | + | // As on Raise my limit: no form while an open request may be unseen. |
| 531 | + | if (isFailed(requests)) { |
| 532 | + | return ( |
| 533 | + | <Card id="overage" title={title} about={about}> |
| 534 | + | <div className="mt-3"> |
| 535 | + | <Unavailable what={requests.what} compact /> |
| 536 | + | </div> |
| 537 | + | </Card> |
| 538 | + | ); |
| 539 | + | } |
| 516 | 540 | | const mine = requests.filter((request) => request.kind === "overage"); |
| 517 | 541 | | const waiting = mine.some((request) => request.status === "open"); |
| 518 | 542 | | return ( |
| 519 | | − | <Card |
| 520 | | − | id="overage" |
| 521 | | − | title="Spent more than you meant to? Tell us." |
| 522 | | − | about="A loop that ran all night, a workflow on every push: say what happened. g1t can credit usage you did not mean, once in 12 months; larger credits, or a second one within 12 months, are reviewed by a person." |
| 523 | | − | > |
| 543 | + | <Card id="overage" title={title} about={about}> |
| 524 | 544 | | {owner && !waiting && ( |
| 525 | 545 | | <Form method="post" className="mt-4 space-y-3"> |
| 526 | 546 | | <input type="hidden" name="intent" value="request" /> |