Fix form keyboard issues and sticky footers in agent screens

This commit is contained in:
Abin Toppo
2026-05-26 16:34:05 +05:30
commit 9ac5e95d52
410 changed files with 86650 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
import type { AxiosError, AxiosInstance } from 'axios';
import { secureStorage } from '../storage/secureStorage';
const unauthorizedHandlers = new Set<() => void>();
export const registerUnauthorizedHandler = (handler: () => void) => {
unauthorizedHandlers.add(handler);
return () => {
unauthorizedHandlers.delete(handler);
};
};
export const attachInterceptors = (client: AxiosInstance) => {
client.interceptors.request.use(async (config) => {
const token = await secureStorage.getAccessToken();
if (token) {
const nextHeaders = (config.headers ?? {}) as Record<string, string>;
nextHeaders.Authorization = `Bearer ${token}`;
config.headers = nextHeaders as never;
}
return config;
});
client.interceptors.response.use(
(response) => response,
async (error: AxiosError) => {
if (error.response?.status === 401) {
await secureStorage.clearSession();
unauthorizedHandlers.forEach((handler) => handler());
}
return Promise.reject(error);
},
);
};