- app/(application)/(user)/delete-account.tsx - assets/images/constants/logo-hipmi_back.png Fix: - app/(application)/(user)/_layout.tsx - assets/images/constants/logo-hipmi.png - components/Grid/GridCustom.tsx - screens/Profile/ListPage.tsx - screens/Profile/menuDrawerSection.tsx - service/api-client/api-user.ts ### No Issue
86 lines
2.3 KiB
TypeScript
86 lines
2.3 KiB
TypeScript
import {
|
|
AlertDefaultSystem,
|
|
BaseBox,
|
|
ButtonCustom,
|
|
CenterCustom,
|
|
StackCustom,
|
|
TextCustom,
|
|
TextInputCustom,
|
|
ViewWrapper,
|
|
} from "@/components";
|
|
import { useAuth } from "@/hooks/use-auth";
|
|
import { apiDeleteUser } from "@/service/api-client/api-user";
|
|
import { Image } from "expo-image";
|
|
import { useLocalSearchParams } from "expo-router/build/hooks";
|
|
import { useState } from "react";
|
|
import Toast from "react-native-toast-message";
|
|
|
|
export default function DeleteAccount() {
|
|
const { token, logout, user } = useAuth();
|
|
const { phone } = useLocalSearchParams();
|
|
const [text, setText] = useState("");
|
|
|
|
const deleteAccount = async () => {
|
|
if (text !== "Delete Account") {
|
|
return Toast.show({
|
|
type: "error",
|
|
text1: "Ketik 'Delete Account' untuk menghapus akun",
|
|
});
|
|
}
|
|
|
|
AlertDefaultSystem({
|
|
title: "Apakah anda yakin ingin menghapus akun ini?",
|
|
message:
|
|
"Semua data yang pernah anda buat akan terhapus secara permanen !",
|
|
textLeft: "Batal",
|
|
textRight: "Ya",
|
|
onPressRight: async () => {
|
|
const response = await apiDeleteUser({ id: user?.id as string });
|
|
console.log("RESPONSE >> ", response);
|
|
logout();
|
|
},
|
|
});
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<ViewWrapper>
|
|
<StackCustom>
|
|
<BaseBox>
|
|
<StackCustom>
|
|
<CenterCustom>
|
|
<Image
|
|
source={require("@/assets/images/constants/logo-hipmi.png")}
|
|
style={{
|
|
width: 150,
|
|
height: 150,
|
|
}}
|
|
/>
|
|
</CenterCustom>
|
|
<TextCustom align="center">
|
|
Anda akan menghapus akun dengan nomor +{phone}
|
|
</TextCustom>
|
|
<TextCustom align="center">
|
|
Ketik 'Delete Account' untuk menghapus akun
|
|
</TextCustom>
|
|
<TextInputCustom
|
|
value={text}
|
|
onChangeText={setText}
|
|
placeholder="Ketik 'Delete Account'"
|
|
/>
|
|
|
|
<ButtonCustom
|
|
backgroundColor="red"
|
|
textColor="white"
|
|
onPress={deleteAccount}
|
|
>
|
|
Submit
|
|
</ButtonCustom>
|
|
</StackCustom>
|
|
</BaseBox>
|
|
</StackCustom>
|
|
</ViewWrapper>
|
|
</>
|
|
);
|
|
}
|