|
1 | 1 | <script lang="ts"> |
2 | 2 | import { invoke } from '@tauri-apps/api/core'; |
3 | 3 | import { revealItemInDir } from '@tauri-apps/plugin-opener'; |
4 | | - import { Button } from 'carbon-components-svelte'; |
| 4 | + import { Button, Select, SelectItem } from 'carbon-components-svelte'; |
5 | 5 | import InlineNotification from '../../components/InlineNotification.svelte'; |
6 | 6 | import { invokeIcaCsvToFile, MissingContactError } from '../../lib/cli'; |
7 | 7 |
|
8 | | - const baseFilename = 'transcript.csv'; |
| 8 | + const baseFilename = 'transcript'; |
9 | 9 |
|
10 | 10 | let isExporting = $state(false); |
| 11 | + let format = $state<'csv' | 'xlsx'>('csv'); |
11 | 12 | let errorMessage = $state(''); |
12 | 13 | let successMessage = $state(''); |
13 | 14 | let exportedFilePath = $state(''); |
|
19 | 20 | successMessage = ''; |
20 | 21 |
|
21 | 22 | try { |
| 23 | + const filename = `${baseFilename}.${format}`; |
22 | 24 | const outputPath = await invoke<string>('resolve_download_output_path', { |
23 | | - baseName: baseFilename |
| 25 | + baseName: filename |
24 | 26 | }); |
25 | 27 | await invokeIcaCsvToFile(['transcript'], outputPath); |
26 | 28 | exportedFilePath = outputPath; |
|
54 | 56 | <header> |
55 | 57 | <h2>Transcript</h2> |
56 | 58 | <p class="transcript-export__description"> |
57 | | - Export your full conversation transcript to CSV in Downloads. The filename will be |
58 | | - incremented when needed (for example, transcript-1.csv). |
| 59 | + Export your full conversation transcript in your selected format to Downloads. The |
| 60 | + filename will be incremented when needed (for example, transcript-1.csv). |
59 | 61 | </p> |
60 | 62 | </header> |
61 | 63 |
|
62 | 64 | <form class="transcript-export__form" onsubmit={exportTranscript}> |
| 65 | + <div class="transcript-export__format"> |
| 66 | + <Select labelText="Format" bind:selected={format} disabled={isExporting}> |
| 67 | + <SelectItem value="csv" text="CSV" /> |
| 68 | + <SelectItem value="xlsx" text="Excel" /> |
| 69 | + </Select> |
| 70 | + </div> |
| 71 | + |
63 | 72 | <Button type="submit" kind="primary" disabled={isExporting}> |
64 | | - {isExporting ? 'Exporting…' : 'Export Transcript CSV'} |
| 73 | + {#if isExporting} |
| 74 | + Exporting… |
| 75 | + {:else} |
| 76 | + Export Transcript |
| 77 | + {/if} |
65 | 78 | </Button> |
66 | 79 | </form> |
67 | 80 |
|
|
106 | 119 |
|
107 | 120 | .transcript-export__form { |
108 | 121 | margin-top: 1.5rem; |
| 122 | + display: flex; |
| 123 | + flex-direction: row; |
| 124 | + align-items: flex-end; |
| 125 | + justify-content: center; |
| 126 | + gap: 1rem; |
| 127 | + } |
| 128 | +
|
| 129 | + .transcript-export__format { |
| 130 | + width: 12rem; |
109 | 131 | } |
110 | 132 |
|
111 | 133 | .transcript-export__notification { |
|
0 commit comments