mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-07 00:14:25 +00:00
Fix some lint issues
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { notifications } from '@mantine/notifications';
|
||||
import { getUsers, getWorkspaces, getSystemStats } from '@/api/admin';
|
||||
import type { SystemStats, WorkspaceStats } from '@/types/adminApi';
|
||||
import type { User } from '@/types/authApi';
|
||||
import type { SystemStats, User, WorkspaceStats } from '@/types/models';
|
||||
|
||||
// Possible types of admin data
|
||||
type AdminDataType = 'stats' | 'workspaces' | 'users';
|
||||
@@ -45,7 +44,7 @@ export const useAdminData = <T extends AdminDataType>(
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const loadData = async () => {
|
||||
const loadData = useCallback(async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
@@ -67,7 +66,8 @@ export const useAdminData = <T extends AdminDataType>(
|
||||
} catch (err) {
|
||||
const message =
|
||||
err instanceof Error
|
||||
? (err as any)?.response?.data?.error || err.message
|
||||
? (err as { response?: { data?: { error?: string } } })?.response
|
||||
?.data?.error || err.message
|
||||
: 'An unknown error occurred';
|
||||
setError(message);
|
||||
notifications.show({
|
||||
@@ -78,11 +78,11 @@ export const useAdminData = <T extends AdminDataType>(
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
}, [type]);
|
||||
|
||||
useEffect(() => {
|
||||
loadData();
|
||||
}, [type]);
|
||||
void loadData();
|
||||
}, [loadData]);
|
||||
|
||||
return { data, loading, error, reload: loadData };
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useState, useCallback, useEffect } from 'react';
|
||||
import { isImageFile } from '../utils/fileHelpers';
|
||||
import { useWorkspace } from '../contexts/WorkspaceContext';
|
||||
import { DEFAULT_FILE } from '@/types/file';
|
||||
import { getFileContent } from '@/api/file';
|
||||
import { DEFAULT_FILE } from '@/types/models';
|
||||
|
||||
interface UseFileContentResult {
|
||||
content: string;
|
||||
@@ -51,7 +51,7 @@ export const useFileContent = (
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedFile && currentWorkspace) {
|
||||
loadFileContent(selectedFile);
|
||||
void loadFileContent(selectedFile);
|
||||
}
|
||||
}, [selectedFile, currentWorkspace, loadFileContent]);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState, useCallback } from 'react';
|
||||
import { listFiles } from '../api/file';
|
||||
import { useWorkspace } from '../contexts/WorkspaceContext';
|
||||
import type { FileNode } from '../types/fileApi';
|
||||
import type { FileNode } from '@/types/models';
|
||||
|
||||
interface UseFileListResult {
|
||||
files: FileNode[];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState, useCallback, useEffect } from 'react';
|
||||
import { DEFAULT_FILE } from '../types/file';
|
||||
import { useWorkspace } from '../contexts/WorkspaceContext';
|
||||
import { useLastOpenedFile } from './useLastOpenedFile';
|
||||
import { DEFAULT_FILE } from '@/types/models';
|
||||
|
||||
interface UseFileNavigationResult {
|
||||
selectedFile: string;
|
||||
@@ -36,14 +36,14 @@ export const useFileNavigation = (): UseFileNavigationResult => {
|
||||
|
||||
const lastFile = await loadLastOpenedFile();
|
||||
if (lastFile) {
|
||||
handleFileSelect(lastFile);
|
||||
await handleFileSelect(lastFile);
|
||||
} else {
|
||||
handleFileSelect(null);
|
||||
await handleFileSelect(null);
|
||||
}
|
||||
};
|
||||
|
||||
if (currentWorkspace) {
|
||||
initializeFile();
|
||||
void initializeFile();
|
||||
}
|
||||
}, [currentWorkspace, loadLastOpenedFile, handleFileSelect]);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { notifications } from '@mantine/notifications';
|
||||
import { saveFile, deleteFile } from '../api/file';
|
||||
import { useWorkspace } from '../contexts/WorkspaceContext';
|
||||
import { useGitOperations } from './useGitOperations';
|
||||
import { FileAction } from '../types/file';
|
||||
import { FileAction } from '@/types/models';
|
||||
|
||||
interface UseFileOperationsResult {
|
||||
handleSave: (filePath: string, content: string) => Promise<boolean>;
|
||||
@@ -28,7 +28,7 @@ export const useFileOperations = (): UseFileOperationsResult => {
|
||||
await handleCommitAndPush(commitMessage);
|
||||
}
|
||||
},
|
||||
[settings]
|
||||
[settings, handleCommitAndPush]
|
||||
);
|
||||
|
||||
const handleSave = useCallback(
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useCallback } from 'react';
|
||||
import { notifications } from '@mantine/notifications';
|
||||
import { pullChanges, commitAndPush } from '../api/git';
|
||||
import { useWorkspace } from '../contexts/WorkspaceContext';
|
||||
import type { CommitHash } from '@/types/git';
|
||||
import type { CommitHash } from '@/types/models';
|
||||
|
||||
interface UseGitOperationsResult {
|
||||
handlePull: () => Promise<boolean>;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useState, useCallback } from 'react';
|
||||
import { notifications } from '@mantine/notifications';
|
||||
import { updateProfile, deleteUser } from '../api/user';
|
||||
import type { User } from '../types/authApi';
|
||||
import type { UpdateProfileRequest } from '../types/userApi';
|
||||
import type { UpdateProfileRequest } from '@/types/api';
|
||||
import type { User } from '@/types/models';
|
||||
|
||||
interface UseProfileSettingsResult {
|
||||
loading: boolean;
|
||||
|
||||
@@ -5,8 +5,8 @@ import {
|
||||
deleteUser as adminDeleteUser,
|
||||
} from '../api/admin';
|
||||
import { notifications } from '@mantine/notifications';
|
||||
import type { User } from '../types/authApi';
|
||||
import type { CreateUserRequest, UpdateUserRequest } from '../types/adminApi';
|
||||
import type { User } from '@/types/models';
|
||||
import type { CreateUserRequest, UpdateUserRequest } from '@/types/api';
|
||||
|
||||
interface UseUserAdminResult {
|
||||
users: User[];
|
||||
@@ -30,7 +30,7 @@ export const useUserAdmin = (): UseUserAdminResult => {
|
||||
message: 'User created successfully',
|
||||
color: 'green',
|
||||
});
|
||||
reload();
|
||||
await reload();
|
||||
return true;
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
@@ -54,7 +54,7 @@ export const useUserAdmin = (): UseUserAdminResult => {
|
||||
message: 'User updated successfully',
|
||||
color: 'green',
|
||||
});
|
||||
reload();
|
||||
await reload();
|
||||
return true;
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
@@ -75,7 +75,7 @@ export const useUserAdmin = (): UseUserAdminResult => {
|
||||
message: 'User deleted successfully',
|
||||
color: 'green',
|
||||
});
|
||||
reload();
|
||||
await reload();
|
||||
return true;
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
|
||||
Reference in New Issue
Block a user