setOpenDrawer(false)}
+ component={mapId ? listPage : listPage2}
+ />
+ >
+ );
+}
diff --git a/src/app_modules/katalog/portofolio/edit/logo/ui_edit_logo.tsx b/src/app_modules/katalog/portofolio/edit/logo/ui_edit_logo.tsx
index b6971b41..cae4cb08 100644
--- a/src/app_modules/katalog/portofolio/edit/logo/ui_edit_logo.tsx
+++ b/src/app_modules/katalog/portofolio/edit/logo/ui_edit_logo.tsx
@@ -84,6 +84,7 @@ export default function Portofolio_EditLogoBisnis({
>
diff --git a/src/app_modules/katalog/portofolio/lib/api_portofolio.ts b/src/app_modules/katalog/portofolio/lib/api_portofolio.ts
index 7e30afa6..94d9e10f 100644
--- a/src/app_modules/katalog/portofolio/lib/api_portofolio.ts
+++ b/src/app_modules/katalog/portofolio/lib/api_portofolio.ts
@@ -1,6 +1,6 @@
export const apiGetPortofolioByProfile = async (path?: string) => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
- if (!token) return null;
+ if (!token) return await token.json().catch(() => null);
const response = await fetch(`/api/new/portofolio${path ? path : ""}`, {
headers: {
@@ -18,7 +18,7 @@ export const apiGetPortofolioByProfile = async (path?: string) => {
export const apiGetOnePortofolioById = async (path: string, cat: string) => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
- if (!token) return null;
+ if (!token) return await token.json().catch(() => null);
const response = await fetch(`/api/new/portofolio/${path}?cat=${cat}`, {
headers: {
@@ -36,7 +36,7 @@ export const apiGetOnePortofolioById = async (path: string, cat: string) => {
export const apiDeletePortofolio = async (path: string) => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
- if (!token) return null;
+ if (!token) return await token.json().catch(() => null);
const response = await fetch(`/api/new/portofolio/${path}`, {
method: "DELETE",
@@ -46,6 +46,5 @@ export const apiDeletePortofolio = async (path: string) => {
},
});
-
return await response.json().catch(() => null);
};
diff --git a/src/app_modules/katalog/portofolio/ui/ui_layout_new.tsx b/src/app_modules/katalog/portofolio/ui/ui_layout_new.tsx
index 9f6b5d75..6a1921bb 100644
--- a/src/app_modules/katalog/portofolio/ui/ui_layout_new.tsx
+++ b/src/app_modules/katalog/portofolio/ui/ui_layout_new.tsx
@@ -2,19 +2,27 @@
import { UIGlobal_LayoutHeaderTamplate, UIGlobal_LayoutTamplate } from "@/app_modules/_global/ui";
import ComponentPortofolio_ButtonMoreNew from "../component/button_more_new";
-export default function PortofolioLayoutNew({ children }: { children: any }) {
- return (
- <>
- }
- />
+export default function PortofolioLayoutNew({
+ children,
+ userLoginId,
+}: {
+ children: any;
+ userLoginId: string
+}) {
+ return (
+ <>
+
}
- >
- {children}
-
- >
- )
+ />
+ }
+ >
+ {children}
+
+ >
+ );
}
\ No newline at end of file
diff --git a/src/app_modules/katalog/profile/_component/button/comp_button_update_background_profile.tsx b/src/app_modules/katalog/profile/_component/button/comp_button_update_background_profile.tsx
index bb947e84..59d5f371 100644
--- a/src/app_modules/katalog/profile/_component/button/comp_button_update_background_profile.tsx
+++ b/src/app_modules/katalog/profile/_component/button/comp_button_update_background_profile.tsx
@@ -29,16 +29,8 @@ export function Profile_ComponentButtonUpdateBackgroundProfile({
async function onUpdate() {
try {
setLoading(true);
- const deletePhoto = await funGlobal_DeleteFileById({
- fileId: fileId,
- dirId: DIRECTORY_ID.profile_background,
- });
-
- if (!deletePhoto.success) {
- ComponentGlobal_NotifikasiPeringatan("Gagal update background");
- return;
- }
+ // Upload gambar baru
const uploadFile = await funGlobal_UploadToStorage({
file: file,
dirId: DIRECTORY_ID.profile_background,
@@ -46,9 +38,19 @@ export function Profile_ComponentButtonUpdateBackgroundProfile({
if (!uploadFile.success) {
setLoading(false);
- return ComponentGlobal_NotifikasiPeringatan(
- "Gagal upload background"
- );
+ ComponentGlobal_NotifikasiPeringatan("Gagal upload background");
+ return;
+ }
+
+ // Hapus gambar lama
+ const deletePhoto = await funGlobal_DeleteFileById({
+ fileId: fileId,
+ dirId: DIRECTORY_ID.profile_background,
+ });
+
+ if (!deletePhoto.success) {
+ setLoading(false);
+ clientLogger.error("Error delete background", deletePhoto.message);
}
const res = await profile_funUpdateBackground({
@@ -60,12 +62,12 @@ export function Profile_ComponentButtonUpdateBackgroundProfile({
ComponentGlobal_NotifikasiBerhasil(res.message);
router.back();
} else {
+ setLoading(false);
ComponentGlobal_NotifikasiGagal(res.message);
}
} catch (error) {
- clientLogger.error("Error upload background", error);
- } finally {
setLoading(false);
+ clientLogger.error("Error upload background", error);
}
}
diff --git a/src/app_modules/katalog/profile/_component/button/comp_button_update_photo_profile.tsx b/src/app_modules/katalog/profile/_component/button/comp_button_update_photo_profile.tsx
index ac721d40..a36365f2 100644
--- a/src/app_modules/katalog/profile/_component/button/comp_button_update_photo_profile.tsx
+++ b/src/app_modules/katalog/profile/_component/button/comp_button_update_photo_profile.tsx
@@ -1,21 +1,21 @@
"use client";
+import { DIRECTORY_ID } from "@/app/lib";
import { MainColor } from "@/app_modules/_global/color";
+import {
+ funGlobal_DeleteFileById,
+ funGlobal_UploadToStorage,
+} from "@/app_modules/_global/fun";
import {
ComponentGlobal_NotifikasiBerhasil,
ComponentGlobal_NotifikasiGagal,
ComponentGlobal_NotifikasiPeringatan,
} from "@/app_modules/_global/notif_global";
-import { Box, Button, Center } from "@mantine/core";
+import { clientLogger } from "@/util/clientLogger";
+import { Box, Button } from "@mantine/core";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { profile_funUpdatePhoto } from "../../fun";
-import {
- funGlobal_DeleteFileById,
- funGlobal_UploadToStorage,
-} from "@/app_modules/_global/fun";
-import { DIRECTORY_ID } from "@/app/lib";
-import { clientLogger } from "@/util/clientLogger";
export function Profile_ComponentButtonUpdatePhotoProfile({
file,
@@ -31,41 +31,45 @@ export function Profile_ComponentButtonUpdatePhotoProfile({
async function onUpdate() {
try {
setLoading(true);
- const deletePhoto = await funGlobal_DeleteFileById({
- fileId: fileId,
- dirId: DIRECTORY_ID.profile_foto,
- });
-
- if (!deletePhoto.success) {
- ComponentGlobal_NotifikasiPeringatan("Gagal update foto profile");
- return;
- }
+ // Upload foto baru
const uploadPhoto = await funGlobal_UploadToStorage({
file: file,
dirId: DIRECTORY_ID.profile_foto,
});
if (!uploadPhoto.success) {
+ setLoading(false);
ComponentGlobal_NotifikasiPeringatan("Gagal upload foto profile");
return;
}
+ // Hapus gambar lama
+ const deletePhoto = await funGlobal_DeleteFileById({
+ fileId: fileId,
+ dirId: DIRECTORY_ID.profile_foto,
+ });
+
+ if (!deletePhoto.success) {
+ setLoading(false);
+ clientLogger.error("Error delete logo", deletePhoto.message);
+ }
+
const res = await profile_funUpdatePhoto({
fileId: uploadPhoto.data.id,
profileId: profileId,
});
-
+
if (res.status === 200) {
ComponentGlobal_NotifikasiBerhasil(res.message);
router.back();
} else {
+ setLoading(false);
ComponentGlobal_NotifikasiGagal(res.message);
}
} catch (error) {
- clientLogger.error("Error update photo profile", error);
- } finally {
setLoading(false);
+ clientLogger.error("Error update photo profile", error);
}
}
return (
diff --git a/src/app_modules/katalog/profile/_component/button/comp_create_new_profile.tsx b/src/app_modules/katalog/profile/_component/button/comp_create_new_profile.tsx
index ccb8fc6a..08f2fcc9 100644
--- a/src/app_modules/katalog/profile/_component/button/comp_create_new_profile.tsx
+++ b/src/app_modules/katalog/profile/_component/button/comp_create_new_profile.tsx
@@ -7,7 +7,7 @@ import {
ComponentGlobal_NotifikasiGagal,
ComponentGlobal_NotifikasiPeringatan,
} from "@/app_modules/_global/notif_global";
-import { gmailRegex } from "@/app_modules/katalog/component/regular_expressions";
+import { emailRegex } from "@/app_modules/katalog/component/regular_expressions";
import { Button } from "@mantine/core";
import _ from "lodash";
import { useRouter } from "next/navigation";
@@ -36,7 +36,7 @@ export function Profile_ComponentCreateNewProfile({
};
if (_.values(newData).includes(""))
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
- if (!newData.email.match(gmailRegex))
+ if (!newData.email.match(emailRegex))
return ComponentGlobal_NotifikasiPeringatan("Format email salah");
if (fotoProfileId == "")
diff --git a/src/app_modules/katalog/profile/create/view.tsx b/src/app_modules/katalog/profile/create/view.tsx
index 77feb0b2..7751a451 100644
--- a/src/app_modules/katalog/profile/create/view.tsx
+++ b/src/app_modules/katalog/profile/create/view.tsx
@@ -4,7 +4,7 @@ import { ComponentGlobal_ErrorInput } from "@/app_modules/_global/component";
import { Select, Stack, TextInput } from "@mantine/core";
import { IconAt } from "@tabler/icons-react";
import { useState } from "react";
-import { gmailRegex } from "../../component/regular_expressions";
+import { emailRegex } from "../../component/regular_expressions";
import { Profile_ComponentCreateNewProfile } from "../_component";
import Profile_ViewUploadBackground from "./view_upload_background";
import Profile_ViewUploadFoto from "./view_upload_foto";
@@ -70,7 +70,7 @@ export default function CreateProfile() {
maxLength={100}
placeholder="Contoh: User@gmail.com"
error={
- value.email.length > 0 && !value.email.match(gmailRegex) ? (
+ value.email.length > 0 && !value.email.match(emailRegex) ? (
) : (
""
diff --git a/src/app_modules/katalog/profile/edit/view.tsx b/src/app_modules/katalog/profile/edit/view.tsx
index 6cbce3dd..8ac1e38e 100644
--- a/src/app_modules/katalog/profile/edit/view.tsx
+++ b/src/app_modules/katalog/profile/edit/view.tsx
@@ -1,17 +1,18 @@
"use client";
+import { MainColor } from "@/app_modules/_global/color/color_pallet";
+import ComponentGlobal_ErrorInput from "@/app_modules/_global/component/error_input";
+import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
+import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
+import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
+import { clientLogger } from "@/util/clientLogger";
import { Button, Loader, Select, Stack, TextInput } from "@mantine/core";
import _ from "lodash";
import { useRouter } from "next/navigation";
import { useState } from "react";
-import { MainColor } from "@/app_modules/_global/color/color_pallet";
-import ComponentGlobal_ErrorInput from "@/app_modules/_global/component/error_input";
-import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
-import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
-import { gmailRegex, validRegex } from "../../component/regular_expressions";
+import { emailRegex } from "../../component/regular_expressions";
import { Profile_funEditById } from "../fun/update/fun_edit_profile_by_id";
import { MODEL_PROFILE } from "../model/interface";
-import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
export default function EditProfile({ data }: { data: MODEL_PROFILE }) {
const router = useRouter();
@@ -26,18 +27,23 @@ export default function EditProfile({ data }: { data: MODEL_PROFILE }) {
// console.log(body)
if (_.values(body).includes(""))
return ComponentGlobal_NotifikasiPeringatan("Lengkapi data");
- if (!body.email.match(gmailRegex))
+ if (!body.email.match(emailRegex))
return ComponentGlobal_NotifikasiPeringatan("Format email salah");
- await Profile_funEditById(body).then((res) => {
+ try {
+ setLoading(true);
+ const res = await Profile_funEditById(body);
if (res.status === 200) {
- setLoading(true);
ComponentGlobal_NotifikasiBerhasil(res.message);
- setTimeout(() => router.back(), 1000);
+ router.back();
} else {
+ setLoading(false);
ComponentGlobal_NotifikasiGagal(res.message);
}
- });
+ } catch (error) {
+ setLoading(false);
+ clientLogger.error("Error update foto profile", error);
+ }
}
if (!dataProfile)
@@ -49,7 +55,6 @@ export default function EditProfile({ data }: { data: MODEL_PROFILE }) {
return (
<>
- {/* {JSON.stringify(dataProfile, null, 2)} */}
) : dataProfile?.email?.length > 0 &&
- !dataProfile?.email.match(gmailRegex) ? (
+ !dataProfile?.email.match(emailRegex) ? (
) : (
""
@@ -156,7 +161,7 @@ export default function EditProfile({ data }: { data: MODEL_PROFILE }) {
},
input: {
backgroundColor: MainColor.white,
- }
+ },
}}
withAsterisk
label="Alamat"
@@ -185,7 +190,7 @@ export default function EditProfile({ data }: { data: MODEL_PROFILE }) {
},
input: {
backgroundColor: MainColor.white,
- }
+ },
}}
withAsterisk
label="Jenis Kelamin"
@@ -216,7 +221,6 @@ export default function EditProfile({ data }: { data: MODEL_PROFILE }) {