aboutsummaryrefslogtreecommitdiff
path: root/src/client/react/components/presentational/IconFromUserType.tsx
blob: 83af34c7921b235ff44a0696074d23b7a21246c7 (plain)
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
import * as React from 'react';
import StudentIcon = require('react-icons/lib/md/person');
import RoomIcon = require('react-icons/lib/md/room');
import ClassIcon = require('react-icons/lib/md/group');
import TeacherIcon = require('react-icons/lib/md/account-circle');

// interface IconFromUserTypeProps {
//   userType: string,
//   defaultIcon?: JSX.Element,
// }

const IconFromUserType: React.StatelessComponent<{ userType?: string, defaultIcon?: JSX.Element }> = (props) => {
  switch (props.userType) {
    case 'c':
      return <ClassIcon />;
    case 't':
      return <TeacherIcon />;
    case 's':
      return <StudentIcon />;
    case 'r':
      return <RoomIcon />;
    default:
      if (props.defaultIcon) {
        return props.defaultIcon;
      }

      throw new Error('`userType` was invalid or not given, but `defaultIcon` is not defined.');
  }
};

export default IconFromUserType;