Commit 385b351f by G

chore: imports from public

parent af54ac7f
# A set of primitives to make styling components faster through the use of tailwind type anotations.
import { Platform } from "react-native";
export const TRACKING = Platform.OS === "android" ? 0.1 : 0;
export const space = {
_2xs: 2,
xs: 4,
sm: 8,
md: 12,
lg: 16,
xl: 20,
_2xl: 24,
_3xl: 28,
_4xl: 32,
_5xl: 40,
} as const;
export const fontSize = {
_2xs: 10,
xs: 12,
sm: 14,
md: 16,
lg: 18,
xl: 20,
_2xl: 22,
_3xl: 26,
_4xl: 32,
_5xl: 40,
} as const;
export const lineHeight = {
none: 1,
normal: 1.5,
relaxed: 1.625,
} as const;
export const borderRadius = {
_2xs: 2,
xs: 4,
sm: 8,
md: 12,
lg: 16,
full: 999,
} as const;
/**
* These correspond to Inter font files we actually load.
*/
export const fontWeight = {
thin: "100",
extralight: "200",
light: "300",
normal: "400",
medium: "500",
semibold: "600",
bold: "700",
extrabold: "800",
black: "900",
} as const;
import { LOG } from "@logger";
import axios from "axios";
import type { AppReduxStore } from "@/redux";
const log = LOG.extend("AxiosInstance");
let store: AppReduxStore;
export const injectStoreIntoAxiosInstance = (_store: AppReduxStore) => {
store = _store;
};
export const axiosInstance = axios.create({
// biome-ignore lint/style/useNamingConvention: <Axios config require baseURL.>
baseURL: process.env.EXPO_PUBLIC_API_URL,
});
axiosInstance.interceptors.request.use(
(config) => {
config.headers.authorization = `Bearer ${store.getState().auth.token.access}`;
config.auth = {
username: "admin",
password: "admin",
};
log.http({ "Request Interceptor Config": config });
return config;
},
(error) => {
log.error({ "Request Interceptor Error": error });
return Promise.reject(error);
},
);
axiosInstance.interceptors.response.use(
(response) => {
log.http({ "Response Interceptor Response Data": response.data });
return response;
},
(error) => {
log.error({ "Response Interceptor Error": error });
if (error.response) {
const { status, data } = error.response;
switch (status) {
case 400:
log.error({ message: "Bad Request", status, data });
break;
case 401:
log.error({
message: "Unauthorized, setting auth status to False",
status,
data,
});
// Handle unauthorized access, e.g., redirect to login
break;
case 404:
log.error({ message: "Not Found", status, data });
break;
case 500:
log.error("Server Error:", "Please try again later");
// Display a user-friendly message, log the error
break;
default:
log.error({ message: "Unknown Error", status, data });
break;
}
}
return Promise.reject(error);
},
);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment