QC: Inno Fix: - app.config.js - app/(application)/(user)/investment/[id]/index.tsx - app/(application)/(user)/voting/(tabs)/index.tsx - app/(application)/(user)/waiting-room.tsx - app/(application)/terms-agreement.tsx - context/AuthContext.tsx - ios/HIPMIBadungConnect.xcodeproj/project.pbxproj - ios/HIPMIBadungConnect/Info.plist - screens/Authentication/LoginView.tsx - screens/Authentication/VerificationView.tsx - screens/Home/topFeatureSection.tsx - screens/Invesment/BoxBerandaSection.tsx - screens/Invesment/ButtonInvestasiSection.tsx - screens/Invesment/DetailDataPublishSection.tsx - service/api-client/api-voting.ts - service/api-config.ts ### No Issue
76 lines
2.0 KiB
TypeScript
76 lines
2.0 KiB
TypeScript
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
import axios, { AxiosInstance } from "axios";
|
|
import Constants from "expo-constants";
|
|
export const BASE_URL = Constants.expoConfig?.extra?.BASE_URL;
|
|
export const API_BASE_URL = Constants.expoConfig?.extra?.API_BASE_URL;
|
|
export const DEEP_LINK_URL = Constants.expoConfig?.extra?.DEEP_LINK_URL || 'hipmimobile://';
|
|
|
|
export const apiConfig: AxiosInstance = axios.create({
|
|
baseURL: API_BASE_URL,
|
|
});
|
|
|
|
|
|
apiConfig.interceptors.request.use(
|
|
async (config) => {
|
|
console.log("API_BASE_URL >>", API_BASE_URL);
|
|
const token = await AsyncStorage.getItem("authToken");
|
|
if (token) {
|
|
// config.timeout = 10000;
|
|
config.headers["Content-Type"] = "application/json";
|
|
config.headers.Authorization = `Bearer ${token}`;
|
|
}
|
|
|
|
return config;
|
|
},
|
|
(error) => {
|
|
return Promise.reject(error);
|
|
}
|
|
);
|
|
|
|
export async function apiVersion() {
|
|
const response = await apiConfig.get("/version");
|
|
return response.data;
|
|
}
|
|
|
|
export async function apiLogin({ nomor }: { nomor: string }) {
|
|
const response = await apiConfig.post("/mobile/auth/login", {
|
|
nomor: nomor,
|
|
});
|
|
return response.data;;
|
|
}
|
|
|
|
export async function apiCheckCodeOtp({ kodeId }: { kodeId: string }) {
|
|
const response = await apiConfig.get(`/auth/check/${kodeId}`);
|
|
return response.data;
|
|
}
|
|
|
|
export async function apiValidationCode({ nomor }: { nomor: string }) {
|
|
const response = await apiConfig.post(`/auth/validasi`, {
|
|
nomor: nomor,
|
|
});
|
|
return response.data;
|
|
}
|
|
|
|
export async function apiRegister({
|
|
data,
|
|
}: {
|
|
data: { nomor: string; username: string; termsOfServiceAccepted: boolean };
|
|
}) {
|
|
const response = await apiConfig.post(`/mobile/auth/register`, {
|
|
data: data,
|
|
});
|
|
return response.data;
|
|
}
|
|
|
|
export async function apiAcceptTermService({
|
|
data,
|
|
}: {
|
|
data: { id: string; termsOfServiceAccepted: boolean };
|
|
}) {
|
|
const response = await apiConfig.post(`/auth/term-service`, {
|
|
data: data,
|
|
});
|
|
return response.data;
|
|
}
|
|
|