diff --git a/frontend/.eslintrc.cjs b/frontend/.eslintrc.cjs index 323a0d3c..88fb220b 100644 --- a/frontend/.eslintrc.cjs +++ b/frontend/.eslintrc.cjs @@ -18,6 +18,7 @@ module.exports = { }, plugins: ['react', 'unused-imports'], rules: { + 'react/prop-types': 'off', 'unused-imports/no-unused-imports': 'error', 'react/react-in-jsx-scope': 'off', 'prettier/prettier': [ diff --git a/frontend/src/components/SkeletonLoader.tsx b/frontend/src/components/SkeletonLoader.tsx index a73fdd17..b73c5835 100644 --- a/frontend/src/components/SkeletonLoader.tsx +++ b/frontend/src/components/SkeletonLoader.tsx @@ -2,7 +2,13 @@ import { useState, useEffect } from 'react'; interface SkeletonLoaderProps { count?: number; - component?: 'default' | 'analysis' | 'logs' | 'table' | 'chatbot' | 'logsTable' | 'dropdown'; + component?: + | 'default' + | 'analysis' + | 'logs' + | 'table' + | 'chatbot' + | 'dropdown'; } const SkeletonLoader: React.FC = ({ @@ -32,178 +38,162 @@ const SkeletonLoader: React.FC = ({ }; }, [count]); - if (component === 'table') { - return ( - <> - {[...Array(4)].map((_, idx) => ( - - -
- - -
- - -
- - -
- - - ))} - - ); - } + const renderTable = () => ( + <> + {[...Array(4)].map((_, idx) => ( + + +
+ + +
+ + +
+ + +
+ + + ))} + + ); - if (component === 'chatbot') { - return ( - <> - {[...Array(4)].map((_, idx) => ( - - -
- - -
- - -
- - -
- - - ))} - - ); - } + const renderChatbot = () => ( + <> + {[...Array(4)].map((_, idx) => ( + + +
+ + +
+ + +
+ + +
+ + + ))} + + ); - if (component === 'dropdown') { - return ( -
-
-
-
-
-
+ const renderDropdown = () => ( +
+
+
+
+
- ); - } - - if (component === 'logsTable') { - return ( -
- {[...Array(8)].map((_, idx) => ( -
-
-
-
-
-
-
-
-
-
- ))} -
- ); - } - - return ( -
- {component === 'default' ? ( - <> - {[...Array(skeletonCount)].map((_, idx) => ( -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ))} - - ) : component === 'analysis' ? ( - <> - {[...Array(skeletonCount)].map((_, idx) => ( -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ))} - - ) : component === 'logs' ? ( - <> - {[...Array(skeletonCount)].map((_, idx) => ( -
-
-
-
-
-
-
-
-
- ))} - - ) : null}
); + + const renderLogs = () => ( +
+ {[...Array(8)].map((_, idx) => ( +
+
+
+
+
+
+
+
+
+
+ ))} +
+ ); + + const renderDefault = () => ( + <> + {[...Array(skeletonCount)].map((_, idx) => ( +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ))} + + ); + + const renderAnalysis = () => ( + <> + {[...Array(skeletonCount)].map((_, idx) => ( +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ))} + + ); + + const componentMap = { + table: renderTable, + chatbot: renderChatbot, + dropdown: renderDropdown, + logs: renderLogs, + default: renderDefault, + analysis: renderAnalysis, + }; + + const render = componentMap[component] || componentMap.default; + + return <>{render()}; }; export default SkeletonLoader; - - diff --git a/frontend/src/settings/Logs.tsx b/frontend/src/settings/Logs.tsx index d1255b1d..3847e775 100644 --- a/frontend/src/settings/Logs.tsx +++ b/frontend/src/settings/Logs.tsx @@ -146,7 +146,7 @@ function LogsTable({ logs, setPage, loading }: LogsTableProps) { className="flex flex-col items-start h-[51vh] overflow-y-auto bg-transparent flex-grow gap-px" > {loading ? ( - + ) : ( logs.map((log, index) => { if (index === logs.length - 1) {