updates
This commit is contained in:
@@ -63,13 +63,23 @@ export const usePolicy = (type: 'privacy' | 'terms' | 'support' | null): UsePoli
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't fetch on server side
|
||||
if (typeof window === 'undefined') {
|
||||
setIsLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
setIsLoading(true);
|
||||
setError(null);
|
||||
const result = await getPolicyByType(type);
|
||||
setData(result);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err : new Error('An error occurred'));
|
||||
const errorMessage = err instanceof Error ? err.message : 'An error occurred while loading the policy';
|
||||
console.error('Policy fetch error:', err);
|
||||
setError(new Error(errorMessage));
|
||||
// Set data to null on error to prevent rendering issues
|
||||
setData(null);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user