Chatwoot/app/javascript/dashboard/helper/URLHelper.js
Nithin David Thomas 99eaf59509
Feature: Ability to set an account name (#667)
* Ability to change the account name 
* Ability to set a language to the account

Addresses: #667  #307  

Co-authored-by: Pranav Raj Sreepuram <pranavrajs@gmail.com>
2020-04-06 22:17:07 +05:30

22 lines
810 B
JavaScript

import queryString from 'query-string';
export const frontendURL = (path, params) => {
const stringifiedParams = params ? `?${queryString.stringify(params)}` : '';
return `/app/${path}${stringifiedParams}`;
};
export const conversationUrl = (accountId, activeInbox, id) => {
const path = activeInbox
? `accounts/${accountId}/inbox/${activeInbox}/conversations/${id}`
: `accounts/${accountId}/conversations/${id}`;
return path;
};
export const accountIdFromPathname = pathname => {
const isInsideAccountScopedURLs = pathname.includes('/app/accounts');
const urlParam = pathname.split('/')[3];
// eslint-disable-next-line no-restricted-globals
const isScoped = isInsideAccountScopedURLs && !isNaN(urlParam);
const accountId = isScoped ? Number(urlParam) : '';
return accountId;
};