4398734bdf
* feat: Adds the ability to save custom filters and display folders on the sidebar * Minor fixes * Review fixes * Review fixes * i18n fixes * Shows conversations when the user click on the folder sidebar item * Spacing fixes * Review fixes Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
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,
|
|
label,
|
|
teamId,
|
|
conversationType = '',
|
|
customViewsId,
|
|
}) => {
|
|
let url = `accounts/${accountId}/conversations/${id}`;
|
|
if (activeInbox) {
|
|
url = `accounts/${accountId}/inbox/${activeInbox}/conversations/${id}`;
|
|
} else if (label) {
|
|
url = `accounts/${accountId}/label/${label}/conversations/${id}`;
|
|
} else if (teamId) {
|
|
url = `accounts/${accountId}/team/${teamId}/conversations/${id}`;
|
|
} else if (customViewsId && customViewsId !== 0) {
|
|
url = `accounts/${accountId}/custom_view/${customViewsId}/conversations/${id}`;
|
|
} else if (conversationType === 'mention') {
|
|
url = `accounts/${accountId}/mentions/conversations/${id}`;
|
|
}
|
|
return url;
|
|
};
|
|
|
|
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;
|
|
};
|