()
| 33 | // ==============================|| CHATFLOWS ||============================== // |
| 34 | |
| 35 | const Chatflows = () => { |
| 36 | const navigate = useNavigate() |
| 37 | const theme = useTheme() |
| 38 | |
| 39 | const [isLoading, setLoading] = useState(true) |
| 40 | const [images, setImages] = useState({}) |
| 41 | const [search, setSearch] = useState('') |
| 42 | const { error, setError } = useError() |
| 43 | |
| 44 | const getAllChatflowsApi = useApi(chatflowsApi.getAllChatflows) |
| 45 | const [view, setView] = useState(localStorage.getItem('chatFlowDisplayStyle') || 'card') |
| 46 | |
| 47 | /* Table Pagination */ |
| 48 | const [currentPage, setCurrentPage] = useState(1) |
| 49 | const [pageLimit, setPageLimit] = useState(() => Number(localStorage.getItem('chatFlowPageSize') || DEFAULT_ITEMS_PER_PAGE)) |
| 50 | const [total, setTotal] = useState(0) |
| 51 | |
| 52 | const onChange = (page, pageLimit) => { |
| 53 | setCurrentPage(page) |
| 54 | setPageLimit(pageLimit) |
| 55 | localStorage.setItem('chatFlowPageSize', pageLimit) |
| 56 | applyFilters(page, pageLimit) |
| 57 | } |
| 58 | |
| 59 | const applyFilters = (page, limit) => { |
| 60 | const params = { |
| 61 | page: page || currentPage, |
| 62 | limit: limit || pageLimit |
| 63 | } |
| 64 | getAllChatflowsApi.request(params) |
| 65 | } |
| 66 | |
| 67 | const handleChange = (event, nextView) => { |
| 68 | if (nextView === null) return |
| 69 | localStorage.setItem('chatFlowDisplayStyle', nextView) |
| 70 | setView(nextView) |
| 71 | } |
| 72 | |
| 73 | const onSearchChange = (event) => { |
| 74 | setSearch(event.target.value) |
| 75 | } |
| 76 | |
| 77 | function filterFlows(data) { |
| 78 | return ( |
| 79 | data?.name.toLowerCase().indexOf(search.toLowerCase()) > -1 || |
| 80 | (data.category && data.category.toLowerCase().indexOf(search.toLowerCase()) > -1) || |
| 81 | data?.id.toLowerCase().indexOf(search.toLowerCase()) > -1 |
| 82 | ) |
| 83 | } |
| 84 | |
| 85 | const addNew = () => { |
| 86 | navigate('/canvas') |
| 87 | } |
| 88 | |
| 89 | const goToCanvas = (selectedChatflow) => { |
| 90 | navigate(`/canvas/${selectedChatflow.id}`) |
| 91 | } |
| 92 |
nothing calls this directly
no test coverage detected