-
Notifications
You must be signed in to change notification settings - Fork 355
/
ProfileContainer.tsx
64 lines (58 loc) · 1.87 KB
/
ProfileContainer.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { isUndefined } from "lodash";
import React from "react";
import { graphql } from "react-relay";
import { withFragmentContainer } from "coral-framework/lib/relay";
import { ProfileContainer_settings as SettingsData } from "coral-stream/__generated__/ProfileContainer_settings.graphql";
import { ProfileContainer_story as StoryData } from "coral-stream/__generated__/ProfileContainer_story.graphql";
import { ProfileContainer_viewer as ViewerData } from "coral-stream/__generated__/ProfileContainer_viewer.graphql";
import Profile from "./Profile";
interface ProfileContainerProps {
viewer: ViewerData;
settings: SettingsData;
story: StoryData;
}
export class ProfileContainer extends React.Component<ProfileContainerProps> {
public render() {
const ssoProfile = this.props.viewer.profiles.find(
(profile) => profile.__typename === "SSOProfile"
);
return (
<Profile
viewer={this.props.viewer}
story={this.props.story}
settings={this.props.settings}
isSSO={!isUndefined(ssoProfile)}
ssoURL={this.props.viewer.ssoURL}
/>
);
}
}
const enhanced = withFragmentContainer<ProfileContainerProps>({
story: graphql`
fragment ProfileContainer_story on Story {
...MyCommentsContainer_story
}
`,
viewer: graphql`
fragment ProfileContainer_viewer on User {
...UserBoxContainer_viewer
...AccountSettingsContainer_viewer
...MyCommentsContainer_viewer
...DeletionRequestCalloutContainer_viewer
...PreferencesContainer_viewer
profiles {
__typename
}
ssoURL
}
`,
settings: graphql`
fragment ProfileContainer_settings on Settings {
...UserBoxContainer_settings
...AccountSettingsContainer_settings
...MyCommentsContainer_settings
...PreferencesContainer_settings
}
`,
})(ProfileContainer);
export default enhanced;