import { createSalespersonManageApi } from '@/api/salespersonManage.js';

const ROOT = '/subPackages/sub_salesperson_manage';

export function resolveManageMode(options) {
	const mode = (options && options.mode) || '';
	if (mode === 'platform' || mode === 'clinic') return mode;
	const loginMode = uni.getStorageSync('loginMode');
	return loginMode === 'platform_admin' ? 'platform' : 'clinic';
}

export function getSalespersonManageContext(mode) {
	const api = createSalespersonManageApi(mode);
	return {
		mode,
		api,
		isPlatform: mode === 'platform',
		listPath: `${ROOT}/index?mode=${mode}`,
		homePath: mode === 'platform'
			? '/subPackages/sub_platform_admin/home/index'
			: '/subPackages/sub_clinic_admin/home/index',
	};
}
