diff --git a/app/(application)/(user)/home.tsx b/app/(application)/(user)/home.tsx index 75ef4fb..f79038d 100644 --- a/app/(application)/(user)/home.tsx +++ b/app/(application)/(user)/home.tsx @@ -16,25 +16,32 @@ import { useEffect, useState } from "react"; export default function Application() { const { token, user } = useAuth(); - const [data, setData] = useState(); - + useEffect(() => { onLoadData(); checkVersion(); }, []); - + async function onLoadData() { const response = await apiUser(user?.id as string); - console.log("Response profile >>", JSON.stringify(response?.data?.Profile, null, 2)); - + console.log( + "[Profile ID]>>", + JSON.stringify(response?.data?.Profile.id, null, 2) + ); + setData(response.data); } - + const checkVersion = async () => { const response = await apiVersion(); - console.log("Version >>", JSON.stringify(response.data, null, 2)); + console.log("[Version] >>", JSON.stringify(response.data, null, 2)); }; + + if (user && user?.termsOfServiceAccepted === false) { + console.log("User is not accept term service"); + return ; + } if (data && data?.active === false) { console.log("User is not active"); diff --git a/app/(application)/_layout.tsx b/app/(application)/_layout.tsx index 952f811..57e4922 100644 --- a/app/(application)/_layout.tsx +++ b/app/(application)/_layout.tsx @@ -9,6 +9,7 @@ export default function ApplicationLayout() { + {/* Take Picture */} { + try { + setIsLoading(true); + const response = await apiAcceptTermService({ + data: { + id: user?.id as string, + termsOfServiceAccepted: term, + }, + }); + + if (!response.success) { + Toast.show({ + type: "error", + text1: "Gagal", + text2: response.message, + }); + + return; + } + + Toast.show({ + type: "success", + text1: "Anda berhasil menerima syarat & ketentuan", + text2: "Silahkan login kembali", + }); + + setTimeout(() => { + logout(); + }, 2000); + } catch (error) { + console.log("error", error); + } finally { + setIsLoading(false); + } + }; + + const footerComponent = ( + + + Setuju + + + ); + + return ( + <> + + + + + + + setTerm(!term)} /> + + + Saya setuju dengan{" "} + { + const toUrl = `${url}/terms-of-service.html`; + openBrowser(toUrl); + }} + > + Syarat & Ketentuan + {" "} + yang melarang konten tidak pantas dan perilaku merugikan. + + + + + + ); +} diff --git a/context/AuthContext.tsx b/context/AuthContext.tsx index 153e485..2d92e7d 100644 --- a/context/AuthContext.tsx +++ b/context/AuthContext.tsx @@ -24,6 +24,7 @@ type AuthContextType = { registerUser: (userData: { username: string; nomor: string; + termsOfServiceAccepted: boolean; }) => Promise; userData: (token: string) => Promise; }; @@ -154,10 +155,12 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => { const registerUser = async (userData: { username: string; nomor: string; + termsOfServiceAccepted: boolean; }) => { setIsLoading(true); try { const response = await apiRegister({ data: userData }); + console.log("response", response); const { token } = response; if (!response.success) { diff --git a/ios/HIPMIBadungConnect/Info.plist b/ios/HIPMIBadungConnect/Info.plist index 4e8209f..dedab2d 100644 --- a/ios/HIPMIBadungConnect/Info.plist +++ b/ios/HIPMIBadungConnect/Info.plist @@ -53,12 +53,15 @@ NSAllowsLocalNetworking - NSCameraUsageDescription - Allow $(PRODUCT_NAME) to access your camera - NSMicrophoneUsageDescription - Allow $(PRODUCT_NAME) to access your microphone + + NSPhotoLibraryUsageDescription - Allow $(PRODUCT_NAME) to access your photos + Untuk mengunggah dokumen dan media bisnis seperti foto profil, logo usaha, poster lowongan, atau bukti transaksi di berbagai fitur aplikasi: Profile, Portofolio, Job Vacancy, Investasi, dan Donasi. + + + NSCameraUsageDescription + Untuk mengambil foto langsung saat mengunggah dokumen bisnis seperti foto profil, logo usaha, poster, atau bukti pembayaran di fitur Profile, Portofolio, Job Vacancy, Investasi, dan Donasi. + NSUserActivityTypes $(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route diff --git a/screens/Authentication/LoginView.tsx b/screens/Authentication/LoginView.tsx index d3f444c..52b628f 100644 --- a/screens/Authentication/LoginView.tsx +++ b/screens/Authentication/LoginView.tsx @@ -102,7 +102,11 @@ export default function LoginView() { } if (token && token !== "" && isAdmin) { - return ; + // Akan di aktifkan jika sudah losos review + // return ; + + // Sementara gunakan ini + return ; } return ( diff --git a/screens/Authentication/RegisterView.tsx b/screens/Authentication/RegisterView.tsx index bba60ee..214a63b 100644 --- a/screens/Authentication/RegisterView.tsx +++ b/screens/Authentication/RegisterView.tsx @@ -1,10 +1,13 @@ +import { CheckboxCustom } from "@/components"; import Spacing from "@/components/_ShareComponent/Spacing"; import ViewWrapper from "@/components/_ShareComponent/ViewWrapper"; import ButtonCustom from "@/components/Button/ButtonCustom"; import TextInputCustom from "@/components/TextInput/TextInputCustom"; import { MainColor } from "@/constants/color-palet"; import { useAuth } from "@/hooks/use-auth"; +import { BASE_URL } from "@/service/api-config"; import { GStyles } from "@/styles/global-styles"; +import { openBrowser } from "@/utils/openBrower"; import { MaterialCommunityIcons } from "@expo/vector-icons"; import { useLocalSearchParams } from "expo-router"; import { useState } from "react"; @@ -14,7 +17,8 @@ import Toast from "react-native-toast-message"; export default function RegisterView() { const { nomor } = useLocalSearchParams(); const [username, setUsername] = useState(""); - + const [term, setTerm] = useState(false); + const url = BASE_URL; const { registerUser, isLoading } = useAuth(); const validasiData = () => { @@ -61,6 +65,7 @@ export default function RegisterView() { await registerUser({ nomor: nomor as string, username: usernameLower, + termsOfServiceAccepted: term, }); } @@ -96,7 +101,39 @@ export default function RegisterView() { } /> - + + setTerm(!term)} /> + + + Saya setuju dengan{" "} + { + const toUrl = `${url}/terms-of-service.html`; + openBrowser(toUrl); + }} + > + Syarat & Ketentuan + {" "} + yang melarang konten tidak pantas dan perilaku merugikan. + + + + Daftar diff --git a/service/api-config.ts b/service/api-config.ts index d185862..ffbc201 100644 --- a/service/api-config.ts +++ b/service/api-config.ts @@ -56,10 +56,22 @@ export async function apiValidationCode({ nomor }: { nomor: string }) { export async function apiRegister({ data, }: { - data: { nomor: string; username: string }; + data: { nomor: string; username: string; termsOfServiceAccepted: boolean }; }) { const response = await apiConfig.post(`/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; +} + diff --git a/types/User.ts b/types/User.ts index 46fee52..a6ca6cb 100644 --- a/types/User.ts +++ b/types/User.ts @@ -14,4 +14,5 @@ export interface IUser { updatedAt?: string | null; masterUserRoleId?: string; MasterUserRole?: IMasterUserRole; + termsOfServiceAccepted?: boolean; }