Fix rejected Apple :
Submission ID: 1efcd8eb-7d68-4348-9925-43a8e1bd7d1e Add: - app/(application)/terms-agreement.tsx Fix: - app/(application)/(user)/home.tsx - app/(application)/_layout.tsx - context/AuthContext.tsx - ios/HIPMIBadungConnect/Info.plist - screens/Authentication/LoginView.tsx - screens/Authentication/RegisterView.tsx - service/api-config.ts - types/User.ts ### NO Issue
This commit is contained in:
@@ -16,25 +16,32 @@ import { useEffect, useState } from "react";
|
|||||||
|
|
||||||
export default function Application() {
|
export default function Application() {
|
||||||
const { token, user } = useAuth();
|
const { token, user } = useAuth();
|
||||||
|
|
||||||
const [data, setData] = useState<any>();
|
const [data, setData] = useState<any>();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onLoadData();
|
onLoadData();
|
||||||
checkVersion();
|
checkVersion();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
async function onLoadData() {
|
async function onLoadData() {
|
||||||
const response = await apiUser(user?.id as string);
|
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);
|
setData(response.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
const checkVersion = async () => {
|
const checkVersion = async () => {
|
||||||
const response = await apiVersion();
|
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 <Redirect href={`/terms-agreement`} />;
|
||||||
|
}
|
||||||
|
|
||||||
if (data && data?.active === false) {
|
if (data && data?.active === false) {
|
||||||
console.log("User is not active");
|
console.log("User is not active");
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export default function ApplicationLayout() {
|
|||||||
<Stack.Screen name="(user)" options={{ headerShown: false }} />
|
<Stack.Screen name="(user)" options={{ headerShown: false }} />
|
||||||
<Stack.Screen name="admin" options={{ headerShown: false }} />
|
<Stack.Screen name="admin" options={{ headerShown: false }} />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{/* Take Picture */}
|
{/* Take Picture */}
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
|
|||||||
115
app/(application)/terms-agreement.tsx
Normal file
115
app/(application)/terms-agreement.tsx
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
import {
|
||||||
|
BoxButtonOnFooter,
|
||||||
|
ButtonCustom,
|
||||||
|
CheckboxCustom,
|
||||||
|
InformationBox,
|
||||||
|
StackCustom,
|
||||||
|
ViewWrapper
|
||||||
|
} from "@/components";
|
||||||
|
import { MainColor } from "@/constants/color-palet";
|
||||||
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
|
import { apiAcceptTermService, BASE_URL } from "@/service/api-config";
|
||||||
|
import { GStyles } from "@/styles/global-styles";
|
||||||
|
import { openBrowser } from "@/utils/openBrower";
|
||||||
|
import { Stack } from "expo-router";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { Text, View } from "react-native";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
|
export default function TermsAgreement() {
|
||||||
|
const { user, logout } = useAuth();
|
||||||
|
const [term, setTerm] = useState(false);
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
const url = BASE_URL;
|
||||||
|
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
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 = (
|
||||||
|
<BoxButtonOnFooter>
|
||||||
|
<ButtonCustom
|
||||||
|
onPress={handleSubmit}
|
||||||
|
disabled={!term}
|
||||||
|
isLoading={isLoading}
|
||||||
|
>
|
||||||
|
Setuju
|
||||||
|
</ButtonCustom>
|
||||||
|
</BoxButtonOnFooter>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Stack.Screen
|
||||||
|
options={{
|
||||||
|
title: "Terms Agreement",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<ViewWrapper footerComponent={footerComponent}>
|
||||||
|
<StackCustom>
|
||||||
|
<InformationBox text="Anda dialihkan ke halaman syarat & ketentuan, karena Anda belum menerima persetujuan syarat & ketentuan." />
|
||||||
|
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
marginTop: 16,
|
||||||
|
marginBottom: 16,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CheckboxCustom value={term} onChange={() => setTerm(!term)} />
|
||||||
|
|
||||||
|
<Text style={GStyles.textLabel}>
|
||||||
|
Saya setuju dengan{" "}
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
color: MainColor.yellow,
|
||||||
|
textDecorationLine: "underline",
|
||||||
|
}}
|
||||||
|
onPress={() => {
|
||||||
|
const toUrl = `${url}/terms-of-service.html`;
|
||||||
|
openBrowser(toUrl);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Syarat & Ketentuan
|
||||||
|
</Text>{" "}
|
||||||
|
yang melarang konten tidak pantas dan perilaku merugikan.
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
</StackCustom>
|
||||||
|
</ViewWrapper>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@ type AuthContextType = {
|
|||||||
registerUser: (userData: {
|
registerUser: (userData: {
|
||||||
username: string;
|
username: string;
|
||||||
nomor: string;
|
nomor: string;
|
||||||
|
termsOfServiceAccepted: boolean;
|
||||||
}) => Promise<void>;
|
}) => Promise<void>;
|
||||||
userData: (token: string) => Promise<any>;
|
userData: (token: string) => Promise<any>;
|
||||||
};
|
};
|
||||||
@@ -154,10 +155,12 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
const registerUser = async (userData: {
|
const registerUser = async (userData: {
|
||||||
username: string;
|
username: string;
|
||||||
nomor: string;
|
nomor: string;
|
||||||
|
termsOfServiceAccepted: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
const response = await apiRegister({ data: userData });
|
const response = await apiRegister({ data: userData });
|
||||||
|
console.log("response", response);
|
||||||
|
|
||||||
const { token } = response;
|
const { token } = response;
|
||||||
if (!response.success) {
|
if (!response.success) {
|
||||||
|
|||||||
@@ -53,12 +53,15 @@
|
|||||||
<key>NSAllowsLocalNetworking</key>
|
<key>NSAllowsLocalNetworking</key>
|
||||||
<true/>
|
<true/>
|
||||||
</dict>
|
</dict>
|
||||||
<key>NSCameraUsageDescription</key>
|
|
||||||
<string>Allow $(PRODUCT_NAME) to access your camera</string>
|
<!-- Photo Library -->
|
||||||
<key>NSMicrophoneUsageDescription</key>
|
|
||||||
<string>Allow $(PRODUCT_NAME) to access your microphone</string>
|
|
||||||
<key>NSPhotoLibraryUsageDescription</key>
|
<key>NSPhotoLibraryUsageDescription</key>
|
||||||
<string>Allow $(PRODUCT_NAME) to access your photos</string>
|
<string>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.</string>
|
||||||
|
|
||||||
|
<!-- Camera -->
|
||||||
|
<key>NSCameraUsageDescription</key>
|
||||||
|
<string>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.</string>
|
||||||
|
|
||||||
<key>NSUserActivityTypes</key>
|
<key>NSUserActivityTypes</key>
|
||||||
<array>
|
<array>
|
||||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string>
|
<string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string>
|
||||||
|
|||||||
@@ -102,7 +102,11 @@ export default function LoginView() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (token && token !== "" && isAdmin) {
|
if (token && token !== "" && isAdmin) {
|
||||||
return <Redirect href={"/(application)/admin/dashboard"} />;
|
// Akan di aktifkan jika sudah losos review
|
||||||
|
// return <Redirect href={"/(application)/admin/dashboard"} />;
|
||||||
|
|
||||||
|
// Sementara gunakan ini
|
||||||
|
return <Redirect href={"/(application)/(user)/home"} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
|
import { CheckboxCustom } from "@/components";
|
||||||
import Spacing from "@/components/_ShareComponent/Spacing";
|
import Spacing from "@/components/_ShareComponent/Spacing";
|
||||||
import ViewWrapper from "@/components/_ShareComponent/ViewWrapper";
|
import ViewWrapper from "@/components/_ShareComponent/ViewWrapper";
|
||||||
import ButtonCustom from "@/components/Button/ButtonCustom";
|
import ButtonCustom from "@/components/Button/ButtonCustom";
|
||||||
import TextInputCustom from "@/components/TextInput/TextInputCustom";
|
import TextInputCustom from "@/components/TextInput/TextInputCustom";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
import { useAuth } from "@/hooks/use-auth";
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
|
import { BASE_URL } from "@/service/api-config";
|
||||||
import { GStyles } from "@/styles/global-styles";
|
import { GStyles } from "@/styles/global-styles";
|
||||||
|
import { openBrowser } from "@/utils/openBrower";
|
||||||
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||||
import { useLocalSearchParams } from "expo-router";
|
import { useLocalSearchParams } from "expo-router";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
@@ -14,7 +17,8 @@ import Toast from "react-native-toast-message";
|
|||||||
export default function RegisterView() {
|
export default function RegisterView() {
|
||||||
const { nomor } = useLocalSearchParams();
|
const { nomor } = useLocalSearchParams();
|
||||||
const [username, setUsername] = useState("");
|
const [username, setUsername] = useState("");
|
||||||
|
const [term, setTerm] = useState(false);
|
||||||
|
const url = BASE_URL;
|
||||||
const { registerUser, isLoading } = useAuth();
|
const { registerUser, isLoading } = useAuth();
|
||||||
|
|
||||||
const validasiData = () => {
|
const validasiData = () => {
|
||||||
@@ -61,6 +65,7 @@ export default function RegisterView() {
|
|||||||
await registerUser({
|
await registerUser({
|
||||||
nomor: nomor as string,
|
nomor: nomor as string,
|
||||||
username: usernameLower,
|
username: usernameLower,
|
||||||
|
termsOfServiceAccepted: term,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +101,39 @@ export default function RegisterView() {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ButtonCustom isLoading={isLoading} onPress={handleRegister}>
|
<View
|
||||||
|
style={{
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
marginTop: 16,
|
||||||
|
marginBottom: 16,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CheckboxCustom value={term} onChange={() => setTerm(!term)} />
|
||||||
|
|
||||||
|
<Text style={GStyles.textLabel}>
|
||||||
|
Saya setuju dengan{" "}
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
color: MainColor.yellow,
|
||||||
|
textDecorationLine: "underline",
|
||||||
|
}}
|
||||||
|
onPress={() => {
|
||||||
|
const toUrl = `${url}/terms-of-service.html`;
|
||||||
|
openBrowser(toUrl);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Syarat & Ketentuan
|
||||||
|
</Text>{" "}
|
||||||
|
yang melarang konten tidak pantas dan perilaku merugikan.
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<ButtonCustom
|
||||||
|
disabled={!term}
|
||||||
|
isLoading={isLoading}
|
||||||
|
onPress={handleRegister}
|
||||||
|
>
|
||||||
Daftar
|
Daftar
|
||||||
</ButtonCustom>
|
</ButtonCustom>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -56,10 +56,22 @@ export async function apiValidationCode({ nomor }: { nomor: string }) {
|
|||||||
export async function apiRegister({
|
export async function apiRegister({
|
||||||
data,
|
data,
|
||||||
}: {
|
}: {
|
||||||
data: { nomor: string; username: string };
|
data: { nomor: string; username: string; termsOfServiceAccepted: boolean };
|
||||||
}) {
|
}) {
|
||||||
const response = await apiConfig.post(`/auth/register`, {
|
const response = await apiConfig.post(`/auth/register`, {
|
||||||
data: data,
|
data: data,
|
||||||
});
|
});
|
||||||
return response.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,4 +14,5 @@ export interface IUser {
|
|||||||
updatedAt?: string | null;
|
updatedAt?: string | null;
|
||||||
masterUserRoleId?: string;
|
masterUserRoleId?: string;
|
||||||
MasterUserRole?: IMasterUserRole;
|
MasterUserRole?: IMasterUserRole;
|
||||||
|
termsOfServiceAccepted?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user