New repo mobile after delete ! #1

Merged
bagasbanuna merged 233 commits from api/24-oct-25 into main 2025-10-27 11:32:16 +08:00
492 changed files with 40259 additions and 1071 deletions
Showing only changes of commit d3c4f04e07 - Show all commits

View File

@@ -54,6 +54,8 @@ export default function ProfileEdit() {
return;
}
Toast.show({
type: "success",
text1: "Sukses",

View File

@@ -50,6 +50,11 @@ export default function UpdatePhotoProfile() {
dirId: DIRECTORY_ID.profile_foto,
});
console.log(
"response upload photo>>",
JSON.stringify(response, null, 2)
);
if (response.success) {
const fileId = response.data.id;
await apiUpdateProfile({

View File

@@ -1,25 +1,34 @@
import {
AvatarCustom,
BaseBox,
ButtonCenteredOnly,
ButtonCustom,
SelectCustom,
Spacing,
StackCustom,
TextInputCustom,
ViewWrapper,
ViewWrapper
} from "@/components";
import BoxButtonOnFooter from "@/components/Box/BoxButtonOnFooter";
import InformationBox from "@/components/Box/InformationBox";
import LandscapeFrameUploaded from "@/components/Image/LandscapeFrameUploaded";
import DIRECTORY_ID from "@/constants/directory-id";
import DUMMY_IMAGE from "@/constants/dummy-image-value";
import { useAuth } from "@/hooks/use-auth";
import { apiCreateProfile } from "@/service/api-client/api-profile";
import { router, useFocusEffect } from "expo-router";
import { useCallback, useState } from "react";
import { View } from "react-native";
import {
apiCreateProfile
} from "@/service/api-client/api-profile";
import { apiValidationEmail } from "@/service/api-client/api-validation";
import { uploadImageService } from "@/service/upload-service";
import pickImage from "@/utils/pickImage";
import { router } from "expo-router";
import { useEffect, useState } from "react";
import { Image, View } from "react-native";
import { Avatar } from "react-native-paper";
import Toast from "react-native-toast-message";
export default function CreateProfile() {
const { user } = useAuth();
const [imagePhoto, setImagePhoto] = useState<string | null>(null);
const [imageBackground, setImageBackground] = useState<string | null>(null);
const [isLoading, setIsLoading] = useState<boolean>(false);
const [data, setData] = useState({
@@ -30,17 +39,19 @@ export default function CreateProfile() {
jenisKelamin: "",
});
useFocusEffect(
useCallback(() => {
Toast.show({
type: "info",
text1: "Lengkapi Profile Anda",
text2: "Untuk menjelajahi fitur-fitur yang ada",
});
}, [])
);
useEffect(() => {
Toast.show({
type: "info",
text1: "Lengkapi Profile Anda",
text2: "Untuk menjelajahi fitur-fitur yang ada",
});
}, []);
const handlerSave = async () => {
let IMG = {
imageId: "",
imageBackgroundId: "",
};
if (!data.name || !data.email || !data.alamat || !data.jenisKelamin) {
Toast.show({
type: "info",
@@ -52,7 +63,72 @@ export default function CreateProfile() {
try {
setIsLoading(true);
const response = await apiCreateProfile(data);
const responseValidateEmail = await apiValidationEmail({
email: data.email,
});
if (!responseValidateEmail.success) {
Toast.show({
type: "error",
text1: "Gagal",
text2: responseValidateEmail.message,
});
return;
}
console.log(
"responseValidateEmail >>",
JSON.stringify(responseValidateEmail, null, 2)
);
if (imagePhoto) {
const responseUploadPhoto = await uploadImageService({
imageUri: imagePhoto,
dirId: DIRECTORY_ID.profile_foto,
});
console.log(
"responseUploadPhoto >>",
JSON.stringify(responseUploadPhoto, null, 2)
);
if (responseUploadPhoto.success) {
const fileIdPhoto = responseUploadPhoto.data.id;
IMG.imageId = fileIdPhoto;
}
}
if (imageBackground) {
const responseUploadBackground = await uploadImageService({
imageUri: imageBackground,
dirId: DIRECTORY_ID.profile_background,
});
console.log(
"responseUploadBackground >>",
JSON.stringify(responseUploadBackground, null, 2)
);
if (responseUploadBackground.success) {
const fileIdBackground = responseUploadBackground.data.id;
IMG.imageBackgroundId = fileIdBackground;
}
}
const fixData = {
...data,
...IMG,
};
const response = await apiCreateProfile(fixData);
if (response.status === 400) {
Toast.show({
type: "error",
@@ -67,7 +143,10 @@ export default function CreateProfile() {
text1: "Sukses",
text2: "Profile berhasil dibuat",
});
console.log("fixResponse >>", JSON.stringify(response, null, 2));
router.push("/(application)/(user)/home");
return;
} catch (error) {
console.log("error create profile >>", error);
} finally {
@@ -92,11 +171,18 @@ export default function CreateProfile() {
<StackCustom>
<InformationBox text="Upload foto profile anda." />
<View style={{ alignItems: "center" }}>
<AvatarCustom size="xl" />
<Avatar.Image
size={100}
source={imagePhoto ? { uri: imagePhoto } : DUMMY_IMAGE.avatar}
/>
<Spacing />
<ButtonCenteredOnly
icon="upload"
onPress={() => router.navigate(`/take-picture/${user?.id}`)}
onPress={() => {
pickImage({
setImageUri: setImagePhoto,
});
}}
>
Upload
</ButtonCenteredOnly>
@@ -106,11 +192,24 @@ export default function CreateProfile() {
<View>
<InformationBox text="Upload foto latar belakang anda." />
<LandscapeFrameUploaded />
<Spacing />
<BaseBox>
<Image
source={
imageBackground
? { uri: imageBackground }
: DUMMY_IMAGE.background
}
style={{ width: "100%", height: 200 }}
/>
</BaseBox>
{/* <Spacing /> */}
<ButtonCenteredOnly
icon="upload"
onPress={() => router.navigate(`/take-picture/${user?.id}`)}
onPress={() => {
pickImage({
setImageUri: setImageBackground,
});
}}
>
Upload
</ButtonCenteredOnly>

View File

@@ -0,0 +1,8 @@
import { apiConfig } from "../api-config";
export async function apiValidationEmail({ email }: { email: string }) {
const response = await apiConfig.post(`/mobile/validate/email`, {
data: email,
});
return response.data;
}

View File

@@ -47,10 +47,11 @@ export async function uploadImageService({
"Content-Type": "multipart/form-data",
Authorization: `Bearer ${token}`,
},
timeout: 30000,
// timeout: 30000,
});
const { data } = response;
console.log("response upload >>", JSON.stringify(data, null, 2));
if (!data.success) {
Toast.show({
@@ -62,10 +63,10 @@ export async function uploadImageService({
return;
}
Toast.show({
type: "success",
text1: "File berhasil diunggah",
});
// Toast.show({
// type: "success",
// text1: "File berhasil diunggah",
// });
return data;
} catch (error) {