Fix API Detail Publish Event

This commit is contained in:
2025-02-12 17:31:02 +08:00
parent dbeab7aa22
commit ddefccb07f
22 changed files with 349 additions and 100 deletions

View File

@@ -1,10 +1,17 @@
import { AdminColor } from '@/app_modules/_global/color/color_pallet';
import CustomSkeleton from '@/app_modules/components/CustomSkeleton';
import { MODEL_EVENT } from '@/app_modules/event/_lib/interface';
import { Grid, Paper, Stack, Text, Title } from '@mantine/core';
import React from 'react';
function ComponentEvent_DetailDataAuthor() {
function ComponentEvent_DetailDataAuthor({ data }: { data: MODEL_EVENT | null }) {
return (
<>
{/* {!data ? (
<CustomSkeleton height={"40vh"} width={"100%"} />
) : (
)} */}
<Paper bg={AdminColor.softBlue} p={"lg"}>
<Stack c={AdminColor.white}>
<Title order={3}>Data User</Title>
@@ -14,7 +21,11 @@ function ComponentEvent_DetailDataAuthor() {
<Text fw={"bold"}>Nama:</Text>
</Grid.Col>
<Grid.Col span={6}>
<Text>Nico Arya</Text>
{data ?
<Text>{data?.Author?.Profile?.name}</Text>
:
<CustomSkeleton height={30} width={"100%"} />
}
</Grid.Col>
</Grid>
<Grid>
@@ -22,7 +33,11 @@ function ComponentEvent_DetailDataAuthor() {
<Text fw={"bold"}>Username:</Text>
</Grid.Col>
<Grid.Col span={6}>
<Text>@NicoArya</Text>
{data ?
<Text>{data?.Author?.username}</Text>
:
<CustomSkeleton height={30} width={"100%"} />
}
</Grid.Col>
</Grid>
<Grid>
@@ -30,7 +45,11 @@ function ComponentEvent_DetailDataAuthor() {
<Text fw={"bold"}>Nomor:</Text>
</Grid.Col>
<Grid.Col span={6}>
<Text>+628123456789</Text>
{data ?
<Text>{data?.Author?.nomor}</Text>
:
<CustomSkeleton height={30} width={"100%"} />
}
</Grid.Col>
</Grid>
<Grid>
@@ -38,12 +57,16 @@ function ComponentEvent_DetailDataAuthor() {
<Text fw={"bold"}>Alamat:</Text>
</Grid.Col>
<Grid.Col span={6}>
<Text>Jl Raya Sesetan</Text>
{data ?
<Text>{data?.Author?.Profile?.alamat}</Text>
:
<CustomSkeleton height={30} width={"100%"} />
}
</Grid.Col>
</Grid>
</Stack>
</Stack>
</Paper>
</Paper >
</>
);
}

View File

@@ -1,20 +1,31 @@
import { AdminColor } from '@/app_modules/_global/color/color_pallet';
import { MODEL_EVENT } from '@/app_modules/event/_lib/interface';
import { Box, Grid, Paper, Stack, Text, Title } from '@mantine/core';
import moment from 'moment';
import React from 'react';
import "moment/locale/id";
import CustomSkeleton from '@/app_modules/components/CustomSkeleton';
function ComponentEvent_DetailDataEvent({ data }: { data: MODEL_EVENT | null }) {
function ComponentEvent_DetailDataEvent() {
return (
<>
{/* {!data ? (
<CustomSkeleton height={"40vh"} width={"100%"} />
) : (
)
} */}
<Paper bg={AdminColor.softBlue} p={"lg"}>
<Stack c={AdminColor.white}>
<Title order={3}>Coba</Title>
{data ? <Title order={3}>{data?.title}</Title> : <CustomSkeleton height={30} width={"100%"} />}
<Stack spacing={"xs"}>
<Grid>
<Grid.Col span={6}>
<Text fw={"bold"}>Lokasi:</Text>
</Grid.Col>
<Grid.Col span={6}>
<Text>Tuban</Text>
{data ? <Text>{data?.lokasi}</Text> : <CustomSkeleton height={30} width={"100%"} />}
</Grid.Col>
</Grid>
<Grid>
@@ -22,7 +33,7 @@ function ComponentEvent_DetailDataEvent() {
<Text fw={"bold"}>Tipe Acara:</Text>
</Grid.Col>
<Grid.Col span={6}>
<Text>Seminar</Text>
{data ? <Text>{data?.EventMaster_TipeAcara?.name}</Text> : <CustomSkeleton height={30} width={"100%"} />}
</Grid.Col>
</Grid>
<Grid>
@@ -30,28 +41,26 @@ function ComponentEvent_DetailDataEvent() {
<Text fw={"bold"}>Tanggal & Waktu Mulai:</Text>
</Grid.Col>
<Grid.Col span={6}>
<Text>Minggu, 17 Januari 2025</Text>
<Text>09:00</Text>
{data ? <Text>{moment(data?.tanggal).format("LLLL")}</Text> : <CustomSkeleton height={30} width={"100%"} />}
</Grid.Col>
</Grid>
<Grid>
<Grid.Col span={6}>
<Grid.Col span={6}>
<Text fw={"bold"}>Tanggal & Waktu Selesai:</Text>
</Grid.Col>
<Grid.Col span={6}>
<Text >Minggu, 17 Januari 2025</Text>
<Text >15:00</Text>
{data ? <Text>{moment(data?.tanggalSelesai).format("LLLL")}</Text> : <CustomSkeleton height={30} width={"100%"} />}
</Grid.Col>
</Grid>
<Grid>
<Grid.Col span={6}>
<Text fw={"bold"}>Deskripsi:</Text>
<Text >Lorem ipsum dolor sit amet consectetur adipisicing elit. Nihil, natus.</Text>
{data ? <Text>{data?.deskripsi}</Text> : <CustomSkeleton height={30} width={"100%"} />}
</Grid.Col>
</Grid>
</Stack>
</Stack>
</Paper>
</Paper >
</>
);
}

View File

@@ -0,0 +1,152 @@
export {
apiGetAdminEventStatusCountDashboard as apiGetEventStatusCountDashboard,
apiGetAdminEventCountTipeAcara as apiGetEventTipeAcara,
apiGetAdminEventRiwayatCount as apiGetEventRiwayatCount,
apiGetAdminEventByStatus as apiGetDataEventByStatus,
apiGetAdminEventRiwayat,
apiGetAdminEventTipeAcara,
apiGetAdminDetailEventById
};
const apiGetAdminEventStatusCountDashboard = async ({
name,
}: {
name: "Publish" | "Review" | "Reject";
}) => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null);
const response = await fetch(`/api/admin/event/dashboard/${name}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
},
});
return await response.json().catch(() => null);
};
const apiGetAdminEventRiwayatCount = async () => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null);
const response = await fetch(`/api/admin/event/dashboard/riwayat`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
},
});
return await response.json().catch(() => null);
};
const apiGetAdminEventCountTipeAcara = async () => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null);
const response = await fetch(`/api/admin/event/dashboard/tipe-acara`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
},
});
return await response.json().catch(() => null);
};
const apiGetAdminEventByStatus = async ({
name,
page,
search,
}: {
name: "Publish" | "Review" | "Reject";
page: string;
search: string;
}) => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null);
const isPage = page ? `?page=${page}` : "";
const isSearch = search ? `&search=${search}` : "";
const respone = await fetch(
`/api/admin/event/status/${name}${isPage}${isSearch}`,
{
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
},
}
);
return await respone.json().catch(() => null);
};
const apiGetAdminEventRiwayat = async ({
page,
search,
}: {
page: string;
search: string;
}) => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null);
const isPage = page ? `?page=${page}` : "";
const isSearch = search ? `&search=${search}` : "";
const response = await fetch(`/api/admin/event/riwayat${isPage}${isSearch}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
},
});
return await response.json().catch(() => null);
};
const apiGetAdminEventTipeAcara = async () => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null);
const response = await fetch(`/api/event/tipe-acara`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
},
});
return await response.json().catch(() => null);
};
const apiGetAdminDetailEventById = async ({ id }: { id: string }) => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null);
const response = await fetch(`/api/admin/event/${id}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
},
})
return await response.json().catch(() => null);
}

View File

@@ -1,4 +1,4 @@
import { apiGetDataEventByStatus } from "@/app/dev/admin/event/_lib/api_fecth_admin_event";
import { apiGetDataEventByStatus } from "@/app_modules/admin/event/_lib/api_fecth_admin_event";
import {
gs_adminEvent_triggerReview,
IRealtimeData,
@@ -75,7 +75,7 @@ export default function AdminEvent_ComponentTableReview() {
const loadInitialData = async () => {
try {
const response = await apiGetDataEventByStatus({
status: "Review",
name: "Review",
page: `${activePage}`,
search: isSearch,
});
@@ -156,17 +156,17 @@ export default function AdminEvent_ComponentTableReview() {
try {
const response = await apiGetDataEventByStatus({
status: "Review",
name: "Review",
page: `${activePage}`,
search: isSearch,
});
if (response?.success && response?.data?.data) {
setData(response.data.data);
setNPage(response.data.nPage || 1);
} else {
setData([]);
}
} catch (error) {
@@ -221,13 +221,13 @@ export default function AdminEvent_ComponentTableReview() {
try {
const response = await apiGetDataEventByStatus({
status: "Review",
name: "Review",
page: `${activePage}`,
search: isSearch,
});
if (response?.success && response?.data?.data) {
setData(response.data.data);
setNPage(response.data.nPage || 1);
} else {
@@ -387,7 +387,7 @@ export default function AdminEvent_ComponentTableReview() {
}
/>
{!data ? (
<CustomSkeleton height={"80vh"} width="100%" />

View File

@@ -22,7 +22,7 @@ import { IconCircleCheck, IconSearch } from "@tabler/icons-react";
import { useRouter } from "next/navigation";
import { useState } from "react";
import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate";
import { apiGetAdminEventRiwayat } from "@/app/dev/admin/event/_lib/api_fecth_admin_event";
import { apiGetAdminEventRiwayat } from "@/app_modules/admin/event/_lib/api_fecth_admin_event";
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
@@ -209,7 +209,7 @@ function DetailRiwayat() {
horizontalSpacing={"md"}
p={"md"}
w={"100%"}
>
<thead>
<tr>

View File

@@ -25,7 +25,7 @@ import { AdminEvent_funCreateTipeAcara } from "../fun/create/fun_create_tipe_aca
import { AdminEvent_funEditActivationTipeAcaraById } from "../fun/edit/fun_edit_activation_tipe_acara";
import { AdminEvent_funEditTipeAcara } from "../fun/edit/fun_edit_tipe_acara";
import { AdminEvent_getListTipeAcara } from "../fun/get/get_list_tipe_acara";
import { apiGetAdminEventTipeAcara } from "@/app/dev/admin/event/_lib/api_fecth_admin_event";
import { apiGetAdminEventTipeAcara } from "@/app_modules/admin/event/_lib/api_fecth_admin_event";
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
import { clientLogger } from "@/util/clientLogger";
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
@@ -168,9 +168,10 @@ function DetailTipeAcara() {
{openCreate ? (
<div>
<Paper p={"sm"} shadow="lg" withBorder>
<Paper p={"sm"} bg={AdminColor.softBlue} shadow="lg" >
<Stack>
<TextInput
<TextInput
styles={{ label: { color: AdminColor.white } }}
value={name ? name : ""}
label="Masukan Tipe"
placeholder="Contoh: Seminar, Workshop, dll."

View File

@@ -1,9 +1,41 @@
import { SimpleGrid } from '@mantine/core';
import React from 'react';
import React, { useState } from 'react';
import ComponentEvent_DetailDataAuthor from '../_component/detail_data_author';
import ComponentEvent_DetailDataEvent from '../_component/detail_data_event';
import { useParams } from 'next/navigation';
import { apiGetAdminDetailEventById } from '../_lib/api_fecth_admin_event';
import { MODEL_EVENT } from '@/app_modules/event/_lib/interface';
import { clientLogger } from '@/util/clientLogger';
import { useShallowEffect } from '@mantine/hooks';
function AdminEvent_ViewDetailData({ }) {
const params = useParams<{ id: string }>();
const [loading, setLoading] = useState(true);
const [data, setData] = useState<MODEL_EVENT | null>(null);
useShallowEffect(() => {
getDetailData();
}, [])
async function getDetailData() {
try {
setLoading(true);
const response = await apiGetAdminDetailEventById({
id: params.id,
})
if (response?.success && response?.data) {
setTimeout(() => {
setData(response.data);
}, 1000)
} else {
console.error("Invalid data format received:", response);
setData(null);
}
} catch (error) {
clientLogger.error("Error get data table detail publish", error);
setData(null);
}
}
return (
<>
<SimpleGrid
@@ -14,12 +46,12 @@ function AdminEvent_ViewDetailData({ }) {
]}
>
{/* //Data Author */}
<ComponentEvent_DetailDataAuthor />
{/* Data Event */}
<ComponentEvent_DetailDataEvent/>
<ComponentEvent_DetailDataAuthor data={data}/>
</SimpleGrid>
{/* Data Event */}
<ComponentEvent_DetailDataEvent data={data} />
</SimpleGrid>
</>
);
}

View File

@@ -6,7 +6,7 @@ import {
apiGetEventRiwayatCount,
apiGetEventStatusCountDashboard,
apiGetEventTipeAcara,
} from "@/app/dev/admin/event/_lib/api_fecth_admin_event";
} from "@/app_modules/admin/event/_lib/api_fecth_admin_event";
import global_limit from "@/lib/limit";
import { AccentColor, MainColor } from "@/app_modules/_global/color";
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
@@ -229,7 +229,7 @@ export default function AdminEvent_Main() {
shadow="md"
radius="md"
p="md"
// sx={{ borderColor: e.color, borderStyle: "solid" }}
// sx={{ borderColor: e.color, borderStyle: "solid" }}
>
<Stack spacing={0}>
<Text fw={"bold"} color={AccentColor.white}>
@@ -265,7 +265,7 @@ export default function AdminEvent_Main() {
shadow="md"
radius="md"
p="md"
// sx={{ borderColor: e.color, borderStyle: "solid" }}
// sx={{ borderColor: e.color, borderStyle: "solid" }}
>
<Stack spacing={0}>
<Text fw={"bold"} color={AccentColor.white}>

View File

@@ -1,6 +1,6 @@
"use client";
import { apiGetDataEventByStatus } from "@/app/dev/admin/event/_lib/api_fecth_admin_event";
import { apiGetDataEventByStatus } from "@/app_modules/admin/event/_lib/api_fecth_admin_event";
import { RouterAdminEvent } from "@/lib/router_admin/router_admin_event";
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
import { MODEL_EVENT } from "@/app_modules/event/_lib/interface";
@@ -55,7 +55,7 @@ function TableStatus() {
const loadInitialData = async () => {
try {
const response = await apiGetDataEventByStatus({
status: "Publish",
name: "Publish",
page: `${activePage}`,
search: isSearch,
});

View File

@@ -29,7 +29,7 @@ import { AdminEvent_funEditCatatanById } from "../fun/edit/fun_edit_status_rejec
import { ComponentAdminGlobal_TitlePage } from "../../_admin_global/_component";
import { MainColor } from "@/app_modules/_global/color";
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
import { apiGetDataEventByStatus } from "@/app/dev/admin/event/_lib/api_fecth_admin_event";
import { apiGetDataEventByStatus } from "@/app_modules/admin/event/_lib/api_fecth_admin_event";
import { clientLogger } from "@/util/clientLogger";
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
@@ -59,7 +59,7 @@ function TableStatus() {
const loadInitialData = async () => {
try {
const response = await apiGetDataEventByStatus({
status: "Reject",
name: "Reject",
page: `${activePage}`,
search: isSearch,
});
@@ -98,7 +98,7 @@ function TableStatus() {
if (res.status === 200) {
try {
const response = await apiGetDataEventByStatus({
status: "Reject",
name: "Reject",
page: `${activePage}`,
search: isSearch,
});
@@ -251,7 +251,7 @@ function TableStatus() {
horizontalSpacing={"md"}
p={"md"}
w={1500}
>
<thead>
<tr>