You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.6 KiB

  1. import useJwt from 'auth/jwt/coreUseJwt';
  2. /**
  3. * Return if user is logged in
  4. * This is completely up to you and how you want to store the token in your frontend application
  5. * e.g. If you are using cookies to store the application please update this function
  6. */
  7. // eslint-disable-next-line arrow-body-style
  8. export const hostname = 'localhost';
  9. const hostPort = '8090';
  10. export const hostPath = `http://${hostname}:${hostPort}`;
  11. //export const apiPath = `http://192.168.0.112:8090/api`;
  12. export const apiPath = `${hostPath}/api`;
  13. // export const apiPath = `/api`;
  14. export const paymentPath = `http://pnspsdev.gld.gov.hk/payment`;
  15. export const iAmSmartPath = `https://<iAM_Smart_domain>`;
  16. export const isUserLoggedIn = () => {
  17. return localStorage.getItem('userData') && localStorage.getItem(useJwt.jwtConfig.storageTokenKeyName);
  18. };
  19. export const getUserData = () => JSON.parse(localStorage.getItem('userData'));
  20. /**
  21. * This function is used for demo purpose route navigation
  22. * In real app you won't need this function because your app will navigate to same route for each users regardless of ability
  23. * Please note role field is just for showing purpose it's not used by anything in frontend
  24. * We are checking role just for ease
  25. * NOTE: If you have different pages to navigate based on user ability then this function can be useful. However, you need to update it.
  26. * @param {String} userRole Role of user
  27. */
  28. export const getHomeRouteForLoggedInUser = (userRole) => {
  29. if (userRole === 'admin') return '/';
  30. if (userRole === 'user') return '/';
  31. if (userRole === 'client') return { name: 'access-control' };
  32. return { name: 'auth-login' };
  33. };