redesign console page

This commit is contained in:
2026-09-03 12:31:07 +05:30
parent d39956a2f1
commit e1bb0a5307
22 changed files with 2478 additions and 22 deletions

View File

@@ -1,5 +1,6 @@
import { useRef, useState } from 'react';
import { useLocation } from 'react-router-dom';
import { useAssistantScope } from './assistantScope';
import { ArrowUp, History, Maximize2, Minimize2, PanelRightClose } from 'lucide-react';
import {
DEFAULT_WIDTH,
@@ -146,7 +147,17 @@ export function AssistantPanel({
const [isDragging, setDragging] = useState(false);
const key = Object.keys(CONTEXT).find((entry) => pathname.startsWith(entry));
const context = (key ? CONTEXT[key] : undefined) ?? FALLBACK;
const routeContext = (key ? CONTEXT[key] : undefined) ?? FALLBACK;
/**
* The heading follows the branch in view.
*
* A panel headed "Across your branches" sitting above a board showing one
* shop is a promise about scope that the page has already broken. Only the
* title moves; everything else about Buddy is untouched.
*/
const scopeLabel = useAssistantScope();
const context = scopeLabel ? { ...routeContext, title: scopeLabel } : routeContext;
/**
* Three widths, in priority order: stacked (the phone layout owns it),

View File

@@ -0,0 +1,21 @@
import { createContext, useContext } from 'react';
/**
* What Nearle Buddy is currently answering about.
*
* The panel names its own scope in its heading — "Across your branches" — and
* that heading is a promise about which data an answer would draw on. When an
* admin narrows to one branch, or a store user opens the console at all, the
* promise is wrong: the board beneath says R mart and the panel above still
* says every branch.
*
* So the SCOPE is published here and the panel reads it. Nothing else about
* Buddy changes — not its width, its controls, its prompts or its placement.
* A page that has no branch scope publishes nothing and the panel keeps the
* per-route wording it has always used.
*/
export const AssistantScopeContext = createContext<string | undefined>(undefined);
export function useAssistantScope(): string | undefined {
return useContext(AssistantScopeContext);
}