@@ -90,10 +90,12 @@ export default function Charts() {
90
90
</ Box >
91
91
) ;
92
92
}
93
-
93
+ type Fields = {
94
+ chartTitle : string ;
95
+ } ;
94
96
function LocalCharts ( ) {
95
97
const { setShowing } = useContext ( AppContext ) ;
96
- const { watch, register, handleSubmit } = useForm ( ) ;
98
+ const { watch, register, handleSubmit } = useForm < Fields > ( ) ;
97
99
const title = watch ( "chartTitle" ) ;
98
100
const [ charts , setCharts ] = useState < string [ ] > ( [ ] ) ;
99
101
const { push } = useHistory ( ) ;
@@ -103,7 +105,7 @@ function LocalCharts() {
103
105
const [ copy , setCopy ] = useState ( "" ) ;
104
106
105
107
const onSubmit = useCallback (
106
- ( { chartTitle } : { chartTitle : string } ) => {
108
+ ( { chartTitle } : Fields ) => {
107
109
if ( chartTitle ) {
108
110
push ( `/${ chartTitle } ` ) ;
109
111
setShowing ( "editor" ) ;
@@ -341,7 +343,9 @@ function CopyChart({
341
343
</ Dialog >
342
344
) ;
343
345
}
344
-
346
+ type CreateNewFields = {
347
+ name : string ;
348
+ } ;
345
349
function HostedCharts ( ) {
346
350
const validSponsor = useIsValidSponsor ( ) ;
347
351
const { session, setShowing } = useContext ( AppContext ) ;
@@ -356,10 +360,11 @@ function HostedCharts() {
356
360
} ,
357
361
} ) ;
358
362
const { data : charts } = useCharts ( ) ;
359
- const { register, watch, handleSubmit } = useForm ( ) ;
363
+ const { register, watch, handleSubmit } = useForm < CreateNewFields > ( ) ;
360
364
const name = watch ( "name" ) ;
365
+
361
366
const onSubmit = useCallback (
362
- ( { name } : { name : string } ) => {
367
+ ( { name } : CreateNewFields ) => {
363
368
session ?. user ?. id && mutate ( { name, user_id : session ?. user ?. id } ) ;
364
369
} ,
365
370
[ mutate , session ?. user ?. id ]
@@ -478,15 +483,17 @@ function CopyHostedChart({
478
483
</ Dialog >
479
484
) ;
480
485
}
481
-
486
+ type CopyHostedFields = {
487
+ name : string ;
488
+ } ;
482
489
function CopyHostedChartInner ( {
483
490
isOpen,
484
491
onDismiss,
485
492
} : {
486
493
isOpen : boolean | number ;
487
494
onDismiss : ( ) => void ;
488
495
} ) {
489
- const { register, handleSubmit, watch } = useForm ( ) ;
496
+ const { register, handleSubmit, watch } = useForm < CopyHostedFields > ( ) ;
490
497
const copyName = watch ( "name" ) ;
491
498
const { push } = useHistory ( ) ;
492
499
const newChart = useMutation ( "makeChart" , makeChart , {
@@ -500,7 +507,8 @@ function CopyHostedChartInner({
500
507
typeof isOpen === "number" ? isOpen . toString ( ) : undefined
501
508
) ;
502
509
const { session } = useContext ( AppContext ) ;
503
- function onSubmit ( { name } : { name : string } ) {
510
+
511
+ function onSubmit ( { name } : CopyHostedFields ) {
504
512
if ( chart && session ?. user ?. id ) {
505
513
newChart . mutate ( {
506
514
name,
0 commit comments