diff --git a/app.config.js b/app.config.js index f253074..ddb73a0 100644 --- a/app.config.js +++ b/app.config.js @@ -4,7 +4,7 @@ export default { expo: { name: "mobile-darmasaba", slug: "mobile-darmasaba", - version: "1.0.0", + version: "1.0.2", jsEngine: "jsc", orientation: "portrait", icon: "./assets/images/icon.png", @@ -21,12 +21,19 @@ export default { }, android: { package: "mobiledarmasaba.app", - versionCode: 1, + versionCode: 6, adaptiveIcon: { foregroundImage: "./assets/images/splash-icon.png", backgroundColor: "#ffffff" }, - googleServicesFile: "./google-services.json" + googleServicesFile: "./google-services.json", + permissions: [ + "READ_EXTERNAL_STORAGE", + "WRITE_EXTERNAL_STORAGE", + "READ_MEDIA_IMAGES", // Android 13+ + "READ_MEDIA_VIDEO", // Android 13+ + "READ_MEDIA_AUDIO" // Android 13+ + ] }, web: { bundler: "metro", diff --git a/app/(application)/_layout.tsx b/app/(application)/_layout.tsx index ba8a7fd..1d1e720 100644 --- a/app/(application)/_layout.tsx +++ b/app/(application)/_layout.tsx @@ -148,7 +148,7 @@ export default function RootLayout() { }} /> - + ) diff --git a/bump-version.js b/bump-version.js new file mode 100644 index 0000000..d6ec7c3 --- /dev/null +++ b/bump-version.js @@ -0,0 +1,38 @@ +const fs = require("fs"); +const path = require("path"); + +const configPath = path.join(__dirname, "app.config.js"); +let configFile = fs.readFileSync(configPath, "utf8"); + +// --- Update versionCode --- +const codeRegex = /versionCode:\s*(\d+)/; +const codeMatch = configFile.match(codeRegex); + +if (!codeMatch) { + console.error("❌ Tidak menemukan versionCode di app.config.js"); + process.exit(1); +} + +const currentCode = parseInt(codeMatch[1], 10); +const newCode = currentCode + 1; +configFile = configFile.replace(codeRegex, `versionCode: ${newCode}`); + +// --- Update versionName --- +const nameRegex = /version:\s*"(.*?)"/; +const nameMatch = configFile.match(nameRegex); + +if (!nameMatch) { + console.error("❌ Tidak menemukan version di app.config.js"); + process.exit(1); +} + +let [major, minor, patch] = nameMatch[1].split(".").map(Number); +patch += 1; // bump patch version +const newName = `${major}.${minor}.${patch}`; +configFile = configFile.replace(nameRegex, `version: "${newName}"`); + +// --- Simpan file --- +fs.writeFileSync(configPath, configFile, "utf8"); + +console.log(`✅ versionCode: ${currentCode} → ${newCode}`); +console.log(`✅ versionName: ${nameMatch[1]} → ${newName}`); diff --git a/components/auth/viewLogin.tsx b/components/auth/viewLogin.tsx index 6f1ab07..4f8d544 100644 --- a/components/auth/viewLogin.tsx +++ b/components/auth/viewLogin.tsx @@ -1,8 +1,10 @@ import Styles from "@/constants/Styles" import { apiCheckPhoneLogin, apiSendOtp } from "@/lib/api" +import { useAuthSession } from "@/providers/AuthProvider" import AsyncStorage from "@react-native-async-storage/async-storage" +import { StatusBar } from "expo-status-bar" import { useState } from "react" -import { Image, SafeAreaView, View } from "react-native" +import { Image, Platform, SafeAreaView, View } from "react-native" import Toast from "react-native-toast-message" import { ButtonForm } from "../buttonForm" import { InputForm } from "../inputForm" @@ -10,7 +12,6 @@ import ModalLoading from "../modalLoading" import Text from "../Text" import ToastCustom from "../toastCustom" - type Props = { onValidate: ({ phone, otp }: { phone: string, otp: number }) => void } @@ -19,20 +20,27 @@ export default function ViewLogin({ onValidate }: Props) { const [loadingLogin, setLoadingLogin] = useState(false) const [disableLogin, setDisableLogin] = useState(true) const [phone, setPhone] = useState('') + const { signIn, encryptToken } = useAuthSession(); const handleCheckPhone = async () => { try { setLoadingLogin(true) - const response = await apiCheckPhoneLogin({ phone: `62${phone}` }); + const response = await apiCheckPhoneLogin({ phone: `62${phone}` }) if (response.success) { - const otp = Math.floor(1000 + Math.random() * 9000) - const responseOtp = await apiSendOtp({ phone: `62${phone}`, otp }) - if (responseOtp == 200) { - await AsyncStorage.setItem('user', response.id); - return onValidate({ phone: `62${phone}`, otp }) + if (response.isWithoutOTP) { + const encrypted = await encryptToken(response.id) + signIn(encrypted) + } else { + const otp = Math.floor(1000 + Math.random() * 9000) + const responseOtp = await apiSendOtp({ phone: `62${phone}`, otp }) + if (responseOtp == 200) { + await AsyncStorage.setItem('user', response.id) + return onValidate({ phone: `62${phone}`, otp }) + } } + } else { + return Toast.show({ type: 'small', text1: response.message, position: 'top' }) } - return Toast.show({ type: 'small', text1: response.message, position: 'top' }) } catch (error) { return Toast.show({ type: 'small', text1: 'Terjadi kesalahan', position: 'top' }) } finally { @@ -42,6 +50,7 @@ export default function ViewLogin({ onValidate }: Props) { return ( + diff --git a/components/auth/viewVerification.tsx b/components/auth/viewVerification.tsx index 9b05956..7416b5f 100644 --- a/components/auth/viewVerification.tsx +++ b/components/auth/viewVerification.tsx @@ -2,8 +2,9 @@ import Styles from "@/constants/Styles"; import { apiSendOtp } from "@/lib/api"; import { useAuthSession } from "@/providers/AuthProvider"; import AsyncStorage from "@react-native-async-storage/async-storage"; +import { StatusBar } from "expo-status-bar"; import { useState } from "react"; -import { Image, View } from "react-native"; +import { Image, Platform, View } from "react-native"; import { OtpInput } from "react-native-otp-entry"; import Toast from 'react-native-toast-message'; import { ButtonForm } from "../buttonForm"; @@ -56,6 +57,7 @@ export default function ViewVerification({ phone, otp }: Props) { return ( <> + diff --git a/eas.json b/eas.json index 1545412..481c66b 100644 --- a/eas.json +++ b/eas.json @@ -1,7 +1,7 @@ { "cli": { "version": ">= 16.10.0", - "appVersionSource": "remote" + "appVersionSource": "local" }, "build": { "development": { @@ -53,4 +53,4 @@ } } } -} +} \ No newline at end of file diff --git a/lib/api.ts b/lib/api.ts index 89a071b..5b88457 100644 --- a/lib/api.ts +++ b/lib/api.ts @@ -2,9 +2,6 @@ import axios from 'axios'; import Constants from 'expo-constants'; const api = axios.create({ - // baseURL: 'http://10.0.2.2:3000/api', - // baseURL: 'https://stg-darmasaba.wibudev.com/api', - // baseURL: 'http://192.168.154.198:3000/api', baseURL: Constants?.expoConfig?.extra?.URL_API }); diff --git a/package.json b/package.json index 31b5d7b..c81e9d6 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,9 @@ "ios": "expo run:ios", "web": "expo start --web", "test": "jest --watchAll", - "lint": "expo lint" + "lint": "expo lint", + "bump": "node bump-version.js", + "build:android": "npm run bump && eas build -p android --profile production" }, "jest": { "preset": "jest-expo"