- Fitur notifikasi ke admin dari user baru - Notifikasi ke user bahwa akunnya telah terverifikasi Fix: - app/(application)/(user)/notifications/index.tsx - app/(application)/(user)/waiting-room.tsx - app/(application)/admin/super-admin/[id]/index.tsx - app/(application)/admin/user-access/[id]/index.tsx - context/AuthContext.tsx - screens/Home/tabsList.ts - service/api-admin/api-admin-user-access.ts - service/api-device-token.ts - service/api-notifications.ts - types/type-notification-category.ts Add: - lib/routeApp.ts ### No Issue
110 lines
2.9 KiB
TypeScript
110 lines
2.9 KiB
TypeScript
import {
|
|
AlertDefaultSystem,
|
|
BoxButtonOnFooter,
|
|
ButtonCustom,
|
|
InformationBox,
|
|
NewWrapper,
|
|
StackCustom
|
|
} from "@/components";
|
|
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
|
import { useAuth } from "@/hooks/use-auth";
|
|
import { apiUser } from "@/service/api-client/api-user";
|
|
import { Ionicons } from "@expo/vector-icons";
|
|
import { router } from "expo-router";
|
|
import { RefreshControl } from "react-native";
|
|
import Toast from "react-native-toast-message";
|
|
|
|
export default function WaitingRoom() {
|
|
const { token, isLoading, logout, userData } = useAuth();
|
|
|
|
async function handleCheck() {
|
|
try {
|
|
const response = await userData(token as string);
|
|
|
|
if (response.active) {
|
|
const checkProfile = await apiUser(response.id);
|
|
|
|
if (checkProfile?.data?.Profile) {
|
|
Toast.show({
|
|
type: "success",
|
|
text1: "Akun anda telah aktif kembali", // text2: "Anda berhasil login",
|
|
});
|
|
router.replace(`/(application)/(user)/home`);
|
|
} else {
|
|
Toast.show({
|
|
type: "success",
|
|
text1: "Selamat ! Akun anda telah aktif", // text2: "Anda berhasil login",
|
|
});
|
|
router.replace(`/(application)/(user)/profile/create`);
|
|
}
|
|
|
|
// router.replace(`/(application)/(user)/profile/create`);
|
|
} else {
|
|
Toast.show({
|
|
type: "error",
|
|
text1: "Akun anda belum aktif",
|
|
text2: "Silahkan hubungi admin",
|
|
});
|
|
}
|
|
} catch (error) {
|
|
console.log("Error check", error);
|
|
}
|
|
}
|
|
|
|
const logoutButton = () => {
|
|
return (
|
|
<>
|
|
<BoxButtonOnFooter>
|
|
<ButtonCustom
|
|
backgroundColor="red"
|
|
textColor="white"
|
|
iconLeft={
|
|
<Ionicons name="log-out" size={ICON_SIZE_BUTTON} color="white" />
|
|
}
|
|
onPress={() => {
|
|
AlertDefaultSystem({
|
|
title: "Keluar",
|
|
message: "Apakah anda yakin ingin keluar?",
|
|
textLeft: "Batal",
|
|
textRight: "Ya",
|
|
onPressRight: () => {
|
|
logout();
|
|
},
|
|
});
|
|
}}
|
|
>
|
|
Keluar
|
|
</ButtonCustom>
|
|
</BoxButtonOnFooter>
|
|
</>
|
|
);
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<NewWrapper
|
|
footerComponent={logoutButton()}
|
|
refreshControl={
|
|
<RefreshControl refreshing={isLoading} onRefresh={handleCheck} />
|
|
}
|
|
>
|
|
<StackCustom>
|
|
<InformationBox
|
|
text="Akun Anda sedang menunggu aktivasi.
|
|
Silakan tunggu beberapa saat. Untuk memperbarui status, tarik layar ke bawah."
|
|
/>
|
|
{/* <ButtonCenteredOnly
|
|
isLoading={isLoading}
|
|
onPress={() => {
|
|
handleCheck();
|
|
}}
|
|
icon="refresh-ccw"
|
|
>
|
|
Check
|
|
</ButtonCenteredOnly> */}
|
|
</StackCustom>
|
|
</NewWrapper>
|
|
</>
|
|
);
|
|
}
|