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('/')
|
router.push('/')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch {
|
||||||
setError('Une erreur est survenue')
|
setError('Une erreur est survenue')
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { Modal } from './Modal';
|
import { Modal } from './Modal';
|
||||||
import { cn } from '@/lib/utils';
|
|
||||||
|
|
||||||
interface KeyboardShortcut {
|
interface KeyboardShortcut {
|
||||||
keys: string[];
|
keys: string[];
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ export function UserPreferencesProvider({ children, initialPreferences }: UserPr
|
|||||||
const [preferences, setPreferences] = useState<UserPreferences>(initialPreferences || defaultPreferences);
|
const [preferences, setPreferences] = useState<UserPreferences>(initialPreferences || defaultPreferences);
|
||||||
const [isPending, startTransition] = useTransition();
|
const [isPending, startTransition] = useTransition();
|
||||||
const { theme, toggleTheme: themeToggleTheme, setTheme: themeSetTheme } = useTheme();
|
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
|
// Fonction pour charger les préférences côté client
|
||||||
const loadUserPreferences = useCallback(async () => {
|
const loadUserPreferences = useCallback(async () => {
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ class UserPreferencesService {
|
|||||||
*/
|
*/
|
||||||
async saveKanbanFilters(userId: string, filters: KanbanFilters): Promise<void> {
|
async saveKanbanFilters(userId: string, filters: KanbanFilters): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const userPrefs = await this.getOrCreateUserPreferences(userId);
|
await this.getOrCreateUserPreferences(userId);
|
||||||
await prisma.userPreferences.update({
|
await prisma.userPreferences.update({
|
||||||
where: { userId },
|
where: { userId },
|
||||||
data: { kanbanFilters: filters }
|
data: { kanbanFilters: filters }
|
||||||
@@ -138,7 +138,7 @@ class UserPreferencesService {
|
|||||||
*/
|
*/
|
||||||
async saveViewPreferences(userId: string, preferences: ViewPreferences): Promise<void> {
|
async saveViewPreferences(userId: string, preferences: ViewPreferences): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const userPrefs = await this.getOrCreateUserPreferences(userId);
|
await this.getOrCreateUserPreferences(userId);
|
||||||
await prisma.userPreferences.update({
|
await prisma.userPreferences.update({
|
||||||
where: { userId },
|
where: { userId },
|
||||||
data: { viewPreferences: preferences }
|
data: { viewPreferences: preferences }
|
||||||
@@ -176,7 +176,7 @@ class UserPreferencesService {
|
|||||||
*/
|
*/
|
||||||
async saveColumnVisibility(userId: string, visibility: ColumnVisibility): Promise<void> {
|
async saveColumnVisibility(userId: string, visibility: ColumnVisibility): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const userPrefs = await this.getOrCreateUserPreferences(userId);
|
await this.getOrCreateUserPreferences(userId);
|
||||||
await prisma.userPreferences.update({
|
await prisma.userPreferences.update({
|
||||||
where: { userId },
|
where: { userId },
|
||||||
data: { columnVisibility: visibility },
|
data: { columnVisibility: visibility },
|
||||||
@@ -230,7 +230,7 @@ class UserPreferencesService {
|
|||||||
*/
|
*/
|
||||||
async saveJiraConfig(userId: string, config: JiraConfig): Promise<void> {
|
async saveJiraConfig(userId: string, config: JiraConfig): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const userPrefs = await this.getOrCreateUserPreferences(userId);
|
await this.getOrCreateUserPreferences(userId);
|
||||||
await prisma.userPreferences.update({
|
await prisma.userPreferences.update({
|
||||||
where: { userId },
|
where: { userId },
|
||||||
data: { jiraConfig: config as any } // eslint-disable-line @typescript-eslint/no-explicit-any
|
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> {
|
async saveTfsConfig(userId: string, config: TfsConfig): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const userPrefs = await this.getOrCreateUserPreferences(userId);
|
await this.getOrCreateUserPreferences(userId);
|
||||||
await prisma.userPreferences.update({
|
await prisma.userPreferences.update({
|
||||||
where: { userId },
|
where: { userId },
|
||||||
data: { tfsConfig: config as any }, // eslint-disable-line @typescript-eslint/no-explicit-any
|
data: { tfsConfig: config as any }, // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||||
@@ -322,7 +322,7 @@ class UserPreferencesService {
|
|||||||
tfsSyncInterval: 'hourly' | 'daily' | 'weekly'
|
tfsSyncInterval: 'hourly' | 'daily' | 'weekly'
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const userPrefs = await this.getOrCreateUserPreferences(userId);
|
await this.getOrCreateUserPreferences(userId);
|
||||||
await prisma.$executeRaw`
|
await prisma.$executeRaw`
|
||||||
UPDATE user_preferences
|
UPDATE user_preferences
|
||||||
SET tfsAutoSync = ${tfsAutoSync}, tfsSyncInterval = ${tfsSyncInterval}
|
SET tfsAutoSync = ${tfsAutoSync}, tfsSyncInterval = ${tfsSyncInterval}
|
||||||
@@ -345,7 +345,7 @@ class UserPreferencesService {
|
|||||||
tfsSyncInterval: 'hourly' | 'daily' | 'weekly';
|
tfsSyncInterval: 'hourly' | 'daily' | 'weekly';
|
||||||
}> {
|
}> {
|
||||||
try {
|
try {
|
||||||
const userPrefs = await this.getOrCreateUserPreferences(userId);
|
await this.getOrCreateUserPreferences(userId);
|
||||||
const result = await prisma.$queryRaw<
|
const result = await prisma.$queryRaw<
|
||||||
Array<{ tfsAutoSync: number; tfsSyncInterval: string }>
|
Array<{ tfsAutoSync: number; tfsSyncInterval: string }>
|
||||||
>`
|
>`
|
||||||
@@ -388,7 +388,7 @@ class UserPreferencesService {
|
|||||||
jiraSyncInterval: 'hourly' | 'daily' | 'weekly'
|
jiraSyncInterval: 'hourly' | 'daily' | 'weekly'
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
try {
|
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
|
// Utiliser une requête SQL brute temporairement pour éviter les problèmes de types
|
||||||
await prisma.$executeRaw`
|
await prisma.$executeRaw`
|
||||||
UPDATE user_preferences
|
UPDATE user_preferences
|
||||||
@@ -512,9 +512,9 @@ class UserPreferencesService {
|
|||||||
*/
|
*/
|
||||||
async resetAllPreferences(userId: string): Promise<void> {
|
async resetAllPreferences(userId: string): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const userPrefs = await this.getOrCreateUserPreferences(userId);
|
await this.getOrCreateUserPreferences(userId);
|
||||||
await prisma.userPreferences.update({
|
await prisma.userPreferences.update({
|
||||||
where: { userId: userPrefs.userId },
|
where: { userId },
|
||||||
data: {
|
data: {
|
||||||
kanbanFilters: DEFAULT_PREFERENCES.kanbanFilters,
|
kanbanFilters: DEFAULT_PREFERENCES.kanbanFilters,
|
||||||
viewPreferences: DEFAULT_PREFERENCES.viewPreferences,
|
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" {
|
declare module "next-auth" {
|
||||||
interface Session {
|
interface Session {
|
||||||
|
|||||||
Reference in New Issue
Block a user