Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | 2x 2x 2x 19x 18x 11x 11x 11x 11x 10x 7x 7x 7x 4x 8x 8x | import { useOrganizationStore } from '../store/organizationStore'
// Correspondances entre les routes frontoffice et backoffice.
// Key = segment frontoffice (relatif à /:orgId), value = segment backoffice.
// Seules les fonctionnalités ayant un réel équivalent de l'autre côté.
const FRONT_TO_BACK = {
'workflow': 'workflows',
'knowledge-base': 'knowledge',
'agent-chat': 'agents',
}
// URL du guide d'utilisation (site statique nooloom-static).
const GUIDE_BASE = 'https://guide.nooloom.data-players.com'
// Mapping fonctionnalité → page du guide (une page par fonctionnalité).
// Key = segment de route (frontoffice ou backoffice), value = chemin guide.
const FEATURE_TO_GUIDE = {
// Frontoffice
'workflow': '/fonctionnalites/workflow/',
'workflow-generic': '/fonctionnalites/workflow-manuel/',
'knowledge-base': '/fonctionnalites/knowledge-bases/',
'agent-chat': '/fonctionnalites/agents/',
// Backoffice
'crawlers': '/fonctionnalites/crawlers/',
'workflows': '/fonctionnalites/workflow/',
'knowledge': '/fonctionnalites/knowledge-bases/',
'external-apis': '/fonctionnalites/apis-externes/',
'agents': '/fonctionnalites/agents/',
'schedules': '/fonctionnalites/planifications/',
'jobs': '/fonctionnalites/jobs/',
'organization': '/fonctionnalites/organisation/',
'subscription': '/fonctionnalites/abonnement/',
'settings': '/fonctionnalites/configuration/',
}
// Convertit le pathname courant vers l'URL de la page du guide correspondante.
// Retourne null si la fonctionnalité n'a pas de page guide dédiée.
export function getGuideHref(pathname, orgId) {
if (!orgId) return null
// Route backoffice : /:orgId/backoffice (racine) ou /:orgId/backoffice/<feature>/...
if (pathname.includes(`/${orgId}/backoffice`)) {
const parts = pathname.replace(`/${orgId}/backoffice`, '').split('/').filter(Boolean)
Iif (parts.length === 0) return `${GUIDE_BASE}/fonctionnalites/`
const guide = FEATURE_TO_GUIDE[parts[0]]
if (!guide) return `${GUIDE_BASE}/fonctionnalites/`
return `${GUIDE_BASE}${guide}`
}
// Route frontoffice : /:orgId/<feature>/...
const parts = pathname.replace(`/${orgId}`, '').split('/').filter(Boolean)
const guide = FEATURE_TO_GUIDE[parts[0]]
if (!guide) return `${GUIDE_BASE}/fonctionnalites/`
return `${GUIDE_BASE}${guide}`
}
// URL de la page générale du guide pour un mode donné (frontoffice / backoffice).
export function getSectionGuideHref(mode, orgId) {
if (!orgId) return null
return mode === 'backoffice'
? `${GUIDE_BASE}/fonctionnalites/`
: `${GUIDE_BASE}/fonctionnalites/`
}
// Convertit un pathname frontoffice (avec orgId) vers le pathname backoffice équivalent.
// Retourne null si aucune correspondance (page publique type /about, /pricing, home).
export function frontofficeToBackoffice(pathname, orgId) {
if (!orgId) return null
const parts = pathname.replace(`/${orgId}`, '').split('/').filter(Boolean)
const [feature, id] = parts
const backFeature = FRONT_TO_BACK[feature]
if (!backFeature) return null
if (id) return `/${orgId}/backoffice/${backFeature}/${id}`
return `/${orgId}/backoffice/${backFeature}`
}
// Convertit un pathname backoffice (avec orgId) vers le pathname frontoffice équivalent.
// Retourne null si aucune correspondance.
export function backofficeToFrontoffice(pathname, orgId) {
if (!orgId) return null
const parts = pathname.replace(`/${orgId}/backoffice`, '').split('/').filter(Boolean)
const [feature, id] = parts
const frontFeature = Object.keys(FRONT_TO_BACK).find((k) => FRONT_TO_BACK[k] === feature)
if (!frontFeature) return null
if (id) return `/${orgId}/${frontFeature}/${id}`
return `/${orgId}/${frontFeature}`
}
// Hook : l'utilisateur peut-il accéder au backoffice de l'orga courante (owner uniquement) ?
export function useCanAccessBackoffice() {
const { currentOrganization } = useOrganizationStore()
return currentOrganization?.role === 'owner'
}
export default frontofficeToBackoffice |