@@ -71,12 +71,6 @@ function Metrics() {
7171 setSelectedMetrics ( allMetrics ) ;
7272 } ;
7373
74- /**
75- * Closes the dropdown if the click event target does not have a parent
76- * element with the class "dropdown".
77- *
78- * @param {MouseEvent } event - The click event.
79- */
8074 const closeDropdownOnOutsideClick = ( event : MouseEvent ) => {
8175 if ( ! ( event . target as Element ) . closest ( ".dropdown" ) ) {
8276 setIsDropdownOpen ( false ) ;
@@ -181,13 +175,6 @@ function Metrics() {
181175 "Words" : 0 ,
182176 } ) ;
183177
184- /**
185- * Sends a POST request to the specified route with the provided text data.
186- * @param metricType The name of the metric to update in the metricResponses signal.
187- * @param route The API route to send the request to.
188- * @returns Promise<void>
189- * @throws Error if the network response is not ok.
190- */
191178 async function postData ( metricType : string , route : string ) : Promise < void > {
192179 const text : string = ( document . querySelector ( "textarea" ) as HTMLTextAreaElement ) . value ;
193180 const endpoint : string = `https://readability-jl-api.onrender.com/${ route } ` ;
@@ -261,13 +248,17 @@ function Metrics() {
261248 }
262249
263250 function downloadMetrics ( ) {
264- const data : { [ key : string ] : number } = metricResponses ( ) ;
251+ const data = metricResponses ( ) ;
265252 const csvContent =
266253 "data:text/csv;charset=utf-8," +
267254 "metric,value\n" +
268255 Object . keys ( data )
269256 . map ( ( key ) => {
270- return `${ key } ,${ data [ key ] } ` ;
257+ let formattedValue : string | number = data [ key ] ;
258+ if ( key === "Average Reading Time" || key === "Average Speaking Time" ) {
259+ formattedValue = `${ formattedValue } seconds` ;
260+ }
261+ return `${ key } ,${ formattedValue } ` ;
271262 } )
272263 . join ( "\n" ) ;
273264 const encodedUri = encodeURI ( csvContent ) ;
0 commit comments