- Deleted apps/web/src/utils/optimisticStoreUpdates.ts (unused file) - File was unused - no imports found in codebase - Mutations already use React Query's onMutate pattern - No TypeScript errors after deletion - Actions 4.4.1.2 and 4.4.1.3 complete
73 lines
2 KiB
TypeScript
73 lines
2 KiB
TypeScript
import { InternalAxiosRequestConfig } from 'axios';
|
||
// CRITICAL FIX: Utiliser le wrapper lazy pour éviter les collisions de noms de variables
|
||
import toast from '@/utils/toast';
|
||
|
||
/**
|
||
* FE-COMP-005: Helper utilities for API toast notifications
|
||
*/
|
||
|
||
/**
|
||
* Enable success toast for an API request
|
||
* @param config Axios request config
|
||
* @param message Optional custom success message
|
||
* @returns Modified config with toast enabled
|
||
*/
|
||
export function withSuccessToast(
|
||
config: InternalAxiosRequestConfig,
|
||
message?: string,
|
||
): InternalAxiosRequestConfig {
|
||
(config as any)._showSuccessToast = true;
|
||
if (message) {
|
||
(config as any)._successMessage = message;
|
||
}
|
||
return config;
|
||
}
|
||
|
||
/**
|
||
* Disable automatic error toast for an API request
|
||
* Useful when you want to handle errors manually
|
||
* @param config Axios request config
|
||
* @returns Modified config with toast disabled
|
||
*/
|
||
export function withoutErrorToast(
|
||
config: InternalAxiosRequestConfig,
|
||
): InternalAxiosRequestConfig {
|
||
(config as any)._disableToast = true;
|
||
return config;
|
||
}
|
||
|
||
/**
|
||
* Show a success toast manually
|
||
* @param message Success message
|
||
* @param duration Toast duration in milliseconds
|
||
*/
|
||
export function showSuccessToast(message: string, duration?: number): void {
|
||
toast.success(message, { duration });
|
||
}
|
||
|
||
/**
|
||
* Show an error toast manually
|
||
* @param message Error message
|
||
* @param duration Toast duration in milliseconds
|
||
*/
|
||
export function showErrorToast(message: string, duration?: number): void {
|
||
toast.error(message, { duration });
|
||
}
|
||
|
||
/**
|
||
* Show an info toast manually
|
||
* @param message Info message
|
||
* @param duration Toast duration in milliseconds
|
||
*/
|
||
export function showInfoToast(message: string, duration?: number): void {
|
||
toast(message, { duration, icon: 'ℹ️' });
|
||
}
|
||
|
||
/**
|
||
* Show a warning toast manually
|
||
* @param message Warning message
|
||
* @param duration Toast duration in milliseconds
|
||
*/
|
||
export function showWarningToast(message: string, duration?: number): void {
|
||
toast(message, { duration, icon: '⚠️' });
|
||
}
|