fix: streamline error handling and clean up unused imports
- Simplified error handling in `LoginPage` by removing the error parameter in the catch block. - Removed unused import of `cn` in `KeyboardShortcutsModal` to clean up the code. - Updated `UserPreferencesContext` to only destructure `status` from `useSession`, improving clarity. - Refactored multiple methods in `UserPreferencesService` to eliminate unnecessary variable assignments, enhancing performance. - Added ESLint directive to suppress unused variable warning for `NextAuth` import in type definitions.
This commit is contained in:
@@ -37,7 +37,7 @@ export default function LoginPage() {
|
||||
router.push('/')
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
} catch {
|
||||
setError('Une erreur est survenue')
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { Modal } from './Modal';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
interface KeyboardShortcut {
|
||||
keys: string[];
|
||||
|
||||
@@ -78,7 +78,7 @@ export function UserPreferencesProvider({ children, initialPreferences }: UserPr
|
||||
const [preferences, setPreferences] = useState<UserPreferences>(initialPreferences || defaultPreferences);
|
||||
const [isPending, startTransition] = useTransition();
|
||||
const { theme, toggleTheme: themeToggleTheme, setTheme: themeSetTheme } = useTheme();
|
||||
const { data: session, status } = useSession();
|
||||
const { status } = useSession();
|
||||
|
||||
// Fonction pour charger les préférences côté client
|
||||
const loadUserPreferences = useCallback(async () => {
|
||||
|
||||
@@ -106,7 +106,7 @@ class UserPreferencesService {
|
||||
*/
|
||||
async saveKanbanFilters(userId: string, filters: KanbanFilters): Promise<void> {
|
||||
try {
|
||||
const userPrefs = await this.getOrCreateUserPreferences(userId);
|
||||
await this.getOrCreateUserPreferences(userId);
|
||||
await prisma.userPreferences.update({
|
||||
where: { userId },
|
||||
data: { kanbanFilters: filters }
|
||||
@@ -138,7 +138,7 @@ class UserPreferencesService {
|
||||
*/
|
||||
async saveViewPreferences(userId: string, preferences: ViewPreferences): Promise<void> {
|
||||
try {
|
||||
const userPrefs = await this.getOrCreateUserPreferences(userId);
|
||||
await this.getOrCreateUserPreferences(userId);
|
||||
await prisma.userPreferences.update({
|
||||
where: { userId },
|
||||
data: { viewPreferences: preferences }
|
||||
@@ -176,7 +176,7 @@ class UserPreferencesService {
|
||||
*/
|
||||
async saveColumnVisibility(userId: string, visibility: ColumnVisibility): Promise<void> {
|
||||
try {
|
||||
const userPrefs = await this.getOrCreateUserPreferences(userId);
|
||||
await this.getOrCreateUserPreferences(userId);
|
||||
await prisma.userPreferences.update({
|
||||
where: { userId },
|
||||
data: { columnVisibility: visibility },
|
||||
@@ -230,7 +230,7 @@ class UserPreferencesService {
|
||||
*/
|
||||
async saveJiraConfig(userId: string, config: JiraConfig): Promise<void> {
|
||||
try {
|
||||
const userPrefs = await this.getOrCreateUserPreferences(userId);
|
||||
await this.getOrCreateUserPreferences(userId);
|
||||
await prisma.userPreferences.update({
|
||||
where: { userId },
|
||||
data: { jiraConfig: config as any } // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
@@ -278,7 +278,7 @@ class UserPreferencesService {
|
||||
*/
|
||||
async saveTfsConfig(userId: string, config: TfsConfig): Promise<void> {
|
||||
try {
|
||||
const userPrefs = await this.getOrCreateUserPreferences(userId);
|
||||
await this.getOrCreateUserPreferences(userId);
|
||||
await prisma.userPreferences.update({
|
||||
where: { userId },
|
||||
data: { tfsConfig: config as any }, // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
@@ -322,7 +322,7 @@ class UserPreferencesService {
|
||||
tfsSyncInterval: 'hourly' | 'daily' | 'weekly'
|
||||
): Promise<void> {
|
||||
try {
|
||||
const userPrefs = await this.getOrCreateUserPreferences(userId);
|
||||
await this.getOrCreateUserPreferences(userId);
|
||||
await prisma.$executeRaw`
|
||||
UPDATE user_preferences
|
||||
SET tfsAutoSync = ${tfsAutoSync}, tfsSyncInterval = ${tfsSyncInterval}
|
||||
@@ -345,7 +345,7 @@ class UserPreferencesService {
|
||||
tfsSyncInterval: 'hourly' | 'daily' | 'weekly';
|
||||
}> {
|
||||
try {
|
||||
const userPrefs = await this.getOrCreateUserPreferences(userId);
|
||||
await this.getOrCreateUserPreferences(userId);
|
||||
const result = await prisma.$queryRaw<
|
||||
Array<{ tfsAutoSync: number; tfsSyncInterval: string }>
|
||||
>`
|
||||
@@ -388,7 +388,7 @@ class UserPreferencesService {
|
||||
jiraSyncInterval: 'hourly' | 'daily' | 'weekly'
|
||||
): Promise<void> {
|
||||
try {
|
||||
const userPrefs = await this.getOrCreateUserPreferences(userId);
|
||||
await this.getOrCreateUserPreferences(userId);
|
||||
// Utiliser une requête SQL brute temporairement pour éviter les problèmes de types
|
||||
await prisma.$executeRaw`
|
||||
UPDATE user_preferences
|
||||
@@ -512,9 +512,9 @@ class UserPreferencesService {
|
||||
*/
|
||||
async resetAllPreferences(userId: string): Promise<void> {
|
||||
try {
|
||||
const userPrefs = await this.getOrCreateUserPreferences(userId);
|
||||
await this.getOrCreateUserPreferences(userId);
|
||||
await prisma.userPreferences.update({
|
||||
where: { userId: userPrefs.userId },
|
||||
where: { userId },
|
||||
data: {
|
||||
kanbanFilters: DEFAULT_PREFERENCES.kanbanFilters,
|
||||
viewPreferences: DEFAULT_PREFERENCES.viewPreferences,
|
||||
|
||||
3
src/types/next-auth.d.ts
vendored
3
src/types/next-auth.d.ts
vendored
@@ -1,4 +1,5 @@
|
||||
import NextAuth from "next-auth"
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
import type NextAuth from "next-auth"
|
||||
|
||||
declare module "next-auth" {
|
||||
interface Session {
|
||||
|
||||
Reference in New Issue
Block a user