Fix rejected Apple
Add: - utils/viersionBadge.ts Fix: - app.config.js - context/AuthContext.tsx - ios/HIPMIBadungConnect/Info.plist - screens/Authentication/LoginView.tsx - screens/Authentication/VerificationView.tsx - service/api-config.ts ### No Issue
This commit is contained in:
@@ -19,7 +19,7 @@ export default {
|
|||||||
"NSLocationWhenInUseUsageDescription": "Aplikasi membutuhkan akses lokasi untuk menampilkan peta.",
|
"NSLocationWhenInUseUsageDescription": "Aplikasi membutuhkan akses lokasi untuk menampilkan peta.",
|
||||||
},
|
},
|
||||||
associatedDomains: ["applinks:cld-dkr-staging-hipmi.wibudev.com"],
|
associatedDomains: ["applinks:cld-dkr-staging-hipmi.wibudev.com"],
|
||||||
buildNumber: "10",
|
buildNumber: "12",
|
||||||
},
|
},
|
||||||
|
|
||||||
android: {
|
android: {
|
||||||
|
|||||||
@@ -72,10 +72,13 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
const loginWithNomor = async (nomor: string) => {
|
const loginWithNomor = async (nomor: string) => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
|
console.log("[Masuk provider]", nomor);
|
||||||
const response = await apiLogin({ nomor: nomor });
|
const response = await apiLogin({ nomor: nomor });
|
||||||
console.log("[RESPONSE AUTH]", JSON.stringify(response));
|
console.log("[RESPONSE AUTH]", JSON.stringify(response));
|
||||||
|
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
|
console.log("[Keluar provider]", nomor);
|
||||||
Toast.show({
|
Toast.show({
|
||||||
type: "success",
|
type: "success",
|
||||||
text1: "Sukses",
|
text1: "Sukses",
|
||||||
@@ -83,10 +86,15 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await AsyncStorage.setItem("kode_otp", response.kodeId);
|
await AsyncStorage.setItem("kode_otp", response.kodeId);
|
||||||
router.replace(`/verification?nomor=${nomor}`);
|
router.push(`/verification?nomor=${nomor}`);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
router.replace(`/register?nomor=${nomor}`);
|
router.push(`/register?nomor=${nomor}`);
|
||||||
|
Toast.show({
|
||||||
|
type: "info",
|
||||||
|
text1: "Info",
|
||||||
|
text2: "Silahkan mendaftar",
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>10</string>
|
<string>12</string>
|
||||||
<key>ITSAppUsesNonExemptEncryption</key>
|
<key>ITSAppUsesNonExemptEncryption</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { NewWrapper } from "@/components";
|
||||||
import ButtonCustom from "@/components/Button/ButtonCustom";
|
import ButtonCustom from "@/components/Button/ButtonCustom";
|
||||||
import Spacing from "@/components/_ShareComponent/Spacing";
|
import Spacing from "@/components/_ShareComponent/Spacing";
|
||||||
import ViewWrapper from "@/components/_ShareComponent/ViewWrapper";
|
import ViewWrapper from "@/components/_ShareComponent/ViewWrapper";
|
||||||
@@ -5,9 +6,11 @@ import { MainColor } from "@/constants/color-palet";
|
|||||||
import { useAuth } from "@/hooks/use-auth";
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
import { apiVersion } from "@/service/api-config";
|
import { apiVersion } from "@/service/api-config";
|
||||||
import { GStyles } from "@/styles/global-styles";
|
import { GStyles } from "@/styles/global-styles";
|
||||||
import { Redirect, router } from "expo-router";
|
import versionBadge from "@/utils/viersionBadge";
|
||||||
|
import VersionBadge from "@/utils/viersionBadge";
|
||||||
|
import { Redirect } from "expo-router";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Text, View } from "react-native";
|
import { RefreshControl, Text, View } from "react-native";
|
||||||
import PhoneInput, { ICountry } from "react-native-international-phone-number";
|
import PhoneInput, { ICountry } from "react-native-international-phone-number";
|
||||||
import Toast from "react-native-toast-message";
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
@@ -16,6 +19,7 @@ export default function LoginView() {
|
|||||||
const [selectedCountry, setSelectedCountry] = useState<null | ICountry>(null);
|
const [selectedCountry, setSelectedCountry] = useState<null | ICountry>(null);
|
||||||
const [inputValue, setInputValue] = useState<string>("");
|
const [inputValue, setInputValue] = useState<string>("");
|
||||||
const [loading, setLoading] = useState<boolean>(false);
|
const [loading, setLoading] = useState<boolean>(false);
|
||||||
|
const [refreshing, setRefreshing] = useState<boolean>(false);
|
||||||
|
|
||||||
const { loginWithNomor, token, isAdmin, isUserActive } = useAuth();
|
const { loginWithNomor, token, isAdmin, isUserActive } = useAuth();
|
||||||
|
|
||||||
@@ -25,7 +29,18 @@ export default function LoginView() {
|
|||||||
|
|
||||||
async function onLoadVersion() {
|
async function onLoadVersion() {
|
||||||
const res = await apiVersion();
|
const res = await apiVersion();
|
||||||
setVersion(res.data);
|
|
||||||
|
if (res.success) {
|
||||||
|
setVersion(versionBadge());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleRefresh() {
|
||||||
|
setRefreshing(true);
|
||||||
|
await onLoadVersion();
|
||||||
|
setInputValue("");
|
||||||
|
setLoading(false);
|
||||||
|
setRefreshing(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleInputValue(phoneNumber: string) {
|
function handleInputValue(phoneNumber: string) {
|
||||||
@@ -65,8 +80,6 @@ export default function LoginView() {
|
|||||||
const isValid = await validateData();
|
const isValid = await validateData();
|
||||||
if (!isValid) return;
|
if (!isValid) return;
|
||||||
|
|
||||||
// const callingCode = selectedCountry?.callingCode.replace(/^\+/, "") || "";
|
|
||||||
// const fixNumber = inputValue.replace(/\s+/g, "");
|
|
||||||
const callingCode = selectedCountry?.callingCode.replace(/^\+/, "") || "";
|
const callingCode = selectedCountry?.callingCode.replace(/^\+/, "") || "";
|
||||||
let fixNumber = inputValue.replace(/\s+/g, "").replace(/^0+/, "");
|
let fixNumber = inputValue.replace(/\s+/g, "").replace(/^0+/, "");
|
||||||
|
|
||||||
@@ -74,9 +87,7 @@ export default function LoginView() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const response = await loginWithNomor(realNumber);
|
await loginWithNomor(realNumber);
|
||||||
console.log("[RESPONSE UI]", response);
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("Error login", error);
|
console.log("Error login", error);
|
||||||
Toast.show({
|
Toast.show({
|
||||||
@@ -130,7 +141,12 @@ export default function LoginView() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ViewWrapper withBackground>
|
<NewWrapper
|
||||||
|
withBackground
|
||||||
|
refreshControl={
|
||||||
|
<RefreshControl refreshing={refreshing} onRefresh={handleRefresh} />
|
||||||
|
}
|
||||||
|
>
|
||||||
<View style={GStyles.authContainer}>
|
<View style={GStyles.authContainer}>
|
||||||
<View>
|
<View>
|
||||||
<View style={GStyles.authContainerTitle}>
|
<View style={GStyles.authContainerTitle}>
|
||||||
@@ -174,6 +190,6 @@ export default function LoginView() {
|
|||||||
Coba
|
Coba
|
||||||
</ButtonCustom> */}
|
</ButtonCustom> */}
|
||||||
</View>
|
</View>
|
||||||
</ViewWrapper>
|
</NewWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ import Toast from "react-native-toast-message";
|
|||||||
export default function VerificationView() {
|
export default function VerificationView() {
|
||||||
const { nomor } = useLocalSearchParams<{ nomor: string }>();
|
const { nomor } = useLocalSearchParams<{ nomor: string }>();
|
||||||
|
|
||||||
|
console.log("[NOMOR]", nomor);
|
||||||
|
|
||||||
const [inputOtp, setInputOtp] = useState<string>("");
|
const [inputOtp, setInputOtp] = useState<string>("");
|
||||||
const [userNumber, setUserNumber] = useState<string>("");
|
const [userNumber, setUserNumber] = useState<string>("");
|
||||||
const [loading, setLoading] = useState<boolean>(false);
|
const [loading, setLoading] = useState<boolean>(false);
|
||||||
@@ -52,7 +54,7 @@ export default function VerificationView() {
|
|||||||
try {
|
try {
|
||||||
const response = await apiCheckCodeOtp({ kodeId });
|
const response = await apiCheckCodeOtp({ kodeId });
|
||||||
console.log(
|
console.log(
|
||||||
"Response check code otp >>",
|
"[OTP] >>",
|
||||||
JSON.stringify(response.otp, null, 2)
|
JSON.stringify(response.otp, null, 2)
|
||||||
);
|
);
|
||||||
// Kita tidak perlu simpan codeOtp di state karena verifikasi dilakukan di backend
|
// Kita tidak perlu simpan codeOtp di state karena verifikasi dilakukan di backend
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ apiConfig.interceptors.request.use(
|
|||||||
async (config) => {
|
async (config) => {
|
||||||
console.log("API_BASE_URL >>", API_BASE_URL);
|
console.log("API_BASE_URL >>", API_BASE_URL);
|
||||||
const token = await AsyncStorage.getItem("authToken");
|
const token = await AsyncStorage.getItem("authToken");
|
||||||
|
// console.log("[TOKEN] >>", token);
|
||||||
if (token) {
|
if (token) {
|
||||||
// config.timeout = 10000;
|
// config.timeout = 10000;
|
||||||
config.headers["Content-Type"] = "application/json";
|
config.headers["Content-Type"] = "application/json";
|
||||||
@@ -33,7 +34,7 @@ export async function apiVersion() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function apiLogin({ nomor }: { nomor: string }) {
|
export async function apiLogin({ nomor }: { nomor: string }) {
|
||||||
const response = await apiConfig.post("/mobile/auth/login", {
|
const response = await apiConfig.post("/auth/mobile-login", {
|
||||||
nomor: nomor,
|
nomor: nomor,
|
||||||
});
|
});
|
||||||
return response.data;;
|
return response.data;;
|
||||||
@@ -45,7 +46,7 @@ export async function apiCheckCodeOtp({ kodeId }: { kodeId: string }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function apiValidationCode({ nomor }: { nomor: string }) {
|
export async function apiValidationCode({ nomor }: { nomor: string }) {
|
||||||
const response = await apiConfig.post(`/auth/validasi`, {
|
const response = await apiConfig.post(`/auth/mobile-validasi`, {
|
||||||
nomor: nomor,
|
nomor: nomor,
|
||||||
});
|
});
|
||||||
return response.data;
|
return response.data;
|
||||||
@@ -56,7 +57,7 @@ export async function apiRegister({
|
|||||||
}: {
|
}: {
|
||||||
data: { nomor: string; username: string; termsOfServiceAccepted: boolean };
|
data: { nomor: string; username: string; termsOfServiceAccepted: boolean };
|
||||||
}) {
|
}) {
|
||||||
const response = await apiConfig.post(`/mobile/auth/register`, {
|
const response = await apiConfig.post(`/auth/mobile-register`, {
|
||||||
data: data,
|
data: data,
|
||||||
});
|
});
|
||||||
return response.data;
|
return response.data;
|
||||||
|
|||||||
18
utils/viersionBadge.ts
Normal file
18
utils/viersionBadge.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
// VersionBadge.tsx
|
||||||
|
import Constants from "expo-constants";
|
||||||
|
import { Platform } from "react-native";
|
||||||
|
|
||||||
|
export default function versionBadge() {
|
||||||
|
const expoConfig = Constants.expoConfig;
|
||||||
|
|
||||||
|
const version = expoConfig?.version; // "1.0.1"
|
||||||
|
const iosBuild = expoConfig?.ios?.buildNumber; // "10"
|
||||||
|
const androidBuild = expoConfig?.android?.versionCode; // 2
|
||||||
|
|
||||||
|
const build =
|
||||||
|
Platform.OS === "ios" ? iosBuild : androidBuild;
|
||||||
|
|
||||||
|
const result = `${version} ( ${build} )`;
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user