;
+}) {
+ return (
+ <>
+
+ {children}
+
+ >
+ );
+}
diff --git a/src/app_modules/_global/component/index.ts b/src/app_modules/_global/component/index.ts
index e5e7bad5..dcd7dc74 100644
--- a/src/app_modules/_global/component/index.ts
+++ b/src/app_modules/_global/component/index.ts
@@ -1,9 +1,15 @@
+import ComponentGlobal_BoxInformation from "./box_information";
import ComponentGlobal_AvatarAndAuthorName from "./comp_author_name_and_avatar";
+import { ComponentGlobal_CardStyles } from "./comp_card_box_and_background";
import ComponentGlobal_CardLoadingOverlay from "./comp_loading_card";
import ComponentGlobal_TampilanAngkaRatusan from "./comp_tampilan_angka_ratusan";
import ComponentGlobal_TampilanRupiah from "./comp_tampilan_rupiah";
+import ComponentGlobal_InputCountDown from "./input_countdown";
export { ComponentGlobal_TampilanRupiah };
export { ComponentGlobal_TampilanAngkaRatusan };
export { ComponentGlobal_AvatarAndAuthorName };
export { ComponentGlobal_CardLoadingOverlay };
+export { ComponentGlobal_BoxInformation };
+export { ComponentGlobal_InputCountDown };
+export { ComponentGlobal_CardStyles };
diff --git a/src/app_modules/_global/component/loader.tsx b/src/app_modules/_global/component/loader.tsx
index 8df65a5d..e3c03c23 100644
--- a/src/app_modules/_global/component/loader.tsx
+++ b/src/app_modules/_global/component/loader.tsx
@@ -1,10 +1,20 @@
import { Loader } from "@mantine/core";
import { MainColor } from "../color/color_pallet";
-export default function ComponentGlobal_Loader({ size }: { size?: number }) {
+export default function ComponentGlobal_Loader({
+ size,
+ variant,
+}: {
+ size?: number;
+ variant?: "dots" | "bars" | "oval";
+}) {
return (
<>
-
+
>
);
}
diff --git a/src/app_modules/_global/fun/index.ts b/src/app_modules/_global/fun/index.ts
new file mode 100644
index 00000000..e85ec448
--- /dev/null
+++ b/src/app_modules/_global/fun/index.ts
@@ -0,0 +1,3 @@
+import { funGlobal_UploadToStorage } from "./upload/fun_upload_to_storage";
+
+export { funGlobal_UploadToStorage };
diff --git a/src/app_modules/_global/fun/upload/fun_upload_to_storage.ts b/src/app_modules/_global/fun/upload/fun_upload_to_storage.ts
new file mode 100644
index 00000000..9ef9155c
--- /dev/null
+++ b/src/app_modules/_global/fun/upload/fun_upload_to_storage.ts
@@ -0,0 +1,55 @@
+import { TokenStorage } from "@/app/lib/token";
+
+export async function funGlobal_UploadToStorage({
+ file,
+ dirId,
+}: {
+ file: File;
+ dirId: string;
+}) {
+ if (!file) console.log("Tidak ada file");
+
+ const allowedMimeTypes = [
+ "image/png",
+ "image/jpeg",
+ "image/gif",
+ "text/csv",
+ "application/pdf",
+ "application/msword",
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
+ "application/vnd.ms-excel",
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ "text/plain",
+ ];
+
+ if (!allowedMimeTypes.includes(file.type)) console.log("File tidak sesuai");
+
+ if (file.size > 100 * 1024 * 1024) console.log("File terlalu besar");
+
+ const formData = new FormData();
+ formData.append("file", file);
+ formData.append("dirId", dirId);
+
+ try {
+ const res = await fetch("https://wibu-storage.wibudev.com/api/upload", {
+ method: "POST",
+ body: formData,
+ headers: {
+ Authorization: `Bearer ${TokenStorage.value}`,
+ },
+ });
+
+ const dataRes = await res.json();
+
+ if (res.ok) {
+ return { success: true, data: dataRes.data };
+ } else {
+ const errorText = await res.text();
+ console.error("Error:", errorText);
+ return { success: false, data: {} };
+ }
+ } catch (error) {
+ console.error("Error:", error);
+ return { success: false, data: {} };
+ }
+}
diff --git a/src/app_modules/_global/notif_global/index.ts b/src/app_modules/_global/notif_global/index.ts
new file mode 100644
index 00000000..355d8145
--- /dev/null
+++ b/src/app_modules/_global/notif_global/index.ts
@@ -0,0 +1,7 @@
+import { ComponentGlobal_NotifikasiBerhasil } from "./notifikasi_berhasil";
+import { ComponentGlobal_NotifikasiGagal } from "./notifikasi_gagal";
+import { ComponentGlobal_NotifikasiPeringatan } from "./notifikasi_peringatan";
+
+export { ComponentGlobal_NotifikasiBerhasil };
+export { ComponentGlobal_NotifikasiGagal };
+export { ComponentGlobal_NotifikasiPeringatan };
diff --git a/src/app_modules/admin/_admin_global/logout.tsx b/src/app_modules/admin/_admin_global/logout.tsx
index 0b2508fc..837d3423 100644
--- a/src/app_modules/admin/_admin_global/logout.tsx
+++ b/src/app_modules/admin/_admin_global/logout.tsx
@@ -1,6 +1,9 @@
"use client";
-import { myConsole } from "@/app/fun/my_console";
-import { ApiHipmi } from "@/app/lib/api";
+import { Warna } from "@/app/lib/warna";
+import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
+import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
+import { auth_Logout } from "@/app_modules/auth/fun/fun_logout";
+import { gs_kodeId } from "@/app_modules/auth/state/state";
import {
ActionIcon,
Button,
@@ -10,15 +13,10 @@ import {
Stack,
Title,
} from "@mantine/core";
-import { useRouter } from "next/navigation";
-import { useAtom } from "jotai";
-import { IconLogout } from "@tabler/icons-react";
-import { Warna } from "@/app/lib/warna";
import { useDisclosure } from "@mantine/hooks";
-import { gs_kodeId, gs_nomor, gs_otp } from "@/app_modules/auth/state/state";
-import { auth_Logout } from "@/app_modules/auth/fun/fun_logout";
-import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
-import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
+import { IconLogout } from "@tabler/icons-react";
+import { useAtom } from "jotai";
+import { useRouter } from "next/navigation";
import { useState } from "react";
export default function Admin_Logout() {
diff --git a/src/app_modules/admin/job/child/arsip/index.tsx b/src/app_modules/admin/job/child/arsip/index.tsx
index 37819715..bb39e9c9 100644
--- a/src/app_modules/admin/job/child/arsip/index.tsx
+++ b/src/app_modules/admin/job/child/arsip/index.tsx
@@ -1,40 +1,21 @@
"use client";
-import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/_admin_global/header_tamplate";
-import { adminEvent_getListPesertaById } from "@/app_modules/admin/event/fun/get/get_list_peserta_by_id";
-import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
-import {
- MODEL_EVENT,
- MODEL_EVENT_PESERTA,
-} from "@/app_modules/event/model/interface";
import { MODEL_JOB } from "@/app_modules/job/model/interface";
import {
- MODEL_VOTE_KONTRIBUTOR,
- MODEL_VOTING,
- MODEL_VOTING_DAFTAR_NAMA_VOTE,
-} from "@/app_modules/vote/model/interface";
-import {
- Avatar,
- Badge,
Box,
Button,
- Card,
Center,
- Divider,
- Grid,
- Group,
Modal,
- Paper,
ScrollArea,
Spoiler,
Stack,
Table,
Text,
- Title,
+ Title
} from "@mantine/core";
import { useDisclosure } from "@mantine/hooks";
-import { IconEyeCheck, IconEyeShare } from "@tabler/icons-react";
+import { IconEyeCheck } from "@tabler/icons-react";
import _ from "lodash";
import { useRouter } from "next/navigation";
import { useState } from "react";
@@ -74,13 +55,13 @@ function TableStatus({ listArsip }: { listArsip: MODEL_JOB[] }) {
|
- {e.imagesId ? (
+ {e.imageId ? (
}
onClick={() => {
- setImg(e.imagesId);
+ setImg(e.imageId);
open();
}}
>
diff --git a/src/app_modules/admin/job/child/publish/index.tsx b/src/app_modules/admin/job/child/publish/index.tsx
index f7bba87f..ac0263a1 100644
--- a/src/app_modules/admin/job/child/publish/index.tsx
+++ b/src/app_modules/admin/job/child/publish/index.tsx
@@ -16,16 +16,14 @@ import {
Table,
Text,
TextInput,
- Title
+ Title,
} from "@mantine/core";
-import {
- IconEyeCheck,
- IconSearch
-} from "@tabler/icons-react";
+import { IconEyeCheck, IconSearch } from "@tabler/icons-react";
import { useRouter } from "next/navigation";
import { useState } from "react";
import adminJob_getListPublish from "../../fun/get/get_list_publish";
import { IconPhotoCheck } from "@tabler/icons-react";
+import { ComponentAdminGlobal_TitlePage } from "@/app_modules/admin/_admin_global/_component";
export default function AdminJob_TablePublish({
dataPublish,
@@ -49,7 +47,7 @@ function TableStatus({ dataPublish }: { dataPublish: any }) {
const [nPage, setNPage] = useState(dataPublish.nPage);
const [activePage, setActivePage] = useState(1);
const [isSearch, setSearch] = useState("");
-
+ const [isLoadingShowImage, setLoadingShowImage] = useState(false);
async function onSearch(s: string) {
setSearch(s);
@@ -102,19 +100,22 @@ function TableStatus({ dataPublish }: { dataPublish: any }) {
|
- {e.imagesId ? (
+ {e.imageId ? (
}
onClick={() => {
- router.push(RouterAdminJob.detail_poster + e?.imagesId);
+ setLoadingShowImage(true);
+ router.push(RouterAdminJob.detail_poster + e?.imageId);
}}
>
Lihat
) : (
-
+
Tidak ada poster
@@ -147,28 +148,22 @@ function TableStatus({ dataPublish }: { dataPublish: any }) {
return (
<>
-
-
{/* {JSON.stringify(listUser, null, 2)} */}
-
-
- Publish
-
- }
- radius={"xl"}
- placeholder="Masukan judul"
- onChange={(val) => {
- onSearch(val.currentTarget.value);
- }}
- />
-
+ }
+ radius={"xl"}
+ placeholder="Masukan judul"
+ onChange={(val) => {
+ onSearch(val.currentTarget.value);
+ }}
+ />
+ }
+ />
@@ -217,8 +212,6 @@ function TableStatus({ dataPublish }: { dataPublish: any }) {
-
-
>
);
}
diff --git a/src/app_modules/admin/job/child/reject/index.tsx b/src/app_modules/admin/job/child/reject/index.tsx
index 8299b4e1..476da95a 100644
--- a/src/app_modules/admin/job/child/reject/index.tsx
+++ b/src/app_modules/admin/job/child/reject/index.tsx
@@ -97,13 +97,13 @@ function TableStatus({ listReject }: { listReject: any }) {
|
- {e.imagesId ? (
+ {e.imageId ? (
}
onClick={() => {
- router.push(RouterAdminJob.detail_poster + e?.imagesId);
+ router.push(RouterAdminJob.detail_poster + e?.imageId);
}}
>
Lihat
diff --git a/src/app_modules/admin/job/child/review/index.tsx b/src/app_modules/admin/job/child/review/index.tsx
index 89b90f5e..bc794da0 100644
--- a/src/app_modules/admin/job/child/review/index.tsx
+++ b/src/app_modules/admin/job/child/review/index.tsx
@@ -85,7 +85,7 @@ function TableStatus({ listReview }: { listReview: any }) {
async function onSearch(s: string) {
setSearch(s);
- setActivePage(1)
+ setActivePage(1);
const loadData = await adminJob_getListReview({
page: 1,
search: s,
@@ -123,13 +123,13 @@ function TableStatus({ listReview }: { listReview: any }) {
|
- {e.imagesId ? (
+ {e.imageId ? (
}
onClick={() => {
- router.push(RouterAdminJob.detail_poster + e?.imagesId);
+ router.push(RouterAdminJob.detail_poster + e?.imageId);
}}
>
Lihat
diff --git a/src/app_modules/admin/job/detail/detail_poster.tsx b/src/app_modules/admin/job/detail/detail_poster.tsx
index 4cf40b10..458f9153 100644
--- a/src/app_modules/admin/job/detail/detail_poster.tsx
+++ b/src/app_modules/admin/job/detail/detail_poster.tsx
@@ -3,23 +3,30 @@
import { RouterJob } from "@/app/lib/router_hipmi/router_job";
import { Center, Image, Stack } from "@mantine/core";
import ComponentAdminGlobal_BackButton from "../../_admin_global/back_button";
+import { APIs } from "@/app/lib";
+import { useState } from "react";
+import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
export default function AdminJob_DetailPoster({
imageId,
}: {
imageId: string;
}) {
+ const [isLoading, setLoading] = useState(true);
+
return (
<>
-
+ setLoading(false)} alt="Foto" src={APIs.GET + imageId} mah={500} maw={300} />
+ {isLoading ? (
+
+
+
+ ) : (
+ ""
+ )}
>
diff --git a/src/app_modules/admin/job/fun/get/get_list_publish.ts b/src/app_modules/admin/job/fun/get/get_list_publish.ts
index 48c0c5f2..9fdccfe8 100644
--- a/src/app_modules/admin/job/fun/get/get_list_publish.ts
+++ b/src/app_modules/admin/job/fun/get/get_list_publish.ts
@@ -27,19 +27,8 @@ export default async function adminJob_getListPublish({
mode: "insensitive",
},
},
- select: {
- id: true,
- title: true,
- isActive: true,
- isArsip: true,
- createdAt: true,
- updatedAt: true,
- content: true,
- deskripsi: true,
- catatan: true,
- authorId: true,
+ include: {
Author: true,
- imagesId: true,
},
});
diff --git a/src/app_modules/admin/job/fun/get/get_list_reject.ts b/src/app_modules/admin/job/fun/get/get_list_reject.ts
index a0bd212d..639fe807 100644
--- a/src/app_modules/admin/job/fun/get/get_list_reject.ts
+++ b/src/app_modules/admin/job/fun/get/get_list_reject.ts
@@ -27,18 +27,8 @@ export default async function adminJob_getListReject({
mode: "insensitive",
},
},
- select: {
- id: true,
- title: true,
- isActive: true,
- createdAt: true,
- updatedAt: true,
- content: true,
- deskripsi: true,
- catatan: true,
- authorId: true,
+ include: {
Author: true,
- imagesId: true,
},
});
diff --git a/src/app_modules/admin/job/fun/get/get_list_review.ts b/src/app_modules/admin/job/fun/get/get_list_review.ts
index a5b1fa49..bdfd4033 100644
--- a/src/app_modules/admin/job/fun/get/get_list_review.ts
+++ b/src/app_modules/admin/job/fun/get/get_list_review.ts
@@ -27,18 +27,8 @@ export default async function adminJob_getListReview({
mode: "insensitive",
},
},
- select: {
- id: true,
- title: true,
- isActive: true,
- createdAt: true,
- updatedAt: true,
- content: true,
- deskripsi: true,
- catatan: true,
- authorId: true,
+ include: {
Author: true,
- imagesId: true,
},
});
diff --git a/src/app_modules/admin/job/fun/get/get_list_table_by_status_id.ts b/src/app_modules/admin/job/fun/get/get_list_table_by_status_id.ts
index 6a83b623..7f91e870 100644
--- a/src/app_modules/admin/job/fun/get/get_list_table_by_status_id.ts
+++ b/src/app_modules/admin/job/fun/get/get_list_table_by_status_id.ts
@@ -13,19 +13,8 @@ export async function AdminJob_getListTableByStatusId(statusId: string) {
isActive: true,
isArsip: true,
},
- select: {
- id: true,
- title: true,
- isActive: true,
- isArsip: true,
- createdAt: true,
- updatedAt: true,
- content: true,
- deskripsi: true,
- catatan: true,
- authorId: true,
+ include: {
Author: true,
- imagesId: true,
},
});
@@ -41,18 +30,8 @@ export async function AdminJob_getListTableByStatusId(statusId: string) {
isActive: true,
isArsip: false,
},
- select: {
- id: true,
- title: true,
- isActive: true,
- createdAt: true,
- updatedAt: true,
- content: true,
- deskripsi: true,
- catatan: true,
- authorId: true,
+ include: {
Author: true,
- imagesId: true,
},
});
@@ -67,18 +46,8 @@ export async function AdminJob_getListTableByStatusId(statusId: string) {
masterStatusId: "2",
isActive: true,
},
- select: {
- id: true,
- title: true,
- isActive: true,
- createdAt: true,
- updatedAt: true,
- content: true,
- deskripsi: true,
- catatan: true,
- authorId: true,
+ include: {
Author: true,
- imagesId: true,
},
});
@@ -94,18 +63,8 @@ export async function AdminJob_getListTableByStatusId(statusId: string) {
masterStatusId: "4",
isActive: true,
},
- select: {
- id: true,
- title: true,
- isActive: true,
- createdAt: true,
- updatedAt: true,
- content: true,
- deskripsi: true,
- catatan: true,
- authorId: true,
+ include: {
Author: true,
- imagesId: true,
},
});
diff --git a/src/app_modules/auth/splash/view.tsx b/src/app_modules/auth/splash/view.tsx
index e115e79d..b017dd7f 100644
--- a/src/app_modules/auth/splash/view.tsx
+++ b/src/app_modules/auth/splash/view.tsx
@@ -13,11 +13,11 @@ import {
import { useShallowEffect } from "@mantine/hooks";
import { useRouter } from "next/navigation";
-export default function SplashScreen({ data }: { data: any }) {
+export default function SplashScreen({ userLoginId }: { userLoginId: any }) {
const router = useRouter();
useShallowEffect(() => {
- if (!data) {
+ if (!userLoginId) {
setTimeout(() => {
return router.push("/dev/auth/login", { scroll: false });
}, 1000);
@@ -38,8 +38,13 @@ export default function SplashScreen({ data }: { data: any }) {
{/* Welcome to */}
-
-
+
+
diff --git a/src/app_modules/fun_global/get_user_token.ts b/src/app_modules/fun_global/get_user_token.ts
index 2be2571e..5702029c 100644
--- a/src/app_modules/fun_global/get_user_token.ts
+++ b/src/app_modules/fun_global/get_user_token.ts
@@ -6,11 +6,14 @@ import fs from "fs";
import { unsealData } from "iron-session";
import { redirect } from "next/navigation";
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
+import _ from "lodash";
const config = yaml.parse(fs.readFileSync("config.yaml").toString());
export async function user_funGetOneUserId() {
- const c = cookies().get("ssn");
- if (!c?.value || c.value === "") return redirect(RouterAuth.login);
+ const kukis = cookies();
+ const c = kukis.get("ssn");
+ if (!c || !c?.value || _.isEmpty(c?.value) || _.isUndefined(c?.value))
+ return redirect(RouterAuth.login);
const token = JSON.parse(
await unsealData(c?.value as string, {
@@ -18,5 +21,5 @@ export async function user_funGetOneUserId() {
})
);
- return token.id
+ return token.id;
}
diff --git a/src/app_modules/investasi/_component/comp_card_border_and_background.tsx b/src/app_modules/investasi/_component/comp_card_border_and_background.tsx
index 7a12ebee..a6942af2 100644
--- a/src/app_modules/investasi/_component/comp_card_border_and_background.tsx
+++ b/src/app_modules/investasi/_component/comp_card_border_and_background.tsx
@@ -1,7 +1,6 @@
import { AccentColor } from "@/app_modules/_global/color";
-import { ComponentGlobal_CardLoadingOverlay } from "@/app_modules/_global/component";
import { Card } from "@mantine/core";
-import React, { useState } from "react";
+import React from "react";
export function Investasi_ComponentStylesCard({
children,
@@ -16,7 +15,6 @@ export function Investasi_ComponentStylesCard({
marginBottom?: string | number;
onClickHandler?: React.MouseEventHandler;
}) {
-
return (
<>
+
+ >
+ );
+}
+
+export default Job_ComponentButtonSaveCreate;
diff --git a/src/app_modules/job/component/button/comp_button_update.tsx b/src/app_modules/job/component/button/comp_button_update.tsx
new file mode 100644
index 00000000..225cb84d
--- /dev/null
+++ b/src/app_modules/job/component/button/comp_button_update.tsx
@@ -0,0 +1,128 @@
+import { MainColor, AccentColor } from "@/app_modules/_global/color";
+import {
+ ComponentGlobal_NotifikasiBerhasil,
+ ComponentGlobal_NotifikasiGagal,
+ ComponentGlobal_NotifikasiPeringatan,
+} from "@/app_modules/_global/notif_global";
+import { Modal, Stack, Title, Group, Button } from "@mantine/core";
+import { useDisclosure, useWindowScroll } from "@mantine/hooks";
+import { useAtom } from "jotai";
+import { useRouter } from "next/navigation";
+import { useState } from "react";
+import { job_EditById } from "../../fun/edit/fun_edit_by_id";
+import { gs_job_hot_menu, gs_job_status } from "../../global_state";
+import { MODEL_JOB } from "../../model/interface";
+import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
+import { DIRECTORY_ID } from "@/app/lib";
+
+export function Job_ComponentButtonUpdate({
+ value,
+ file,
+}: {
+ value: MODEL_JOB;
+ file: File;
+}) {
+ const router = useRouter();
+ const [isLoading, setIsLoading] = useState(false);
+
+ const [hotMenu, setHotMenu] = useAtom(gs_job_hot_menu);
+ const [status, setStatus] = useAtom(gs_job_status);
+ const [opened, { open, close }] = useDisclosure(false);
+ const [scroll, scrollTo] = useWindowScroll();
+
+ async function onUpdate() {
+ if (file === null) {
+ const update = await job_EditById({
+ data: value,
+ });
+ if (update.status !== 200)
+ return ComponentGlobal_NotifikasiGagal(update.message);
+ } else {
+ const uploadFile = await funGlobal_UploadToStorage({
+ file: file,
+ dirId: DIRECTORY_ID.job_image,
+ });
+
+ if (!uploadFile.success)
+ return ComponentGlobal_NotifikasiPeringatan("Gagal upload gambar");
+
+ const updateWithFile = await job_EditById({
+ data: value,
+ });
+ if (updateWithFile.status !== 200)
+ return ComponentGlobal_NotifikasiGagal(updateWithFile.message);
+ }
+
+ setHotMenu(2);
+ setStatus("Draft");
+ setIsLoading(true);
+ router.back();
+ return ComponentGlobal_NotifikasiBerhasil("Berhasil Update");
+ }
+
+ return (
+ <>
+
+
+
+ Anda yakin menyimpan data ini ?
+
+
+
+
+
+
+
+
+
+ >
+ );
+}
diff --git a/src/app_modules/job/component/detail/comp_box_upload_image.tsx b/src/app_modules/job/component/detail/comp_box_upload_image.tsx
new file mode 100644
index 00000000..f9de93fb
--- /dev/null
+++ b/src/app_modules/job/component/detail/comp_box_upload_image.tsx
@@ -0,0 +1,24 @@
+import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
+import { Box } from "@mantine/core";
+
+export function Job_ComponentBoxUploadImage({
+ children,
+}: {
+ children: React.ReactNode;
+}) {
+ return (
+ <>
+
+
+ {children}
+
+
+ >
+ );
+}
diff --git a/src/app_modules/job/component/detail/detail_data.tsx b/src/app_modules/job/component/detail/detail_data.tsx
index d5216eb2..9727bcd8 100644
--- a/src/app_modules/job/component/detail/detail_data.tsx
+++ b/src/app_modules/job/component/detail/detail_data.tsx
@@ -1,21 +1,35 @@
"use client";
-import { Card, Stack, Skeleton, Image, Text, Center } from "@mantine/core";
-import { MODEL_JOB } from "../../model/interface";
-import { RouterJob } from "@/app/lib/router_hipmi/router_job";
+import { APIs } from "@/app/lib";
import {
AccentColor,
MainColor,
} from "@/app_modules/_global/color/color_pallet";
+import {
+ Card,
+ Center,
+ Image,
+ Loader,
+ Paper,
+ Skeleton,
+ Stack,
+ Text,
+} from "@mantine/core";
+import { MODEL_JOB } from "../../model/interface";
+import { useState } from "react";
+import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
export default function ComponentJob_DetailData({
data,
}: {
data?: MODEL_JOB;
}) {
+ const [isLoading, setIsLoading] = useState(true);
+
return (
<>
{/* {JSON.stringify(data, null, 2)} */}
+
{data ? (
- {data.imagesId ? (
+ {data.imageId ? (
+ {isLoading ? (
+
+
+
+
+
+ ) : (
+ ""
+ )}
+
{
+ setIsLoading(false);
+ }}
+ onError={() => {
+ setIsLoading(false);
+ }}
+ alt="Image"
+ src={APIs.GET + data?.imageId}
+ maw={200}
/>
) : (
diff --git a/src/app_modules/job/component/index.ts b/src/app_modules/job/component/index.ts
new file mode 100644
index 00000000..616e108c
--- /dev/null
+++ b/src/app_modules/job/component/index.ts
@@ -0,0 +1,7 @@
+import Job_ComponentButtonSaveCreate from "./button/comp_button_save_create";
+import { Job_ComponentButtonUpdate } from "./button/comp_button_update";
+import { Job_ComponentBoxUploadImage } from "./detail/comp_box_upload_image";
+
+export { Job_ComponentButtonSaveCreate };
+export { Job_ComponentBoxUploadImage };
+export { Job_ComponentButtonUpdate };
diff --git a/src/app_modules/job/create/TextEdit.tsx b/src/app_modules/job/create/TextEdit.tsx
deleted file mode 100644
index c75551cd..00000000
--- a/src/app_modules/job/create/TextEdit.tsx
+++ /dev/null
@@ -1,61 +0,0 @@
-"use client";
-
-import { Center, Stack } from "@mantine/core";
-import { useShallowEffect } from "@mantine/hooks";
-import dynamic from "next/dynamic";
-import React, { useState } from "react";
-const ReactQuill = dynamic(
- () => {
- return import("react-quill");
- },
- { ssr: false }
-);
-import "react-quill/dist/quill.snow.css";
-
-export default function Demo() {
- const [value, setValue] = useState("");
- const [udah, setUdah] = useState(false);
-
- // useShallowEffect(() => {
- // if (window && window.document) setUdah(true);
- // }, []);
-
- // if (!udah) return <>>;
- return (
-
- Judul Lowongan Kerja
-
- Syarat & Ketentuan :
-
- - Minimal pendidika SMA / Sederajat
- - Pasif berbahasa inggris
- - Dll,.
-
-
- Deskripsi :
- Jika berminat dapat menghubungi WA berikut
- +6281 xxx xxx xx
- Kirim CV anda melalui email berikut
- @test-hipmi.com
- Atau kunjungi website kami:
- https://test-hipmi.wibudev.com/
- `}
- modules={{
- toolbar: [
- [{ header: [1, 2, 3, 4, 5, 6, false] }],
- ["bold", "italic", "underline", "link"],
- // [{ align: [] }],
- [{ list: "ordered" }, { list: "bullet" }],
-
- ["clean"],
- ],
- }}
- theme="snow"
- onChange={setValue}
- />
- {/* {value}
- */}
-
- );
-}
diff --git a/src/app_modules/job/create/view.tsx b/src/app_modules/job/create/view.tsx
index 57a33249..23c6bcce 100644
--- a/src/app_modules/job/create/view.tsx
+++ b/src/app_modules/job/create/view.tsx
@@ -1,24 +1,19 @@
"use client";
import {
+ AspectRatio,
+ Box,
Button,
Center,
FileButton,
- Group,
Image,
- Loader,
- Paper,
Stack,
Text,
TextInput,
} from "@mantine/core";
import { IconCamera, IconUpload } from "@tabler/icons-react";
-import { useAtom } from "jotai";
-import { useRouter } from "next/navigation";
-import { useState } from "react";
-import { gs_job_hot_menu, gs_job_status } from "../global_state";
-
import dynamic from "next/dynamic";
+import { useState } from "react";
import "react-quill/dist/quill.snow.css";
const ReactQuill = dynamic(
() => {
@@ -27,22 +22,21 @@ const ReactQuill = dynamic(
{ ssr: false }
);
-import { RouterJob } from "@/app/lib/router_hipmi/router_job";
import {
AccentColor,
MainColor,
} from "@/app_modules/_global/color/color_pallet";
-import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
-import ComponentGlobal_InputCountDown from "@/app_modules/_global/component/input_countdown";
-import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
-import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
-import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
-import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
-import mqtt_client from "@/util/mqtt_client";
-import { useShallowEffect } from "@mantine/hooks";
+
+import {
+ ComponentGlobal_BoxInformation,
+ ComponentGlobal_CardStyles,
+ ComponentGlobal_InputCountDown,
+} from "@/app_modules/_global/component";
+import {
+ Job_ComponentBoxUploadImage,
+ Job_ComponentButtonSaveCreate,
+} from "../component";
import { defaultDeskripsi, defaultSyarat } from "../component/default_value";
-import { Job_funCreate } from "../fun/create/fun_create";
-import { MODEL_JOB } from "../model/interface";
export default function Job_Create() {
const [value, setValue] = useState({
@@ -52,272 +46,172 @@ export default function Job_Create() {
});
const [reload, setReload] = useState(false);
const [file, setFile] = useState(null);
- const [images, setImages] = useState();
+ const [img, setImg] = useState();
- useShallowEffect(() => {
- if (window && window.document) setReload(true);
- }, []);
+ // useShallowEffect(() => {
+ // if (window && window.document) setReload(true);
+ // }, []);
return (
- <>
- {!reload ? (
-
-
-
- ) : (
-
-
- {images ? (
-
- ) : (
-
-
-
-
- Upload Gambar
-
-
-
+
+
+
+
+
+ {img ? (
+
+
+
+ ) : (
+
+
+
+ Upload Gambar
+
+
+ )}
+
+
+
+ {
+ try {
+ const buffer = URL.createObjectURL(
+ new Blob([new Uint8Array(await files.arrayBuffer())])
+ );
+ setImg(buffer);
+ setFile(files);
+ } catch (error) {
+ console.log(error);
+ }
+ }}
+ accept="image/png,image/jpeg"
+ >
+ {(props) => (
+
)}
-
- {
- try {
- const buffer = URL.createObjectURL(
- new Blob([new Uint8Array(await files.arrayBuffer())])
- );
- if (files.size > 200000) {
- ComponentGlobal_NotifikasiPeringatan(
- "Maaf, Ukuran file terlalu besar, maksimal 2mb",
- 3000
- );
- } else {
- setImages(buffer);
- setFile(files);
- }
- } catch (error) {
- console.log(error);
- }
- }}
- accept="image/png,image/jpeg"
- >
- {(props) => (
-
- )}
-
-
-
-
-
-
- {
- setValue({
- ...value,
- title: val.currentTarget.value,
- });
- }}
- />
-
-
-
- Syarat & Ketentuan
-
- {" "}
- *
-
-
-
-
- {
- setValue({
- ...value,
- content: val,
- });
- }}
- />
-
-
-
-
-
- Deskripsi
-
- {" "}
- *
-
-
-
- {
- setValue({
- ...value,
- deskripsi: val,
- });
- }}
- />
-
-
-
-
-
-
-
- )}
- >
- );
-}
-
-function ButtonAction({ value, file }: { value: MODEL_JOB; file: FormData }) {
- const router = useRouter();
- const [isLoading, setIsLoading] = useState(false);
-
- const [hotMenu, setHotMenu] = useAtom(gs_job_hot_menu);
- const [status, setStatus] = useAtom(gs_job_status);
-
- async function onCreate() {
- const gambar = new FormData();
- gambar.append("file", file as any);
-
- const create = await Job_funCreate(value as any, gambar);
- if (create.status === 201) {
- const dataNotif: any = {
- appId: create.data?.id as any,
- kategoriApp: "JOB",
- status: create.data?.MasterStatus?.name as any,
- userId: create.data?.authorId as any,
- pesan: create.data?.title as any,
- title: "Job baru",
- };
-
- const notif = await notifikasiToAdmin_funCreate({
- data: dataNotif as any,
- });
- // console.log(notif); .
-
- if (notif.status === 201) {
- mqtt_client.publish(
- "ADMIN",
- JSON.stringify({
- count: 1,
- })
- );
- setHotMenu(2);
- setStatus("Review");
- router.replace(RouterJob.status);
- setIsLoading(true);
- ComponentGlobal_NotifikasiBerhasil(create.message);
- }
- } else {
- ComponentGlobal_NotifikasiGagal(create.message);
- }
- }
-
- return (
- <>
-
-
-
-
+
+
- >
+
+
+
+ {
+ setValue({
+ ...value,
+ title: val.currentTarget.value,
+ });
+ }}
+ />
+
+
+
+ Syarat & Ketentuan
+
+ {" "}
+ *
+
+
+
+
+ {
+ setValue({
+ ...value,
+ content: val,
+ });
+ }}
+ />
+
+
+
+
+
+
+ Deskripsi
+
+ {" "}
+ *
+
+
+
+
+ {
+ setValue({
+ ...value,
+ deskripsi: val,
+ });
+ }}
+ />
+
+
+
+
+
+
+
+
);
}
diff --git a/src/app_modules/job/edit/view.tsx b/src/app_modules/job/edit/view.tsx
index 180d70db..4810d7fa 100644
--- a/src/app_modules/job/edit/view.tsx
+++ b/src/app_modules/job/edit/view.tsx
@@ -3,6 +3,7 @@
import { RouterJob } from "@/app/lib/router_hipmi/router_job";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
import {
+ AspectRatio,
Button,
Center,
FileButton,
@@ -14,7 +15,7 @@ import {
Stack,
Text,
TextInput,
- Title
+ Title,
} from "@mantine/core";
import {
useDisclosure,
@@ -36,55 +37,53 @@ import ComponentGlobal_InputCountDown from "@/app_modules/_global/component/inpu
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
import dynamic from "next/dynamic";
-import { Job_EditById } from "../fun/edit/fun_edit_by_id";
+import { job_EditById } from "../fun/edit/fun_edit_by_id";
const ReactQuill = dynamic(
() => {
return import("react-quill");
},
{ ssr: false }
);
+import "react-quill/dist/quill.snow.css";
+import { Job_ComponentBoxUploadImage, Job_ComponentButtonUpdate } from "../component";
+import { APIs } from "@/app/lib";
+import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
export default function Job_Edit({ dataJob }: { dataJob: MODEL_JOB }) {
const [value, setValue] = useState(dataJob);
-
const [reload, setReload] = useState(false);
const [file, setFile] = useState(null);
- const [images, setImages] = useState();
- const [maxFile, setMaxFile] = useState(false);
+ const [img, setImg] = useState();
- useShallowEffect(() => {
- if (window && window.document) setReload(true);
- }, []);
+ // useShallowEffect(() => {
+ // if (window && window.document) setReload(true);
+ // }, []);
return (
<>
- {!reload ? (
-
-
-
- ) : (
-
-
- {images ? (
-
- ) : value.imagesId ? (
-
+
+
+
+ {value.imageId ? (
+
+
+
) : (
-
-
-
-
- Upload Gambar
-
-
-
+
+
+
+ Upload Gambar
+
+
)}
+
+
{
try {
@@ -92,19 +91,8 @@ export default function Job_Edit({ dataJob }: { dataJob: MODEL_JOB }) {
new Blob([new Uint8Array(await files.arrayBuffer())])
);
- if (files.size > 200000) {
- // setMaxFile(true);
- ComponentGlobal_NotifikasiPeringatan(
- "Maaf, Ukuran file terlalu besar, maksimal 2mb",
- 3000
- );
- } else {
- // console.log(buffer, "ini buffer");
- // console.log(files, " ini file");
-
- setImages(buffer);
- setFile(files);
- }
+ setImg(buffer);
+ setFile(files);
} catch (error) {
console.log(error);
}
@@ -121,21 +109,15 @@ export default function Job_Edit({ dataJob }: { dataJob: MODEL_JOB }) {
border: `1px solid ${AccentColor.yellow}`,
}}
>
-
+
)}
-
+
+
-
+
+
+
-
-
- )}
+
+
>
);
}
-function ButtonAction({ value, file }: { value: MODEL_JOB; file: FormData }) {
- const router = useRouter();
- const [isLoading, setIsLoading] = useState(false);
- const [hotMenu, setHotMenu] = useAtom(gs_job_hot_menu);
- const [status, setStatus] = useAtom(gs_job_status);
- const [opened, { open, close }] = useDisclosure(false);
- const [scroll, scrollTo] = useWindowScroll();
-
- async function onUpdate() {
- const gambar = new FormData();
- gambar.append("file", file as any);
-
- await Job_EditById(value, gambar).then((res) => {
- if (res.status === 200) {
- setHotMenu(2);
- setStatus("Draft");
- ComponentGlobal_NotifikasiBerhasil(res.message);
- setIsLoading(true);
- router.back();
- } else {
- ComponentGlobal_NotifikasiGagal(res.message);
- }
- });
- }
-
- return (
- <>
-
-
-
- Anda yakin menyimpan data ini ?
-
-
-
-
-
-
-
-
- >
- );
-}
diff --git a/src/app_modules/job/fun/create/fun_create.ts b/src/app_modules/job/fun/create/fun_create.ts
deleted file mode 100644
index 7f0a8fd2..00000000
--- a/src/app_modules/job/fun/create/fun_create.ts
+++ /dev/null
@@ -1,95 +0,0 @@
-"use server";
-
-import prisma from "@/app/lib/prisma";
-import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
-import _ from "lodash";
-import { v4 } from "uuid";
-import fs from "fs";
-import { revalidatePath } from "next/cache";
-import { MODEL_JOB } from "../../model/interface";
-import path from "path";
-const root = process.cwd();
-
-export async function Job_funCreate(req: MODEL_JOB, file: FormData) {
- const authorId = await user_funGetOneUserId();
-
- const dataImage: any = file.get("file");
- if (dataImage !== "null") {
- const fileName = dataImage.name;
- const fileExtension = _.lowerCase(dataImage.name.split(".").pop());
- const fRandomName = v4(fileName) + "." + fileExtension;
-
- const upload = await prisma.images.create({
- data: {
- url: fRandomName,
- label: "JOB",
- },
- select: {
- id: true,
- url: true,
- },
- });
-
- if (!upload) return { status: 400, message: "Gagal upload gambar" };
- const uploadFolder = Buffer.from(await dataImage.arrayBuffer());
- fs.writeFileSync(
- path.join(root, `public/job/${upload.url}`),
- uploadFolder
- );
- const createDataWithImg = await prisma.job.create({
- data: {
- title: req.title,
- content: req.content,
- deskripsi: req.deskripsi,
- authorId: authorId,
- imagesId: upload.id,
- },
- select: {
- id: true,
- authorId: true,
- MasterStatus: {
- select: {
- name: true,
- },
- },
- title: true,
- },
- });
-
- if (!createDataWithImg) return { status: 400, message: "Gagal Disimpan" };
- revalidatePath("/dev/job/main/status");
- return {
- data: createDataWithImg,
- status: 201,
- message: "Berhasil Disimpan",
- };
- } else {
- const createDataWithoutImg = await prisma.job.create({
- data: {
- title: req.title,
- content: req.content,
- deskripsi: req.deskripsi,
- authorId: authorId,
- },
- select: {
- id: true,
- authorId: true,
- MasterStatus: {
- select: {
- name: true,
- },
- },
- title: true,
- },
- });
-
- if (!createDataWithoutImg)
- return { status: 400, message: "Gagal Disimpan" };
- revalidatePath("/dev/job/main/status");
- return {
- data: createDataWithoutImg,
- status: 201,
- message: "Berhasil Disimpan",
- };
- }
-}
diff --git a/src/app_modules/job/fun/create/fun_create_no_file.ts b/src/app_modules/job/fun/create/fun_create_no_file.ts
new file mode 100644
index 00000000..0d8e5137
--- /dev/null
+++ b/src/app_modules/job/fun/create/fun_create_no_file.ts
@@ -0,0 +1,37 @@
+"use server";
+
+import { prisma } from "@/app/lib";
+import { user_funGetOneUserId } from "@/app_modules/fun_global";
+import { revalidatePath } from "next/cache";
+import { MODEL_JOB } from "../../model/interface";
+
+export async function job_funCreateNoFile({ data }: { data: MODEL_JOB }) {
+ const authorId = await user_funGetOneUserId();
+
+ const createNoImage = await prisma.job.create({
+ data: {
+ title: data.title,
+ content: data.content,
+ deskripsi: data.deskripsi,
+ authorId: authorId,
+ },
+ select: {
+ id: true,
+ authorId: true,
+ MasterStatus: {
+ select: {
+ name: true,
+ },
+ },
+ title: true,
+ },
+ });
+
+ if (!createNoImage) return { status: 400, message: "Gagal Disimpan" };
+ revalidatePath("/dev/job/main/status");
+ return {
+ status: 201,
+ message: "Berhasil Disimpan",
+ data: createNoImage,
+ };
+}
diff --git a/src/app_modules/job/fun/create/fun_create_with_file.ts b/src/app_modules/job/fun/create/fun_create_with_file.ts
new file mode 100644
index 00000000..2007946f
--- /dev/null
+++ b/src/app_modules/job/fun/create/fun_create_with_file.ts
@@ -0,0 +1,131 @@
+"use server";
+
+import prisma from "@/app/lib/prisma";
+import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
+import _ from "lodash";
+import { v4 } from "uuid";
+import fs from "fs";
+import { revalidatePath } from "next/cache";
+import { MODEL_JOB } from "../../model/interface";
+import path from "path";
+import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
+import { DIRECTORY_ID } from "@/app/lib";
+
+export async function job_funCreateWithFile({
+ data,
+ fileId,
+}: {
+ data: MODEL_JOB;
+ fileId: string;
+}) {
+ const authorId = await user_funGetOneUserId();
+ console.log(authorId);
+
+ const createDataWithoutImg = await prisma.job.create({
+ data: {
+ title: data.title,
+ content: data.content,
+ deskripsi: data.deskripsi,
+ authorId: authorId,
+ imageId: fileId,
+ },
+ select: {
+ id: true,
+ authorId: true,
+ MasterStatus: {
+ select: {
+ name: true,
+ },
+ },
+ title: true,
+ },
+ });
+
+ if (!createDataWithoutImg) return { status: 400, message: "Gagal Disimpan" };
+ revalidatePath("/dev/job/main/status");
+ return {
+ data: createDataWithoutImg,
+ status: 201,
+ message: "Berhasil Disimpan",
+ };
+
+ // const dataImage: any = file.get("file");
+ // if (dataImage !== "null") {
+ // const fileName = dataImage.name;
+ // const fileExtension = _.lowerCase(dataImage.name.split(".").pop());
+ // const fRandomName = v4(fileName) + "." + fileExtension;
+
+ // const upload = await prisma.images.create({
+ // data: {
+ // url: fRandomName,
+ // label: "JOB",
+ // },
+ // select: {
+ // id: true,
+ // url: true,
+ // },
+ // });
+
+ // if (!upload) return { status: 400, message: "Gagal upload gambar" };
+ // const uploadFolder = Buffer.from(await dataImage.arrayBuffer());
+ // fs.writeFileSync(
+ // path.join(root, `public/job/${upload.url}`),
+ // uploadFolder
+ // );
+ // const createDataWithImg = await prisma.job.create({
+ // data: {
+ // title: req.title,
+ // content: req.content,
+ // deskripsi: req.deskripsi,
+ // authorId: authorId,
+ // imagesId: upload.id,
+ // },
+ // select: {
+ // id: true,
+ // authorId: true,
+ // MasterStatus: {
+ // select: {
+ // name: true,
+ // },
+ // },
+ // title: true,
+ // },
+ // });
+
+ // if (!createDataWithImg) return { status: 400, message: "Gagal Disimpan" };
+ // revalidatePath("/dev/job/main/status");
+ // return {
+ // data: createDataWithImg,
+ // status: 201,
+ // message: "Berhasil Disimpan",
+ // };
+ // } else {
+ // const createDataWithoutImg = await prisma.job.create({
+ // data: {
+ // title: req.title,
+ // content: req.content,
+ // deskripsi: req.deskripsi,
+ // authorId: authorId,
+ // },
+ // select: {
+ // id: true,
+ // authorId: true,
+ // MasterStatus: {
+ // select: {
+ // name: true,
+ // },
+ // },
+ // title: true,
+ // },
+ // });
+
+ // if (!createDataWithoutImg)
+ // return { status: 400, message: "Gagal Disimpan" };
+ // revalidatePath("/dev/job/main/status");
+ // return {
+ // data: createDataWithoutImg,
+ // status: 201,
+ // message: "Berhasil Disimpan",
+ // };
+ // }
+}
diff --git a/src/app_modules/job/fun/edit/fun_edit_by_id.ts b/src/app_modules/job/fun/edit/fun_edit_by_id.ts
index 9d341fd5..ec59bcdb 100644
--- a/src/app_modules/job/fun/edit/fun_edit_by_id.ts
+++ b/src/app_modules/job/fun/edit/fun_edit_by_id.ts
@@ -6,68 +6,51 @@ import { v4 } from "uuid";
import fs from "fs";
import { MODEL_JOB } from "../../model/interface";
import { revalidatePath } from "next/cache";
+import { RouterJob } from "@/app/lib/router_hipmi/router_job";
-export async function Job_EditById(req: MODEL_JOB, file: FormData) {
- // console.log(file);
- // console.log(req);
- // return { status: 200 };
-
- const dataImage: any = file.get("file");
- if (dataImage !== "null") {
- const fileName = dataImage.name;
- const fileExtension = _.lowerCase(dataImage.name.split(".").pop());
- const fRandomName = v4(fileName) + "." + fileExtension;
-
- const upload = await prisma.images.create({
- data: {
- url: fRandomName,
- label: "JOB",
- },
- select: {
- id: true,
- url: true,
- },
- });
-
- if (!upload) return { status: 400, message: "Gagal upload gambar" };
- const uploadFolder = Buffer.from(await dataImage.arrayBuffer());
- fs.writeFileSync(`./public/job/${upload.url}`, uploadFolder);
-
+export async function job_EditById({
+ data,
+ imageId,
+}: {
+ data: MODEL_JOB;
+ imageId?: string;
+}) {
+ if (imageId == undefined) {
const updt = await prisma.job.update({
where: {
- id: req.id,
+ id: data.id,
},
data: {
- title: req.title,
- content: req.content,
- deskripsi: req.deskripsi,
- imagesId: upload.id,
+ title: data.title,
+ content: data.content,
+ deskripsi: data.deskripsi,
},
});
-
if (!updt) return { status: 400, message: "Gagal Update" };
- revalidatePath("/dev/job/detail/draft");
+ revalidatePath(RouterJob.status);
+
return {
status: 200,
- message: "Berhasil Disimpan",
+ message: "Berhasil Update",
};
} else {
- const updt = await prisma.job.update({
+ const updtWithFile = await prisma.job.update({
where: {
- id: req.id,
+ id: data.id,
},
data: {
- title: req.title,
- content: req.content,
- deskripsi: req.deskripsi,
+ title: data.title,
+ content: data.content,
+ deskripsi: data.deskripsi,
+ imageId: imageId,
},
});
+ if (!updtWithFile) return { status: 400, message: "Gagal Update" };
+ revalidatePath(RouterJob.status);
- if (!updt) return { status: 400, message: "Gagal Update" };
- revalidatePath("/dev/job/detail/draft");
return {
status: 200,
- message: "Berhasil Disimpan",
+ message: "Berhasil Update",
};
}
}
diff --git a/src/app_modules/job/fun/get/get_two_for_home_view.ts b/src/app_modules/job/fun/get/get_two_for_home_view.ts
index e1a0fd6a..fe9db5d6 100644
--- a/src/app_modules/job/fun/get/get_two_for_home_view.ts
+++ b/src/app_modules/job/fun/get/get_two_for_home_view.ts
@@ -10,6 +10,7 @@ export async function job_getTwoForHomeView() {
},
where: {
isActive: true,
+ masterStatusId: "1"
},
select: {
id: true,
diff --git a/src/app_modules/job/fun/index.ts b/src/app_modules/job/fun/index.ts
new file mode 100644
index 00000000..3e4cf25f
--- /dev/null
+++ b/src/app_modules/job/fun/index.ts
@@ -0,0 +1,5 @@
+import { job_funCreateNoFile } from "./create/fun_create_no_file";
+import { job_funCreateWithFile } from "./create/fun_create_with_file";
+
+export { job_funCreateWithFile };
+export { job_funCreateNoFile };
diff --git a/src/app_modules/job/model/interface.ts b/src/app_modules/job/model/interface.ts
index 46548408..9ded22d2 100644
--- a/src/app_modules/job/model/interface.ts
+++ b/src/app_modules/job/model/interface.ts
@@ -1,11 +1,13 @@
import { MODEL_USER } from "@/app_modules/home/model/interface";
-import { MODEL_IMAGES, MODEL_NEW_DEFAULT_MASTER } from "@/app_modules/model_global/interface";
+import {
+ MODEL_NEW_DEFAULT_MASTER
+} from "@/app_modules/model_global/interface";
export interface MODEL_JOB {
id: string;
- title: string
+ title: string;
content: string;
- deskripsi: string
+ deskripsi: string;
isActive: boolean;
isArsip: boolean;
createdAt: Date;
@@ -13,8 +15,7 @@ export interface MODEL_JOB {
catatan: string;
authorId: string;
Author: MODEL_USER;
- Images: MODEL_IMAGES
- imagesId: string
- MasterStatus: MODEL_NEW_DEFAULT_MASTER
- masterStatusId: string
+ MasterStatus: MODEL_NEW_DEFAULT_MASTER;
+ masterStatusId: string;
+ imageId: string;
}
diff --git a/src/app_modules/job/non_user_view/view.tsx b/src/app_modules/job/non_user_view/view.tsx
index e98a6a23..82d59658 100644
--- a/src/app_modules/job/non_user_view/view.tsx
+++ b/src/app_modules/job/non_user_view/view.tsx
@@ -1,16 +1,28 @@
"use client";
-import { Card, Center, Image, Overlay, Stack, Text, Title } from "@mantine/core";
+import {
+ Card,
+ Center,
+ Image,
+ Overlay,
+ Stack,
+ Text,
+ Title,
+} from "@mantine/core";
import ComponentJob_DetailData from "../component/detail/detail_data";
import { RouterJob } from "@/app/lib/router_hipmi/router_job";
import { data } from "autoprefixer";
import { MODEL_JOB } from "../model/interface";
-import { AccentColor, MainColor } from "@/app_modules/_global/color/color_pallet";
+import {
+ AccentColor,
+ MainColor,
+} from "@/app_modules/_global/color/color_pallet";
+import { APIs } from "@/app/lib";
export default function Job_NonUserView({ data }: { data: MODEL_JOB }) {
return (
<>
-
+
- {data.imagesId ? (
+ {data.imageId ? (
) : (
diff --git a/src/app_modules/notifikasi/fun/create/create_notif_to_admin.tsx b/src/app_modules/notifikasi/fun/create/create_notif_to_admin.ts
similarity index 100%
rename from src/app_modules/notifikasi/fun/create/create_notif_to_admin.tsx
rename to src/app_modules/notifikasi/fun/create/create_notif_to_admin.ts
diff --git a/src/app_modules/notifikasi/fun/create/create_notif_to_user.tsx b/src/app_modules/notifikasi/fun/create/create_notif_to_user.ts
similarity index 100%
rename from src/app_modules/notifikasi/fun/create/create_notif_to_user.tsx
rename to src/app_modules/notifikasi/fun/create/create_notif_to_user.ts
diff --git a/src/app_modules/notifikasi/fun/index.ts b/src/app_modules/notifikasi/fun/index.ts
new file mode 100644
index 00000000..a8995e3c
--- /dev/null
+++ b/src/app_modules/notifikasi/fun/index.ts
@@ -0,0 +1,9 @@
+import notifikasiToAdmin_funCreate from "./create/create_notif_to_admin";
+import notifikasiToUser_funCreate from "./create/create_notif_to_user";
+import { notifikasiToUser_CreateGroupCollaboration } from "./create/create_notif_to_user_collaboration";
+import { notifikasiToUser_CreateKabarDonasi } from "./create/create_notif_to_user_kabar_donasi";
+
+export { notifikasiToAdmin_funCreate };
+export { notifikasiToUser_CreateGroupCollaboration };
+export { notifikasiToUser_CreateKabarDonasi };
+export { notifikasiToUser_funCreate };
diff --git a/src/app_modules/notifikasi/ui/ui_notifiaksi.tsx b/src/app_modules/notifikasi/ui/ui_notifiaksi.tsx
index 1083ecb7..8a6c84ba 100644
--- a/src/app_modules/notifikasi/ui/ui_notifiaksi.tsx
+++ b/src/app_modules/notifikasi/ui/ui_notifiaksi.tsx
@@ -21,17 +21,15 @@ import {
gs_vote_status,
} from "@/app_modules/vote/global_state";
import { Box, Button, Center, Flex, Stack } from "@mantine/core";
+import { useShallowEffect } from "@mantine/hooks";
import { useAtom } from "jotai";
-import _, { find } from "lodash";
+import _ from "lodash";
import { ScrollOnly } from "next-scroll-loader";
import { useState } from "react";
-import { ComponentNotifikasi_CardSkeleton } from "../component";
import { ComponentNotifiaksi_CardView } from "../component/card_view";
import notifikasi_getByUserId from "../fun/get/get_notifiaksi_by_id";
-import { MODEL_NOTIFIKASI } from "../model/interface";
-import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
import { gs_notifikasi_kategori_app } from "../lib";
-import { useShallowEffect } from "@mantine/hooks";
+import { MODEL_NOTIFIKASI } from "../model/interface";
export function Notifikasi_UiView({
listNotifikasi,
diff --git a/src/app_modules/zCoba/ui_coba_upload_file.tsx b/src/app_modules/zCoba/ui_coba_upload_file.tsx
new file mode 100644
index 00000000..7877bef7
--- /dev/null
+++ b/src/app_modules/zCoba/ui_coba_upload_file.tsx
@@ -0,0 +1,219 @@
+import { TokenStorage } from "@/app/lib/token";
+import {
+ Box,
+ Button,
+ Card,
+ Center,
+ FileButton,
+ Image,
+ Paper,
+ Stack,
+ Text,
+} from "@mantine/core";
+import { useShallowEffect } from "@mantine/hooks";
+import { IconCamera, IconUpload } from "@tabler/icons-react";
+import { useState } from "react";
+import { AccentColor, MainColor } from "../_global/color";
+import {
+ ComponentGlobal_NotifikasiBerhasil,
+ ComponentGlobal_NotifikasiPeringatan,
+} from "../_global/notif_global";
+import { DIRECTORY_ID } from "@/app/lib";
+import { funGlobal_UploadToStorage } from "../_global/fun";
+
+export default function Coba_UploadFile() {
+ const [data, setData] = useState();
+ const [file, setFile] = useState(null);
+ const [images, setImages] = useState();
+
+ async function loadListDir(setData: any) {
+ const rootDirEndPoint = await fetch(
+ "https://wibu-storage.wibudev.com/api/dir/root/list",
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${TokenStorage.value}`,
+ },
+ }
+ );
+ const dataDir = await rootDirEndPoint.json();
+ // console.log(dataDir);
+
+ const dirHipmiEndPoint = await fetch(
+ `https://wibu-storage.wibudev.com/api/dir/${dataDir.dirs[0].id}/list`,
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${TokenStorage.value}`,
+ },
+ }
+ );
+
+ const hipmiDir = await dirHipmiEndPoint.json();
+ // console.log(hipmiDir.dirs[0]);
+ setData(hipmiDir.dirs[0]);
+ }
+
+ // async function CcekToken() {
+ // const rootDirEndPoint = await fetch(
+ // "https://wibu-storage.wibudev.com/api/dir/root/list",
+ // {
+ // method: "GET",
+ // headers: {
+ // "Content-Type": "application/json",
+ // Authorization: `Bearer ${process.env.WS_APIKEY}`,
+ // },
+ // }
+ // );
+ // const dataDir = await rootDirEndPoint.json();
+ // console.log(dataDir);
+ // }
+
+ useShallowEffect(() => {
+ loadListDir(setData);
+ // CekToken()
+ }, [setData]);
+
+ const [imagesId, setImagesId] = useState("");
+ return (
+
+
+
+ {images ? (
+
+ ) : (
+
+
+
+
+ Upload Gambar
+
+
+
+ )}
+
+ {
+ try {
+ const buffer = URL.createObjectURL(
+ new Blob([new Uint8Array(await files.arrayBuffer())])
+ );
+ setImages(buffer);
+ setFile(files);
+ } catch (error) {
+ console.log(error);
+ }
+ }}
+ accept="image/png,image/jpeg"
+ >
+ {(props) => (
+
+ )}
+
+
+
+
+
+
+
+ {/*
+ {JSON.stringify(data, null, 2)}
+ */}
+
+ {/*
+
+ */}
+
+ );
+}
+
+async function coba_ButtonFileUpload({
+ file,
+ dirId,
+ onDone,
+}: {
+ file: File;
+ dirId: string;
+ onDone: () => void;
+}) {
+ if (!file) return ComponentGlobal_NotifikasiPeringatan("Tidak ada file");
+
+ const allowedMimeTypes = [
+ "image/png",
+ "image/jpeg",
+ "image/gif",
+ "text/csv",
+ "application/pdf",
+ "application/msword",
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
+ "application/vnd.ms-excel",
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ "text/plain",
+ ];
+
+ if (!allowedMimeTypes.includes(file.type))
+ return ComponentGlobal_NotifikasiPeringatan("File tidak sesuai");
+
+ if (file.size > 100 * 1024 * 1024)
+ return ComponentGlobal_NotifikasiPeringatan("File terlalu besar");
+
+ const formData = new FormData();
+ formData.append("file", file);
+ formData.append("dirId", dirId);
+
+ try {
+ const res = await fetch("https://wibu-storage.wibudev.com/api/upload", {
+ method: "POST",
+ body: formData,
+ headers: {
+ Authorization: `Bearer ${TokenStorage.value}`,
+ },
+ });
+
+ const dataRes = await res.json();
+
+ if (res.ok) {
+ console.log("File Sukses Di Upload");
+ console.log(dataRes);
+ } else {
+ const errorText = await res.text();
+ console.log("jika error", errorText);
+ }
+ } catch (error) {
+ console.error("Upload error:", error);
+ } finally {
+ onDone();
+ }
+}
|