Add scheduleregdww5sudfw lside ddd n
This commit is contained in:
parent
6706c6ca7e
commit
b8ef1e3e91
@ -3,9 +3,14 @@
|
||||
*/
|
||||
export function safeTranslation(t: any, key: string, fallback: string = '') {
|
||||
try {
|
||||
if (!t || typeof t !== 'function') {
|
||||
console.warn(`Translation function not available for key "${key}"`);
|
||||
return fallback;
|
||||
}
|
||||
|
||||
const translation = t(key);
|
||||
// If the translation returns the key itself or contains "MISSING", use fallback
|
||||
if (translation === key || translation.includes('MISSING')) {
|
||||
if (!translation || translation === key || translation.includes('MISSING')) {
|
||||
return fallback;
|
||||
}
|
||||
return translation;
|
||||
@ -14,3 +19,30 @@ export function safeTranslation(t: any, key: string, fallback: string = '') {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function to check if the server is responding
|
||||
* Can be used to detect server issues early
|
||||
*/
|
||||
export async function checkServerConnection() {
|
||||
try {
|
||||
const response = await fetch('/api/health', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Cache-Control': 'no-cache',
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
isConnected: response.ok,
|
||||
status: response.status,
|
||||
statusText: response.statusText,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Server connection check failed:', error);
|
||||
return {
|
||||
isConnected: false,
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
};
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user