# fix
- authentication
- profile
- pencarian user
- forum
## No issue
This commit is contained in:
2024-05-20 10:55:13 +08:00
parent 66b9902d97
commit dbeb740d1f
58 changed files with 1374 additions and 386 deletions

View File

@@ -15,14 +15,14 @@ export default function ComponentEvent_DetailData({
const jam = tgl.toLocaleTimeString([], {
hour: "2-digit",
minute: "2-digit",
hour12: false,
});
return (
<>
{/* <pre>{JSON.stringify(jam)}</pre> */}
<Paper withBorder p={"md"} shadow="lg">
<Stack px={"sm"}>
<Title order={4}>{data ? data?.title : null}</Title>
<Title w={"100%"} order={4}>{data ? data?.title : null}</Title>
<Grid>
<Grid.Col span={4}>
<Text fw={"bold"} fz={"sm"}>
@@ -52,7 +52,7 @@ export default function ComponentEvent_DetailData({
</Text>
</Grid.Col>
<Grid.Col span={1}>:</Grid.Col>
<Grid.Col span={"auto"}>{hari}</Grid.Col>
<Grid.Col span={"auto"}>{hari ? hari : ""}</Grid.Col>
</Grid>
<Grid>
<Grid.Col span={4}>
@@ -61,7 +61,7 @@ export default function ComponentEvent_DetailData({
</Text>
</Grid.Col>
<Grid.Col span={1}>:</Grid.Col>
<Grid.Col span={"auto"}>{jam}</Grid.Col>
<Grid.Col span={"auto"}>{jam ? jam : ""}</Grid.Col>
</Grid>
<Stack spacing={2}>
<Text fw={"bold"} fz={"sm"}>

View File

@@ -1,17 +1,23 @@
"use client"
"use client";
import { Group, Text } from "@mantine/core";
import { IconAlertTriangle } from "@tabler/icons-react";
export default function ComponentEvent_ErrorMaximalInput({max}:{max: number}){
return (
<>
<Group spacing={"xs"}>
<IconAlertTriangle size={15} />
<Text fz={10} fs={"italic"}>
Maksimal {max} karakter !
</Text>
</Group>
</>
);
}
export default function ComponentEvent_ErrorMaximalInput({
max,
text,
}: {
max?: number;
text?: string;
}) {
return (
<>
<Group spacing={"xs"}>
<IconAlertTriangle size={15} />
<Text fz={10} fs={"italic"}>
{text ? text : ` Maksimal ${max} karakter !`}
</Text>
</Group>
</>
);
}

View File

@@ -15,7 +15,7 @@ export default function ComponentEvent_HeaderTamplate({
bg,
}: {
hideBack?: boolean;
changeIconBack?: any
changeIconBack?: any;
route?: any;
route2?: any;
title: string;
@@ -23,6 +23,8 @@ export default function ComponentEvent_HeaderTamplate({
bg?: any;
}) {
const router = useRouter();
const [isLoadingBack, setLoadingBack] = useState(false);
const [isLoadingOtherIcon, setLoadingOtherIcon] = useState(false);
return (
<>
<Header
@@ -35,8 +37,10 @@ export default function ComponentEvent_HeaderTamplate({
<ActionIcon variant="transparent" disabled></ActionIcon>
) : (
<ActionIcon
loading={isLoadingBack ? true : false}
variant="transparent"
onClick={() => {
setLoadingBack(true);
if (route === null || route === undefined) {
return router.back();
} else {
@@ -44,7 +48,7 @@ export default function ComponentEvent_HeaderTamplate({
}
}}
>
{changeIconBack ? changeIconBack: <IconChevronLeft />}
{changeIconBack ? changeIconBack : <IconChevronLeft />}
</ActionIcon>
)}
<Title order={5}>{title}</Title>
@@ -54,8 +58,12 @@ export default function ComponentEvent_HeaderTamplate({
} else {
return (
<ActionIcon
loading={isLoadingOtherIcon ? true : false}
variant="transparent"
onClick={() => router.push(route2)}
onClick={() => {
setLoadingOtherIcon(true);
router.push(route2);
}}
>
{icon}
</ActionIcon>

View File

@@ -0,0 +1,13 @@
"use client";
import { Center } from "@mantine/core";
export default function ComponentEvent_IsEmptyData({ text }: { text: string }) {
return (
<>
<Center h={"50vh"} fz={"sm"} c="gray" fw={"bold"} style={{zIndex: 1}}>
{text}
</Center>
</>
);
}

View File

@@ -48,23 +48,21 @@ export default function Event_Create({
const [tabsStatus, setTabsStatus] = useAtom(gs_event_status);
const [listTipe, setListTipe] = useState(listTipeAcara);
const [hotMenu, setHotMenu] = useAtom(gs_event_hotMenu);
// Masimal karakter state
const [maxTitle, setMaxTitle] = useState("");
const [maxLokasi, setMaxLokasi] = useState("");
const [maxDeskripsi, setMaxDeskripsi] = useState("");
const [isTime, setIsTime] = useState(false);
const [isLoading, setLoading] = useState(false);
const [value, setValue] = useState({
title: "",
lokasi: "",
deskripsi: "",
tanggal: Date,
tanggal: Date.toString(),
eventMaster_TipeAcaraId: 0,
authorId: authorId,
});
return (
<>
{/* <pre>{JSON.stringify(value, null, 2)}</pre> */}
<Stack px={"sm"}>
<TextInput
label="Judul"
@@ -72,21 +70,19 @@ export default function Event_Create({
withAsterisk
maxLength={100}
error={
maxTitle.length >= 100 ? (
value.title.length >= 100 ? (
<ComponentEvent_ErrorMaximalInput max={100} />
) : (
""
)
}
onChange={(val) => {
setMaxTitle(val.target.value);
setValue({
...value,
title: val.target.value,
});
}}
/>
<Select
withAsterisk
label="Tipe Acara"
@@ -107,16 +103,15 @@ export default function Event_Create({
label="Lokasi"
placeholder="Masukan lokasi acara"
withAsterisk
maxLength={200}
maxLength={100}
error={
maxLokasi.length >= 200 ? (
<ComponentEvent_ErrorMaximalInput max={200} />
value.lokasi.length >= 100 ? (
<ComponentEvent_ErrorMaximalInput max={100} />
) : (
""
)
}
onChange={(val) => {
setMaxLokasi(val.target.value);
setValue({
...value,
lokasi: val.target.value,
@@ -124,48 +119,68 @@ export default function Event_Create({
}}
/>
<DateTimePicker
// onClick={() => {
// console.log(moment().diff(moment("2024-02-01"), "days"));
// }}
excludeDate={(date) => {
return moment(date).diff(Date.now(), "days") < 0;
}}
withAsterisk
label="Tanggal & Waktu "
placeholder="Masukan tangal dan waktu acara"
onChange={(val: any) =>
error={
isTime ? (
<ComponentEvent_ErrorMaximalInput text="Invalid Time !" />
) : (
""
)
}
onChange={(val) => {
// console.log(
// moment(val?.toISOString().toString()).diff(moment(), "minutes" )
// );
moment(val?.toISOString().toString()).diff(moment(), "minutes") < 0
? setIsTime(true)
: setIsTime(false);
setValue({
...value,
tanggal: val,
})
}
tanggal: val as any,
});
}}
/>
<Textarea
label="Deskripsi"
placeholder="Deskripsikan acara yang akan di selenggarakan"
withAsterisk
autosize
maxLength={500}
maxLength={200}
error={
maxDeskripsi.length >= 500 ? (
<ComponentEvent_ErrorMaximalInput max={500} />
value.deskripsi.length >= 200 ? (
<ComponentEvent_ErrorMaximalInput max={200} />
) : (
""
)
}
onChange={(val) => {
setMaxDeskripsi(val.target.value);
setValue({
...value,
deskripsi: val.target.value,
});
}}
/>
<Button
disabled={
value.title === "" ||
value.lokasi === "" ||
value.deskripsi === "" ||
value.eventMaster_TipeAcaraId === 0 ||
value.tanggal === "function Date() { [native code] }"
}
loaderPosition="center"
loading={isLoading ? true : false}
radius={"xl"}
mt={"xl"}
onClick={() => onSave(router, setTabsStatus, value, setHotMenu)}
onClick={() =>
onSave(router, setTabsStatus, value, setHotMenu, setLoading)
}
>
Simpan
</Button>
@@ -178,19 +193,30 @@ async function onSave(
router: AppRouterInstance,
setTabsStatus: any,
value: any,
setHotMenu: any
setHotMenu: any,
setLoading: any
) {
if (_.values(value).includes(""))
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
if (value.title.length >= 100) return null;
if (value.lokasi.length >= 100) return null;
if (value.eventMaster_TipeAcaraId === 0)
return ComponentGlobal_NotifikasiPeringatan("Pilih Tipe Acara");
if (moment(value.tanggal).format() === "Invalid date")
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Tanggal");
if (
moment(value.tanggal.toISOString().toString()).diff(moment(), "minutes") < 0
)
return null;
if (value.deskripsi.length >= 200) return null;
await Event_funCreate(value).then((res) => {
if (res.status === 201) {
ComponentGlobal_NotifikasiBerhasil(res.message);
setTabsStatus("Review");
setHotMenu(1);
setLoading(true);
router.push(RouterEvent.status_page);
} else {
ComponentGlobal_NotifikasiGagal(res.message);

View File

@@ -1,8 +1,8 @@
"use client";
import { Button, Stack } from "@mantine/core";
import { Button, Group, Stack } from "@mantine/core";
import ComponentEvent_DetailData from "../../component/detail/detail_data";
import { useRouter } from "next/navigation";
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
import { useAtom } from "jotai";
import { gs_event_status } from "../../global_state";
@@ -10,52 +10,73 @@ import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_glob
import { MODEL_EVENT } from "../../model/interface";
import { Event_funEditStatusById } from "../../fun/edit/fun_edit_status_by_id";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
import { useState } from "react";
import React, { useState } from "react";
import ComponentEvent_CatatanReject from "../../component/catatan_reject";
import { useRouter } from "next/navigation";
export default function Event_DetailDraft({
dataEvent,
}: {
dataEvent: MODEL_EVENT;
}) {
const router = useRouter();
const [tabsStatus, setTabsStatus] = useAtom(gs_event_status);
return (
<>
{/* <pre>{JSON.stringify(dataEvent.catatan)}</pre> */}
{/* <pre>{JSON.stringify(dataEvent.catatan)}</pre> */}
<Stack spacing={"lg"}>
{dataEvent.catatan ? (
<ComponentEvent_CatatanReject catatan={dataEvent.catatan} />
{dataEvent?.catatan ? (
<ComponentEvent_CatatanReject catatan={dataEvent?.catatan} />
) : (
""
)}
<ComponentEvent_DetailData data={dataEvent} />
<Button
radius={"xl"}
color="yellow"
onClick={() => {
onClick(router, setTabsStatus, dataEvent.id);
}}
>
Ajukan Review
</Button>
<ButtonAction eventId={dataEvent?.id} />
</Stack>
</>
);
}
async function onClick(
router: AppRouterInstance,
setTabsStatus: any,
eventId: string
) {
await Event_funEditStatusById("2", eventId).then((res) => {
if (res.status === 200) {
ComponentGlobal_NotifikasiBerhasil(res.message, 1500);
setTabsStatus("Review");
router.back();
} else {
ComponentGlobal_NotifikasiGagal(res.message);
}
});
function ButtonAction({ eventId }: { eventId: string }) {
const router = useRouter();
const [tabsStatus, setTabsStatus] = useAtom(gs_event_status);
async function onDelete() {
console.log(eventId);
}
async function onAjukan() {
await Event_funEditStatusById("2", eventId).then((res) => {
if (res.status === 200) {
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
setTabsStatus("Review");
router.back();
} else {
ComponentGlobal_NotifikasiGagal(res.message);
}
});
}
return (
<>
<Group grow>
<Button
radius={"xl"}
color="yellow"
onClick={() => {
onAjukan();
}}
>
Ajukan Review
</Button>
<Button
radius={"xl"}
color="red"
onClick={() => {
// onClick(router, setTabsStatus, dataEvent.id);
}}
>
Hapus
</Button>
</Group>
</>
);
}

View File

@@ -22,5 +22,5 @@ export default function LayoutEvent_DetailDraft({
{children}
</AppComponentGlobal_LayoutTamplate>
</>
);
)
}

View File

@@ -11,6 +11,7 @@ import { MODEL_EVENT } from "../../model/interface";
import { Event_funEditStatusById } from "../../fun/edit/fun_edit_status_by_id";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
import ComponentEvent_CatatanReject from "../../component/catatan_reject";
import { useState } from "react";
export default function Event_DetailReview({
dataEvent,
@@ -19,15 +20,20 @@ export default function Event_DetailReview({
}) {
const router = useRouter();
const [tabsStatus, setTabsStatus] = useAtom(gs_event_status);
const [isLoading, setLoading] = useState(false);
return (
<>
<Stack spacing={"xl"}>
<ComponentEvent_DetailData data={dataEvent} />
<Button
loaderPosition="center"
loading={isLoading ? true : false}
radius={"xl"}
color={"red"}
onClick={() => onClick(router, setTabsStatus, dataEvent.id)}
color={"orange"}
onClick={() =>
onClick(router, setTabsStatus, dataEvent.id, setLoading)
}
>
Batalkan Review
</Button>
@@ -39,12 +45,14 @@ export default function Event_DetailReview({
async function onClick(
router: AppRouterInstance,
setTabsStatus: any,
eventId: string
eventId: string,
setLoading: any
) {
await Event_funEditStatusById("3", eventId).then((res) => {
if (res.status === 200) {
ComponentGlobal_NotifikasiBerhasil(res.message, 1500);
setTabsStatus("Draft");
setLoading(true);
router.back();
} else {
ComponentGlobal_NotifikasiGagal(res.message);

View File

@@ -9,6 +9,7 @@ export async function Event_getByStatusId(statusId: string, authorId: string) {
tanggal: "desc",
},
where: {
active: true,
eventMaster_StatusId: "1",
authorId: authorId,
tanggal: {
@@ -27,9 +28,10 @@ export async function Event_getByStatusId(statusId: string, authorId: string) {
if (statusId === "2") {
const data = await prisma.event.findMany({
orderBy: {
createdAt: "desc",
updatedAt: "desc",
},
where: {
active: true,
eventMaster_StatusId: "2",
authorId: authorId,
},
@@ -44,7 +46,11 @@ export async function Event_getByStatusId(statusId: string, authorId: string) {
}
if (statusId === "3") {
const data = await prisma.event.findMany({
orderBy: {
updatedAt: "desc",
},
where: {
active: true,
eventMaster_StatusId: "3",
authorId: authorId,
},
@@ -59,7 +65,11 @@ export async function Event_getByStatusId(statusId: string, authorId: string) {
}
if (statusId === "4") {
const data = await prisma.event.findMany({
orderBy: {
updatedAt: "desc",
},
where: {
active: true,
eventMaster_StatusId: "4",
authorId: authorId,
},

View File

@@ -9,6 +9,7 @@ export async function Event_getListAllPublish() {
tanggal: "desc",
},
where: {
active: true,
eventMaster_StatusId: "1",
tanggal: {
gte: new Date(),

View File

@@ -30,6 +30,8 @@ import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
import ComponentGlobal_AuthorNameOnHeader from "@/app_modules/component_global/author_name_on_header";
import _ from "lodash";
import { IconCirclePlus } from "@tabler/icons-react";
import ComponentEvent_IsEmptyData from "../component/is_empty_data";
import { useWindowScroll } from "@mantine/hooks";
export default function Event_Beranda({
dataEvent,
@@ -37,21 +39,18 @@ export default function Event_Beranda({
dataEvent: MODEL_EVENT[];
}) {
const router = useRouter();
const [loading, setLoading] = useState(false);
const [isLoading, setLoading] = useState(false);
const [scroll, scrollTo] = useWindowScroll();
// if (_.isEmpty(dataEvent))
// return (
// <Center h={"80vh"}>
// <Text fw={"bold"} fz={"sm"}>
// Tidak Ada Event
// </Text>
// </Center>
// );
return (
<>
<Affix position={{ bottom: rem(150), right: rem(30) }}>
<Affix position={{ bottom: rem(150), right: rem(30) }} zIndex={99}>
<ActionIcon
loading={loading ? true : false}
loading={isLoading ? true : false}
opacity={scroll.y > 0 ? 0.5 : ""}
style={{
transition: "0.5s",
}}
size={"xl"}
radius={"xl"}
variant="transparent"
@@ -64,49 +63,46 @@ export default function Event_Beranda({
<IconCirclePlus color="white" size={40} />
</ActionIcon>
</Affix>
{_.isEmpty(dataEvent) ? (
<Center h={"80vh"}>
<Text fw={"bold"} fz={"sm"}>
Tidak Ada Event
</Text>
</Center>
<ComponentEvent_IsEmptyData text="Tidak ada data" />
) : (
<Box>
{dataEvent.map((e, i) => (
<Card key={e.id} shadow="lg" radius={"md"} withBorder mb={"sm"}>
<Card.Section px={"sm"} pt={"sm"}>
<ComponentGlobal_AuthorNameOnHeader
profileId={e.Author.Profile.id}
imagesId={e.Author.Profile.imagesId}
authorName={e.Author.Profile.name}
/>
</Card.Section>
<Card.Section
p={"sm"}
onClick={() => router.push(RouterEvent.detail_main + e.id)}
>
<Stack>
<Grid>
<Grid.Col span={8}>
<Title order={6} truncate>
{e.title}
</Title>
</Grid.Col>
<Grid.Col span={4}>
<Text fz={"sm"} truncate>
{moment(e.tanggal).format("ll")}
</Text>
</Grid.Col>
</Grid>
{Array(10)
.fill(0)
.map((e, i) => (
<Card key={i} shadow="lg" radius={"md"} withBorder mb={"sm"}>
<Card.Section px={"sm"} pt={"sm"}>
<ComponentGlobal_AuthorNameOnHeader
profileId={e?.Author.Profile.id}
imagesId={e?.Author.Profile.imagesId}
authorName={e?.Author.Profile.name}
/>
</Card.Section>
<Card.Section
p={"sm"}
onClick={() => router.push(RouterEvent.detail_main + e?.id)}
>
<Stack>
<Grid>
<Grid.Col span={8}>
<Title order={6} truncate>
{e?.title}
</Title>
</Grid.Col>
<Grid.Col span={4}>
<Text fz={"sm"} truncate>
{moment(e?.tanggal).format("ll")}
</Text>
</Grid.Col>
</Grid>
<Text fz={"sm"} lineClamp={2}>
{e.deskripsi}
</Text>
</Stack>
</Card.Section>
</Card>
))}
<Text fz={"sm"} lineClamp={2}>
{e?.deskripsi}
</Text>
</Stack>
</Card.Section>
</Card>
))}
</Box>
)}
</>