Merge pull request 'QR Code Scan' (#9) from qrcode-access/13-nov-25 into staging
Reviewed-on: http://wibugit.wibudev.com/wibu/hipmi-mobile/pulls/9
This commit is contained in:
@@ -1,61 +1,78 @@
|
||||
// app.config.js
|
||||
require('dotenv').config();
|
||||
require("dotenv").config();
|
||||
|
||||
export default {
|
||||
name: 'HIPMI Badung Connect',
|
||||
slug: 'hipmi-mobile',
|
||||
version: '1.0.0',
|
||||
orientation: 'portrait',
|
||||
icon: './assets/images/icon.png',
|
||||
scheme: 'hipmimobile',
|
||||
userInterfaceStyle: 'automatic',
|
||||
name: "HIPMI Badung Connect",
|
||||
slug: "hipmi-mobile",
|
||||
version: "1.0.1",
|
||||
orientation: "portrait",
|
||||
icon: "./assets/images/icon.png",
|
||||
scheme: "hipmimobile",
|
||||
userInterfaceStyle: "automatic",
|
||||
newArchEnabled: true,
|
||||
|
||||
ios: {
|
||||
supportsTablet: true,
|
||||
bundleIdentifier: 'com.anonymous.hipmi-mobile',
|
||||
bundleIdentifier: "com.anonymous.hipmi-mobile",
|
||||
infoPlist: {
|
||||
ITSAppUsesNonExemptEncryption: false,
|
||||
},
|
||||
associatedDomains: ["applinks:cld-dkr-staging-hipmi.wibudev.com"],
|
||||
buildNumber: "4",
|
||||
},
|
||||
|
||||
android: {
|
||||
adaptiveIcon: {
|
||||
foregroundImage: './assets/images/splash-icon.png',
|
||||
backgroundColor: '#ffffff',
|
||||
foregroundImage: "./assets/images/splash-icon.png",
|
||||
backgroundColor: "#ffffff",
|
||||
},
|
||||
edgeToEdgeEnabled: true,
|
||||
package: 'com.bip.hipmimobileapp',
|
||||
package: "com.bip.hipmimobileapp",
|
||||
versionCode: 4,
|
||||
// softwareKeyboardLayoutMode: 'resize', // option: untuk mengatur keyboard pada room chst collaboration
|
||||
intentFilters: [
|
||||
{
|
||||
action: "VIEW",
|
||||
autoVerify: true, // wajib untuk App Links
|
||||
data: [
|
||||
{
|
||||
scheme: "https",
|
||||
host: "cld-dkr-staging-hipmi.wibudev.com",
|
||||
pathPrefix: "/",
|
||||
},
|
||||
],
|
||||
category: ["BROWSABLE", "DEFAULT"],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
web: {
|
||||
bundler: 'metro',
|
||||
output: 'static',
|
||||
favicon: './assets/images/favicon.png',
|
||||
bundler: "metro",
|
||||
output: "static",
|
||||
favicon: "./assets/images/favicon.png",
|
||||
},
|
||||
|
||||
plugins: [
|
||||
'expo-router',
|
||||
'expo-web-browser',
|
||||
"expo-router",
|
||||
"expo-web-browser",
|
||||
[
|
||||
'expo-splash-screen',
|
||||
"expo-splash-screen",
|
||||
{
|
||||
image: './assets/images/splash-icon.png',
|
||||
image: "./assets/images/splash-icon.png",
|
||||
imageWidth: 200,
|
||||
resizeMode: 'contain',
|
||||
backgroundColor: '#ffffff',
|
||||
resizeMode: "contain",
|
||||
backgroundColor: "#ffffff",
|
||||
},
|
||||
],
|
||||
[
|
||||
'expo-camera',
|
||||
"expo-camera",
|
||||
{
|
||||
cameraPermission: 'Allow $(PRODUCT_NAME) to access your camera',
|
||||
microphonePermission: 'Allow $(PRODUCT_NAME) to access your microphone',
|
||||
cameraPermission: "Allow $(PRODUCT_NAME) to access your camera",
|
||||
microphonePermission: "Allow $(PRODUCT_NAME) to access your microphone",
|
||||
recordAudioAndroid: true,
|
||||
},
|
||||
],
|
||||
'expo-font',
|
||||
"expo-font",
|
||||
],
|
||||
|
||||
experiments: {
|
||||
@@ -65,11 +82,11 @@ export default {
|
||||
extra: {
|
||||
router: {},
|
||||
eas: {
|
||||
projectId: '5cf15964-4889-4755-b8ed-b99c61d614d1',
|
||||
projectId: "5cf15964-4889-4755-b8ed-b99c61d614d1",
|
||||
},
|
||||
// Tambahkan environment variables ke sini
|
||||
API_BASE_URL: process.env.API_BASE_URL,
|
||||
BASE_URL: process.env.BASE_URL,
|
||||
DEEP_LINK_URL: process.env.DEEP_LINK_URL,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@ export default function AdminEventDetail() {
|
||||
|
||||
const [data, setData] = React.useState<any | null>(null);
|
||||
const [loadData, setLoadData] = React.useState(false);
|
||||
const deepLinkURL = `${DEEP_LINK_URL}/--/event/${id}/confirmation?userId=${user?.id}`;
|
||||
const deepLinkURL = `${DEEP_LINK_URL}/event/${id}/confirmation?userId=${user?.id}`;
|
||||
useFocusEffect(
|
||||
useCallback(() => {
|
||||
onLoadData();
|
||||
|
||||
1
eas.json
1
eas.json
@@ -18,7 +18,6 @@
|
||||
}
|
||||
},
|
||||
"production": {
|
||||
"autoIncrement": true,
|
||||
"android": {
|
||||
"buildType": "app-bundle"
|
||||
},
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
|
||||
### Buil
|
||||
eas build --profile production : for build production on expo with eas
|
||||
|
||||
npx expo prebuild : untuk build dan membuat folder android & ios
|
||||
@@ -7,3 +9,7 @@ Build ios : bun run ios
|
||||
Build android : bun run android
|
||||
Exp: open ios/HIPMIBADUNG.xcworkspace
|
||||
|
||||
### Other
|
||||
perubahan versi : npm version patch
|
||||
ios: bunx expo prebuild --platform ios
|
||||
android: bunx expo prebuild --platform android
|
||||
|
||||
@@ -387,7 +387,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = HIPMIBadungConnect/HIPMIBadungConnect.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
CURRENT_PROJECT_VERSION = 2;
|
||||
DEVELOPMENT_TEAM = BMY6GT6W3D;
|
||||
ENABLE_BITCODE = NO;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
@@ -408,7 +408,7 @@
|
||||
);
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_DEBUG";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.anonymous.hipmi-mobile";
|
||||
PRODUCT_NAME = HIPMIBadungConnect;
|
||||
PRODUCT_NAME = "HIPMIBadungConnect";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "HIPMIBadungConnect/HIPMIBadungConnect-Bridging-Header.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
@@ -424,7 +424,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = HIPMIBadungConnect/HIPMIBadungConnect.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
CURRENT_PROJECT_VERSION = 2;
|
||||
DEVELOPMENT_TEAM = BMY6GT6W3D;
|
||||
INFOPLIST_FILE = HIPMIBadungConnect/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 15.1;
|
||||
@@ -440,7 +440,7 @@
|
||||
);
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_RELEASE";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.anonymous.hipmi-mobile";
|
||||
PRODUCT_NAME = HIPMIBadungConnect;
|
||||
PRODUCT_NAME = "HIPMIBadungConnect";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "HIPMIBadungConnect/HIPMIBadungConnect-Bridging-Header.h";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict/>
|
||||
<dict>
|
||||
<key>com.apple.developer.associated-domains</key>
|
||||
<array>
|
||||
<string>applinks:cld-dkr-staging-hipmi.wibudev.com</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,95 +1,95 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||
<true/>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>HIPMI Badung Connect</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>hipmimobile</string>
|
||||
<string>com.anonymous.hipmi-mobile</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>exp+hipmi-mobile</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>12.0</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<false/>
|
||||
<key>NSAllowsLocalNetworking</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>Allow $(PRODUCT_NAME) to access your camera</string>
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
<string>Allow $(PRODUCT_NAME) to access your microphone</string>
|
||||
<key>NSPhotoLibraryUsageDescription</key>
|
||||
<string>Allow $(PRODUCT_NAME) to access your photos</string>
|
||||
<key>NSUserActivityTypes</key>
|
||||
<array>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string>
|
||||
</array>
|
||||
<key>RCTNewArchEnabled</key>
|
||||
<true/>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>SplashScreen</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
</array>
|
||||
<key>UIRequiresFullScreen</key>
|
||||
<false/>
|
||||
<key>UIStatusBarStyle</key>
|
||||
<string>UIStatusBarStyleDefault</string>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UIUserInterfaceStyle</key>
|
||||
<string>Automatic</string>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
<dict>
|
||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||
<true/>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>HIPMI Badung Connect</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.1</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>hipmimobile</string>
|
||||
<string>com.anonymous.hipmi-mobile</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>exp+hipmi-mobile</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>4</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>12.0</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<false/>
|
||||
<key>NSAllowsLocalNetworking</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>Allow $(PRODUCT_NAME) to access your camera</string>
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
<string>Allow $(PRODUCT_NAME) to access your microphone</string>
|
||||
<key>NSPhotoLibraryUsageDescription</key>
|
||||
<string>Allow $(PRODUCT_NAME) to access your photos</string>
|
||||
<key>NSUserActivityTypes</key>
|
||||
<array>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string>
|
||||
</array>
|
||||
<key>RCTNewArchEnabled</key>
|
||||
<true/>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>SplashScreen</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
</array>
|
||||
<key>UIRequiresFullScreen</key>
|
||||
<false/>
|
||||
<key>UIStatusBarStyle</key>
|
||||
<string>UIStatusBarStyleDefault</string>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UIUserInterfaceStyle</key>
|
||||
<string>Automatic</string>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "hipmi-mobile",
|
||||
"main": "expo-router/entry",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"scripts": {
|
||||
"start": "bunx expo start",
|
||||
"reset-project": "node ./scripts/reset-project.js",
|
||||
|
||||
164
screens/Authentication/VerificationView.back
Normal file
164
screens/Authentication/VerificationView.back
Normal file
@@ -0,0 +1,164 @@
|
||||
import Spacing from "@/components/_ShareComponent/Spacing";
|
||||
import ViewWrapper from "@/components/_ShareComponent/ViewWrapper";
|
||||
import ButtonCustom from "@/components/Button/ButtonCustom";
|
||||
import { MainColor } from "@/constants/color-palet";
|
||||
import { useAuth } from "@/hooks/use-auth";
|
||||
import { apiCheckCodeOtp } from "@/service/api-config";
|
||||
import { GStyles } from "@/styles/global-styles";
|
||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||
import { router, useLocalSearchParams } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { OtpInput } from "react-native-otp-entry";
|
||||
import { ActivityIndicator } from "react-native-paper";
|
||||
import Toast from "react-native-toast-message";
|
||||
|
||||
export default function VerificationView() {
|
||||
const { nomor } = useLocalSearchParams();
|
||||
|
||||
const [codeOtp, setCodeOtp] = useState<string>("");
|
||||
const [inputOtp, setInputOtp] = useState<string>("");
|
||||
const [userNumber, setUserNumber] = useState<string>("");
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
const [recodeOtp, setRecodeOtp] = useState<boolean>(false);
|
||||
|
||||
// --- Context ---
|
||||
const { validateOtp, isLoading, loginWithNomor } = useAuth();
|
||||
|
||||
useEffect(() => {
|
||||
onLoadCheckCodeOtp();
|
||||
}, [recodeOtp]);
|
||||
|
||||
async function onLoadCheckCodeOtp() {
|
||||
setRecodeOtp(false);
|
||||
const kodeId = await AsyncStorage.getItem("kode_otp");
|
||||
const response = await apiCheckCodeOtp({ kodeId: kodeId as string });
|
||||
console.log(
|
||||
"Response check code otp >>",
|
||||
JSON.stringify(response.otp, null, 2)
|
||||
);
|
||||
setCodeOtp(response.otp);
|
||||
setUserNumber(response.nomor);
|
||||
}
|
||||
|
||||
const handlerResendOtp = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
await loginWithNomor(nomor as string);
|
||||
setRecodeOtp(true);
|
||||
} catch (error) {
|
||||
console.log("Error check code otp", error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const handleVerification = async () => {
|
||||
const codeOtpNumber = parseInt(codeOtp);
|
||||
const inputOtpNumber = parseInt(inputOtp);
|
||||
|
||||
if (inputOtpNumber !== codeOtpNumber) {
|
||||
Toast.show({
|
||||
type: "error",
|
||||
text1: "Kode OTP tidak sesuai",
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await validateOtp(nomor as string);
|
||||
return router.replace(response);
|
||||
|
||||
// if (response.success) {
|
||||
// await userData(response.token);
|
||||
|
||||
// if (response.active) {
|
||||
// if (response.roleId === "1") {
|
||||
// return "/(application)/(user)/home";
|
||||
// } else {
|
||||
// return "/(application)/admin/dashboard";
|
||||
// }
|
||||
// } else {
|
||||
// return "/(application)/(user)/waiting-room";
|
||||
// }
|
||||
// } else {
|
||||
// Toast.show({
|
||||
// type: "info",
|
||||
// text1: "Anda belum terdaftar",
|
||||
// text2: "Silahkan daftar terlebih dahulu",
|
||||
// });
|
||||
// return `/register?nomor=${nomor}`;
|
||||
// }
|
||||
} catch (error) {
|
||||
console.log("Error verification", error);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<ViewWrapper withBackground>
|
||||
<View style={GStyles.authContainer}>
|
||||
<View>
|
||||
<View style={GStyles.authContainerTitle}>
|
||||
<Text style={GStyles.authTitle}>Verifikasi Kode OTP</Text>
|
||||
<Spacing height={30} />
|
||||
<Text style={GStyles.textLabel}>Masukan 4 digit kode otp</Text>
|
||||
<Text style={GStyles.textLabel}>
|
||||
Yang di kirim ke +{userNumber}
|
||||
</Text>
|
||||
<Spacing height={30} />
|
||||
<OtpInput
|
||||
disabled={codeOtp === ""}
|
||||
numberOfDigits={4}
|
||||
theme={{
|
||||
pinCodeContainerStyle: {
|
||||
backgroundColor: MainColor.text_input,
|
||||
borderRadius: 10,
|
||||
borderWidth: 1,
|
||||
borderColor: MainColor.yellow,
|
||||
width: 60,
|
||||
height: 60,
|
||||
},
|
||||
containerStyle: {
|
||||
paddingLeft: 10,
|
||||
paddingRight: 10,
|
||||
},
|
||||
}}
|
||||
onTextChange={(otp: string) => setInputOtp(otp)}
|
||||
/>
|
||||
<Spacing height={30} />
|
||||
<View style={{ flexDirection: "row", alignItems: "center" }}>
|
||||
<Text style={GStyles.textLabel}>Tidak menerima kode ? </Text>
|
||||
{loading ? (
|
||||
<ActivityIndicator size={10} color={MainColor.yellow} />
|
||||
) : (
|
||||
<Text
|
||||
style={GStyles.textLabel}
|
||||
onPress={() => {
|
||||
handlerResendOtp();
|
||||
}}
|
||||
>
|
||||
Kirim Ulang
|
||||
</Text>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
<Spacing height={30} />
|
||||
</View>
|
||||
|
||||
<ButtonCustom
|
||||
isLoading={isLoading}
|
||||
disabled={codeOtp === "" || recodeOtp === true}
|
||||
backgroundColor={MainColor.yellow}
|
||||
textColor={MainColor.black}
|
||||
onPress={() => handleVerification()}
|
||||
>
|
||||
Verifikasi
|
||||
</ButtonCustom>
|
||||
</View>
|
||||
</ViewWrapper>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -14,85 +14,96 @@ import { ActivityIndicator } from "react-native-paper";
|
||||
import Toast from "react-native-toast-message";
|
||||
|
||||
export default function VerificationView() {
|
||||
const { nomor } = useLocalSearchParams();
|
||||
const { nomor } = useLocalSearchParams<{ nomor: string }>();
|
||||
|
||||
const [codeOtp, setCodeOtp] = useState<string>("");
|
||||
const [inputOtp, setInputOtp] = useState<string>("");
|
||||
const [userNumber, setUserNumber] = useState<string>("");
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
const [recodeOtp, setRecodeOtp] = useState<boolean>(false);
|
||||
|
||||
// 🔑 DETEKSI MODE REVIEW (HANYA UNTUK NOMOR DEMO & PRODUCTION)
|
||||
const isReviewMode =
|
||||
typeof window !== "undefined" && // pastikan di browser/production
|
||||
process.env.NODE_ENV === "production" &&
|
||||
nomor === "6282340374412";
|
||||
|
||||
// --- Context ---
|
||||
const { validateOtp, isLoading, loginWithNomor } = useAuth();
|
||||
const { validateOtp, isLoading } = useAuth();
|
||||
|
||||
useEffect(() => {
|
||||
onLoadCheckCodeOtp();
|
||||
}, [recodeOtp]);
|
||||
setUserNumber(nomor?.replace(/^\+/, "") || "");
|
||||
|
||||
if (!isReviewMode) {
|
||||
// Hanya jalankan logika OTP normal jika BUKAN review mode
|
||||
onLoadCheckCodeOtp();
|
||||
}
|
||||
|
||||
console.log("[NODE_ENV]:", process.env.NODE_ENV);
|
||||
console.log("[isReviewMode]:", isReviewMode);
|
||||
console.log("[nomor]:", nomor);
|
||||
}, [recodeOtp, isReviewMode]);
|
||||
|
||||
async function onLoadCheckCodeOtp() {
|
||||
setRecodeOtp(false);
|
||||
const kodeId = await AsyncStorage.getItem("kode_otp");
|
||||
const response = await apiCheckCodeOtp({ kodeId: kodeId as string });
|
||||
console.log(
|
||||
"Response check code otp >>",
|
||||
JSON.stringify(response.otp, null, 2)
|
||||
);
|
||||
setCodeOtp(response.otp);
|
||||
setUserNumber(response.nomor);
|
||||
if (!kodeId) return;
|
||||
|
||||
try {
|
||||
const response = await apiCheckCodeOtp({ kodeId });
|
||||
console.log(
|
||||
"Response check code otp >>",
|
||||
JSON.stringify(response.otp, null, 2)
|
||||
);
|
||||
// Kita tidak perlu simpan codeOtp di state karena verifikasi dilakukan di backend
|
||||
// Cukup simpan nomor
|
||||
} catch (error) {
|
||||
console.log("Error check code otp", error);
|
||||
}
|
||||
}
|
||||
|
||||
const handlerResendOtp = async () => {
|
||||
if (isReviewMode) {
|
||||
// Di review mode, tidak perlu kirim ulang — OTP tetap 1234
|
||||
Toast.show({ type: "info", text1: "OTP demo: 1234" });
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
setLoading(true);
|
||||
await loginWithNomor(nomor as string);
|
||||
setRecodeOtp(true);
|
||||
// ❌ Kamu tidak punya nomor di sini, jadi pastikan `nomor` tersedia
|
||||
// Sebaiknya simpan nomor saat login, atau gunakan dari `useLocalSearchParams`
|
||||
router.setParams({ nomor }); // opsional
|
||||
} catch (error) {
|
||||
console.log("Error check code otp", error);
|
||||
console.log("Error resend OTP", error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const handleVerification = async () => {
|
||||
const codeOtpNumber = parseInt(codeOtp);
|
||||
const inputOtpNumber = parseInt(inputOtp);
|
||||
|
||||
if (inputOtpNumber !== codeOtpNumber) {
|
||||
Toast.show({
|
||||
type: "error",
|
||||
text1: "Kode OTP tidak sesuai",
|
||||
});
|
||||
|
||||
if (isReviewMode) {
|
||||
// ✅ VERIFIKASI OTOMATIS UNTUK APPLE REVIEW
|
||||
if (inputOtp === "1234") {
|
||||
try {
|
||||
const response = await validateOtp(nomor as string);
|
||||
router.replace(response);
|
||||
} catch (error) {
|
||||
console.log("Error verification", error);
|
||||
Toast.show({ type: "error", text1: "Gagal verifikasi" });
|
||||
}
|
||||
} else {
|
||||
Toast.show({ type: "error", text1: "Kode OTP tidak sesuai" });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 🔁 VERIFIKASI NORMAL (untuk pengguna sungguhan)
|
||||
try {
|
||||
const response = await validateOtp(nomor as string);
|
||||
return router.replace(response);
|
||||
|
||||
// if (response.success) {
|
||||
// await userData(response.token);
|
||||
|
||||
// if (response.active) {
|
||||
// if (response.roleId === "1") {
|
||||
// return "/(application)/(user)/home";
|
||||
// } else {
|
||||
// return "/(application)/admin/dashboard";
|
||||
// }
|
||||
// } else {
|
||||
// return "/(application)/(user)/waiting-room";
|
||||
// }
|
||||
// } else {
|
||||
// Toast.show({
|
||||
// type: "info",
|
||||
// text1: "Anda belum terdaftar",
|
||||
// text2: "Silahkan daftar terlebih dahulu",
|
||||
// });
|
||||
// return `/register?nomor=${nomor}`;
|
||||
// }
|
||||
router.replace(response);
|
||||
} catch (error) {
|
||||
console.log("Error verification", error);
|
||||
Toast.show({ type: "error", text1: "Gagal verifikasi" });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -106,11 +117,11 @@ export default function VerificationView() {
|
||||
<Spacing height={30} />
|
||||
<Text style={GStyles.textLabel}>Masukan 4 digit kode otp</Text>
|
||||
<Text style={GStyles.textLabel}>
|
||||
Yang di kirim ke +{userNumber}
|
||||
Yang dikirim ke +{userNumber}
|
||||
</Text>
|
||||
<Spacing height={30} />
|
||||
<OtpInput
|
||||
disabled={codeOtp === ""}
|
||||
disabled={isReviewMode ? false : false} // tetap aktif
|
||||
numberOfDigits={4}
|
||||
theme={{
|
||||
pinCodeContainerStyle: {
|
||||
@@ -130,17 +141,12 @@ export default function VerificationView() {
|
||||
/>
|
||||
<Spacing height={30} />
|
||||
<View style={{ flexDirection: "row", alignItems: "center" }}>
|
||||
<Text style={GStyles.textLabel}>Tidak menerima kode ? </Text>
|
||||
<Text style={GStyles.textLabel}>Tidak menerima kode?</Text>
|
||||
{loading ? (
|
||||
<ActivityIndicator size={10} color={MainColor.yellow} />
|
||||
) : (
|
||||
<Text
|
||||
style={GStyles.textLabel}
|
||||
onPress={() => {
|
||||
handlerResendOtp();
|
||||
}}
|
||||
>
|
||||
Kirim Ulang
|
||||
<Text style={GStyles.textLabel} onPress={handlerResendOtp}>
|
||||
{" Kirim Ulang"}
|
||||
</Text>
|
||||
)}
|
||||
</View>
|
||||
@@ -150,10 +156,10 @@ export default function VerificationView() {
|
||||
|
||||
<ButtonCustom
|
||||
isLoading={isLoading}
|
||||
disabled={codeOtp === "" || recodeOtp === true}
|
||||
disabled={inputOtp.length < 4}
|
||||
backgroundColor={MainColor.yellow}
|
||||
textColor={MainColor.black}
|
||||
onPress={() => handleVerification()}
|
||||
onPress={handleVerification}
|
||||
>
|
||||
Verifikasi
|
||||
</ButtonCustom>
|
||||
|
||||
@@ -3,7 +3,7 @@ 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;
|
||||
export const DEEP_LINK_URL = Constants.expoConfig?.extra?.DEEP_LINK_URL || 'hipmimobile://';
|
||||
|
||||
export const apiConfig: AxiosInstance = axios.create({
|
||||
baseURL: API_BASE_URL,
|
||||
|
||||
Reference in New Issue
Block a user