@@ -43,7 +43,6 @@ function UsageView({ attributionId }: UsageViewProps) {
43
43
const [ endDate , setEndDate ] = useState ( dayjs ( ) ) ;
44
44
const supportedClasses = useWorkspaceClasses ( ) ;
45
45
const location = useLocation ( ) ;
46
- const usageDownload = useFeatureFlag ( "usageDownload" ) ;
47
46
48
47
useEffect ( ( ) => {
49
48
const match = / # ( \d { 4 } - \d { 2 } - \d { 2 } ) : ( \d { 4 } - \d { 2 } - \d { 2 } ) / . exec ( location . hash ) ;
@@ -145,14 +144,10 @@ function UsageView({ attributionId }: UsageViewProps) {
145
144
< >
146
145
< Header title = "Usage" subtitle = "Organization usage, updated every 15 minutes." />
147
146
< div className = "app-container pt-5" >
148
- { usageDownload && (
149
- < div className = "flex justify-end mb-4" >
150
- < DownloadUsage attributionId = { attributionId } startDate = { startDate } endDate = { endDate } />
151
- </ div >
152
- ) }
153
147
{ errorMessage && < p className = "text-base" > { errorMessage } </ p > }
154
148
155
149
< UsageToolbar
150
+ attributionId = { attributionId }
156
151
startDate = { startDate }
157
152
endDate = { endDate }
158
153
onStartDateChange = { setStartDate }
@@ -305,12 +300,21 @@ export default UsageView;
305
300
306
301
// TODO: move these into the `/usage` folder once the export as csv feature is merged into this
307
302
type UsageToolbarProps = {
303
+ attributionId : AttributionId ;
308
304
startDate : Dayjs ;
309
305
endDate : Dayjs ;
310
306
onStartDateChange : ( val : Dayjs ) => void ;
311
307
onEndDateChange : ( val : Dayjs ) => void ;
312
308
} ;
313
- const UsageToolbar : FC < UsageToolbarProps > = ( { startDate, endDate, onStartDateChange, onEndDateChange } ) => {
309
+ const UsageToolbar : FC < UsageToolbarProps > = ( {
310
+ attributionId,
311
+ startDate,
312
+ endDate,
313
+ onStartDateChange,
314
+ onEndDateChange,
315
+ } ) => {
316
+ const usageDownload = useFeatureFlag ( "usageDownload" ) ;
317
+
314
318
const handleRangeChanged = useCallback (
315
319
( start : Dayjs , end : Dayjs ) => {
316
320
onStartDateChange ( start ) ;
@@ -322,38 +326,45 @@ const UsageToolbar: FC<UsageToolbarProps> = ({ startDate, endDate, onStartDateCh
322
326
return (
323
327
< div
324
328
className = { classNames (
325
- "flex items-start flex-col space-y-3 px-3" ,
326
- "sm :flex-row sm :items-center sm :space-x-4 sm :space-y-0" ,
329
+ "flex flex-col items-start space-y-3 justify-between px-3" ,
330
+ "md :flex-row md :items-center md :space-x-4 md :space-y-0" ,
327
331
) }
328
332
>
329
- < UsageDateRangePicker onChange = { handleRangeChanged } />
330
-
331
- < div className = "flex items-center space-x-1" >
332
- < DatePicker
333
- selected = { startDate . toDate ( ) }
334
- onChange = { ( date ) => date && onStartDateChange ( dayjs ( date ) ) }
335
- selectsStart
336
- startDate = { startDate . toDate ( ) }
337
- endDate = { endDate . toDate ( ) }
338
- maxDate = { endDate . toDate ( ) }
339
- customInput = { < DateDisplay /> }
340
- dateFormat = { "MMM d, yyyy" }
341
- // tab loop enabled causes a bug w/ layout shift to the right of input when open
342
- enableTabLoop = { false }
343
- />
344
- < Subheading > to</ Subheading >
345
- < DatePicker
346
- selected = { endDate . toDate ( ) }
347
- onChange = { ( date ) => date && onEndDateChange ( dayjs ( date ) ) }
348
- selectsEnd
349
- startDate = { startDate . toDate ( ) }
350
- endDate = { endDate . toDate ( ) }
351
- minDate = { startDate . toDate ( ) }
352
- customInput = { < DateDisplay /> }
353
- dateFormat = { "MMM d, yyyy" }
354
- enableTabLoop = { false }
355
- />
333
+ < div
334
+ className = { classNames (
335
+ "flex flex-col items-start space-y-3" ,
336
+ "sm:flex-row sm:items-center sm:space-x-4 sm:space-y-0" ,
337
+ ) }
338
+ >
339
+ < UsageDateRangePicker onChange = { handleRangeChanged } />
340
+ < div className = "flex items-center space-x-1" >
341
+ < DatePicker
342
+ selected = { startDate . toDate ( ) }
343
+ onChange = { ( date ) => date && onStartDateChange ( dayjs ( date ) ) }
344
+ selectsStart
345
+ startDate = { startDate . toDate ( ) }
346
+ endDate = { endDate . toDate ( ) }
347
+ maxDate = { endDate . toDate ( ) }
348
+ customInput = { < DateDisplay /> }
349
+ dateFormat = { "MMM d, yyyy" }
350
+ // tab loop enabled causes a bug w/ layout shift to the right of input when open
351
+ enableTabLoop = { false }
352
+ />
353
+ < Subheading > to</ Subheading >
354
+ < DatePicker
355
+ selected = { endDate . toDate ( ) }
356
+ onChange = { ( date ) => date && onEndDateChange ( dayjs ( date ) ) }
357
+ selectsEnd
358
+ startDate = { startDate . toDate ( ) }
359
+ endDate = { endDate . toDate ( ) }
360
+ minDate = { startDate . toDate ( ) }
361
+ customInput = { < DateDisplay /> }
362
+ dateFormat = { "MMM d, yyyy" }
363
+ enableTabLoop = { false }
364
+ />
365
+ </ div >
356
366
</ div >
367
+ { usageDownload && < DownloadUsage attributionId = { attributionId } startDate = { startDate } endDate = { endDate } /> }
357
368
</ div >
358
369
) ;
359
370
} ;
0 commit comments