Improve logging more, fix credentials sync issues, migrate more to be toasts

This commit is contained in:
LukeGus
2025-09-09 18:31:41 -05:00
parent 797e022d6e
commit 7ffeb51571
2 changed files with 66 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
import { useState } from 'react';
import { toast } from 'sonner';
interface ConfirmationOptions {
title: string;
description: string;
confirmText?: string;
cancelText?: string;
variant?: 'default' | 'destructive';
}
export function useConfirmation() {
const [isOpen, setIsOpen] = useState(false);
const [options, setOptions] = useState<ConfirmationOptions | null>(null);
const [onConfirm, setOnConfirm] = useState<(() => void) | null>(null);
const confirm = (opts: ConfirmationOptions, callback: () => void) => {
setOptions(opts);
setOnConfirm(() => callback);
setIsOpen(true);
};
const handleConfirm = () => {
if (onConfirm) {
onConfirm();
}
setIsOpen(false);
setOptions(null);
setOnConfirm(null);
};
const handleCancel = () => {
setIsOpen(false);
setOptions(null);
setOnConfirm(null);
};
// For simple confirmations, we can use a toast with action
const confirmWithToast = (message: string, callback: () => void, variant: 'default' | 'destructive' = 'default') => {
const actionText = variant === 'destructive' ? 'Delete' : 'Confirm';
const cancelText = 'Cancel';
toast(message, {
action: {
label: actionText,
onClick: callback
},
cancel: {
label: cancelText,
onClick: () => {}
},
duration: 10000, // Longer duration for confirmations
className: variant === 'destructive' ? 'border-red-500' : ''
});
};
return {
isOpen,
options,
confirm,
handleConfirm,
handleCancel,
confirmWithToast
};
}

View File

@@ -922,6 +922,7 @@ export async function getOIDCConfig(): Promise<any> {
return response.data; return response.data;
} catch (error: any) { } catch (error: any) {
console.warn('Failed to fetch OIDC config:', error.response?.data?.error || error.message); console.warn('Failed to fetch OIDC config:', error.response?.data?.error || error.message);
// Don't show toast for OIDC config as it's optional
return null; return null;
} }
} }