()
| 33 | } |
| 34 | |
| 35 | const ReportBugForm: FC<{}> = () => { |
| 36 | const { Form, data, state } = useFetcher() |
| 37 | const { room, roomHistory } = useRoomContext() |
| 38 | const { roomName } = useParams() |
| 39 | const { identity } = room |
| 40 | |
| 41 | const info: BugReportInfo = { |
| 42 | roomName, |
| 43 | identity, |
| 44 | roomHistory, |
| 45 | url: typeof location !== 'undefined' ? location.href : undefined, |
| 46 | } |
| 47 | |
| 48 | const [copied, copy] = useCopyToClipboard() |
| 49 | |
| 50 | const infoString = JSON.stringify(info, null, 2) |
| 51 | |
| 52 | return data ? ( |
| 53 | <div className="space-y-4"> |
| 54 | <DialogTitle>Thank you!</DialogTitle> |
| 55 | <Description>Your report has been submitted!</Description> |
| 56 | </div> |
| 57 | ) : ( |
| 58 | <div className="space-y-4"> |
| 59 | <DialogTitle>Report a bug</DialogTitle> |
| 60 | <Description> |
| 61 | The Calls team will be notified with tracing details. |
| 62 | </Description> |
| 63 | <details className="cursor-pointer"> |
| 64 | <summary className="text-sm text-zinc-500 dark:text-zinc-400"> |
| 65 | Debug Info (included automatically) |
| 66 | </summary> |
| 67 | <div className="space-y-4"> |
| 68 | {/* Empty div so the button gets padding top from stack */} |
| 69 | <div></div> |
| 70 | <Button |
| 71 | className="text-sm" |
| 72 | onClick={() => { |
| 73 | copy(infoString) |
| 74 | }} |
| 75 | > |
| 76 | {copied ? 'Copied!' : 'Copy'} |
| 77 | </Button> |
| 78 | <TextArea rows={10} readOnly defaultValue={infoString}></TextArea> |
| 79 | </div> |
| 80 | </details> |
| 81 | |
| 82 | <Form method="post" action="/api/bugReport"> |
| 83 | <div className="space-y-4"> |
| 84 | <Label className="font-bold">Description</Label> |
| 85 | <TextArea name="description" rows={8}></TextArea> |
| 86 | </div> |
| 87 | <input name="info" type="hidden" value={JSON.stringify(info)} /> |
| 88 | <Button |
| 89 | className="mt-4 text-sm" |
| 90 | type="submit" |
| 91 | disabled={state === 'submitting'} |
| 92 | > |
nothing calls this directly
no test coverage detected