@@ -7,14 +7,15 @@ import { Button, ButtonStretch, ButtonVariant } from '../button';
7
7
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs' ;
8
8
import theme from '../../../theme' ;
9
9
import PresetsContent from './Presets' ;
10
- import { SearchForm } from './SearchForm ' ;
11
- import { PresetType } from '../displayFilter/ComparePopover ' ;
10
+ import { PresetType } from '../displayFilter/AddNewFieldPopover ' ;
11
+ import { AddNewDisplayFilterForm } from './AddNewDisplayFilterForm ' ;
12
12
13
13
export interface DateManagerProps {
14
14
presets : PresetType [ ] ;
15
- compare : ( { alias, value } : { alias : string ; value : number } ) => void ;
15
+ addClickedHandler : ( { alias, value } : { alias : string ; value : number } ) => void ;
16
16
close : ( ) => void ;
17
17
loading : boolean ;
18
+ oldReferenceName : string ;
18
19
}
19
20
20
21
const formattedDate = (
@@ -24,7 +25,13 @@ const formattedDate = (
24
25
return `${ dayjs ( date ) . format ( 'YYYY-MM-DD' ) } ${ dayjs ( hour ) . format ( 'HH:mm:ss' ) } ` ;
25
26
} ;
26
27
27
- export const DateManager = ( { presets, compare, close, loading } : DateManagerProps ) => {
28
+ export const DateManager = ( {
29
+ presets,
30
+ addClickedHandler,
31
+ close,
32
+ loading,
33
+ oldReferenceName,
34
+ } : DateManagerProps ) => {
28
35
const defaultDisplayName = `as of ${ dayjs ( ) . format ( 'YYYY-MM-DD' ) } ${ dayjs ( ) . format ( 'HH:mm:ss' ) } ` ;
29
36
30
37
const [ date , setDate ] = useState < null | Dayjs > ( dayjs ( ) ) ;
@@ -38,7 +45,7 @@ export const DateManager = ({ presets, compare, close, loading }: DateManagerPro
38
45
useEffect ( ( ) => {
39
46
const value = formattedDate ( date , hour ) ;
40
47
if ( ! displayNameTouched ) {
41
- setDisplayName ( `as of ${ value } ` ) ;
48
+ setDisplayName ( `copy of ${ oldReferenceName } ` ) ;
42
49
}
43
50
setValue ( dayjs ( value ) . unix ( ) ) ;
44
51
} , [ hour , date ] ) ;
@@ -48,12 +55,12 @@ export const DateManager = ({ presets, compare, close, loading }: DateManagerPro
48
55
< ThemeProvider theme = { theme } >
49
56
< Box width = { '530px' } height = { '100%' } color = { '#172D32' } px = { 1 } >
50
57
< Typography component = { 'div' } p = { 1 } variant = { 'mediumBold' } >
51
- Compare to previous version
58
+ Add new field
52
59
</ Typography >
53
60
< Divider sx = { { backgroundColor : '#F8FAFC' } } />
54
61
55
62
< Box display = { 'flex' } >
56
- < SearchForm
63
+ < AddNewDisplayFilterForm
57
64
setErrorDate = { setErrorDate }
58
65
setDisplayName = { setDisplayName }
59
66
setDisplayNameTouched = { setDisplayNameTouched }
@@ -90,11 +97,11 @@ export const DateManager = ({ presets, compare, close, loading }: DateManagerPro
90
97
stretch = { ButtonStretch . Slim }
91
98
variant = { ButtonVariant . Primary }
92
99
onClick = { ( ) => {
93
- compare ( { value , alias : displayName } ) ;
100
+ addClickedHandler ( { alias : displayName , value } ) ;
94
101
close ( ) ;
95
102
} }
96
103
disabled = { ! date || errorDate || loading }
97
- label = { loading ? 'loading...' : 'Search ' }
104
+ label = { loading ? 'loading...' : 'Add Field ' }
98
105
/>
99
106
</ Box >
100
107
</ Box >
0 commit comments