godcrm/components/AIChatPanel/hooks/useInlineSelectors.ts
GOD CRM Release f89e074dd1
Some checks failed
CI / Lint / Typecheck / Test / Build (push) Has been cancelled
CI / PostgreSQL Integration Tests (push) Has been cancelled
GOD CRM — public scrubbed snapshot
Governed substrate for autonomous agents: scoped identity (passports),
audited actions, MCP workspace. Infra IPs and secrets redacted for public release.
2026-08-10 04:01:45 +03:00

68 lines
No EOL
2.2 KiB
TypeScript

/**
* useInlineSelectors Hook
* Handles TasksSource and FilesSource inline selector logic
*/
import { useState, useCallback } from 'react';
import { TasksSourceConfig, FilesSourceConfig } from '../types';
export function useInlineSelectors() {
const [tasksSource, setTasksSource] = useState<TasksSourceConfig | undefined>();
const [filesSource, setFilesSource] = useState<FilesSourceConfig | undefined>();
const [showTasksSelector, setShowTasksSelector] = useState(false);
const [showFilePicker, setShowFilePicker] = useState(false);
const [taskProjectId, setTaskProjectId] = useState<number | null>(null);
// Auto-mapping functionality for tasks table
const autoMapTasksTable = useCallback((tables: Array<{ id: number; name: string; icon?: string }>) => {
// Look for tables that might contain tasks
const taskTable = tables.find(table =>
table.name.toLowerCase().includes('task') ||
table.name.toLowerCase().includes('todo') ||
table.name.toLowerCase().includes('issue')
);
if (taskTable) {
setTasksSource({
tableId: taskTable.id,
tableName: taskTable.name,
tableIcon: taskTable.icon || 'list',
displayColumn: 'title' // Default display column
});
}
}, []);
// Auto-mapping functionality for files table
const autoMapFilesTable = useCallback((tables: Array<{ id: number; name: string; icon?: string; project_id?: number }>) => {
// Look for tables that might contain files
const filesTable = tables.find(table =>
table.name.toLowerCase().includes('file') ||
table.name.toLowerCase().includes('document') ||
table.name.toLowerCase().includes('attachment')
);
if (filesTable) {
setFilesSource({
tableId: filesTable.id,
tableName: filesTable.name,
tableIcon: filesTable.icon || 'file',
projectId: filesTable.project_id
});
}
}, []);
return {
tasksSource,
filesSource,
showTasksSelector,
showFilePicker,
taskProjectId,
setTasksSource,
setFilesSource,
setShowTasksSelector,
setShowFilePicker,
setTaskProjectId,
autoMapTasksTable,
autoMapFilesTable
};
}