Fix create profile

This commit is contained in:
2024-12-10 11:11:45 +08:00
parent 8f5acae10d
commit b2e48ba06c
4 changed files with 96 additions and 50 deletions

View File

@@ -54,6 +54,7 @@ export function Profile_ComponentCreateNewProfile({
file: filePP,
dirId: DIRECTORY_ID.profile_foto,
});
// console.log("ini foto", uploadPhoto);
if (!uploadPhoto.success) {
setLoading(false);
return ComponentGlobal_NotifikasiPeringatan(
@@ -61,29 +62,36 @@ export function Profile_ComponentCreateNewProfile({
);
}
const uploadBackground = await funGlobal_UploadToStorage({
file: fileBG,
dirId: DIRECTORY_ID.profile_background,
});
if (!uploadBackground.success) {
setLoading(false);
return ComponentGlobal_NotifikasiPeringatan(
"Gagal upload background profile"
);
}
if (uploadPhoto.success) {
const uploadBackground = await funGlobal_UploadToStorage({
file: fileBG,
dirId: DIRECTORY_ID.profile_background,
});
// console.log("ini background", uploadBackground);
if (!uploadBackground.success) {
setLoading(false);
return ComponentGlobal_NotifikasiPeringatan(
"Gagal upload background profile"
);
}
const create = await funCreateNewProfile({
data: newData as any,
imageId: uploadPhoto.data.id,
imageBackgroundId: uploadBackground.data.id,
});
if (create.status === 201) {
ComponentGlobal_NotifikasiBerhasil("Berhasil membuat profile", 3000);
router.push(RouterHome.main_home, { scroll: false });
} else {
ComponentGlobal_NotifikasiGagal(create.message);
setLoading(false);
if (uploadBackground.success) {
const create = await funCreateNewProfile({
data: newData as any,
imageId: uploadPhoto.data.id,
imageBackgroundId: uploadBackground.data.id,
});
if (create.status === 201) {
ComponentGlobal_NotifikasiBerhasil(
"Berhasil membuat profile",
3000
);
router.push(RouterHome.main_home, { scroll: false });
} else {
ComponentGlobal_NotifikasiGagal(create.message);
setLoading(false);
}
}
}
} catch (error) {
console.log(error);