Fix build errors and warnings
- Fix optional chain expression errors in DownloadedScriptsTab, ScriptsGrid, and colorUtils - Fix React hooks dependency warnings in InstalledScriptsTab - Update useCallback dependency array to include containerStatusMutation - Update useEffect dependency array to include fetchContainerStatuses - Build now passes successfully with no errors or warnings
This commit is contained in:
@@ -385,7 +385,7 @@ export function DownloadedScriptsTab({ onInstallScript }: DownloadedScriptsTabPr
|
||||
);
|
||||
}
|
||||
|
||||
if (!downloadedScripts || downloadedScripts.length === 0) {
|
||||
if (!downloadedScripts?.length) {
|
||||
return (
|
||||
<div className="text-center py-12">
|
||||
<div className="text-muted-foreground">
|
||||
|
||||
@@ -322,7 +322,7 @@ export function InstalledScriptsTab() {
|
||||
if (serverIds.length > 0) {
|
||||
containerStatusMutation.mutate({ serverIds });
|
||||
}
|
||||
}, []);
|
||||
}, [containerStatusMutation]);
|
||||
|
||||
// Run cleanup when component mounts and scripts are loaded (only once)
|
||||
useEffect(() => {
|
||||
@@ -337,7 +337,7 @@ export function InstalledScriptsTab() {
|
||||
if (scripts.length > 0) {
|
||||
fetchContainerStatuses();
|
||||
}
|
||||
}, [scripts.length]); // Only depend on scripts.length to prevent infinite loops
|
||||
}, [scripts.length, fetchContainerStatuses]);
|
||||
|
||||
const scriptsWithStatus = scripts.map(script => ({
|
||||
...script,
|
||||
|
||||
@@ -571,7 +571,7 @@ export function ScriptsGrid({ onInstallScript }: ScriptsGridProps) {
|
||||
);
|
||||
}
|
||||
|
||||
if (!scriptsWithStatus || scriptsWithStatus.length === 0) {
|
||||
if (!scriptsWithStatus?.length) {
|
||||
return (
|
||||
<div className="text-center py-12">
|
||||
<div className="text-muted-foreground">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* to ensure optimal readability based on luminance
|
||||
*/
|
||||
export function getContrastColor(hexColor: string): 'black' | 'white' {
|
||||
if (!hexColor || hexColor.length !== 7 || !hexColor.startsWith('#')) {
|
||||
if (!hexColor?.length || hexColor.length !== 7 || !hexColor.startsWith('#')) {
|
||||
return 'black'; // Default to black for invalid colors
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user