diff --git a/package.json b/package.json index 90d5bef6..079d0f9c 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "@mantine/core": "^6.0.17", "@mantine/dates": "^6.0.17", "@mantine/dropzone": "^7.1.3", + "@mantine/form": "^7.6.1", "@mantine/hooks": "^6.0.17", "@mantine/next": "^6.0.17", "@mantine/notifications": "^6.0.17", diff --git a/public/profile/background/47266738-b42b-4f91-9b26-5730f334edaf.jpeg b/public/profile/background/47266738-b42b-4f91-9b26-5730f334edaf.jpeg new file mode 100644 index 00000000..8cd38350 Binary files /dev/null and b/public/profile/background/47266738-b42b-4f91-9b26-5730f334edaf.jpeg differ diff --git a/public/profile/background/64f55ff4-6192-4c0f-ac9e-d64c94ba670b.png b/public/profile/background/64f55ff4-6192-4c0f-ac9e-d64c94ba670b.png new file mode 100644 index 00000000..d0c9754c Binary files /dev/null and b/public/profile/background/64f55ff4-6192-4c0f-ac9e-d64c94ba670b.png differ diff --git a/public/profile/background/8099f775-c551-4715-bd9b-901b0bc4ffaa.jpeg b/public/profile/background/8099f775-c551-4715-bd9b-901b0bc4ffaa.jpeg new file mode 100644 index 00000000..b43c0679 Binary files /dev/null and b/public/profile/background/8099f775-c551-4715-bd9b-901b0bc4ffaa.jpeg differ diff --git a/public/profile/background/9be88bcd-90b5-47ef-8161-3044e1d3dd1e.jpeg b/public/profile/background/9be88bcd-90b5-47ef-8161-3044e1d3dd1e.jpeg new file mode 100644 index 00000000..32ce4052 Binary files /dev/null and b/public/profile/background/9be88bcd-90b5-47ef-8161-3044e1d3dd1e.jpeg differ diff --git a/public/profile/background/c6563aed-bd2c-4446-83e1-82107878aca2.jpeg b/public/profile/background/c6563aed-bd2c-4446-83e1-82107878aca2.jpeg new file mode 100644 index 00000000..b43c0679 Binary files /dev/null and b/public/profile/background/c6563aed-bd2c-4446-83e1-82107878aca2.jpeg differ diff --git a/public/profile/background/fb718146-8db1-4a44-aa3a-cb4dd607d9df.jpeg b/public/profile/background/fb718146-8db1-4a44-aa3a-cb4dd607d9df.jpeg new file mode 100644 index 00000000..66e914cb Binary files /dev/null and b/public/profile/background/fb718146-8db1-4a44-aa3a-cb4dd607d9df.jpeg differ diff --git a/public/profile/foto/0d7763e6-6a57-4521-8ac6-2784e4241cd2.jpeg b/public/profile/foto/0d7763e6-6a57-4521-8ac6-2784e4241cd2.jpeg new file mode 100644 index 00000000..4c3167d8 Binary files /dev/null and b/public/profile/foto/0d7763e6-6a57-4521-8ac6-2784e4241cd2.jpeg differ diff --git a/public/profile/foto/186134d1-1ed2-4521-a696-82a8f0c924c8.jpeg b/public/profile/foto/186134d1-1ed2-4521-a696-82a8f0c924c8.jpeg new file mode 100644 index 00000000..af6599d6 Binary files /dev/null and b/public/profile/foto/186134d1-1ed2-4521-a696-82a8f0c924c8.jpeg differ diff --git a/public/profile/foto/1c0cf07a-1ada-4a50-a88e-af5675d6d541.png b/public/profile/foto/1c0cf07a-1ada-4a50-a88e-af5675d6d541.png new file mode 100644 index 00000000..6e04e0ec Binary files /dev/null and b/public/profile/foto/1c0cf07a-1ada-4a50-a88e-af5675d6d541.png differ diff --git a/public/profile/foto/31510ea9-13ee-47b1-84f8-4ebd1413f9be.jpeg b/public/profile/foto/31510ea9-13ee-47b1-84f8-4ebd1413f9be.jpeg new file mode 100644 index 00000000..af6599d6 Binary files /dev/null and b/public/profile/foto/31510ea9-13ee-47b1-84f8-4ebd1413f9be.jpeg differ diff --git a/public/profile/foto/46c2413f-7b3d-4e55-b82f-31bab6d063b5.jpeg b/public/profile/foto/46c2413f-7b3d-4e55-b82f-31bab6d063b5.jpeg new file mode 100644 index 00000000..309c5830 Binary files /dev/null and b/public/profile/foto/46c2413f-7b3d-4e55-b82f-31bab6d063b5.jpeg differ diff --git a/public/profile/foto/7cfc36fd-239e-48eb-80fc-3558c5169f5d.jpeg b/public/profile/foto/7cfc36fd-239e-48eb-80fc-3558c5169f5d.jpeg new file mode 100644 index 00000000..af6599d6 Binary files /dev/null and b/public/profile/foto/7cfc36fd-239e-48eb-80fc-3558c5169f5d.jpeg differ diff --git a/public/profile/foto/9e8d7468-ca2a-4d64-bf10-abfe4f31c660.jpeg b/public/profile/foto/9e8d7468-ca2a-4d64-bf10-abfe4f31c660.jpeg new file mode 100644 index 00000000..3b15a8f8 Binary files /dev/null and b/public/profile/foto/9e8d7468-ca2a-4d64-bf10-abfe4f31c660.jpeg differ diff --git a/public/profile/foto/dda719a4-b392-4c4d-90c5-5607a12eb51b.jpeg b/public/profile/foto/dda719a4-b392-4c4d-90c5-5607a12eb51b.jpeg new file mode 100644 index 00000000..3b15a8f8 Binary files /dev/null and b/public/profile/foto/dda719a4-b392-4c4d-90c5-5607a12eb51b.jpeg differ diff --git a/src/app/dev/home/page.tsx b/src/app/dev/home/page.tsx index 477453b1..017f267d 100644 --- a/src/app/dev/home/page.tsx +++ b/src/app/dev/home/page.tsx @@ -9,7 +9,7 @@ export default async function Page() { const userId = await User_getUserId(); const dataUser = await user_getOneById(userId); // await new Promise((a, b) => { - // setTimeout(a, 1000); + // setTimeout(a, 4000); // }); return ( diff --git a/src/app/dev/katalog/[id]/page.tsx b/src/app/dev/katalog/[id]/page.tsx index bba193be..a486bd3d 100644 --- a/src/app/dev/katalog/[id]/page.tsx +++ b/src/app/dev/katalog/[id]/page.tsx @@ -23,9 +23,9 @@ export default async function Page({ params }: { params: { id: string } }) { const dataProfile = await Profile_getOneProfileAndUserById(profileId); // console.log(dataProfile) - await new Promise((a, b) => { - setTimeout(a, 1000); - }); + // await new Promise((a, b) => { + // setTimeout(a, 1000); + // }); return ( <> diff --git a/src/app/dev/profile/edit/[id]/loading.tsx b/src/app/dev/profile/edit/[id]/loading.tsx new file mode 100644 index 00000000..b1f8b62f --- /dev/null +++ b/src/app/dev/profile/edit/[id]/loading.tsx @@ -0,0 +1,9 @@ +import ComponentGlobal_V2_LoadingPage from "@/app_modules/component_global/loading_page_v2"; + +export default async function Page() { + return ( + <> + + + ); +} diff --git a/src/app/zCoba/page.tsx b/src/app/zCoba/page.tsx index 5778dd02..7246f4be 100644 --- a/src/app/zCoba/page.tsx +++ b/src/app/zCoba/page.tsx @@ -1,19 +1,51 @@ "use client"; -import { NotifPeringatan } from "@/app_modules/donasi/component/notifikasi/notif_peringatan"; -import { Box, Button, Group } from "@mantine/core"; -import { notifications } from "@mantine/notifications"; +import { + Box, + Center, + Group, + LoadingOverlay, + Paper, + Skeleton, + Text, +} from "@mantine/core"; + +export default function ComponentCobaCoba_LoadingPage() { + const listhHuruf = [ + { + huruf: "H", + }, + { + huruf: "I", + }, + { + huruf: "P", + }, + { + huruf: "M", + }, + { + huruf: "I", + }, + ]; + const customLOader = ( +
+ + {listhHuruf.map((e, i) => ( +
+ + + {e.huruf} + +
+ ))} +
+
+ ); -export default function Coba() { return ( <> - - - - - + ); } diff --git a/src/app_modules/auth/fun/fun_logout.ts b/src/app_modules/auth/fun/fun_logout.ts index a00bf9fc..6312472b 100644 --- a/src/app_modules/auth/fun/fun_logout.ts +++ b/src/app_modules/auth/fun/fun_logout.ts @@ -9,9 +9,8 @@ export async function auth_Logout(kodeId: string) { name: "ssn", value: "", maxAge: 0, - path: "/dev/auth/login", }); - + const c = cookies().get("ssn"); if (c?.value !== "") return { status: 400, message: "Gagal Logout" }; diff --git a/src/app_modules/auth/logout/view.tsx b/src/app_modules/auth/logout/view.tsx index 2ed684b6..51524892 100644 --- a/src/app_modules/auth/logout/view.tsx +++ b/src/app_modules/auth/logout/view.tsx @@ -20,25 +20,14 @@ export default function User_Logout() { const [loading, setLoading] = useState(false); const [loading2, setLoading2] = useState(false); - const onLogout = async () => { - // await fetch(ApiHipmi.logout) - // .then((res) => res.json()) - // .then((val) => { - // if (val.status == 200) { - // setnomor(null); - // setCode(null); - // ComponentGlobal_NotifikasiBerhasil("Anda Berhasil Logout") - // return router.push("/dev/auth/login"); - // } - // }); - }; - async function onClickLogout() { + // await auth_Logout(kodeId).then((res) => { + // ComponentGlobal_NotifikasiBerhasil("Berhasil Logout"); + // }); await auth_Logout(kodeId).then((res) => { if (res.status === 200) { - setKodeId(""); ComponentGlobal_NotifikasiBerhasil(res.message); - router.push(RouterAuth.login) + setKodeId(""); } else { ComponentGlobal_NotifikasiPeringatan(res.message); } diff --git a/src/app_modules/component_global/loading_page_v2.tsx b/src/app_modules/component_global/loading_page_v2.tsx index 4ebb72fe..d05c5d3d 100644 --- a/src/app_modules/component_global/loading_page_v2.tsx +++ b/src/app_modules/component_global/loading_page_v2.tsx @@ -1,25 +1,43 @@ "use client"; -import { Box, Center, Group, LoadingOverlay, Skeleton } from "@mantine/core"; +import { Box, Center, Group, LoadingOverlay, Skeleton, Text } from "@mantine/core"; export default function ComponentGlobal_V2_LoadingPage() { - const customLOader = ( -
- - {Array(3) - .fill(0) - .map((e, i) => ( - - ))} - -
- ); +const listhHuruf = [ + { + huruf: "H", + }, + { + huruf: "I", + }, + { + huruf: "P", + }, + { + huruf: "M", + }, + { + huruf: "I", + }, +]; +const customLOader = ( +
+ + {listhHuruf.map((e, i) => ( +
+ + + {e.huruf} + +
+ ))} +
+
+); - return ( - <> - - - - - ); +return ( + <> + + +); } diff --git a/src/app_modules/forum/komentar/index.tsx b/src/app_modules/forum/komentar/index.tsx index 1393c49a..fa484005 100644 --- a/src/app_modules/forum/komentar/index.tsx +++ b/src/app_modules/forum/komentar/index.tsx @@ -59,10 +59,10 @@ export default function Forum_Komentar({ forumId }: { forumId: string }) { }} /> - - + + {/* - + */} diff --git a/src/app_modules/fun_global/get_user_token.ts b/src/app_modules/fun_global/get_user_token.ts index 39b7e1bf..82f54dd1 100644 --- a/src/app_modules/fun_global/get_user_token.ts +++ b/src/app_modules/fun_global/get_user_token.ts @@ -10,7 +10,7 @@ const config = yaml.parse(fs.readFileSync("config.yaml").toString()); export async function User_getUserId() { const c = cookies().get("ssn"); - if (!c?.value) return redirect(RouterAuth.login); + if (!c?.value || c.value === "") return redirect(RouterAuth.login); const token = JSON.parse( diff --git a/src/app_modules/home/layout.tsx b/src/app_modules/home/layout.tsx index a543d71b..e0ab35e9 100644 --- a/src/app_modules/home/layout.tsx +++ b/src/app_modules/home/layout.tsx @@ -41,6 +41,7 @@ export default function HomeLayout({ const router = useRouter(); const [user, setUser] = useState(dataUser); const [loading, setLoading] = useState(false); + const [loadingUS, setLoadingUS] = useState(false); const listFooter = [ { id: 1, @@ -88,19 +89,26 @@ export default function HomeLayout({ if (user?.Profile === null) { ComponentGlobal_NotifikasiPeringatan("Lengkapi Profile"); } else { + setLoadingUS(true); // router.push(RouterProfile.katalog + `${user.Profile.id}`); router.push(RouterUserSearch.main); } }} > - - - - - - Temukan pengguna - - + {loadingUS ? ( +
+ +
+ ) : ( + + + + + + Temukan pengguna + + + )} - - - {user?.Profile === null ? ( - - ) : loading ? ( - - ) : ( - - )} - - - Profile - - + {loading ? ( +
+ +
+ ) : ( + + + {user?.Profile === null ? ( + + ) : ( + + )} + + + Profile + + + )}
diff --git a/src/app_modules/katalog/profile/create/layout.tsx b/src/app_modules/katalog/profile/create/layout.tsx index 548ac59d..658adcf6 100644 --- a/src/app_modules/katalog/profile/create/layout.tsx +++ b/src/app_modules/katalog/profile/create/layout.tsx @@ -1,5 +1,6 @@ "use client"; +import ComponentGlobal_HeaderTamplate from "@/app_modules/component_global/header_tamplate"; import { ActionIcon, AppShell, @@ -18,15 +19,16 @@ export default function ProfileLayout({ children }: { children: any }) { - - router.push("/dev/home")}> - - - Create Profile - - - + //
+ // + // router.push("/dev/home")}> + // + // + // Create Profile + // + // + //
+ } > {children} diff --git a/src/app_modules/katalog/profile/create/view.tsx b/src/app_modules/katalog/profile/create/view.tsx index c3e0ef02..e68ddd6c 100644 --- a/src/app_modules/katalog/profile/create/view.tsx +++ b/src/app_modules/katalog/profile/create/view.tsx @@ -14,6 +14,7 @@ import { Paper, Select, Stack, + Text, TextInput, } from "@mantine/core"; import { useAtom } from "jotai"; @@ -22,7 +23,7 @@ import { useRouter } from "next/navigation"; import { useState } from "react"; import toast from "react-simple-toasts"; import funCreateNewProfile from "../fun/fun_create_profile"; -import { IconCamera } from "@tabler/icons-react"; +import { IconAt, IconCamera, IconUpload } from "@tabler/icons-react"; import ComponentKatalog_NotedBox from "../../component/noted_box"; import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime"; import { MODEL_PROFILE } from "../model/interface"; @@ -31,9 +32,9 @@ import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_glob import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog"; import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal"; import { RouterHome } from "@/app/lib/router_hipmi/router_home"; +import { useForm } from "@mantine/form"; export default function CreateProfile({ userId }: { userId: any }) { - const router = useRouter(); const [filePP, setFilePP] = useState(null); const [imgPP, setImgPP] = useState(); const [fileBG, setFileBG] = useState(null); @@ -53,16 +54,32 @@ export default function CreateProfile({ userId }: { userId: any }) {
- + {imgPP ? ( + + + + ) : ( + + + + )}
1000000) { + ComponentGlobal_NotifikasiPeringatan( + "Maaf, Ukuran file terlalu besar, maximum 1mb", + 3000 + ); + } else { + setImgPP(buffer); + setFilePP(files); + } // console.log(buffer, "ini buffer"); // console.log(files, " ini file"); - setImgPP(buffer); - setFilePP(files); } catch (error) { console.log(error); } @@ -104,13 +128,25 @@ export default function CreateProfile({ userId }: { userId: any }) { - Foto + {imgBG ? ( + Foto + ) : ( + + + + Upload Background + + + )} @@ -121,10 +157,17 @@ export default function CreateProfile({ userId }: { userId: any }) { const buffer = URL.createObjectURL( new Blob([new Uint8Array(await files.arrayBuffer())]) ); + if (files.size > 1000000) { + ComponentGlobal_NotifikasiPeringatan( + "Maaf, Ukuran file terlalu besar, maximum 1mb", + 3000 + ); + } else { + setImgBG(buffer); + setFileBG(files); + } // console.log(buffer, "ini buffer"); // console.log(files, " ini file"); - setImgBG(buffer); - setFileBG(files); } catch (error) { console.log(error); } @@ -148,96 +191,139 @@ export default function CreateProfile({ userId }: { userId: any }) { - { - setValue({ - ...value, - name: val.target.value, - }); - }} - /> - { - setValue({ - ...value, - email: val.target.value, - }); - }} - /> - { - setValue({ - ...value, - alamat: val.target.value, - }); - }} - /> - { + setValue({ + ...value, + jenisKelamin: val as string, + }); + }} + /> + + ); } -async function onSubmit( - router: AppRouterInstance, - value: MODEL_PROFILE, - userId: string, - filePP: FormData, - fileBg: FormData -) { - const body = { - userId: userId, - name: value.name, - email: value.email, - alamat: value.alamat, - jenisKelamin: value.jenisKelamin, - }; - if(_.values(body).includes("")) return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data") +function ButtonAction({ + value, + userId, + filePP, + fileBg, +}: { + value: MODEL_PROFILE; + userId: string; + filePP: FormData; + fileBg: FormData; +}) { + const router = useRouter(); + const [loading, setLoading] = useState(false); - const gambarPP = new FormData(); - gambarPP.append("filePP", filePP as any); + async function onSubmit() { + const body = { + userId: userId, + name: value.name, + email: value.email, + alamat: value.alamat, + jenisKelamin: value.jenisKelamin, + }; + if (_.values(body).includes("")) + return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data"); + if (!body.email.includes("@")) + return ComponentGlobal_NotifikasiPeringatan("Invalid Email"); - const gambarBG = new FormData(); - gambarBG.append("fileBG", fileBg as any); + const gambarPP = new FormData(); + gambarPP.append("filePP", filePP as any); - - if(!gambarPP) return ComponentGlobal_NotifikasiPeringatan("Lengkapi foto profile") - if(!gambarBG) return ComponentGlobal_NotifikasiPeringatan("Lengkapi background profile") - - - await funCreateNewProfile(body as any, gambarPP, gambarBG).then((res) => { - if (res.status === 201) { - ComponentGlobal_NotifikasiBerhasil("Berhasil Membuat Profile") - router.push(RouterHome.main_home); - } else { - ComponentGlobal_NotifikasiGagal(res.message); - } - }); + const gambarBG = new FormData(); + gambarBG.append("fileBG", fileBg as any); + if (!gambarPP) + return ComponentGlobal_NotifikasiPeringatan("Lengkapi foto profile"); + if (!gambarBG) + return ComponentGlobal_NotifikasiPeringatan( + "Lengkapi background profile" + ); + + await funCreateNewProfile(body as any, gambarPP, gambarBG).then((res) => { + if (res.status === 201) { + setLoading(true); + ComponentGlobal_NotifikasiBerhasil("Berhasil Membuat Profile", 3000); + router.push(RouterHome.main_home); + } else { + ComponentGlobal_NotifikasiGagal(res.message); + } + }); + } + + return ( + <> + + + ); } diff --git a/src/app_modules/katalog/profile/edit/view.tsx b/src/app_modules/katalog/profile/edit/view.tsx index 164489fd..599262e0 100644 --- a/src/app_modules/katalog/profile/edit/view.tsx +++ b/src/app_modules/katalog/profile/edit/view.tsx @@ -23,15 +23,19 @@ export default function EditProfile({ data }: { data: MODEL_PROFILE }) { //Get data profile const [dataProfile, setDataProfile] = useState(data); + const [loading, setLoading] = useState(false); async function onUpdate() { const body = dataProfile; + + // console.log(body) if (_.values(body).includes("")) return toast("Lengkapi data"); await Profile_funEditById(body).then((res) => { if (res.status === 200) { + setLoading(true); ComponentGlobal_NotifikasiBerhasil(res.message); - setTimeout(() => router.back(), 1000) + setTimeout(() => router.back(), 1000); } else { ComponentGlobal_NotifikasiGagal(res.message); } @@ -47,18 +51,42 @@ export default function EditProfile({ data }: { data: MODEL_PROFILE }) { return ( <> + {/*
{JSON.stringify(dataProfile, null, 2)}
*/} - { + // const dataUsername = _.clone(dataProfile) + + setDataProfile({ + ...(dataProfile as any), + User: { + username: val.target.value, + }, + }); + }} + /> + + { setDataProfile({ ...dataProfile, @@ -68,9 +96,15 @@ export default function EditProfile({ data }: { data: MODEL_PROFILE }) { /> 0 && !dataProfile?.email.includes("@") + ? "Invalid email" + : "" + } + value={dataProfile?.email} onChange={(val) => { setDataProfile({ ...dataProfile, @@ -80,6 +114,7 @@ export default function EditProfile({ data }: { data: MODEL_PROFILE }) { />