| 1 | import { Text } from '@react-email/components'; |
| 2 | |
| 3 | import { text } |
| 4 | import { brand } |
| 5 | import { |
| 6 | Pill, |
| 7 | previewThread, |
| 8 | Quote, |
| 9 | ThreadEmail, |
| 10 | type ThreadProps, |
| 11 | } from '../components/thread.js'; |
| 12 | |
| 13 | const VERDICTS = { |
| 14 | approved: { label: ' |
| 15 | changes_requested: { |
| 16 | label: 'Changes requested', |
| 17 | verb: 'requested changes on', |
| 18 | color: brand.danger |
| 19 | }, |
| 20 | commented: { label: ' |
| 21 | } as const; |
| 22 | |
| 23 | interface ThreadReviewProps extends |
| 24 | state: keyof |
| 25 | body: string |
| 26 | /** Line comments submitted with the review. */ |
| 27 | commentCount: number; |
| 28 | } |
| 29 | |
| 30 | export default function ThreadReview |
| 31 | state, |
| 32 | body, |
| 33 | commentCount, |
| 34 | ...thread |
| 35 | }: ThreadReviewProps) |
| 36 | const verdict = |
| 37 | return ( |
| 38 | <ThreadEmail |
| 39 | thread={thread} |
| 40 | preview={`${thread |
| 41 | > |
| 42 | <Text style={ |
| 43 | <Pill color={ |
| 44 | </Text> |
| 45 | <Text style={ |
| 46 | <span style={text |
| 47 | request |
| 48 | {commentCount > 0 |
| 49 | ? ` and left ${commentCount} |
| 50 | : ''} |
| 51 | . |
| 52 | </Text> |
| 53 | {body && <Quote |
| 54 | </ThreadEmail> |
| 55 | ); |
| 56 | } |
| 57 | |
| 58 | ThreadReview.PreviewProps = { |
| 59 | ...previewThread, |
| 60 | isPullRequest: true, |
| 61 | path: '/alice/ghost/pulls/42', |
| 62 | reason: 'author', |
| 63 | state: 'changes_requested', |
| 64 | body: 'Close, but the count overflows past 99.', |
| 65 | commentCount: 2, |
| 66 | } satisfies ThreadReviewProps; |