File size: 912 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// @flow
import React from 'react';
import compose from 'recompose/compose';
import Thread from './thread';

const ProfilePure = (props: Object): ?React$Element<any> => {
  const { type } = props;
  switch (type) {
    case 'thread': {
      return <Thread {...props} />;
    }
    default: {
      return null;
    }
  }
};

export type ProfileSizeProps =
  | 'mini'
  | 'full'
  | 'miniWithAction'
  | 'upsell'
  | 'simple'
  | 'listItemWithAction';

type ProfileProps = {
  data: Object,
  profileSize?: ProfileSizeProps,
};

/*
  Create exportables which just wrap a type prop, so in the UI we can Write
  <UserProfile /> and this file will handle the type declaration, which will
  then get passed to our switch statement above to return the right component.
*/
export const Profile = compose()(ProfilePure);
export const ThreadProfile = (props: ProfileProps) => (
  <Profile type="thread" {...props} />
);