diff --git a/.claude/agents/xbyk-component-reference.md b/.claude/agents/xbyk-component-reference.md index 0296551..a2fd309 100644 --- a/.claude/agents/xbyk-component-reference.md +++ b/.claude/agents/xbyk-component-reference.md @@ -3,7 +3,7 @@ name: xbyk-component-reference description: Quick reference guide for native Xperience by Kentico admin components. Consult when choosing components, understanding XbyK design system, or ensuring consistent UI patterns. tools: Read, mcp__kentico-docs-mcp__kentico_docs_search, mcp__kentico-docs-mcp__kentico_docs_fetch model: haiku -color: teal +color: pink --- You are a quick reference guide for native Xperience by Kentico (XbyK) admin UI components from `@kentico/xperience-admin-components`. diff --git a/CLAUDE.md b/CLAUDE.md index 44b3143..b31b0ed 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -167,7 +167,7 @@ C:\Projects\xperience-community-sustainability\ **XbyK Components Used**: - Native: `Card`, `Button`, `Stack`, `Row`, `Column`, `Headline`, `Spacing`, `Icon` -- Patterns: `usePageCommand` hook for backend commands, `inProgress` prop for loading states +- Patterns: `usePageCommand` hook for backend commands, manual `useState` for loading states, `inProgress` and `disabled` props on buttons - Responsive: `colsLg`/`colsMd` breakpoints for grid layout **File Organization**: @@ -190,6 +190,46 @@ C:\Projects\xperience-community-sustainability\ } ``` +**usePageCommand Hook - Loading State Pattern**: +- **IMPORTANT**: `usePageCommand` does NOT provide a built-in `inProgress` property +- **Return type**: Only returns `{ execute: (data?: TCommandData) => void }` +- **Loading states must be managed manually** using `useState` +- **Correct pattern**: + ```typescript + // 1. Create manual state + const [isLoading, setIsLoading] = useState(false); + + // 2. Configure usePageCommand with after/onError callbacks + const { execute: myCommand } = usePageCommand( + Commands.MyCommand, + { + after: (response) => { + // Process response... + setIsLoading(false); // Stop loading when done + }, + onError: (err) => { + console.error(err); + setIsLoading(false); // Stop loading on error + }, + } + ); + + // 3. Set loading state before executing + const handleClick = () => { + setIsLoading(true); + myCommand(); + }; + + // 4. Use state for button props +