1
1
import React from "react"
2
- import { createFragmentContainer , graphql } from "react-relay"
2
+ import { graphql } from "react-relay"
3
3
4
- import { ArtistConsignButton_artist } from "v2/__generated__/ArtistConsignButton_artist.graphql"
4
+ import {
5
+ ArtistConsignButton_artist ,
6
+ ArtistConsignButton_artist$key ,
7
+ } from "v2/__generated__/ArtistConsignButton_artist.graphql"
5
8
import { RouterLink } from "v2/Artsy/Router/RouterLink"
6
9
import { Media } from "v2/Utils/Responsive"
7
10
@@ -15,14 +18,35 @@ import {
15
18
color ,
16
19
} from "@artsy/palette"
17
20
import { AnalyticsSchema , useTracking } from "v2/Artsy"
21
+ import { useFragment } from "relay-hooks"
18
22
19
23
export interface ArtistConsignButtonProps {
20
- artist : ArtistConsignButton_artist
24
+ artist : ArtistConsignButton_artist$key
21
25
}
22
26
23
- export const ArtistConsignButton : React . FC < ArtistConsignButtonProps > = ( {
24
- artist,
25
- } ) => {
27
+ export const ArtistConsignButton : React . FC < ArtistConsignButtonProps > = props => {
28
+ const artist = useFragment < ArtistConsignButton_artist$key > (
29
+ graphql `
30
+ fragment ArtistConsignButton_artist on Artist {
31
+ targetSupply {
32
+ isInMicrofunnel
33
+ isTargetSupply
34
+ }
35
+
36
+ internalID
37
+ slug
38
+ name
39
+ href
40
+ image {
41
+ cropped(width: 66, height: 66) {
42
+ url
43
+ }
44
+ }
45
+ }
46
+ ` ,
47
+ props . artist
48
+ )
49
+
26
50
const tracking = useTracking ( )
27
51
28
52
const trackGetStartedClick = ( { destinationPath } ) => {
@@ -38,15 +62,18 @@ export const ArtistConsignButton: React.FC<ArtistConsignButtonProps> = ({
38
62
} )
39
63
}
40
64
41
- const props = { artist, trackGetStartedClick }
65
+ const passedProps = {
66
+ artist,
67
+ trackGetStartedClick,
68
+ }
42
69
43
70
return (
44
71
< >
45
72
< Media at = "xs" >
46
- < ArtistConsignButtonSmall { ...props } />
73
+ < ArtistConsignButtonSmall { ...passedProps } />
47
74
</ Media >
48
75
< Media greaterThan = "xs" >
49
- < ArtistConsignButtonLarge { ...props } />
76
+ < ArtistConsignButtonLarge { ...passedProps } />
50
77
</ Media >
51
78
</ >
52
79
)
@@ -56,9 +83,11 @@ interface Tracking {
56
83
trackGetStartedClick : ( props : { destinationPath : string } ) => void
57
84
}
58
85
59
- export const ArtistConsignButtonLarge : React . FC <
60
- ArtistConsignButtonProps & Tracking
61
- > = props => {
86
+ interface Props extends Tracking {
87
+ artist : ArtistConsignButton_artist
88
+ }
89
+
90
+ export const ArtistConsignButtonLarge : React . FC < Props > = props => {
62
91
const { showImage, imageURL, headline, consignURL } = getData ( props )
63
92
64
93
return (
@@ -105,9 +134,7 @@ export const ArtistConsignButtonLarge: React.FC<
105
134
)
106
135
}
107
136
108
- export const ArtistConsignButtonSmall : React . FC <
109
- ArtistConsignButtonProps & Tracking
110
- > = props => {
137
+ export const ArtistConsignButtonSmall : React . FC < Props > = props => {
111
138
const { showImage, imageURL, headline, consignURL } = getData ( props )
112
139
113
140
return (
@@ -169,27 +196,3 @@ function getData(props) {
169
196
consignURL,
170
197
}
171
198
}
172
-
173
- export const ArtistConsignButtonFragmentContainer = createFragmentContainer (
174
- ArtistConsignButton ,
175
- {
176
- artist : graphql `
177
- fragment ArtistConsignButton_artist on Artist {
178
- targetSupply {
179
- isInMicrofunnel
180
- isTargetSupply
181
- }
182
-
183
- internalID
184
- slug
185
- name
186
- href
187
- image {
188
- cropped(width: 66, height: 66) {
189
- url
190
- }
191
- }
192
- }
193
- ` ,
194
- }
195
- )
0 commit comments