Update Versi 1.5.27 #32

Merged
bagasbanuna merged 1009 commits from staging into main 2025-12-17 12:22:28 +08:00
199 changed files with 6182 additions and 1145 deletions
Showing only changes of commit fde17fd42d - Show all commits

View File

@@ -1,16 +1,94 @@
import { job_getAllListPublish } from "@/app_modules/job/fun/get/get_all_publish";
import _ from "lodash";
import { prisma } from "@/app/lib";
import { NextResponse } from "next/server";
export const dynamic = "force-dynamic";
export async function GET(params: Request) {
const { searchParams } = new URL(params.url);
const page = searchParams.get("page");
const search = searchParams.get("search");
export async function GET(request: Request) {
try {
const { searchParams } = new URL(request.url);
const search = searchParams.get("search");
const page = searchParams.get("page");
const dataTake = 10;
const dataSkip = Number(page) * dataTake - dataTake;
const data = await job_getAllListPublish({
page: _.toNumber(page),
search: search as string,
});
if (search != "") {
const data = await prisma.job.findMany({
take: dataTake,
skip: dataSkip,
orderBy: {
updatedAt: "desc",
},
where: {
masterStatusId: "1",
isActive: true,
isArsip: false,
title: {
mode: "insensitive",
contains: search as string,
},
},
select: {
id: true,
title: true,
Author: {
select: {
id: true,
username: true,
Profile: true,
},
},
},
});
return NextResponse.json({ data });
return NextResponse.json(
{
success: true,
message: "Berhasil ambil data",
data: data,
},
{ status: 200 }
);
} else {
const data = await prisma.job.findMany({
take: dataTake,
skip: dataSkip,
orderBy: {
updatedAt: "desc",
},
where: {
masterStatusId: "1",
isActive: true,
isArsip: false,
title: {
mode: "insensitive",
},
},
select: {
id: true,
title: true,
Author: {
select: {
id: true,
username: true,
Profile: true,
},
},
},
});
return NextResponse.json(
{
success: true,
message: "Berhasil ambil data",
data: data,
},
{ status: 200 }
);
}
} catch (error) {
console.error(error);
return NextResponse.json({
success: false,
message: "Gagal ambil data",
});
}
}

View File

@@ -5,11 +5,11 @@ import { useShallowEffect } from "@mantine/hooks";
import { useRouter } from "next/navigation";
export default function Page() {
const router = useRouter()
const router = useRouter();
useShallowEffect(() => {
setTimeout(() => {
// window.location.replace("/dev/home");
router.replace("/dev/home");
router.replace("/dev/home", { scroll: false });
}, 1000);
}, []);

View File

@@ -24,6 +24,7 @@ export function ComponentGlobal_ButtonUploadFileImage({
if (files.size > MAX_SIZE) {
ComponentGlobal_NotifikasiPeringatan(PemberitahuanMaksimalFile);
return;
} else {
onSetFile(files);
onSetImage(buffer);

View File

@@ -54,6 +54,8 @@ export async function funGlobal_UploadToStorage({
if (res.ok) {
const dataRes = await res.json();
// const cekLog = await res.text();
// console.log(cekLog);
return { success: true, data: dataRes.data };
} else {
const errorText = await res.text();

View File

@@ -10,18 +10,16 @@ import {
Image,
rem,
ScrollArea,
Skeleton,
Text,
Title,
Skeleton
} from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import { IconX } from "@tabler/icons-react";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { MainColor } from "../color";
import ComponentGlobal_Loader from "../component/loader";
import UIGlobal_LayoutHeaderTamplate from "./ui_header_tamplate";
import { UIHeader } from "./ui_layout_tamplate";
import ComponentGlobal_Loader from "../component/loader";
export function UIGlobal_ImagePreview({ fileId }: { fileId: string }) {
const router = useRouter();

View File

@@ -1,7 +1,17 @@
import { AccentColor, MainColor } from "@/app_modules/_global/color";
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
import { ActionIcon, Box, Group, Image, Paper, SimpleGrid, Skeleton, Stack, Text } from "@mantine/core";
import {
ActionIcon,
Box,
Group,
Image,
Paper,
SimpleGrid,
Skeleton,
Stack,
Text,
} from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import { IconUserSearch } from "@tabler/icons-react";
import _ from "lodash";
@@ -9,185 +19,182 @@ import { useRouter } from "next/navigation";
import { useState } from "react";
import { apiGetDataHome } from "../fun/get/api_home";
import { listMenuHomeBody, menuHomeJob } from "./list_menu_home";
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
export default function BodyHome() {
const router = useRouter()
const [dataUser, setDataUser] = useState<any>({})
const [dataJob, setDataJob] = useState<any[]>([])
const [loadingJob, setLoadingJob] = useState(true)
const router = useRouter();
const [dataUser, setDataUser] = useState<any>({});
const [dataJob, setDataJob] = useState<any[]>([]);
const [loadingJob, setLoadingJob] = useState(true);
useShallowEffect(() => {
cekUserLogin()
getHomeJob()
}, []);
useShallowEffect(() => {
cekUserLogin();
getHomeJob();
}, []);
async function cekUserLogin() {
try {
const response = await apiGetDataHome("?cat=cek_profile")
if (response.success) {
setDataUser(response.data);
}
} catch (error) {
console.error(error);
async function cekUserLogin() {
try {
const response = await apiGetDataHome("?cat=cek_profile");
if (response.success) {
setDataUser(response.data);
}
}
} catch (error) {
console.error(error);
}
}
async function getHomeJob() {
try {
setLoadingJob(true)
const response = await apiGetDataHome("?cat=job")
if (response.success) {
setDataJob(response.data);
}
} catch (error) {
console.error(error);
} finally {
setLoadingJob(false)
async function getHomeJob() {
try {
setLoadingJob(true);
const response = await apiGetDataHome("?cat=job");
if (response.success) {
setDataJob(response.data);
}
}
} catch (error) {
console.error(error);
} finally {
setLoadingJob(false);
}
}
return (
<Box>
<Paper
radius={"xl"}
mb={"xs"}
style={{
borderRadius: "10px 10px 10px 10px",
border: `2px solid ${AccentColor.blue}`,
}}
>
<Image radius={"lg"} alt="logo" src={"/aset/home/home-hipmi-new.png"} />
</Paper>
return (
<Box>
<Paper
radius={"xl"}
mb={"xs"}
style={{
borderRadius: "10px 10px 10px 10px",
border: `2px solid ${AccentColor.blue}`,
}}
>
<Image radius={"lg"} alt="logo" src={"/aset/home/home-hipmi-new.png"} />
</Paper>
<Stack my={"sm"}>
<SimpleGrid
cols={2}
spacing="md"
>
{listMenuHomeBody.map((e, i) => (
<Paper
key={e.id}
h={150}
bg={MainColor.darkblue}
style={{
borderRadius: "10px 10px 10px 10px",
border: `2px solid ${AccentColor.blue}`,
}}
onClick={() => {
if (dataUser.profile === undefined || dataUser?.profile === null) {
return ComponentGlobal_NotifikasiPeringatan(
"Lengkapi Profile"
);
} else {
if (e.link === "") {
return ComponentGlobal_NotifikasiPeringatan(
"Cooming Soon !!"
);
} else {
router.push(e.link, { scroll: false });
}
}
}}
>
<Stack align="center" justify="center" h={"100%"}>
<ActionIcon
size={50}
variant="transparent"
c={e.link === "" ? "gray.3" : "white"}
>
{e.icon}
</ActionIcon>
<Text c={e.link === "" ? "gray.3" : "white"} fz={"xs"}>
{e.name}
</Text>
</Stack>
</Paper>
))}
</SimpleGrid>
{/* Job View */}
<Stack my={"sm"}>
<SimpleGrid cols={2} spacing="md">
{listMenuHomeBody.map((e, i) => (
<Paper
p={"md"}
w={"100%"}
bg={MainColor.darkblue}
style={{
borderRadius: "10px 10px 10px 10px",
border: `2px solid ${AccentColor.blue}`,
}}
>
<Stack
onClick={() => {
if (dataUser.profile === undefined || dataUser?.profile === null) {
return ComponentGlobal_NotifikasiPeringatan(
"Lengkapi Profile"
);
} else {
if (menuHomeJob.link === "") {
return ComponentGlobal_NotifikasiPeringatan(
"Cooming Soon !!"
);
} else {
return router.push(menuHomeJob.link, { scroll: false });
}
}
}}
>
<Group>
<ActionIcon
variant="transparent"
size={40}
c={menuHomeJob.link === "" ? "gray.3" : "white"}
>
{menuHomeJob.icon}
</ActionIcon>
<Text c={menuHomeJob.link === "" ? "gray.3" : "white"}>
{menuHomeJob.name}
</Text>
</Group>
{
loadingJob ?
Array(2)
.fill(null)
.map((_, i) => (
<Box key={i} mb={"md"}>
<Skeleton height={10} mt={0} radius="xl" width={"50%"} />
<Skeleton height={10} mt={10} radius="xl" />
<Skeleton height={10} mt={10} radius="xl" />
</Box>
))
: _.isEmpty(dataJob) ?
(<ComponentGlobal_IsEmptyData text="Tidak ada data" height={10} />)
: (
<SimpleGrid cols={2} spacing="md">
{dataJob.map((e, i) => (
<Stack key={e.id}>
<Group spacing={"xs"}>
<Stack h={"100%"} align="center" justify="flex-start">
<IconUserSearch size={20} color="white" />
</Stack>
<Stack spacing={0} w={"60%"}>
<Text
lineClamp={1}
fz={"sm"}
c={MainColor.yellow}
fw={"bold"}
>
{e?.Author.username}
</Text>
<Text fz={"sm"} c={"white"} lineClamp={2}>
{e?.title}
</Text>
</Stack>
</Group>
</Stack>
))}
</SimpleGrid>
)
key={e.id}
h={150}
bg={MainColor.darkblue}
style={{
borderRadius: "10px 10px 10px 10px",
border: `2px solid ${AccentColor.blue}`,
}}
onClick={() => {
if (
dataUser.profile === undefined ||
dataUser?.profile === null
) {
router.push(RouterProfile.create, { scroll: false });
} else {
if (e.link === "") {
return ComponentGlobal_NotifikasiPeringatan(
"Cooming Soon !!"
);
} else {
router.push(e.link, { scroll: false });
}
</Stack>
}
}}
>
<Stack align="center" justify="center" h={"100%"}>
<ActionIcon
size={50}
variant="transparent"
c={e.link === "" ? "gray.3" : "white"}
>
{e.icon}
</ActionIcon>
<Text c={e.link === "" ? "gray.3" : "white"} fz={"xs"}>
{e.name}
</Text>
</Stack>
</Paper>
</Stack>
</Box>
);
}
))}
</SimpleGrid>
{/* Job View */}
<Paper
p={"md"}
w={"100%"}
bg={MainColor.darkblue}
style={{
borderRadius: "10px 10px 10px 10px",
border: `2px solid ${AccentColor.blue}`,
}}
>
<Stack
onClick={() => {
if (
dataUser.profile === undefined ||
dataUser?.profile === null
) {
router.push(RouterProfile.create, { scroll: false });
} else {
if (menuHomeJob.link === "") {
return ComponentGlobal_NotifikasiPeringatan(
"Cooming Soon !!"
);
} else {
return router.push(menuHomeJob.link, { scroll: false });
}
}
}}
>
<Group>
<ActionIcon
variant="transparent"
size={40}
c={menuHomeJob.link === "" ? "gray.3" : "white"}
>
{menuHomeJob.icon}
</ActionIcon>
<Text c={menuHomeJob.link === "" ? "gray.3" : "white"}>
{menuHomeJob.name}
</Text>
</Group>
{loadingJob ? (
Array(2)
.fill(null)
.map((_, i) => (
<Box key={i} mb={"md"}>
<Skeleton height={10} mt={0} radius="xl" width={"50%"} />
<Skeleton height={10} mt={10} radius="xl" />
<Skeleton height={10} mt={10} radius="xl" />
</Box>
))
) : _.isEmpty(dataJob) ? (
<ComponentGlobal_IsEmptyData text="Tidak ada data" height={10} />
) : (
<SimpleGrid cols={2} spacing="md">
{dataJob.map((e, i) => (
<Stack key={e.id}>
<Group spacing={"xs"}>
<Stack h={"100%"} align="center" justify="flex-start">
<IconUserSearch size={20} color="white" />
</Stack>
<Stack spacing={0} w={"60%"}>
<Text
lineClamp={1}
fz={"sm"}
c={MainColor.yellow}
fw={"bold"}
>
{e?.Author.username}
</Text>
<Text fz={"sm"} c={"white"} lineClamp={2}>
{e?.title}
</Text>
</Stack>
</Group>
</Stack>
))}
</SimpleGrid>
)}
</Stack>
</Paper>
</Stack>
</Box>
);
}

View File

@@ -1,7 +1,14 @@
import { APIs } from "@/app/lib";
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
import { ActionIcon, Box, Center, SimpleGrid, Stack, Text } from "@mantine/core";
import {
ActionIcon,
Box,
Center,
SimpleGrid,
Stack,
Text,
} from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import { IconUserCircle } from "@tabler/icons-react";
import { useRouter } from "next/navigation";
@@ -11,103 +18,104 @@ import { Home_ComponentAvatarProfile } from "./comp_avatar_profile";
import { listMenuHomeFooter } from "./list_menu_home";
export default function FooterHome() {
const router = useRouter()
const [dataUser, setDataUser] = useState<any>({})
const router = useRouter();
const [dataUser, setDataUser] = useState<any>({});
useShallowEffect(() => {
cekUserLogin();
}, []);
useShallowEffect(() => {
cekUserLogin();
}, []);
async function cekUserLogin() {
try {
const response = await apiGetDataHome("?cat=cek_profile")
if (response.success) {
setDataUser(response.data);
}
} catch (error) {
console.error(error);
async function cekUserLogin() {
try {
const response = await apiGetDataHome("?cat=cek_profile");
if (response.success) {
setDataUser(response.data);
}
}
} catch (error) {
console.error(error);
}
}
return (
<Box
style={{
zIndex: 99,
borderRadius: "20px 20px 0px 0px",
}}
w={"100%"}
bottom={0}
h={"9vh"}
>
<SimpleGrid cols={listMenuHomeFooter.length + 1}>
{listMenuHomeFooter.map((e) => (
<Center h={"9vh"} key={e.id}>
<Stack align="center" spacing={0}
onClick={() => {
if (dataUser.profile === undefined || dataUser?.profile === null) {
ComponentGlobal_NotifikasiPeringatan("Lengkapi Profile");
} else {
if (e.link == "") {
ComponentGlobal_NotifikasiPeringatan("Cooming Soon")
} else {
router.push(e.link, { scroll: false })
}
}
}}
>
<ActionIcon
radius={"xl"}
c={e.link === "" ? "gray" : "white"}
variant="transparent"
>
{e.icon}
</ActionIcon>
<Text
lineClamp={1}
c={e.link === "" ? "gray" : "white"}
fz={12}
>
{e.name}
</Text>
</Stack>
</Center>
))}
return (
<Box
style={{
zIndex: 99,
borderRadius: "20px 20px 0px 0px",
}}
w={"100%"}
bottom={0}
h={"9vh"}
>
<SimpleGrid cols={listMenuHomeFooter.length + 1}>
{listMenuHomeFooter.map((e) => (
<Center h={"9vh"} key={e.id}>
<Stack
align="center"
spacing={0}
onClick={() => {
if (
dataUser.profile === undefined ||
dataUser?.profile === null
) {
router.push(RouterProfile.create, { scroll: false });
} else {
if (e.link == "") {
ComponentGlobal_NotifikasiPeringatan("Cooming Soon");
} else {
router.push(e.link, { scroll: false });
}
}
}}
>
<ActionIcon
radius={"xl"}
c={e.link === "" ? "gray" : "white"}
variant="transparent"
>
{e.icon}
</ActionIcon>
<Text lineClamp={1} c={e.link === "" ? "gray" : "white"} fz={12}>
{e.name}
</Text>
</Stack>
</Center>
))}
<Center h={"9vh"}>
<Stack
align="center"
spacing={2}
onClick={() => {
if (dataUser.profile === undefined || dataUser?.profile === null) {
router.push(RouterProfile.create, { scroll: false });
} else {
router.push(
RouterProfile.katalogOLD + `${dataUser?.profile}`,
{ scroll: false }
);
}
}}
>
<ActionIcon variant={"transparent"}>
{dataUser.profile === undefined || dataUser?.profile === null
?
<IconUserCircle color="white" />
:
<Home_ComponentAvatarProfile
url={APIs.GET({
fileId: dataUser?.imageId as string,
size: "50"
})}
/>
}
</ActionIcon>
<Text fz={10} c={"white"}>
Profile
</Text>
</Stack>
</Center>
</SimpleGrid>
</Box>
);
}
<Center h={"9vh"}>
<Stack
align="center"
spacing={2}
onClick={() => {
if (
dataUser.profile === undefined ||
dataUser?.profile === null
) {
router.push(RouterProfile.create, { scroll: false });
} else {
router.push(RouterProfile.katalogOLD + `${dataUser?.profile}`, {
scroll: false,
});
}
}}
>
<ActionIcon variant={"transparent"}>
{dataUser.profile === undefined || dataUser?.profile === null ? (
<IconUserCircle color="white" />
) : (
<Home_ComponentAvatarProfile
url={APIs.GET({
fileId: dataUser?.imageId as string,
size: "50",
})}
/>
)}
</ActionIcon>
<Text fz={10} c={"white"}>
Profile
</Text>
</Stack>
</Center>
</SimpleGrid>
</Box>
);
}

View File

@@ -16,112 +16,120 @@ import notifikasi_countUserNotifikasi from "../notifikasi/fun/count/fun_count_by
import BodyHome from "./component/body_home";
import FooterHome from "./component/footer_home";
import { apiGetDataHome } from "./fun/get/api_home";
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
export default function HomeViewNew({ countNotifikasi }: { countNotifikasi: number; }) {
const [countNtf, setCountNtf] = useState(countNotifikasi);
const [newUserNtf, setNewUserNtf] = useAtom(gs_user_ntf);
const [countLoadNtf, setCountLoadNtf] = useAtom(gs_count_ntf);
const [dataUser, setDataUser] = useState<any>({})
const router = useRouter();
export default function HomeViewNew({
countNotifikasi,
}: {
countNotifikasi: number;
}) {
const [countNtf, setCountNtf] = useState(countNotifikasi);
const [newUserNtf, setNewUserNtf] = useAtom(gs_user_ntf);
const [countLoadNtf, setCountLoadNtf] = useAtom(gs_count_ntf);
const [dataUser, setDataUser] = useState<any>({});
const router = useRouter();
useShallowEffect(() => {
onLoadNotifikasi({
onLoad(val) {
setCountNtf(val);
},
});
useShallowEffect(() => {
onLoadNotifikasi({
onLoad(val) {
setCountNtf(val);
},
});
setCountNtf(countLoadNtf as any);
}, [countLoadNtf, setCountNtf]);
setCountNtf(countLoadNtf as any);
}, [countLoadNtf, setCountNtf]);
useShallowEffect(() => {
setCountNtf(countNtf + newUserNtf);
setNewUserNtf(0);
}, [newUserNtf, setCountNtf]);
useShallowEffect(() => {
setCountNtf(countNtf + newUserNtf);
setNewUserNtf(0);
}, [newUserNtf, setCountNtf]);
async function onLoadNotifikasi({ onLoad }: { onLoad: (val: any) => void }) {
const loadNotif = await notifikasi_countUserNotifikasi();
onLoad(loadNotif);
}
async function onLoadNotifikasi({ onLoad }: { onLoad: (val: any) => void }) {
const loadNotif = await notifikasi_countUserNotifikasi();
onLoad(loadNotif);
}
useShallowEffect(() => {
cekUserLogin();
}, []);
useShallowEffect(() => {
cekUserLogin();
}, []);
async function cekUserLogin() {
try {
const response = await apiGetDataHome("?cat=cek_profile")
if (response.success) {
setDataUser(response.data);
}
} catch (error) {
console.error(error);
async function cekUserLogin() {
try {
const response = await apiGetDataHome("?cat=cek_profile");
if (response.success) {
setDataUser(response.data);
}
}
} catch (error) {
console.error(error);
}
}
return (
<>
<UIGlobal_LayoutTamplate
header={
<UIGlobal_LayoutHeaderTamplate
title="HIPMI"
customButtonLeft={
<ActionIcon
radius={"xl"}
variant={"transparent"}
onClick={() => {
if (dataUser.profile === undefined || dataUser?.profile === null) {
ComponentGlobal_NotifikasiPeringatan("Lengkapi Profile");
} else {
router.push(RouterUserSearch.main, { scroll: false });
}
}}
>
<IconUserSearch color="white" />
</ActionIcon>
return (
<>
<UIGlobal_LayoutTamplate
header={
<UIGlobal_LayoutHeaderTamplate
title="HIPMI"
customButtonLeft={
<ActionIcon
radius={"xl"}
variant={"transparent"}
onClick={() => {
if (
dataUser.profile === undefined ||
dataUser?.profile === null
) {
router.push(RouterProfile.create, { scroll: false });
} else {
router.push(RouterUserSearch.main, { scroll: false });
}
customButtonRight={
<ActionIcon
variant="transparent"
onClick={() => {
if (dataUser.profile === undefined || dataUser?.profile === null) {
ComponentGlobal_NotifikasiPeringatan("Lengkapi Profile");
} else {
router.push(RouterNotifikasi.categoryApp({ name: "semua" }), {
scroll: false,
});
}
}}
>
{
countNotifikasi > 0
?
<Indicator
processing
color={MainColor.yellow}
label={
<Text fz={10} c={MainColor.darkblue}>
{countNotifikasi > 99 ? "99+" : countNotifikasi}
</Text>
}
>
<IconBell color="white" />
</Indicator>
:
<IconBell color="white" />
}
</ActionIcon>
}
/>
}}
>
<IconUserSearch color="white" />
</ActionIcon>
}
footer={<FooterHome />}
>
<BodyHome />
</UIGlobal_LayoutTamplate>
</>
);
customButtonRight={
<ActionIcon
variant="transparent"
onClick={() => {
if (
dataUser.profile === undefined ||
dataUser?.profile === null
) {
router.push(RouterProfile.create, { scroll: false });
} else {
router.push(
RouterNotifikasi.categoryApp({ name: "semua" }),
{
scroll: false,
}
);
}
}}
>
{countNotifikasi > 0 ? (
<Indicator
processing
color={MainColor.yellow}
label={
<Text fz={10} c={MainColor.darkblue}>
{countNotifikasi > 99 ? "99+" : countNotifikasi}
</Text>
}
>
<IconBell color="white" />
</Indicator>
) : (
<IconBell color="white" />
)}
</ActionIcon>
}
/>
}
footer={<FooterHome />}
>
<BodyHome />
</UIGlobal_LayoutTamplate>
</>
);
}

View File

@@ -1,124 +0,0 @@
"use client";
import { gs_jobTiggerBeranda } from "@/app/lib/global_state";
import { RouterJob } from "@/app/lib/router_hipmi/router_job";
import ComponentGlobal_CreateButton from "@/app_modules/_global/component/button_create";
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
import { Box, Center, Loader, Stack, TextInput } from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import { IconSearch } from "@tabler/icons-react";
import { useAtom } from "jotai";
import _ from "lodash";
import { ScrollOnly } from "next-scroll-loader";
import { useState } from "react";
import {
Job_ComponentButtonUpdateBeranda,
Job_ComponentSkeletonBeranda,
} from "../../component";
import ComponentJob_BerandaCardView from "../../component/beranda/card_view";
import { job_getAllListPublish } from "../../fun/get/get_all_publish";
import { MODEL_JOB } from "../../model/interface";
import { API_RouteJob } from "@/app/lib/api_user_router/route_api_job";
export function Job_UiBeranda() {
const [data, setData] = useState<MODEL_JOB[] | null>(null);
const [activePage, setActivePage] = useState(1);
const [isSearch, setIsSearch] = useState("");
// Notifikasi
const [isShowUpdate, setIsShowUpdate] = useState(false);
const [isTriggerJob, setIsTriggerJob] = useAtom(gs_jobTiggerBeranda);
useShallowEffect(() => {
if (isTriggerJob == true) {
setIsShowUpdate(true);
}
}, [isTriggerJob]);
useShallowEffect(() => {
setIsTriggerJob(false);
setIsShowUpdate(false);
onLoadNewData();
}, []);
async function onSearch(text: string) {
setIsSearch(text);
const loadData = await job_getAllListPublish({
page: activePage,
search: text,
});
setData(loadData as any);
setActivePage(1);
}
async function onLoadNewData() {
const loadData = await fetch(API_RouteJob.get_all({ page: activePage }));
const res = await loadData.json();
setData(res.data);
}
return (
<>
<Stack my={1} spacing={30}>
{isShowUpdate && (
<Job_ComponentButtonUpdateBeranda
onSetIsNewPost={(val) => {
setIsShowUpdate(val);
setIsTriggerJob(val);
}}
onSetData={(val: any[]) => {
setData(val);
}}
/>
)}
<ComponentGlobal_CreateButton path={RouterJob.create} />
<TextInput
style={{
position: "sticky",
top: 0,
zIndex: 99,
}}
radius={"xl"}
icon={<IconSearch />}
placeholder="Pekerjaan apa yang anda cari ?"
onChange={(val) => {
onSearch(val.currentTarget.value);
}}
/>
{_.isNull(data) ? (
<Job_ComponentSkeletonBeranda />
) : _.isEmpty(data) ? (
<ComponentGlobal_IsEmptyData />
) : (
// --- Main component --- //
<ScrollOnly
height="75vh"
renderLoading={() => (
<Center mt={"lg"}>
<Loader color={"yellow"} />
</Center>
)}
data={data}
setData={setData as any}
moreData={async () => {
const loadData = await job_getAllListPublish({
page: activePage + 1,
search: isSearch,
});
setActivePage((val) => val + 1);
return loadData;
}}
>
{(item) => <ComponentJob_BerandaCardView data={item} />}
</ScrollOnly>
)}
</Stack>
</>
);
}

View File

@@ -1,10 +1,124 @@
"use client";
import { API_RouteJob } from "@/app/lib/api_user_router/route_api_job";
import { gs_jobTiggerBeranda } from "@/app/lib/global_state";
import { RouterJob } from "@/app/lib/router_hipmi/router_job";
import ComponentGlobal_CreateButton from "@/app_modules/_global/component/button_create";
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
import { Center, Loader, Stack, TextInput } from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import { IconSearch } from "@tabler/icons-react";
import { useAtom } from "jotai";
import _ from "lodash";
import { ScrollOnly } from "next-scroll-loader";
import { useState } from "react";
import {
Job_ComponentButtonUpdateBeranda,
Job_ComponentSkeletonBeranda,
} from "../../component";
import ComponentJob_BerandaCardView from "../../component/beranda/card_view";
import { MODEL_JOB } from "../../model/interface";
import { Job_UiBeranda } from "./ui_beranda";
export default function Job_ViewBeranda() {
const [data, setData] = useState<MODEL_JOB[] | null>(null);
const [activePage, setActivePage] = useState(1);
const [isSearch, setIsSearch] = useState("");
// Notifikasi
const [isShowUpdate, setIsShowUpdate] = useState(false);
const [isTriggerJob, setIsTriggerJob] = useAtom(gs_jobTiggerBeranda);
useShallowEffect(() => {
if (isTriggerJob == true) {
setIsShowUpdate(true);
}
}, [isTriggerJob]);
useShallowEffect(() => {
setIsTriggerJob(false);
setIsShowUpdate(false);
onLoadNewData();
}, []);
async function onSearch(text: string) {
setIsSearch(text);
const loadData = await fetch(
API_RouteJob.get_all({ page: activePage, search: text })
);
const res = await loadData.json();
setData(res.data as any);
setActivePage(1);
}
async function onLoadNewData() {
const loadData = await fetch(API_RouteJob.get_all({ page: activePage }));
const res = await loadData.json();
// console.log(res.data);
setData(res.data);
}
return (
<>
<Job_UiBeranda />
<Stack my={1} spacing={30}>
{isShowUpdate && (
<Job_ComponentButtonUpdateBeranda
onSetIsNewPost={(val) => {
setIsShowUpdate(val);
setIsTriggerJob(val);
}}
onSetData={(val: any[]) => {
setData(val);
}}
/>
)}
<ComponentGlobal_CreateButton path={RouterJob.create} />
<TextInput
style={{
position: "sticky",
top: 0,
zIndex: 99,
}}
radius={"xl"}
icon={<IconSearch />}
placeholder="Pekerjaan apa yang anda cari ?"
onChange={(val) => {
onSearch(val.currentTarget.value);
}}
/>
{_.isNull(data) ? (
<Job_ComponentSkeletonBeranda />
) : _.isEmpty(data) ? (
<ComponentGlobal_IsEmptyData />
) : (
// --- Main component --- //
<ScrollOnly
height="75vh"
renderLoading={() => (
<Center mt={"lg"}>
<Loader color={"yellow"} />
</Center>
)}
data={data}
setData={setData as any}
moreData={async () => {
const loadData = await fetch(
API_RouteJob.get_all({ page: activePage, search: isSearch })
);
const res = await loadData.json();
setActivePage((val) => val + 1);
return res.data;
}}
>
{(item) => <ComponentJob_BerandaCardView data={item} />}
</ScrollOnly>
)}
</Stack>
</>
);
}

View File

@@ -12,25 +12,22 @@ import _ from "lodash";
import { useRouter } from "next/navigation";
import { useState } from "react";
import funCreatePortofolio from "../../fun/fun_create_portofolio";
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
import { DIRECTORY_ID } from "@/app/lib";
export function Portofolio_ComponentButtonSelanjutnya({
profileId,
dataPortofolio,
file,
dataMedsos,
imageId,
}: {
profileId: string;
dataPortofolio: MODEL_PORTOFOLIO_OLD;
file: File;
dataMedsos: any;
imageId: string
}) {
const router = useRouter();
const [loading, setLoading] = useState(false);
async function onSubmit() {
setLoading(true);
const porto = {
namaBisnis: dataPortofolio.namaBisnis,
masterBidangBisnisId: dataPortofolio.masterBidangBisnisId,
@@ -39,34 +36,33 @@ export function Portofolio_ComponentButtonSelanjutnya({
deskripsi: dataPortofolio.deskripsi,
};
if (_.values(porto).includes(""))
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
const uploadFileToStorage = await funGlobal_UploadToStorage({
file: file,
dirId: DIRECTORY_ID.portofolio_logo,
});
if (!uploadFileToStorage.success)
return ComponentGlobal_NotifikasiPeringatan("Gagal upload gambar");
const res = await funCreatePortofolio({
profileId: profileId,
data: dataPortofolio as any,
medsos: dataMedsos,
fileId: uploadFileToStorage.data.id,
});
if (res.status === 201) {
ComponentGlobal_NotifikasiBerhasil("Berhasil disimpan");
router.replace(RouterMap.create + res.id, { scroll: false });
} else {
ComponentGlobal_NotifikasiGagal("Gagal disimpan");
try {
setLoading(true);
if (_.values(porto).includes("")) {
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
}
const res = await funCreatePortofolio({
profileId: profileId,
data: dataPortofolio as any,
medsos: dataMedsos,
fileId: imageId,
});
if (res.status === 201) {
ComponentGlobal_NotifikasiBerhasil("Berhasil disimpan");
router.replace(RouterMap.create + res.id, { scroll: false });
} else {
ComponentGlobal_NotifikasiGagal("Gagal disimpan");
}
} catch (error) {
console.error(error);
} finally {
setLoading(false);
}
}
return (
<>
<Button
disabled={_.values(dataPortofolio).includes("") || file === null}
disabled={_.values(dataPortofolio).includes("") || imageId == ""}
mt={"md"}
radius={50}
loading={loading ? true : false}

View File

@@ -25,6 +25,11 @@ import { Portofolio_ComponentButtonSelanjutnya } from "../component";
import { MAX_SIZE } from "@/app_modules/_global/lib";
import { PemberitahuanMaksimalFile } from "@/app_modules/_global/lib/max_size";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
import {
funGlobal_DeleteFileById,
funGlobal_UploadToStorage,
} from "@/app_modules/_global/fun";
import { DIRECTORY_ID } from "@/app/lib";
export default function CreatePortofolio({
bidangBisnis,
@@ -49,8 +54,8 @@ export default function CreatePortofolio({
tiktok: "",
});
const [file, setFile] = useState<File | any>(null);
const [img, setImg] = useState<any | null>(null);
const [imageId, setImageId] = useState("");
return (
<>
@@ -187,15 +192,61 @@ export default function CreatePortofolio({
const buffer = URL.createObjectURL(
new Blob([new Uint8Array(await files.arrayBuffer())])
);
if (files.size > MAX_SIZE) {
setImg(null);
setFile(null);
ComponentGlobal_NotifikasiPeringatan(
PemberitahuanMaksimalFile
);
return;
}
// if (files.size > MAX_SIZE) {
// setImg(null);
// setFile(null);
// ComponentGlobal_NotifikasiPeringatan(
// PemberitahuanMaksimalFile
// );
// } else {
// setImg(buffer);
// setFile(files);
// }
if (imageId != "") {
const deletePhoto = await funGlobal_DeleteFileById({
fileId: imageId,
});
if (deletePhoto.success) {
setImageId("");
const uploadPhoto = await funGlobal_UploadToStorage({
file: files,
dirId: DIRECTORY_ID.portofolio_logo,
});
if (uploadPhoto.success) {
setImageId(uploadPhoto.data.id);
setImg(buffer);
} else {
ComponentGlobal_NotifikasiPeringatan(
"Gagal upload foto"
);
}
}
} else {
setImg(buffer);
setFile(files);
const uploadPhoto = await funGlobal_UploadToStorage({
file: files,
dirId: DIRECTORY_ID.portofolio_logo,
});
if (uploadPhoto.success) {
setImageId(uploadPhoto.data.id);
setImg(buffer);
} else {
ComponentGlobal_NotifikasiPeringatan("Gagal upload foto");
}
}
} catch (error) {
console.log(error);
@@ -306,12 +357,10 @@ export default function CreatePortofolio({
<Portofolio_ComponentButtonSelanjutnya
dataPortofolio={dataPortofolio as any}
dataMedsos={dataMedsos}
file={file}
profileId={profileId}
imageId={imageId}
/>
</Stack>
{/* <pre> {JSON.stringify(bidangBisnis, null, 2)}</pre> */}
</>
);
}

View File

@@ -1,9 +1,7 @@
"use client";
import { DIRECTORY_ID } from "@/app/lib";
import { RouterHome } from "@/app/lib/router_hipmi/router_home";
import { AccentColor, MainColor } from "@/app_modules/_global/color";
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
import {
ComponentGlobal_NotifikasiBerhasil,
ComponentGlobal_NotifikasiGagal,
@@ -19,14 +17,10 @@ import { MODEL_PROFILE } from "../../model/interface";
export function Profile_ComponentCreateNewProfile({
value,
// filePP,
// fileBG,
fotoProfileId,
backgroundProfileId,
}: {
value: MODEL_PROFILE;
// filePP: File;
// fileBG: File;
fotoProfileId: string;
backgroundProfileId: string;
}) {
@@ -55,24 +49,6 @@ export function Profile_ComponentCreateNewProfile({
try {
setLoading(true);
// const uploadPhoto = await funGlobal_UploadToStorage({
// file: filePP,
// dirId: DIRECTORY_ID.profile_foto,
// });
// if (!uploadPhoto.success) {
// ComponentGlobal_NotifikasiPeringatan("Gagal upload foto profile");
// return;
// }
// const uploadBackground = await funGlobal_UploadToStorage({
// file: fileBG,
// dirId: DIRECTORY_ID.profile_background,
// });
// if (!uploadBackground.success) {
// ComponentGlobal_NotifikasiPeringatan("Gagal upload background profile");
// return;
// }
const create = await funCreateNewProfile({
data: newData as any,
imageId: fotoProfileId,
@@ -91,7 +67,6 @@ export function Profile_ComponentCreateNewProfile({
if (create.status === 500) {
ComponentGlobal_NotifikasiGagal(create.message);
}
} catch (error) {
console.log("Terjadi kesalahan", error);
} finally {

View File

@@ -7,7 +7,10 @@ import {
ComponentGlobal_BoxUploadImage,
ComponentGlobal_ErrorInput,
} from "@/app_modules/_global/component";
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
import {
funGlobal_DeleteFileById,
funGlobal_UploadToStorage,
} from "@/app_modules/_global/fun";
import { MAX_SIZE } from "@/app_modules/_global/lib";
import { PemberitahuanMaksimalFile } from "@/app_modules/_global/lib/max_size";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
@@ -95,6 +98,35 @@ export default function CreateProfile() {
ComponentGlobal_NotifikasiPeringatan(
PemberitahuanMaksimalFile
);
setImgPP(null);
setFilePP(null);
return;
}
if (fotoProfileId != "") {
const deleteFotoProfile = await funGlobal_DeleteFileById({
fileId: fotoProfileId,
});
if (deleteFotoProfile.success) {
setFotoProfileId("");
const uploadPhoto = await funGlobal_UploadToStorage({
file: files,
dirId: DIRECTORY_ID.profile_foto,
});
if (uploadPhoto.success) {
setFotoProfileId(uploadPhoto.data.id);
setImgPP(buffer);
setFilePP(files);
} else {
ComponentGlobal_NotifikasiPeringatan(
"Gagal upload foto profile"
);
}
}
} else {
const uploadPhoto = await funGlobal_UploadToStorage({
file: files,
@@ -169,6 +201,35 @@ export default function CreateProfile() {
ComponentGlobal_NotifikasiPeringatan(
PemberitahuanMaksimalFile
);
setImgBG(null);
setFileBG(null);
return;
}
if (backgroundProfileId != "") {
const deleteFotoBg = await funGlobal_DeleteFileById({
fileId: backgroundProfileId,
});
if (deleteFotoBg.success) {
setBackgroundProfileId("");
const uploadBackground =
await funGlobal_UploadToStorage({
file: files,
dirId: DIRECTORY_ID.profile_background,
});
if (uploadBackground.success) {
setBackgroundProfileId(uploadBackground.data.id);
setImgBG(buffer);
setFileBG(files);
} else {
ComponentGlobal_NotifikasiPeringatan(
"Gagal upload background profile"
);
}
}
} else {
const uploadBackground = await funGlobal_UploadToStorage({
file: files,
@@ -284,8 +345,6 @@ export default function CreateProfile() {
<Profile_ComponentCreateNewProfile
value={value as any}
// filePP={filePP as any}
// fileBG={fileBG as any}
fotoProfileId={fotoProfileId}
backgroundProfileId={backgroundProfileId}
/>

View File

@@ -4,57 +4,51 @@ import { MainColor } from "@/app_modules/_global/color";
import {
ComponentGlobal_NotifikasiBerhasil,
ComponentGlobal_NotifikasiGagal,
ComponentGlobal_NotifikasiPeringatan,
} from "@/app_modules/_global/notif_global";
import { Button } from "@mantine/core";
import { useRouter } from "next/navigation";
import { map_funCreatePin } from "../../fun/create/fun_create_pin";
import { DIRECTORY_ID } from "@/app/lib";
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
import { useState } from "react";
import { map_funCreatePin } from "../../fun/create/fun_create_pin";
export function ComponentMap_ButtonSavePin({
namePin,
lat,
long,
portofolioId,
file,
imageId,
}: {
namePin: string;
lat: string;
long: string;
portofolioId: string;
file: File;
imageId: string;
}) {
const router = useRouter();
const [loading, setLoading] = useState(false)
const [loading, setLoading] = useState(false);
async function onSavePin() {
setLoading(true)
const uploadFileToStorage = await funGlobal_UploadToStorage({
file: file,
dirId: DIRECTORY_ID.map_image,
});
try {
setLoading(true);
if (!uploadFileToStorage.success)
return ComponentGlobal_NotifikasiPeringatan("Gagal upload gambar");
const res = await map_funCreatePin({
data: {
latitude: lat as any,
longitude: long as any,
namePin: namePin as any,
imageId: uploadFileToStorage.data.id,
Portofolio: {
create: { id: portofolioId } as any,
const res = await map_funCreatePin({
data: {
latitude: lat as any,
longitude: long as any,
namePin: namePin as any,
imageId: imageId,
Portofolio: {
create: { id: portofolioId } as any,
},
},
},
});
res.status === 200
? (ComponentGlobal_NotifikasiBerhasil(res.message), router.back())
: ComponentGlobal_NotifikasiGagal(res.message);
setLoading(false)
});
res.status === 200
? (ComponentGlobal_NotifikasiBerhasil(res.message), router.back())
: ComponentGlobal_NotifikasiGagal(res.message);
} catch (error) {
console.error(error);
} finally {
setLoading(false);
}
}
return (
@@ -63,7 +57,7 @@ export function ComponentMap_ButtonSavePin({
loading={loading}
my={"xl"}
style={{ transition: "0.5s" }}
disabled={namePin === "" || file === null ? true : false}
disabled={namePin === "" || imageId == "" ? true : false}
radius={"xl"}
loaderPosition="center"
bg={MainColor.yellow}

View File

@@ -5,6 +5,8 @@ import {
MainColor,
} from "@/app_modules/_global/color/color_pallet";
import { ComponentGlobal_BoxUploadImage } from "@/app_modules/_global/component";
import { MAX_SIZE } from "@/app_modules/_global/lib";
import { PemberitahuanMaksimalFile } from "@/app_modules/_global/lib/max_size";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
import {
AspectRatio,
@@ -29,8 +31,11 @@ import Map, {
} from "react-map-gl";
import { ComponentMap_ButtonSavePin } from "../_component";
import { defaultLatLong, defaultMapZoom } from "../lib/default_lat_long";
import { MAX_SIZE } from "@/app_modules/_global/lib";
import { PemberitahuanMaksimalFile } from "@/app_modules/_global/lib/max_size";
import {
funGlobal_DeleteFileById,
funGlobal_UploadToStorage,
} from "@/app_modules/_global/fun";
import { DIRECTORY_ID } from "@/app/lib";
export function UiMap_CreatePin({
mapboxToken,
@@ -42,8 +47,8 @@ export function UiMap_CreatePin({
const [[lat, long], setLatLong] = useState([0, 0]);
const [isPin, setIsPin] = useState(false);
const [namePin, setNamePin] = useState("");
const [file, setFile] = useState<File | any>(null);
const [img, setImg] = useState<any | null>(null);
const [imageId, setImageId] = useState("");
return (
<>
@@ -146,14 +151,60 @@ export function UiMap_CreatePin({
if (files.size > MAX_SIZE) {
setImg(null);
setFile(null);
ComponentGlobal_NotifikasiPeringatan(
PemberitahuanMaksimalFile,
3000
);
return;
}
// if (files.size > MAX_SIZE) {
// setImg(null);
// ComponentGlobal_NotifikasiPeringatan(
// PemberitahuanMaksimalFile,
// 3000
// );
// } else {
// setImg(buffer);
// }
if (imageId != "") {
const deletePhoto = await funGlobal_DeleteFileById({
fileId: imageId,
});
if (deletePhoto.success) {
setImageId("");
const uploadPhoto = await funGlobal_UploadToStorage({
file: files,
dirId: DIRECTORY_ID.map_image,
});
if (uploadPhoto.success) {
setImageId(uploadPhoto.data.id);
setImg(buffer);
} else {
ComponentGlobal_NotifikasiPeringatan(
"Gagal upload gambar"
);
}
}
} else {
setImg(buffer);
setFile(files);
const uploadPhoto = await funGlobal_UploadToStorage({
file: files,
dirId: DIRECTORY_ID.map_image,
});
if (uploadPhoto.success) {
setImageId(uploadPhoto.data.id);
setImg(buffer);
} else {
ComponentGlobal_NotifikasiPeringatan(
"Gagal upload gambar"
);
}
}
} catch (error) {
console.log(error);
@@ -183,7 +234,7 @@ export function UiMap_CreatePin({
lat={lat as any}
long={long as any}
portofolioId={portofolioId}
file={file}
imageId={imageId}
/>
</Stack>
</>