Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import * as L from 'partial.lenses';
  2. import * as R from 'ramda';
  3.  
  4. const cardTypes = {
  5.   INSTAGRAM: {
  6.     title: 'follow us on instagram',
  7.     body:
  8.       'Check out our Instagram for the latest Somnia Amor information and news.',
  9.     icon: 'whatshot',
  10.     href: 'https://www.instagram.com/',
  11.   },
  12.   ABOUT: {
  13.     title: 'learn about our process',
  14.     body:
  15.       'If you have any questions about what we do, check the about page.',
  16.     icon: 'local_library',
  17.     link: '/landing/home',
  18.   },
  19.   WELCOME: {
  20.     title: 'welcome to somnia amor!',
  21.     body:
  22.       'Create your profile to start getting matched with awesome people.',
  23.     icon: 'mood',
  24.     link: '/dashboard/profile',
  25.   },
  26.   REQUEST_MATCHMAKER: {
  27.     title: 'enough typing, lets talk!',
  28.     body:
  29.       'Book an appointment to speak on the phone with one of our expert matchmakers.',
  30.     icon: 'mood',
  31.   },
  32.   MATCHMAKER_REQUESTED: {
  33.     title: 'stay tuned!',
  34.     body:
  35.       'You should recieve an email from one of our expert matchmakers shortly.',
  36.     icon: 'check',
  37.     color: 'green',
  38.   },
  39.   MATCHMAKER_ASSIGNED: {
  40.     title: 'meet your matchmaker!',
  41.     body:
  42.       'Check out your new matchmaker\'s contact details and more.',
  43.     icon: 'new_releases',
  44.   },
  45.   MATCHMAKER: {
  46.     title: 'your matchmaker',
  47.   },
  48. };
  49.  
  50. const populateNotifications = types => user => L.modify(
  51.   ['notifications', L.elems],
  52.   notification => R.pipe(
  53.     R.assoc('type', notification),
  54.     R.ifElse(
  55.       R.pipe(
  56.         R.prop('type'),
  57.         R.equals('MATCHMAKER'),
  58.       ),
  59.       x => R.mergeLeft(
  60.         R.pick(
  61.           ['email', 'firstName', 'lastName', 'bio', 'avatar'],
  62.           user.matchmaker,
  63.         ),
  64.         x,
  65.       ),
  66.       x => x,
  67.     ),
  68.   )(types[notification]),
  69. )(user);
  70.  
  71. const populateUser = user => populateNotifications(cardTypes)(user);
  72.  
  73. // NOTE: these are ordered by increasing permission level:
  74. const userRoles = ['CLIENT', 'MATCHMAKER', 'ADMIN'];
  75.  
  76. const getPermissionLevel = roles => role => roles.indexOf(role);
  77. const getPermissionLevel$ = getPermissionLevel(userRoles);
  78.  
  79. export {
  80.   populateUser,
  81.   getPermissionLevel$ as getPermissionLevel,
  82. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement