Initial commit
This commit is contained in:
57
src/components/ai-assistant/placement.js
Normal file
57
src/components/ai-assistant/placement.js
Normal file
@@ -0,0 +1,57 @@
|
||||
import { ASSISTANT_CONTEXTS } from './contexts';
|
||||
|
||||
/**
|
||||
* Where the Krow AI Assistant appears.
|
||||
*
|
||||
* The assistant occupies a permanent column in the page layout, so enabling it
|
||||
* on a page is a layout decision, not a feature flag — which is exactly why the
|
||||
* decision lives in one table rather than being scattered across pages.
|
||||
*
|
||||
* Matching is exact, not prefix-based: `/candidates` must not leak an assistant
|
||||
* onto a future `/candidates/:id`, and `/positions/:id` must not inherit one
|
||||
* from `/positions`.
|
||||
*/
|
||||
const PLACEMENT = {
|
||||
employer: {
|
||||
'/': 'employer.overview',
|
||||
'/candidates': 'employer.candidates',
|
||||
'/analytics': 'employer.analytics',
|
||||
},
|
||||
admin: {
|
||||
'/admin': 'admin.controlCenter', // Control Center
|
||||
'/candidates': 'admin.candidates', // Candidates Analysis
|
||||
'/tracking': 'admin.activity', // Activity
|
||||
},
|
||||
talent: {
|
||||
'/employee': 'talent.portal', // My Portal
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Pages that must never carry the assistant, listed explicitly so the intent is
|
||||
* documented rather than implied by omission.
|
||||
*
|
||||
* Employer: Positions, Position Detail, Create Position, Hired History,
|
||||
* Talent Pool, Profile.
|
||||
* Admin: everything except the three above.
|
||||
* Talent: everything except My Portal.
|
||||
*/
|
||||
export const EXCLUDED_ROUTES = [
|
||||
'/positions', '/positions/new', '/positions/:id',
|
||||
'/hired', '/talent-pool', '/profile', '/apply',
|
||||
'/university', '/university/:id', '/me', '/identity',
|
||||
'/owliver', '/design-system',
|
||||
];
|
||||
|
||||
/** Returns the context for a role and path, or `null` to render no assistant. */
|
||||
export function resolveAssistantContext(role, pathname) {
|
||||
const id = PLACEMENT[role]?.[pathname];
|
||||
return id ? ASSISTANT_CONTEXTS[id] : null;
|
||||
}
|
||||
|
||||
/** Every enabled role/route pair — used by the placement verification. */
|
||||
export function enabledRoutes() {
|
||||
return Object.entries(PLACEMENT).flatMap(([role, routes]) =>
|
||||
Object.entries(routes).map(([path, contextId]) => ({ role, path, contextId }))
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user