feat(categories): add bidirectional piece/component category conversion
Add a "Convertir" button on piece and component category lists that allows converting an entire category (and all its items) between piece and component. Includes a modal with eligibility checks and blocker display. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -219,3 +219,33 @@ export function getModelType(id: string, opts: { signal?: AbortSignal } = {}) {
|
||||
signal: opts.signal,
|
||||
})).then(normalizeModelType);
|
||||
}
|
||||
|
||||
export interface ConversionCheck {
|
||||
canConvert: boolean;
|
||||
direction: 'piece_to_component' | 'component_to_piece' | null;
|
||||
itemCount: number;
|
||||
names: string[];
|
||||
blockers: string[];
|
||||
}
|
||||
|
||||
export interface ConversionResult {
|
||||
success: boolean;
|
||||
convertedCount: number;
|
||||
error?: string | null;
|
||||
}
|
||||
|
||||
export function checkConversion(id: string, opts: { signal?: AbortSignal } = {}) {
|
||||
const requestFetch = useRequestFetch();
|
||||
return requestFetch<ConversionCheck>(`${ENDPOINT}/${id}/conversion-check`, createOptions({
|
||||
method: 'GET',
|
||||
signal: opts.signal,
|
||||
}));
|
||||
}
|
||||
|
||||
export function convertCategory(id: string, opts: { signal?: AbortSignal } = {}) {
|
||||
const requestFetch = useRequestFetch();
|
||||
return requestFetch<ConversionResult>(`${ENDPOINT}/${id}/convert`, createOptions({
|
||||
method: 'POST',
|
||||
signal: opts.signal,
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user