Portal/rsconcept/frontend/src/app/urls.ts

65 lines
1.7 KiB
TypeScript
Raw Normal View History

2024-06-07 20:17:03 +03:00
/**
* Module: Internal navigation constants.
*/
import { buildConstants } from '@/utils/buildConstants';
/**
* Routes.
*/
export const routes = {
login: 'login',
signup: 'signup',
profile: 'profile',
restore_password: 'restore-password',
password_change: 'password-change',
library: 'library',
create_schema: 'library/create',
manuals: 'manuals',
help: 'manuals',
rsforms: 'rsforms',
oss: 'oss',
icons: 'icons'
2024-06-07 20:17:03 +03:00
};
interface SchemaProps {
id: number | string;
tab: number;
version?: number | string;
active?: number | string;
}
interface OssProps {
id: number | string;
tab: number;
}
/**
* Internal navigation URLs.
*/
export const urls = {
admin: `${buildConstants.backend}/admin`,
home: '/',
login: `/${routes.login}`,
login_hint: (userName: string) => `/login?username=${userName}`,
profile: `/${routes.profile}`,
2024-07-26 21:08:31 +03:00
icons: `/icons`,
2024-06-07 20:17:03 +03:00
signup: `/${routes.signup}`,
library: `/${routes.library}`,
library_filter: (strategy: string) => `/library?filter=${strategy}`,
create_schema: `/${routes.create_schema}`,
manuals: `/${routes.manuals}`,
help_topic: (topic: string) => `/manuals?topic=${topic}`,
schema: (id: number | string, version?: number | string) =>
`/rsforms/${id}` + (version !== undefined ? `?v=${version}` : ''),
oss: (id: number | string, tab?: number) => `/oss/${id}` + (tab !== undefined ? `?tab=${tab}` : ''),
2024-06-07 20:17:03 +03:00
schema_props: ({ id, tab, version, active }: SchemaProps) => {
const versionStr = version !== undefined ? `v=${version}&` : '';
const activeStr = active !== undefined ? `&active=${active}` : '';
return `/rsforms/${id}?${versionStr}tab=${tab}${activeStr}`;
},
oss_props: ({ id, tab }: OssProps) => {
return `/oss/${id}?tab=${tab}`;
}
};