Fix Alur Login & Load data forum , user search
Admin – User Access - app/(application)/admin/user-access/[id]/index.tsx Authentication - context/AuthContext.tsx - screens/Authentication/EULASection.tsx - screens/Authentication/LoginView.tsx Forum - screens/Forum/ViewBeranda3.tsx Profile & UI Components - components/Image/AvatarComp.tsx - screens/Profile/AvatarAndBackground.tsx ### No Issue
This commit is contained in:
@@ -7,13 +7,21 @@ import {
|
||||
StyleSheet,
|
||||
} from "react-native";
|
||||
import { useState, useRef } from "react";
|
||||
import { useLocalSearchParams, useRouter } from "expo-router";
|
||||
import { router, useLocalSearchParams, useRouter } from "expo-router";
|
||||
import { SafeAreaView } from "react-native-safe-area-context";
|
||||
import { AccentColor, MainColor } from "@/constants/color-palet";
|
||||
import { useAuth } from "@/hooks/use-auth";
|
||||
import Toast from "react-native-toast-message";
|
||||
|
||||
|
||||
export default function EULASection({ nomor, onSetModalVisible }: { nomor: string, onSetModalVisible: (visible: boolean) => void }) {
|
||||
export default function EULASection({
|
||||
nomor,
|
||||
onSetModalVisible,
|
||||
setLoadingTerm,
|
||||
}: {
|
||||
nomor: string;
|
||||
onSetModalVisible: (visible: boolean) => void;
|
||||
setLoadingTerm: (loading: boolean) => void;
|
||||
}) {
|
||||
const { acceptedTerms } = useAuth();
|
||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||
const [isAtBottom, setIsAtBottom] = useState(false);
|
||||
@@ -35,12 +43,26 @@ export default function EULASection({ nomor, onSetModalVisible }: { nomor: strin
|
||||
if (!isAtBottom) return;
|
||||
|
||||
setIsLoading(true);
|
||||
await acceptedTerms(nomor as string, onSetModalVisible);
|
||||
const responseAccept = await acceptedTerms(
|
||||
nomor as string,
|
||||
onSetModalVisible,
|
||||
);
|
||||
|
||||
console.log("Accept terms", responseAccept);
|
||||
setLoadingTerm(true);
|
||||
|
||||
setTimeout(() => {
|
||||
router.replace(responseAccept);
|
||||
}, 500);
|
||||
} catch (error) {
|
||||
console.log("Error accept terms", error);
|
||||
Toast.show({
|
||||
type: "error",
|
||||
text1: "Error",
|
||||
text2: "Terjadi kesalahan saat menerima syarat dan ketentuan",
|
||||
});
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
import { NewWrapper, TextCustom } from "@/components";
|
||||
import { NewWrapper } from "@/components";
|
||||
import ButtonCustom from "@/components/Button/ButtonCustom";
|
||||
import ModalReactNative from "@/components/Modal/ModalReactNative";
|
||||
import Spacing from "@/components/_ShareComponent/Spacing";
|
||||
import ViewWrapper from "@/components/_ShareComponent/ViewWrapper";
|
||||
import { MainColor } from "@/constants/color-palet";
|
||||
import { useAuth } from "@/hooks/use-auth";
|
||||
import { apiVersion, BASE_URL } from "@/service/api-config";
|
||||
import { GStyles } from "@/styles/global-styles";
|
||||
import { openBrowser } from "@/utils/openBrower";
|
||||
import versionBadge from "@/utils/viersionBadge";
|
||||
import VersionBadge from "@/utils/viersionBadge";
|
||||
import { Redirect } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Modal, RefreshControl, Text, View } from "react-native";
|
||||
import { RefreshControl, Text, View } from "react-native";
|
||||
import PhoneInput, { ICountry } from "react-native-international-phone-number";
|
||||
import Toast from "react-native-toast-message";
|
||||
import EULASection from "./EULASection";
|
||||
@@ -26,6 +24,7 @@ export default function LoginView() {
|
||||
const [refreshing, setRefreshing] = useState<boolean>(false);
|
||||
const [modalVisible, setModalVisible] = useState(false);
|
||||
const [numberToEULA, setNumberToEULA] = useState<string>("");
|
||||
const [loadingTerm, setLoadingTerm] = useState<boolean>(false);
|
||||
|
||||
const { loginWithNomor, token, isAdmin, isUserActive } = useAuth();
|
||||
|
||||
@@ -90,7 +89,6 @@ export default function LoginView() {
|
||||
let fixNumber = inputValue.replace(/\s+/g, "").replace(/^0+/, "");
|
||||
|
||||
const realNumber = callingCode + fixNumber;
|
||||
|
||||
|
||||
try {
|
||||
setLoading(true);
|
||||
@@ -129,6 +127,8 @@ export default function LoginView() {
|
||||
return <Redirect href={"/(application)/(user)/home"} />;
|
||||
}
|
||||
|
||||
console.log("load term", loadingTerm);
|
||||
|
||||
return (
|
||||
<NewWrapper
|
||||
withBackground
|
||||
@@ -137,7 +137,6 @@ export default function LoginView() {
|
||||
}
|
||||
>
|
||||
<View style={GStyles.authContainer}>
|
||||
|
||||
<View>
|
||||
<View style={GStyles.authContainerTitle}>
|
||||
<Text style={GStyles.authSubTitle}>WELCOME TO</Text>
|
||||
@@ -172,21 +171,15 @@ export default function LoginView() {
|
||||
|
||||
<Spacing />
|
||||
|
||||
<ButtonCustom onPress={handleLogin} isLoading={loading}>
|
||||
<ButtonCustom
|
||||
onPress={handleLogin}
|
||||
disabled={loadingTerm}
|
||||
isLoading={loading || loadingTerm}
|
||||
>
|
||||
Login
|
||||
</ButtonCustom>
|
||||
<Spacing height={50} />
|
||||
|
||||
{/* <ButtonCustom
|
||||
onPress={() => {
|
||||
setModalVisible(true);
|
||||
console.log("Show modal", modalVisible);
|
||||
}}
|
||||
>
|
||||
Show Modal
|
||||
</ButtonCustom> */}
|
||||
{/* <CheckboxCustom value={term} onChange={() => setTerm(!term)} /> */}
|
||||
|
||||
<Text
|
||||
style={{ ...GStyles.textLabel, textAlign: "center", fontSize: 12 }}
|
||||
>
|
||||
@@ -208,7 +201,11 @@ export default function LoginView() {
|
||||
</View>
|
||||
|
||||
<ModalReactNative isVisible={modalVisible}>
|
||||
<EULASection nomor={numberToEULA || ""} onSetModalVisible={setModalVisible} />
|
||||
<EULASection
|
||||
nomor={numberToEULA || ""}
|
||||
onSetModalVisible={setModalVisible}
|
||||
setLoadingTerm={setLoadingTerm}
|
||||
/>
|
||||
</ModalReactNative>
|
||||
</NewWrapper>
|
||||
);
|
||||
|
||||
@@ -2,21 +2,20 @@ import {
|
||||
AvatarComp,
|
||||
BackButton,
|
||||
FloatingButton,
|
||||
SearchInput,
|
||||
TextCustom,
|
||||
SearchInput
|
||||
} from "@/components";
|
||||
import NewWrapper from "@/components/_ShareComponent/NewWrapper";
|
||||
import { useAuth } from "@/hooks/use-auth";
|
||||
import { MainColor } from "@/constants/color-palet";
|
||||
import { createPaginationComponents } from "@/helpers/paginationHelpers";
|
||||
import { useAuth } from "@/hooks/use-auth";
|
||||
import { usePagination } from "@/hooks/use-pagination";
|
||||
import Forum_BoxDetailSection from "@/screens/Forum/DiscussionBoxSection";
|
||||
import { apiForumGetAll } from "@/service/api-client/api-forum";
|
||||
import { apiUser } from "@/service/api-client/api-user";
|
||||
import { router, Stack } from "expo-router";
|
||||
import _ from "lodash";
|
||||
import { useEffect, useState } from "react";
|
||||
import { RefreshControl, View } from "react-native";
|
||||
import { MainColor } from "@/constants/color-palet";
|
||||
import { usePagination } from "@/hooks/use-pagination";
|
||||
import { RefreshControl, TouchableOpacity, View } from "react-native";
|
||||
|
||||
const PAGE_SIZE = 5;
|
||||
|
||||
@@ -36,7 +35,7 @@ export default function Forum_ViewBeranda3() {
|
||||
const pagination = usePagination({
|
||||
fetchFunction: async (page, searchQuery) => {
|
||||
if (!user?.id) return { data: [] };
|
||||
|
||||
|
||||
return await apiForumGetAll({
|
||||
category: "beranda",
|
||||
search: searchQuery || "",
|
||||
@@ -51,16 +50,17 @@ export default function Forum_ViewBeranda3() {
|
||||
});
|
||||
|
||||
// Generate komponen (menggantikan 40+ lines code!)
|
||||
const { ListEmptyComponent, ListFooterComponent } = createPaginationComponents({
|
||||
loading: pagination.loading,
|
||||
refreshing: pagination.refreshing,
|
||||
listData: pagination.listData,
|
||||
searchQuery: search,
|
||||
emptyMessage: "Tidak ada diskusi",
|
||||
emptySearchMessage: "Tidak ada hasil pencarian",
|
||||
skeletonCount: 5,
|
||||
skeletonHeight: 150,
|
||||
});
|
||||
const { ListEmptyComponent, ListFooterComponent } =
|
||||
createPaginationComponents({
|
||||
loading: pagination.loading,
|
||||
refreshing: pagination.refreshing,
|
||||
listData: pagination.listData,
|
||||
searchQuery: search,
|
||||
emptyMessage: "Tidak ada diskusi",
|
||||
emptySearchMessage: "Tidak ada hasil pencarian",
|
||||
skeletonCount: 5,
|
||||
skeletonHeight: 150,
|
||||
});
|
||||
|
||||
// Render item forum
|
||||
const renderForumItem = ({ item }: { item: any }) => (
|
||||
@@ -74,11 +74,11 @@ export default function Forum_ViewBeranda3() {
|
||||
/>
|
||||
);
|
||||
|
||||
// const ListHeaderComponent = (
|
||||
// <View style={{ paddingVertical: 8, alignItems: "center" }}>
|
||||
// <TextCustom>Diskusi Terbaru</TextCustom>
|
||||
// </View>
|
||||
// );
|
||||
// const ListHeaderComponent = (
|
||||
// <View style={{ paddingVertical: 8, alignItems: "center" }}>
|
||||
// <TextCustom>Diskusi Terbaru</TextCustom>
|
||||
// </View>
|
||||
// );
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -87,11 +87,15 @@ export default function Forum_ViewBeranda3() {
|
||||
title: "Forum",
|
||||
headerLeft: () => <BackButton />,
|
||||
headerRight: () => (
|
||||
<AvatarComp
|
||||
fileId={dataUser?.Profile?.imageId}
|
||||
size="base"
|
||||
href={`/forum/${user?.id}/forumku`}
|
||||
/>
|
||||
<TouchableOpacity
|
||||
onPress={() => router.navigate(`/forum/${user?.id}/forumku`)}
|
||||
>
|
||||
<AvatarComp
|
||||
fileId={dataUser?.Profile?.imageId}
|
||||
size="base"
|
||||
href={`/forum/${user?.id}/forumku`}
|
||||
/>
|
||||
</TouchableOpacity>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
@@ -129,4 +133,4 @@ export default function Forum_ViewBeranda3() {
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ const AvatarAndBackground = ({
|
||||
`/(application)/(image)/preview-image/${backgroundId}`
|
||||
);
|
||||
}}
|
||||
disabled={!backgroundId}
|
||||
>
|
||||
<ImageBackground
|
||||
source={
|
||||
|
||||
Reference in New Issue
Block a user