Merge pull request #326 from bipproduction/bagas/21-feb-25
fix load event & loading creating colab
This commit is contained in:
@@ -7,13 +7,7 @@ import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_glo
|
|||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||||
import { clientLogger } from "@/util/clientLogger";
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
import mqtt_client from "@/util/mqtt_client";
|
import mqtt_client from "@/util/mqtt_client";
|
||||||
import {
|
import { Button, Select, Stack, TextInput, Textarea } from "@mantine/core";
|
||||||
Button,
|
|
||||||
Select,
|
|
||||||
Stack,
|
|
||||||
TextInput,
|
|
||||||
Textarea
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
@@ -51,7 +45,6 @@ export default function Colab_Create() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (listIndustri == null) {
|
if (listIndustri == null) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -194,34 +187,32 @@ function ButtonAction({ value }: { value: any }) {
|
|||||||
if (value.projectCollaborationMaster_IndustriId === 0)
|
if (value.projectCollaborationMaster_IndustriId === 0)
|
||||||
return ComponentGlobal_NotifikasiPeringatan("Pilih Industri");
|
return ComponentGlobal_NotifikasiPeringatan("Pilih Industri");
|
||||||
|
|
||||||
const res = await colab_funCreateProyek(value);
|
|
||||||
try {
|
try {
|
||||||
setLoading(true)
|
setLoading(true);
|
||||||
|
|
||||||
|
const res = await colab_funCreateProyek(value);
|
||||||
if (res.status === 201) {
|
if (res.status === 201) {
|
||||||
setLoading(true);
|
|
||||||
router.back();
|
router.back();
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
} else {
|
} else {
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
clientLogger.error("Error create proyek", error);
|
clientLogger.error("Error create proyek", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Button
|
<Button
|
||||||
disabled={
|
disabled={
|
||||||
!value.title ||
|
!value.title ||
|
||||||
!value.lokasi ||
|
!value.lokasi ||
|
||||||
!value.purpose ||
|
!value.purpose ||
|
||||||
!value.benefit ||
|
!value.benefit ||
|
||||||
value.projectCollaborationMaster_IndustriId === 0
|
value.projectCollaborationMaster_IndustriId === 0
|
||||||
? true
|
? true
|
||||||
: false
|
: false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,22 +9,27 @@ import { MODEL_COLLABORATION } from "../../model/interface";
|
|||||||
export default async function colab_funCreateProyek(
|
export default async function colab_funCreateProyek(
|
||||||
value: MODEL_COLLABORATION
|
value: MODEL_COLLABORATION
|
||||||
) {
|
) {
|
||||||
const userLoginId = await funGetUserIdByToken();
|
try {
|
||||||
|
const userLoginId = await funGetUserIdByToken();
|
||||||
|
if (!userLoginId) return { status: 400, message: "Gagal Membuat Proyek" };
|
||||||
|
|
||||||
const data = await prisma.projectCollaboration.create({
|
const data = await prisma.projectCollaboration.create({
|
||||||
data: {
|
data: {
|
||||||
title: value.title,
|
title: value.title,
|
||||||
lokasi: value.lokasi,
|
lokasi: value.lokasi,
|
||||||
purpose: value.purpose,
|
purpose: value.purpose,
|
||||||
benefit: value.benefit,
|
benefit: value.benefit,
|
||||||
projectCollaborationMaster_IndustriId:
|
projectCollaborationMaster_IndustriId:
|
||||||
value.projectCollaborationMaster_IndustriId,
|
value.projectCollaborationMaster_IndustriId,
|
||||||
userId: userLoginId,
|
userId: userLoginId,
|
||||||
// jumlah_partisipan: + value.jumlah_partisipan,
|
// jumlah_partisipan: + value.jumlah_partisipan,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!data) return { status: 400, message: "Gagal Membuat Proyek" };
|
if (!data) return { status: 400, message: "Gagal Membuat Proyek" };
|
||||||
revalidatePath(RouterColab.beranda);
|
revalidatePath(RouterColab.beranda);
|
||||||
return { data, status: 201, message: "Berhasil Membuat Proyek" };
|
return { data, status: 201, message: "Berhasil Membuat Proyek" };
|
||||||
|
} catch (error) {
|
||||||
|
return { status: 500, message: "Gagal Membuat Proyek" };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ export default function Forum_Forumku({
|
|||||||
const userId = params.id;
|
const userId = params.id;
|
||||||
const [dataUser, setDataUser] = useState<MODEL_USER | null>(null);
|
const [dataUser, setDataUser] = useState<MODEL_USER | null>(null);
|
||||||
const [dataPosting, setDataPosting] = useState<MODEL_FORUM_POSTING[]>([]);
|
const [dataPosting, setDataPosting] = useState<MODEL_FORUM_POSTING[]>([]);
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [activePage, setActivePage] = useState(1);
|
const [activePage, setActivePage] = useState(1);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
@@ -61,6 +62,7 @@ export default function Forum_Forumku({
|
|||||||
|
|
||||||
const handleLoadDataForum = async () => {
|
const handleLoadDataForum = async () => {
|
||||||
try {
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
const response = await apiGetForumkuById({
|
const response = await apiGetForumkuById({
|
||||||
id: userId,
|
id: userId,
|
||||||
page: "1",
|
page: "1",
|
||||||
@@ -69,9 +71,14 @@ export default function Forum_Forumku({
|
|||||||
if (response.success) {
|
if (response.success) {
|
||||||
setDataPosting(response.data);
|
setDataPosting(response.data);
|
||||||
setActivePage(1);
|
setActivePage(1);
|
||||||
|
setIsLoading(false);
|
||||||
|
} else {
|
||||||
|
setDataPosting([]);
|
||||||
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
clientLogger.error("Error get data forum");
|
clientLogger.error("Error get data forum");
|
||||||
|
setIsLoading(false);
|
||||||
setDataPosting([]);
|
setDataPosting([]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -109,7 +116,7 @@ export default function Forum_Forumku({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!dataPosting.length ? (
|
{!dataPosting.length && isLoading ? (
|
||||||
<Forum_SkeletonCard />
|
<Forum_SkeletonCard />
|
||||||
) : _.isEmpty(dataPosting) ? (
|
) : _.isEmpty(dataPosting) ? (
|
||||||
<Forum_ComponentIsDataEmpty />
|
<Forum_ComponentIsDataEmpty />
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ const middlewareConfig: MiddlewareConfig = {
|
|||||||
"/api/logs/*",
|
"/api/logs/*",
|
||||||
"/api/auth/*",
|
"/api/auth/*",
|
||||||
"/api/origin-url",
|
"/api/origin-url",
|
||||||
|
"/api/job*",
|
||||||
// "/api/event/*",
|
// "/api/event/*",
|
||||||
|
|
||||||
// ADMIN API
|
// ADMIN API
|
||||||
|
|||||||
Reference in New Issue
Block a user