| 1 | import type { FormEvent, ReactNode } from "react"; |
| 2 | |
| 3 | import { Button } |
| 4 | import { Card, CardContent |
| 5 | import { Spinner } |
| 6 | |
| 7 | /** One setting: a heading, a card holding its field, and a footer that explains it and saves it. */ |
| 8 | export function SettingCard({ |
| 9 | title, |
| 10 | hint, |
| 11 | children, |
| 12 | onSubmit, |
| 13 | pending, |
| 14 | canSave, |
| 15 | submitText = "Save" |
| 16 | }: { |
| 17 | title: string |
| 18 | hint: ReactNode |
| 19 | children: ReactNode |
| 20 | onSubmit: () |
| 21 | pending: boolean |
| 22 | canSave: boolean |
| 23 | submitText?: string |
| 24 | }) { |
| 25 | return ( |
| 26 | <section> |
| 27 | <h2 className="mb-3 text-sm font-semibold |
| 28 | <form |
| 29 | onSubmit={(event: |
| 30 | event.preventDefault(); |
| 31 | onSubmit(); |
| 32 | }} |
| 33 | > |
| 34 | <Card className=" |
| 35 | <CardContent className=" |
| 36 | <CardFooter className=" |
| 37 | <p className="text-sm text-muted-foreground |
| 38 | <Button type=" |
| 39 | {pending && <Spinner |
| 40 | {submitText} |
| 41 | </Button> |
| 42 | </CardFooter> |
| 43 | </Card> |
| 44 | </form> |
| 45 | </section> |
| 46 | ); |
| 47 | } |