@bizzy-phoenix/utils
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("js-cookie"),require("axios")):"function"==typeof define&&define.amd?define(["exports","js-cookie","axios"],e):e(t.utils={},t.Cookies,t.axios)}(this,function(t,e,r){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e,r=r&&r.hasOwnProperty("default")?r.default:r;var o="get",n="post",a="put",u="delete",i=function(t){return null!=t},s=function(t){return i(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.token)?t.state.auth.authUser.token:""},d=function(t){return i(t&&t.auth&&t.auth.authUser&&t.auth.authUser.token)?t.auth.authUser.token:""},h=function(t){return{"Content-Type":"application/json",Authorization:s(t)}},p=function(t){return{"Content-Type":"application/json",Authorization:d(t)}};t.getHeaderToken=h,t.getHeaderTokenDirectFromStore=p,t.__apiGet=function(t,e,n){return r({url:e,method:o,headers:h(t),params:n})},t.__apiGetWithTokenDirectFromStore=function(t,e,n){return r({url:e,method:o,headers:p(t),params:n})},t.__apiGetCustomHeader=function(t,e,n){return r({url:e,method:o,headers:t,params:n})},t.__apiGetNonAuth=function(t,e){return r({url:t,method:o,params:e})},t.__apiPost=function(t,e,o,a){return r({url:e,method:n,headers:h(t),data:o,onUploadProgress:a})},t.__apiPostCustomHeader=function(t,e,o,a){var u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:function(){};return r({url:e,method:n,headers:t,data:o,params:a,onUploadProgress:u})},t.__apiPostNonAuth=function(t,e,o){return r({url:t,method:n,data:e,onUploadProgress:o})},t.__apiPut=function(t,e,o){return r({url:e,method:a,headers:h(t),data:o})},t.__apiPutNonAuth=function(t,e){return r({url:t,method:a,data:e})},t.__apiDelete=function(t,e,o){return r({url:e,method:u,headers:h(t),data:o})},t.__apiDeleteNonAuth=function(t,e){return r({url:t,method:u,data:e})},Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("js-cookie"),require("axios")):"function"==typeof define&&define.amd?define(["exports","js-cookie","axios"],e):e(t.utils={},t.Cookies,t.axios)}(this,function(t,e,r){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e,r=r&&r.hasOwnProperty("default")?r.default:r;var o="get",n="post",a="put",u="delete",i=function(t){return null!=t},s=function(t){return function(t){return!!i(t&&t.state&&t.state.auth&&t.state.auth.authUser)}(t)&&i(t.state.auth.authUser.token)?t.state.auth.authUser.token:""},d=function(t){return i(t&&t.auth&&t.auth.authUser&&t.auth.authUser.token)?t.auth.authUser.token:""},h=function(t){return{"Content-Type":"application/json",Authorization:s(t)}},p=function(t){return{"Content-Type":"application/json",Authorization:d(t)}};t.getHeaderToken=h,t.getHeaderTokenDirectFromStore=p,t.__apiGet=function(t,e,n){return r({url:e,method:o,headers:h(t),params:n})},t.__apiGetWithTokenDirectFromStore=function(t,e,n){return r({url:e,method:o,headers:p(t),params:n})},t.__apiGetCustomHeader=function(t,e,n){return r({url:e,method:o,headers:t,params:n})},t.__apiGetNonAuth=function(t,e){return r({url:t,method:o,params:e})},t.__apiPost=function(t,e,o,a){return r({url:e,method:n,headers:h(t),data:o,onUploadProgress:a})},t.__apiPostCustomHeader=function(t,e,o,a){var u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:function(){};return r({url:e,method:n,headers:t,data:o,params:a,onUploadProgress:u})},t.__apiPostNonAuth=function(t,e,o){return r({url:t,method:n,data:e,onUploadProgress:o})},t.__apiPut=function(t,e,o){return r({url:e,method:a,headers:h(t),data:o})},t.__apiPutNonAuth=function(t,e){return r({url:t,method:a,data:e})},t.__apiDelete=function(t,e,o){return r({url:e,method:u,headers:h(t),data:o})},t.__apiDeleteNonAuth=function(t,e){return r({url:t,method:u,data:e})},Object.defineProperty(t,"__esModule",{value:!0})}); |
@@ -1,1 +0,1 @@ | ||
!function(t,a){"object"==typeof exports&&"undefined"!=typeof module?a(exports,require("js-cookie")):"function"==typeof define&&define.amd?define(["exports","js-cookie"],a):a(t.utils={},t.Cookies)}(this,function(t,a){"use strict";a=a&&a.hasOwnProperty("default")?a.default:a;var e="active-group-id",u=function(t){return null!=t},s=function(t){return u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.user&&t.state.auth.authUser.user.first_name)?t.state.auth.authUser.user.first_name:""},r=function(t){return u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.user&&t.state.auth.authUser.user.last_name)?t.state.auth.authUser.user.last_name:""},h=function(t){return!0===t.requestor},n=function(t){return u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.data_JWT&&t.state.auth.authUser.data_JWT.customer)?t.state.auth.authUser.data_JWT.customer.roles:[]},o=function(t){return!!u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.data_JWT&&t.state.auth.authUser.data_JWT.punchout)&&t.state.auth.authUser.data_JWT.punchout.is_user_punchout},i=function(t){var u=parseInt(a.get(e),10);return u||(u=t.state.auth.loadDataJWT.groupIds),u},d=function(t){return u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.data_JWT&&t.state.auth.authUser.data_JWT.groups)?t.state.auth.authUser.data_JWT.groups:[]};t.getToken=function(t){return u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.token)?t.state.auth.authUser.token:""},t.getTokenDirectFromStore=function(t){return u(t&&t.auth&&t.auth.authUser&&t.auth.authUser.token)?t.auth.authUser.token:""},t.getAddons=function(t){return u(t&&t.state&&t.state.auth&&t.state.auth.addons)?t.state.auth.addons:[]},t.getUsername=function(t){return u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.user&&t.state.auth.authUser.user.username)?t.state.auth.authUser.user.username:""},t.getUserFirstName=s,t.getUserLastName=r,t.getUserFullName=function(t){return"".concat(s(t)," ").concat(r(t))},t.getUserDefaultGroupId=function(t){if(u(t&&t.authUser&&t.authUser.data_JWT)&&(r=t.authUser.data_JWT.groups,u(r)&&r.length>0)){var a=t.authUser.data_JWT.groups,e=a.find(function(t){return function(t){return!0===t.default}(t)&&h(t)});if(u(e&&e.id))return e.id;var s=a.find(function(t){return h(t)});if(u(s&&s.id))return s.id}var r;return!1},t.getCustomerRoles=n,t.getCustomerChannelType=function(t){return u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.data_JWT&&t.state.auth.authUser.data_JWT.customer)?t.state.auth.authUser.data_JWT.customer.channel_type:""},t.getCustomerTopDays=function(t){return u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.data_JWT&&t.state.auth.authUser.data_JWT.customer)?t.state.auth.authUser.data_JWT.customer.top_days:""},t.getCustomerOrganizationID=function(t){return u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.data_JWT&&t.state.auth.authUser.data_JWT.customer)?t.state.auth.authUser.data_JWT.customer.organization_id:""},t.getCustomerPersonID=function(t){return u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.data_JWT&&t.state.auth.authUser.data_JWT.customer)?t.state.auth.authUser.data_JWT.customer.person_id:""},t.getCustomerName=function(t){return u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.data_JWT)?t.state.auth.authUser.data_JWT.username:""},t.getCustomerOrganizationName=function(t){return u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.data_JWT&&t.state.auth.authUser.data_JWT.customer&&t.state.auth.authUser.data_JWT.customer.organization_name)?t.state.auth.authUser.data_JWT.customer.organization_name.trim():""},t.isCustomerSuperAdmin=function(t){return!!u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.data_JWT&&t.state.auth.authUser.data_JWT.customer)&&t.state.auth.authUser.data_JWT.customer.superadmin===t.state.auth.authUser.data_JWT.customer.person_id},t.isPunchOutUser=o,t.isPunchOut=function(t){return!!u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.data_JWT&&t.state.auth.authUser.data_JWT.punchout)&&t.state.auth.authUser.data_JWT.punchout.is_punchout},t.isContract=function(t){return!!u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.data_JWT&&t.state.auth.authUser.data_JWT.customer)&&1===t.state.auth.authUser.data_JWT.customer.has_agreement},t.getActiveGroupId=i,t.getGroups=d,t.getSelectedGroup=function(t){var a=i(t);return d(t).find(function(t){return t.id===a})},t.isSalesAdmin=function(t){return o(t)&&t.state.auth.authUser.data_JWT.punchout.sales_admin_id===t.state.auth.authUser.data_JWT.customer.person_id},t.getCustomerInformation=function(t){return u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.data_JWT&&t.state.auth.authUser.data_JWT.customer)?t.state.auth.authUser.data_JWT.customer:null},t.getCustomerVendorInformation=function(t){return u(t&&t.state&&t.state.auth&&t.state.auth.sellerUser&&t.state.auth.sellerUser.data_JWT&&t.state.auth.sellerUser.data_JWT.customer)?t.state.auth.sellerUser.data_JWT.customer:null},t.isVendor=function(t){return!!u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.data_JWT&&t.state.auth.authUser.data_JWT.customer)&&t.state.auth.authUser.data_JWT.customer.is_vendor},t.isLoggedIn=function(t){return u(t&&t.state&&t.state.auth&&t.state.auth.authUser)},t.loggedAsSellerOnly=function(t){return!t.authUser.data_JWT&&t.sellerUser.data_JWT},t.isCustomerHaveRole=function(t,a){var e=(n(t)||[]).find(function(t){return t.role_id===a});return u(e)},Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("js-cookie")):"function"==typeof define&&define.amd?define(["exports","js-cookie"],e):e(t.utils={},t.Cookies)}(this,function(t,e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;var a="active-group-id",u=function(t){return null!=t},r=function(t){return!!u(t&&t.state&&t.state.auth&&t.state.auth.authUser)},s=function(t){return!(!r(t)||!u(t.state.auth.authUser.data_JWT&&t.state.auth.authUser.data_JWT.customer))},n=function(t){return u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.user&&t.state.auth.authUser.user.first_name)?t.state.auth.authUser.user.first_name:""},o=function(t){return u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.user&&t.state.auth.authUser.user.last_name)?t.state.auth.authUser.user.last_name:""},h=function(t){return!0===t.requestor},i=function(t){return s(t)?t.state.auth.authUser.data_JWT.customer.roles:[]},c=function(t){return s(t)?t.state.auth.authUser.data_JWT.customer.organization_id:""},d=function(t){return!!u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.data_JWT&&t.state.auth.authUser.data_JWT.punchout)&&t.state.auth.authUser.data_JWT.punchout.is_user_punchout},U=function(t){var u=parseInt(e.get(a),10);return u||(u=t.state.auth.loadDataJWT.groupIds),u},f=function(t){return!(!s(t)||!u(t.state.auth.authUser.data_JWT.customer.is_parent))&&t.state.auth.authUser.data_JWT.customer.is_parent},_=function(t){return s(t)?t.state.auth.authUser.data_JWT.customer.parent_id:""};t.getToken=function(t){return r(t)&&u(t.state.auth.authUser.token)?t.state.auth.authUser.token:""},t.getTokenDirectFromStore=function(t){return u(t&&t.auth&&t.auth.authUser&&t.auth.authUser.token)?t.auth.authUser.token:""},t.getAddons=function(t){return u(t&&t.state&&t.state.auth&&t.state.auth.addons)?t.state.auth.addons:[]},t.getUsername=function(t){return u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.user&&t.state.auth.authUser.user.username)?t.state.auth.authUser.user.username:""},t.getUserFirstName=n,t.getUserLastName=o,t.getUserFullName=function(t){return"".concat(n(t)," ").concat(o(t))},t.getUserDefaultGroupId=function(t){if(u(t&&t.authUser&&t.authUser.data_JWT)&&(s=t.authUser.data_JWT.groups,u(s)&&s.length>0)){var e=t.authUser.data_JWT.groups,a=e.find(function(t){return function(t){return!0===t.default}(t)&&h(t)});if(u(a&&a.id))return a.id;var r=e.find(function(t){return h(t)});if(u(r&&r.id))return r.id}var s;return!1},t.getCustomerRoles=i,t.getCustomerChannelType=function(t){return s(t)?t.state.auth.authUser.data_JWT.customer.channel_type:""},t.getCustomerTopDays=function(t){return s(t)?t.state.auth.authUser.data_JWT.customer.top_days:""},t.getCustomerOrganizationID=c,t.getCustomerPersonID=function(t){return s(t)?t.state.auth.authUser.data_JWT.customer.person_id:""},t.getCustomerUsername=function(t){return u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.data_JWT&&t.state.auth.authUser.data_JWT.username)?t.state.auth.authUser.data_JWT.username:""},t.getCustomerOrganizationName=function(t){return s(t)&&u(t.state.auth.authUser.data_JWT.customer.organization_name)?t.state.auth.authUser.data_JWT.customer.organization_name.trim():""},t.isCustomerSuperAdmin=function(t){return!!s(t)&&t.state.auth.authUser.data_JWT.customer.superadmin===t.state.auth.authUser.data_JWT.customer.person_id},t.isPunchOutUser=d,t.isPunchOut=function(t){return!!u(t&&t.state&&t.state.auth&&t.state.auth.authUser&&t.state.auth.authUser.data_JWT&&t.state.auth.authUser.data_JWT.punchout)&&t.state.auth.authUser.data_JWT.punchout.is_punchout},t.isContract=function(t){return 1===t.state.auth.authUser.data_JWT.customer.has_agreement},t.getActiveGroupId=U,t.getSelectedGroup=function(t){var e=U(t);return t.state.auth.authUser.data_JWT.groups.find(function(t){return t.id===e})},t.isSalesAdmin=function(t){return d(t)&&t.state.auth.authUser.data_JWT.punchout.sales_admin_id===t.state.auth.authUser.data_JWT.customer.person_id},t.getCustomerInformation=function(t){return!!s(t)&&t.state.auth.authUser.data_JWT.customer},t.getCustomerVendorInformation=function(t){return!!u(t.state.auth.sellerUser&&t.state.auth.sellerUser.data_JWT&&t.state.auth.sellerUser.data_JWT.customer)&&t.state.auth.sellerUser.data_JWT.customer},t.isLoggedIn=function(t){return u(t.state.auth.authUser)},t.isVendor=function(t){return!(!s(t)||!u(t.state.auth.authUser.data_JWT.customer.is_vendor))&&t.state.auth.authUser.data_JWT.customer.is_vendor},t.isParent=f,t.getCustomerParentOrganizationID=_,t.isAccountCompanySwitched=function(t){return f(t)&&c(t)!==_(t)},t.loggedAsSellerOnly=function(t){return!t.authUser.data_JWT&&t.sellerUser.data_JWT},t.isCustomerHaveRole=function(t,e){var a=(i(t)||[]).find(function(t){return t.role_id===e});return u(a)},Object.defineProperty(t,"__esModule",{value:!0})}); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.utils={})}(this,function(e){"use strict";var t=function(e){return null!=e};e.__isNotNull=t,e.__isNotEmptyString=function(e){return!(!t(e)||""===e)},e.__isNotEmptyArray=function(e){return!!(t(e)&&e.length>0)},e.__isFunction=function(e){return!(!t(e)||"function"!=typeof e)},e.__slugify=function(e){return null===e||""===e?"":e.toString().toLowerCase().trim().replace(" / "," ").replace(" & ","-").replace(/ /g,"-").replace(/--/g,"-").replace(/[^\w.]/g,"-").replace(/--/g,"-").replace(/-_/g,"_")},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.utils={})}(this,function(t){"use strict";function e(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var u,c=t[Symbol.iterator]();!(r=(u=c.next()).done)&&(n.push(u.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==c.return||c.return()}finally{if(o)throw i}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var n=function(t){return null!=t};t.__isNotNull=n,t.__isNotEmptyString=function(t){return!(!n(t)||""===t)},t.__isNotEmptyArray=function(t){return!!(n(t)&&t.length>0)},t.__isFunction=function(t){return!(!n(t)||"function"!=typeof t)},t.__slugify=function(t){return null===t||""===t?"":t.toString().toLowerCase().trim().replace(" / "," ").replace(" & ","-").replace(/ /g,"-").replace(/--/g,"-").replace(/[^\w.]/g,"-").replace(/--/g,"-").replace(/-_/g,"_")},t.__createQueryString=function(t){return"?".concat(Object.entries(t).map(function(t){var n=e(t,2),r=n[0],o=n[1];return"".concat(encodeURIComponent(r),"=").concat(encodeURIComponent(o))}).join("&"))},t.__cloneDeep=function(t){return JSON.parse(JSON.stringify(t))},t.__categoryParser=function(t){var e={id:null,type:null};try{var n=t.split(".");return e.id=Number(n[n.length-1]),n=n[0].split("_"),e.type=n[n.length-1],e}catch(t){return e}},Object.defineProperty(t,"__esModule",{value:!0})}); |
{ | ||
"name": "@bizzy-phoenix/utils", | ||
"author": "Bizzy Indonesia", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Helper collections for Bizzy Phoenix projects - Part of Bizzy Common Web", | ||
@@ -22,3 +22,3 @@ "license": "Apache-2.0", | ||
}, | ||
"gitHead": "bb4393d12bb491e546029273b166c994b99367c9" | ||
"gitHead": "fc4869a0658c28471b48f6f83578fc0ab11da26c" | ||
} |
@@ -69,3 +69,3 @@ # @bizzy-phoenix/utils | ||
| `getCustomerPersonID` | `$store` | | ||
| `getCustomerName` | `$store` | | ||
| `getCustomerUsername` | `$store` | | ||
| `getCustomerOrganizationName` | `$store` | | ||
@@ -86,2 +86,3 @@ | `isCustomerSuperAdmin` | `$store` | | ||
| `isCustomerHaveRole` | `$store` | | ||
| `isAccountCompanySwitched` | `$store` | | ||
@@ -88,0 +89,0 @@ |
169
src/auth.js
@@ -8,9 +8,25 @@ import Cookies from 'js-cookie'; | ||
export const getToken = ($store) => { | ||
const isNotEmptyAuthUser = ($store) => { | ||
if (__isNotNull($store | ||
&& $store.state | ||
&& $store.state.auth | ||
&& $store.state.auth.authUser | ||
&& $store.state.auth.authUser.token) | ||
&& $store.state.auth.authUser) | ||
) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
const isNotEmptyCustomer = ($store) => { | ||
if (isNotEmptyAuthUser($store) | ||
&& __isNotNull($store.state.auth.authUser.data_JWT | ||
&& $store.state.auth.authUser.data_JWT.customer) | ||
) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
export const getToken = ($store) => { | ||
if (isNotEmptyAuthUser($store) && __isNotNull($store.state.auth.authUser.token)) { | ||
return $store.state.auth.authUser.token; | ||
@@ -109,9 +125,3 @@ } | ||
export const getCustomerRoles = ($store) => { | ||
if (__isNotNull($store | ||
&& $store.state | ||
&& $store.state.auth | ||
&& $store.state.auth.authUser | ||
&& $store.state.auth.authUser.data_JWT | ||
&& $store.state.auth.authUser.data_JWT.customer) | ||
) { | ||
if (isNotEmptyCustomer($store)) { | ||
return $store.state.auth.authUser.data_JWT.customer.roles; | ||
@@ -123,9 +133,3 @@ } | ||
export const getCustomerChannelType = ($store) => { | ||
if (__isNotNull($store | ||
&& $store.state | ||
&& $store.state.auth | ||
&& $store.state.auth.authUser | ||
&& $store.state.auth.authUser.data_JWT | ||
&& $store.state.auth.authUser.data_JWT.customer) | ||
) { | ||
if (isNotEmptyCustomer($store)) { | ||
return $store.state.auth.authUser.data_JWT.customer.channel_type; | ||
@@ -137,9 +141,3 @@ } | ||
export const getCustomerTopDays = ($store) => { | ||
if (__isNotNull($store | ||
&& $store.state | ||
&& $store.state.auth | ||
&& $store.state.auth.authUser | ||
&& $store.state.auth.authUser.data_JWT | ||
&& $store.state.auth.authUser.data_JWT.customer) | ||
) { | ||
if (isNotEmptyCustomer($store)) { | ||
return $store.state.auth.authUser.data_JWT.customer.top_days; | ||
@@ -151,9 +149,3 @@ } | ||
export const getCustomerOrganizationID = ($store) => { | ||
if (__isNotNull($store | ||
&& $store.state | ||
&& $store.state.auth | ||
&& $store.state.auth.authUser | ||
&& $store.state.auth.authUser.data_JWT | ||
&& $store.state.auth.authUser.data_JWT.customer) | ||
) { | ||
if (isNotEmptyCustomer($store)) { | ||
return $store.state.auth.authUser.data_JWT.customer.organization_id; | ||
@@ -165,9 +157,3 @@ } | ||
export const getCustomerPersonID = ($store) => { | ||
if (__isNotNull($store | ||
&& $store.state | ||
&& $store.state.auth | ||
&& $store.state.auth.authUser | ||
&& $store.state.auth.authUser.data_JWT | ||
&& $store.state.auth.authUser.data_JWT.customer) | ||
) { | ||
if (isNotEmptyCustomer($store)) { | ||
return $store.state.auth.authUser.data_JWT.customer.person_id; | ||
@@ -178,3 +164,3 @@ } | ||
export const getCustomerName = ($store) => { | ||
export const getCustomerUsername = ($store) => { | ||
if (__isNotNull($store | ||
@@ -184,3 +170,4 @@ && $store.state | ||
&& $store.state.auth.authUser | ||
&& $store.state.auth.authUser.data_JWT) | ||
&& $store.state.auth.authUser.data_JWT | ||
&& $store.state.auth.authUser.data_JWT.username) | ||
) { | ||
@@ -193,9 +180,4 @@ return $store.state.auth.authUser.data_JWT.username; | ||
export const getCustomerOrganizationName = ($store) => { | ||
if (__isNotNull($store | ||
&& $store.state | ||
&& $store.state.auth | ||
&& $store.state.auth.authUser | ||
&& $store.state.auth.authUser.data_JWT | ||
&& $store.state.auth.authUser.data_JWT.customer | ||
&& $store.state.auth.authUser.data_JWT.customer.organization_name) | ||
if (isNotEmptyCustomer($store) | ||
&& __isNotNull($store.state.auth.authUser.data_JWT.customer.organization_name) | ||
) { | ||
@@ -208,9 +190,3 @@ return $store.state.auth.authUser.data_JWT.customer.organization_name.trim(); | ||
export const isCustomerSuperAdmin = ($store) => { | ||
if (__isNotNull($store | ||
&& $store.state | ||
&& $store.state.auth | ||
&& $store.state.auth.authUser | ||
&& $store.state.auth.authUser.data_JWT | ||
&& $store.state.auth.authUser.data_JWT.customer) | ||
) { | ||
if (isNotEmptyCustomer($store)) { | ||
return $store.state.auth.authUser.data_JWT.customer.superadmin === $store.state.auth.authUser.data_JWT.customer.person_id; | ||
@@ -247,14 +223,3 @@ } | ||
export const isContract = ($store) => { | ||
if (__isNotNull($store | ||
&& $store.state | ||
&& $store.state.auth | ||
&& $store.state.auth.authUser | ||
&& $store.state.auth.authUser.data_JWT | ||
&& $store.state.auth.authUser.data_JWT.customer) | ||
) { | ||
return $store.state.auth.authUser.data_JWT.customer.has_agreement === 1; | ||
} | ||
return false; | ||
}; | ||
export const isContract = $store => $store.state.auth.authUser.data_JWT.customer.has_agreement === 1; | ||
@@ -269,19 +234,5 @@ export const getActiveGroupId = ($store) => { | ||
export const getGroups = ($store) => { | ||
if (__isNotNull($store | ||
&& $store.state | ||
&& $store.state.auth | ||
&& $store.state.auth.authUser | ||
&& $store.state.auth.authUser.data_JWT | ||
&& $store.state.auth.authUser.data_JWT.groups) | ||
) { | ||
return $store.state.auth.authUser.data_JWT.groups; | ||
} | ||
return []; | ||
}; | ||
export const getSelectedGroup = ($store) => { | ||
const activeGroupId = getActiveGroupId($store); | ||
const groups = getGroups($store); | ||
return groups.find(group => group.id === activeGroupId); | ||
return $store.state.auth.authUser.data_JWT.groups.find(group => group.id === activeGroupId); | ||
}; | ||
@@ -294,44 +245,50 @@ | ||
export const getCustomerInformation = ($store) => { | ||
if (__isNotNull($store | ||
&& $store.state | ||
&& $store.state.auth | ||
&& $store.state.auth.authUser | ||
&& $store.state.auth.authUser.data_JWT | ||
&& $store.state.auth.authUser.data_JWT.customer)) { | ||
if (isNotEmptyCustomer($store)) { | ||
return $store.state.auth.authUser.data_JWT.customer; | ||
} | ||
return null; | ||
return false; | ||
}; | ||
export const getCustomerVendorInformation = ($store) => { | ||
if (__isNotNull($store | ||
&& $store.state | ||
&& $store.state.auth | ||
&& $store.state.auth.sellerUser | ||
&& $store.state.auth.sellerUser.data_JWT | ||
&& $store.state.auth.sellerUser.data_JWT.customer) | ||
) { | ||
if (__isNotNull($store.state.auth.sellerUser | ||
&& $store.state.auth.sellerUser.data_JWT | ||
&& $store.state.auth.sellerUser.data_JWT.customer)) { | ||
return $store.state.auth.sellerUser.data_JWT.customer; | ||
} | ||
return null; | ||
return false; | ||
}; | ||
export const isLoggedIn = $store => __isNotNull($store.state.auth.authUser); | ||
export const isVendor = ($store) => { | ||
if (__isNotNull($store | ||
&& $store.state | ||
&& $store.state.auth | ||
&& $store.state.auth.authUser | ||
&& $store.state.auth.authUser.data_JWT | ||
&& $store.state.auth.authUser.data_JWT.customer) | ||
if (isNotEmptyCustomer($store) | ||
&& __isNotNull($store.state.auth.authUser.data_JWT.customer.is_vendor) | ||
) { | ||
return $store.state.auth.authUser.data_JWT.customer.is_vendor; | ||
} | ||
return false; | ||
}; | ||
export const isLoggedIn = $store => __isNotNull($store | ||
&& $store.state | ||
&& $store.state.auth | ||
&& $store.state.auth.authUser); | ||
export const isParent = ($store) => { | ||
if (isNotEmptyCustomer($store) | ||
&& __isNotNull($store.state.auth.authUser.data_JWT.customer.is_parent) | ||
) { | ||
return $store.state.auth.authUser.data_JWT.customer.is_parent; | ||
} | ||
return false; | ||
}; | ||
export const getCustomerParentOrganizationID = ($store) => { | ||
if (isNotEmptyCustomer($store)) { | ||
return $store.state.auth.authUser.data_JWT.customer.parent_id; | ||
} | ||
return ''; | ||
}; | ||
export const isAccountCompanySwitched = $store => isParent($store) && getCustomerOrganizationID($store) !== getCustomerParentOrganizationID($store); | ||
export const loggedAsSellerOnly = authState => !authState.authUser.data_JWT && authState.sellerUser.data_JWT; | ||
@@ -338,0 +295,0 @@ |
163
48999
621